PDA

View Full Version : Stratified MessageBox & Window



khebs@live.com
13 Jan 2011, 7:13 AM
/*
* show
* Shows Ext Message Box
*
* @param {String}
* @param {String}
* @param {String}
* @param {Object}
* @param {Object}
*/
exports.show = function(title, message, icon, buttons, cfg) {
// Hide all popups
Ext.menu.MenuMgr.hideAll();

if (!Ext.isDefined(cfg))
cfg = {};

var btn = true, r;

var c = Ext.applyIf(cfg, {
title : title,
msg : message,
icon : icon,
buttons : Ext.isDefined(buttons) ? buttons : Ext.Msg.OK,
minWidth : 330,
noWait : false,
fn: function (b) {
btn = b;
if (Ext.isFunction(r))
r();
}
});

var msg = Ext.Msg.show(c);
var dlg = msg.getDialog();

if (msg.noWait === true)
return true;

// wait for messagebox closed.
waitfor () {
r = resume;
// add listener
dlg.addListener('close', r);
}

// remove listener
dlg.removeListener('close', r);

return btn;
};


Ext.Window



/**
* showModal
* SJS Mod for blocking modal window
* @param {Boolean} True as showed as modaled window.
* @return {Object}
*/
Ext.Window.showModal = function(modal) {
var r;

waitfor () {
r = resume;

if (modal === true)
this.modal = true;

this.show();
this.on('hide', r);
}

this.removeListener('hide', r);

return this;
};


SAMPLES:



// Ask
//
if (msgbox.show(locale.AppLogoutTitle, util.sprintf(locale.AppLogoutMessage, res.APP_ACRONAME), msgbox.QUESTION, {
ok: ' ' + locale.AppLogoutBtnYes + ' ',
cancel: ' ' + locale.AppLogoutBtnNo + ' '
}) == 'ok') {
// Clear this event since, we are now logging out
//
window.onbeforeunload = function(){};

exports.purge();
require('ui:mdi').setHidden(true);
exports.login();
};


// LOGIN Sample

// Proceed Login
//
if (exports.isLogin() === false) {
require('forms:login').init().showModal();
}

var mdi = require('ui:mdi');

if (mdi.isRendered()) {
mdi.attachOnUnload();
mdi.setHidden(false);
}



:) Fix something if still needs to be fixed..