diff --git a/qui/controls/desktop/Tasks.js b/qui/controls/desktop/Tasks.js index 3c753f2b185d16b81d5d56155c16be6bf80d8035..ef755bdd53994be0ffebe7562c648c019ca8fbab 100644 --- a/qui/controls/desktop/Tasks.js +++ b/qui/controls/desktop/Tasks.js @@ -7,13 +7,6 @@ * @module qui/controls/desktop/Tasks * @author www.pcsg.de (Henning Leutz) * - * @require qui/QUI - * @require qui/controls/Control - * @require qui/controls/loader/Loader - * @require qui/controls/taskbar/Bar - * @require qui/controls/taskbar/Task - * @require css!qui/controls/desktop/Tasks.css - * * @event onResize [this] * @event onRefresh [this] */ @@ -51,14 +44,31 @@ define('qui/controls/desktop/Tasks', [ options: { name: 'taskpanel', - icon: 'icon-tasks fa fa-tasks', + icon: 'fa fa-tasks', // header - header: true, // true to create a panel header when panel is created - title : 'Tasks' // the title inserted into the panel's header + header : true, // true to create a panel header when panel is created + title : 'Tasks', // the title inserted into the panel's header + limit : false, + 'message.to.much.tasks': false }, initialize: function (options) { + var limit = 50; + var message = 'Unfortunately, too many tasks are open. Some tasks have been closed.'; + + if (QUI.getAttribute('control-task-panel-limit')) { + limit = QUI.getAttribute('control-task-panel-limit'); + } + + if (QUI.getAttribute('control-task-panel-limit-message')) { + message = QUI.getAttribute('control-task-panel-limit-message'); + } + + options.limit = options.limit || limit; + + options['message.to.much.tasks'] = options['message.to.much.tasks'] || message; + this.parent(options); this.Loader = new Loader(); @@ -319,9 +329,35 @@ define('qui/controls/desktop/Tasks', [ return this; } - this.$Taskbar.appendChild( - this.instanceToTask(Instance) - ); + var self = this, + Task = this.instanceToTask(Instance), + limit = this.getAttribute('limit'); + + if (this.$Taskbar && limit && limit <= this.$Taskbar.length()) { + var First = null, + children = this.$Taskbar.getChildren(), + iType = Instance.getType(); + + for (var i = 0, len = children.length; i < len; i++) { + if (children[i].getType() === iType) { + First = children[i]; + } + } + + if (First === null) { + First = children[0]; + } + + if (First) { + First.destroy(); + } + + QUI.getMessageHandler().then(function (MH) { + MH.addInformation(self.getAttribute('message.to.much.tasks')); + }); + } + + this.$Taskbar.appendChild(Task); return this; }, diff --git a/qui/controls/messages/Message.js b/qui/controls/messages/Message.js index 48c4b28eaae7c703dc522ce132ba7be2fbdccbbd..42e4aa96cb81d1a0b2dd24826f3cc3da8303480e 100644 --- a/qui/controls/messages/Message.js +++ b/qui/controls/messages/Message.js @@ -113,23 +113,28 @@ define('qui/controls/messages/Message', [ Time = this.getAttribute('time'); var time = ('0' + Time.getDate()).slice(-2) + '.' + - ('0' + (Time.getMonth() + 1)).slice(-2) + '.' + - Time.getFullYear(); + ('0' + (Time.getMonth() + 1)).slice(-2) + '.' + + Time.getFullYear(); var hours = ('0' + Time.getHours()).slice(-2); var minutes = ('0' + Time.getMinutes()).slice(-2); + var message = this.getAttribute('message'); time = time + ' ' + hours + ':' + minutes; + if (typeOf(message) !== 'string') { + message = message.toString(); + } + var Elm = new Element('div', { 'class': 'messages-message box', html : '<div class="messages-message-header">' + - '<span class="messages-message-header-time">' + time + '</span>' + - '<span class="messages-message-destroy icon-remove-circle fa fa-close"></span>' + - '</div>' + - '<div class="messages-message-text">' + - this.getAttribute('message').replace(/\n/g, '<br />') + - '</div>', + '<span class="messages-message-header-time">' + time + '</span>' + + '<span class="messages-message-destroy icon-remove-circle fa fa-close"></span>' + + '</div>' + + '<div class="messages-message-text">' + + message.replace(/\n/g, '<br />') + + '</div>', events : { click: function () { self.fireEvent('click', [self]); diff --git a/qui/controls/taskbar/Bar.js b/qui/controls/taskbar/Bar.js index af8dc38952a426014afd1f0114edd19c91574b43..abb62765fcf0a535ff3ee82ab8a7770e0367f7b8 100644 --- a/qui/controls/taskbar/Bar.js +++ b/qui/controls/taskbar/Bar.js @@ -142,7 +142,7 @@ define('qui/controls/taskbar/Bar', [ self.appendChild(Task); self.$unserializedTasks++; - if (self.$unserializedTasks == tasks.length) { + if (self.$unserializedTasks === tasks.length) { self.fireEvent('unserializeFinish', [self]); } }; @@ -175,8 +175,8 @@ define('qui/controls/taskbar/Bar', [ 'class' : 'qui-taskbar qui-task-drop box', 'data-quiid': this.getId(), html : '<div class="qui-taskbar-container">' + - '<div class="qui-taskbar-container-tasks"></div>' + - '</div>', + '<div class="qui-taskbar-container-tasks"></div>' + + '</div>', events : { contextmenu: this.$openContextMenu } @@ -186,11 +186,11 @@ define('qui/controls/taskbar/Bar', [ this.$Elm.setStyles(this.getAttribute('styles')); } - if (this.getAttribute('position') == 'bottom') { + if (this.getAttribute('position') === 'bottom') { this.$Elm.addClass('qui-taskbar-bottom'); } - if (this.getAttribute('position') == 'top') { + if (this.getAttribute('position') === 'top') { this.$Elm.addClass('qui-taskbar-top'); } @@ -348,6 +348,15 @@ define('qui/controls/taskbar/Bar', [ return this; }, + /** + * Return the number of the children tasks + * + * @return {Number} + */ + length: function () { + return this.$tasks.length; + }, + /** * Return the first task children * @@ -441,7 +450,7 @@ define('qui/controls/taskbar/Bar', [ tid = Task.getId(); for (var i = 0, len = tasks.length; i < len; i++) { - if (tid != tasks[i].getId()) { + if (tid !== tasks[i].getId()) { tasks[i].destroy(); } } @@ -615,7 +624,7 @@ define('qui/controls/taskbar/Bar', [ // open other task if (this.$LastTask && - this.$LastTask.getId() == Task.getId()) { + this.$LastTask.getId() === Task.getId()) { this.$LastTask = null; } @@ -629,14 +638,14 @@ define('qui/controls/taskbar/Bar', [ this.$Active = null; if (this.$LastTask && - this.$LastTask.getId() != Task.getId()) { + this.$LastTask.getId() !== Task.getId()) { this.$LastTask.click(); return; } var FirstTask = this.firstChild(); - if (FirstTask && Task.getId() == FirstTask.getId()) { + if (FirstTask && Task.getId() === FirstTask.getId()) { if (typeof this.$tasks[1] !== 'undefined') { return this.$tasks[1].click(); }