3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
17 * Copyright(c) 2006-2011 Sencha Inc.
18 * licensing@sencha.com
19 * http://www.sencha.com/license
23 * @class Ext.ux.desktop.TaskBar
24 * @extends Ext.toolbar.Toolbar
26 Ext.define('Ext.ux.desktop.TaskBar', {
27 extend: 'Ext.toolbar.Toolbar', // TODO - make this a basic hbox panel...
31 'Ext.resizer.Splitter',
34 'Ext.ux.desktop.StartMenu'
37 alias: 'widget.taskbar',
42 * @cfg {String} startBtnText
43 * The text for the Start Button.
45 startBtnText: 'Start',
47 initComponent: function () {
50 me.startMenu = new Ext.ux.desktop.StartMenu(me.startConfig);
52 me.quickStart = new Ext.toolbar.Toolbar(me.getQuickStart());
54 me.windowBar = new Ext.toolbar.Toolbar(me.getWindowBarConfig());
56 me.tray = new Ext.toolbar.Toolbar(me.getTrayConfig());
61 cls: 'ux-start-button',
62 iconCls: 'ux-start-button-icon',
69 xtype: 'splitter', html: ' ',
70 height: 14, width: 2, // TODO - there should be a CSS way here
71 cls: 'x-toolbar-separator x-toolbar-separator-horizontal'
82 afterLayout: function () {
85 me.windowBar.el.on('contextmenu', me.onButtonContextMenu, me);
89 * This method returns the configuration object for the Quick Start toolbar. A derived
90 * class can override this method, call the base version to build the config and
91 * then modify the returned object before returning it.
93 getQuickStart: function () {
94 var me = this, ret = {
101 Ext.each(this.quickStart, function (item) {
103 tooltip: { text: item.name, align: 'bl-tl' },
104 //tooltip: item.name,
105 overflowText: item.name,
106 iconCls: item.iconCls,
108 handler: me.onQuickStartClick,
117 * This method returns the configuration object for the Tray toolbar. A derived
118 * class can override this method, call the base version to build the config and
119 * then modify the returned object before returning it.
121 getTrayConfig: function () {
124 items: this.trayItems
126 delete this.trayItems;
130 getWindowBarConfig: function () {
133 cls: 'ux-desktop-windowbar',
135 layout: { overflowHandler: 'Scroller' }
139 getWindowBtnFromEl: function (el) {
140 var c = this.windowBar.getChildByElement(el);
144 onQuickStartClick: function (btn) {
145 var module = this.app.getModule(btn.module);
147 module.createWindow();
151 onButtonContextMenu: function (e) {
152 var me = this, t = e.getTarget(), btn = me.getWindowBtnFromEl(t);
155 me.windowMenu.theWin = btn.win;
156 me.windowMenu.showBy(t);
160 onWindowBtnClick: function (btn) {
163 if (win.minimized || win.hidden) {
165 } else if (win.active) {
172 addTaskButton: function(win) {
174 iconCls: win.iconCls,
178 text: Ext.util.Format.ellipsis(win.title, 20),
180 click: this.onWindowBtnClick,
186 var cmp = this.windowBar.add(config);
191 removeTaskButton: function (btn) {
192 var found, me = this;
193 me.windowBar.items.each(function (item) {
200 me.windowBar.remove(found);
205 setActiveButton: function(btn) {
209 this.windowBar.items.each(function (item) {
219 * @class Ext.ux.desktop.TrayClock
220 * @extends Ext.toolbar.TextItem
221 * This class displays a clock on the toolbar.
223 Ext.define('Ext.ux.desktop.TrayClock', {
224 extend: 'Ext.toolbar.TextItem',
226 alias: 'widget.trayclock',
228 cls: 'ux-desktop-trayclock',
236 initComponent: function () {
241 if (typeof(me.tpl) == 'string') {
242 me.tpl = new Ext.XTemplate(me.tpl);
246 afterRender: function () {
248 Ext.Function.defer(me.updateTime, 100, me);
252 onDestroy: function () {
256 window.clearTimeout(me.timer);
263 updateTime: function () {
264 var me = this, time = Ext.Date.format(new Date(), me.timeFormat),
265 text = me.tpl.apply({ time: time });
266 if (me.lastText != text) {
270 me.timer = Ext.Function.defer(me.updateTime, 10000, me);