Messages.js
1.82 KB
Ext.define("treps.Messages",
{
requires: [
"Ext.window.MessageBox",
"treps.Constants"
],
singleton : true,
bubble : null,
showWarning: function(message)
{
Ext.Msg.show({
title:treps.Constants.APP_TITLE+" - Warning",
msg: message,
buttons: Ext.Msg.OK,
icon: Ext.Msg.WARNING
});
},
showError: function(message,onOk)
{
Ext.Msg.show({
title:treps.Constants.APP_TITLE+" - Error",
msg: message,
buttons: Ext.Msg.OK,
icon: Ext.Msg.ERROR,
fn: function(buttonId)
{
if ((buttonId == "ok") && (onOk != null))
onOk.call();
}
});
},
showInfo: function(message,onOk)
{
Ext.Msg.show({
title:treps.Constants.APP_TITLE+" - Info",
msg: message,
buttons: Ext.Msg.OK,
icon: Ext.Msg.INFO
});
},
showQuestion: function(message,onYes,onNo)
{
Ext.Msg.show({
title:treps.Constants.APP_TITLE+" - Question",
msg: message,
buttons: Ext.Msg.YESNO,
icon: Ext.Msg.QUESTION,
fn: function(buttonId)
{
if ((buttonId == "yes") && (onYes != null))
onYes.call();
if ((buttonId == "no") && (onNo != null))
onNo.call();
}
});
},
showBubble: function(title, messageHTML, target, anchor)
{
if (!this.bubble)
this.bubble = new Ext.ToolTip({
target: target,
anchor: anchor,
anchorToTarget: true,
title: title,
html: messageHTML,
closable: true,
autoHide: false
});
else
{
this.hideBubble();
this.bubble.setTitle(title);
this.bubble.update(messageHTML);
this.bubble.setTarget(target);
this.bubble.anchor = anchor;
}
this.bubble.show();
},
hideBubble: function()
{
if (this.bubble)
{
this.bubble.hide();
this.bubble.setTarget(null);
}
}
}
);