ToolbarNotifier reimplemented

This commit is contained in:
Ezequiel Bergamaschi 2014-06-16 01:35:34 -03:00
parent a5344c8400
commit 8f3b55b650

View File

@ -19,47 +19,28 @@
mindplot.widget.ToolbarNotifier = new Class({ mindplot.widget.ToolbarNotifier = new Class({
initialize:function () { initialize:function () {
}, this.container = $('#headerNotifier');
logError:function (userMsg) {
this.logMessage(userMsg, mindplot.widget.ToolbarNotifier.MsgKind.ERROR);
}, },
hide:function () { hide:function () {
this.container.hide();
}, },
logMessage:function (msg, fade) { logMessage:function (msg, fade) {
$assert(msg, 'msg can not be null'); $assert(msg, 'msg can not be null');
var container = $('#headerNotifier');
// In case of print,embedded no message is displayed .... // In case of print,embedded no message is displayed ....
if (container) { if (this.container && !this.container.data('transitioning')) {
container.set('text', msg); this.container.data('transitioning', true);
container.setStyle('display', 'block'); this.container.text(msg);
container.position({ this.container.css({top: "5px", left: ($(window).width() - this.container.width()) / 2 - 9});
relativeTo:document.id('header'), this.container.show().fadeOut(5000);
position:'upperCenter',
edge:'centerTop'
});
if (!$defined(fade) || fade) {
this._effect = container.fadeIn('slow');
} else {
this._effect = container.fadeIn(0);
}
} }
this.container.data('transitioning', false);
} }
}); });
mindplot.widget.ToolbarNotifier.MsgKind = {
INFO:1,
WARNING:2,
ERROR:3,
FATAL:4
};
var toolbarNotifier = new mindplot.widget.ToolbarNotifier(); var toolbarNotifier = new mindplot.widget.ToolbarNotifier();
$notify = toolbarNotifier.logMessage.bind(toolbarNotifier); $notify = function(msg) {
toolbarNotifier.logMessage(msg);
};