2013-12-20 16:31:41 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Doodle3D project (http://doodle3d.com).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013, Doodle3D
|
|
|
|
* This software is licensed under the terms of the GNU GPL v2 or later.
|
|
|
|
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
|
|
*/
|
|
|
|
|
2013-10-18 19:11:10 +02:00
|
|
|
function Message() {
|
|
|
|
|
|
|
|
Message.ERROR = "error";
|
|
|
|
Message.WARNING = "warning";
|
|
|
|
Message.NOTICE = "notice";
|
|
|
|
Message.INFO = "info";
|
|
|
|
|
|
|
|
this.mode = "";
|
|
|
|
|
|
|
|
this.$element;
|
|
|
|
|
|
|
|
var self = this;
|
2013-10-23 15:33:10 +02:00
|
|
|
var autoHideDelay = 5000;
|
2013-10-18 19:11:10 +02:00
|
|
|
var autohideTimeout;
|
|
|
|
|
|
|
|
this.init = function($element) {
|
|
|
|
this.$element = $element;
|
|
|
|
}
|
2013-12-19 17:33:06 +01:00
|
|
|
this.set = function(text,mode,autoHide,disableEffect) {
|
|
|
|
console.log("Message:set: ",text,mode,autoHide,disableEffect);
|
|
|
|
if(disableEffect) {
|
|
|
|
self.fill(text,mode,autoHide)
|
|
|
|
} else{
|
|
|
|
self.hide(function() {
|
|
|
|
self.show();
|
|
|
|
self.fill(text,mode,autoHide)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.fill = function(text,mode,autoHide) {
|
|
|
|
//console.log("Message:fill: ",text,mode,autoHide);
|
|
|
|
self.clear();
|
|
|
|
self.$element.text(text);
|
|
|
|
self.$element.addClass(mode);
|
|
|
|
self.mode = mode;
|
|
|
|
clearTimeout(autohideTimeout);
|
|
|
|
if(autoHide) {
|
|
|
|
autohideTimeout = setTimeout(function(){ self.hide()},autoHideDelay);
|
|
|
|
}
|
2013-10-18 19:11:10 +02:00
|
|
|
}
|
|
|
|
this.clear = function($element) {
|
|
|
|
this.$element.text("");
|
|
|
|
this.$element.removeClass(this.mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.show = function() {
|
|
|
|
this.$element.fadeIn(200);
|
|
|
|
}
|
|
|
|
this.hide = function(complete) {
|
|
|
|
this.$element.fadeOut(200,complete);
|
|
|
|
}
|
2013-12-20 16:31:41 +01:00
|
|
|
}
|