[qo-modules-dev] [53] There's a bug currently in Ext3 svn.

[ Thread Index | Date Index | More lists.tuxfamily.org/qo-modules-dev Archives ]


Revision: 53
Author:   mjlecomte
Date:     2008-12-06 15:17:25 +0100 (Sat, 06 Dec 2008)

Log Message:
-----------
There's a bug currently in Ext3 svn.  I reverted the part that had the bug until they fix it.  I altered some of the classes to make them more loosely coupled by using events instead of direct function calls.  The classes for desktop were very tightly coupled originally, this is another step closer to making them operate independently.  The idea here is that someone may say they don't want a "taskbar" or want to replace it with something different.

Modified Paths:
--------------
    mickael/trunk/ext/v3.0.0-a1/ext-all-debug.js
    mickael/trunk/ext/v3.0.0-a1/ext-all.js
    mickael/trunk/ext/v3.0.0-a1/ext-core-debug.js
    mickael/trunk/ext/v3.0.0-a1/ext-core.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/desktop.html
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/App.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/Module.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/button/TaskButton.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/ActiveApps.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/Appbar.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/TaskBar.js
    mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/view/Desktop.js


Modified: mickael/trunk/ext/v3.0.0-a1/ext-all-debug.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/ext-all-debug.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/ext-all-debug.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -2316,7 +2316,7 @@
         
         within : function(el, related){
             var t = this[related ? "getRelatedTarget" : "getTarget"]();
-            return t && ((allowEl ? (t === Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
+            return t && Ext.fly(el).contains(t);
         },
 
         getPoint : function(){

Modified: mickael/trunk/ext/v3.0.0-a1/ext-all.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/ext-all.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/ext-all.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -206,7 +206,7 @@
 E.stopPropagation(this.browserEvent);}},getCharCode:function(){return this.charCode||this.keyCode;},getKey:function(){var k=this.keyCode||this.charCode;return Ext.isSafari?(safariKeys[k]||k):k;},getPageX:function(){return this.xy[0];},getPageY:function(){return this.xy[1];},getTime:function(){if(this.browserEvent){return E.getTime(this.browserEvent);}
 return null;},getXY:function(){return this.xy;},getTarget:function(selector,maxDepth,returnEl){return selector?Ext.fly(this.target).findParent(selector,maxDepth,returnEl):(returnEl?Ext.get(this.target):this.target);},getRelatedTarget:function(){if(this.browserEvent){return E.getRelatedTarget(this.browserEvent);}
 return null;},getWheelDelta:function(){var e=this.browserEvent;var delta=0;if(e.wheelDelta){delta=e.wheelDelta/120;}else if(e.detail){delta=-e.detail/3;}
-return delta;},hasModifier:function(){return((this.ctrlKey||this.altKey)||this.shiftKey)?true:false;},within:function(el,related){var t=this[related?"getRelatedTarget":"getTarget"]();return t&&((allowEl?(t===Ext.getDom(el)):false)||Ext.fly(el).contains(t));},getPoint:function(){return new Ext.lib.Point(this.xy[0],this.xy[1]);}};return new Ext.EventObjectImpl();}();
+return delta;},hasModifier:function(){return((this.ctrlKey||this.altKey)||this.shiftKey)?true:false;},within:function(el,related){var t=this[related?"getRelatedTarget":"getTarget"]();return t&&Ext.fly(el).contains(t);},getPoint:function(){return new Ext.lib.Point(this.xy[0],this.xy[1]);}};return new Ext.EventObjectImpl();}();
 
 (function(){var D=Ext.lib.Dom;var E=Ext.lib.Event;var A=Ext.lib.Anim;var propCache={};var camelRe=/(-[a-z])/gi;var camelFn=function(m,a){return a.charAt(1).toUpperCase();};var view=document.defaultView;Ext.Element=function(element,forceNew){var dom=typeof element=="string"?document.getElementById(element):element;if(!dom){return null;}
 var id=dom.id;if(forceNew!==true&&id&&Ext.Element.cache[id]){return Ext.Element.cache[id];}

Modified: mickael/trunk/ext/v3.0.0-a1/ext-core-debug.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/ext-core-debug.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/ext-core-debug.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -2316,7 +2316,7 @@
         
         within : function(el, related){
             var t = this[related ? "getRelatedTarget" : "getTarget"]();
-            return t && ((allowEl ? (t === Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
+            return t && Ext.fly(el).contains(t);
         },
 
         getPoint : function(){

Modified: mickael/trunk/ext/v3.0.0-a1/ext-core.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/ext-core.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/ext-core.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -206,7 +206,7 @@
 E.stopPropagation(this.browserEvent);}},getCharCode:function(){return this.charCode||this.keyCode;},getKey:function(){var k=this.keyCode||this.charCode;return Ext.isSafari?(safariKeys[k]||k):k;},getPageX:function(){return this.xy[0];},getPageY:function(){return this.xy[1];},getTime:function(){if(this.browserEvent){return E.getTime(this.browserEvent);}
 return null;},getXY:function(){return this.xy;},getTarget:function(selector,maxDepth,returnEl){return selector?Ext.fly(this.target).findParent(selector,maxDepth,returnEl):(returnEl?Ext.get(this.target):this.target);},getRelatedTarget:function(){if(this.browserEvent){return E.getRelatedTarget(this.browserEvent);}
 return null;},getWheelDelta:function(){var e=this.browserEvent;var delta=0;if(e.wheelDelta){delta=e.wheelDelta/120;}else if(e.detail){delta=-e.detail/3;}
-return delta;},hasModifier:function(){return((this.ctrlKey||this.altKey)||this.shiftKey)?true:false;},within:function(el,related){var t=this[related?"getRelatedTarget":"getTarget"]();return t&&((allowEl?(t===Ext.getDom(el)):false)||Ext.fly(el).contains(t));},getPoint:function(){return new Ext.lib.Point(this.xy[0],this.xy[1]);}};return new Ext.EventObjectImpl();}();
+return delta;},hasModifier:function(){return((this.ctrlKey||this.altKey)||this.shiftKey)?true:false;},within:function(el,related){var t=this[related?"getRelatedTarget":"getTarget"]();return t&&Ext.fly(el).contains(t);},getPoint:function(){return new Ext.lib.Point(this.xy[0],this.xy[1]);}};return new Ext.EventObjectImpl();}();
 
 (function(){var D=Ext.lib.Dom;var E=Ext.lib.Event;var A=Ext.lib.Anim;var propCache={};var camelRe=/(-[a-z])/gi;var camelFn=function(m,a){return a.charAt(1).toUpperCase();};var view=document.defaultView;Ext.Element=function(element,forceNew){var dom=typeof element=="string"?document.getElementById(element):element;if(!dom){return null;}
 var id=dom.id;if(forceNew!==true&&id&&Ext.Element.cache[id]){return Ext.Element.cache[id];}

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/desktop.html
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/desktop.html	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/desktop.html	2008-12-06 14:17:25 UTC (rev 53)
@@ -12,12 +12,13 @@
 
  	<!-- LIBS -->
  	<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
+<!--
+    <script type="text/javascript" src="../../ext-all.js"></script>
 
-    <script type="text/javascript" src="../../ext-all.js"></script>
-<!--
 -->
-<!--    
+    
     <script type="text/javascript" src="../../ext-all-detail.js"></script>
+<!--
 -->
  	<!-- OVERRIDES -->       <!-- Destroy context menus -->
     <script type="text/javascript" src="js/overrides/override.js"></script>

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/App.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/App.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/App.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -24,6 +24,18 @@
         //add events
         this.addEvents(
             /**
+             * @event activate
+             * Fires when a module is setActive.
+             * @param {Ext.ux.App} this
+             */
+            'activate',
+            /**
+             * @event aftercreate
+             * Fires before a module is created (fires from the module's afterRender method).
+             * @param {Ext.ux.App} this
+             */
+            'aftercreate',
+            /**
              * @event beforecreate
              * Fires before a module is created.  Return false to disable creation of another module instance.
              * @param {Ext.ux.App} this
@@ -31,7 +43,7 @@
             'beforecreate',
             /**
              * @event beforeunload
-             * Fires before the window is unloaded (after the browser window beforeunload event).
+             * Fires before the browser window is unloaded (after the browser window beforeunload event).
              * @param {Ext.ux.App} this
              */
             'beforeunload',
@@ -42,6 +54,18 @@
              */
             'changecount',
             /**
+             * @event deactivate
+             * Fires after the module has been visually deactivated via setActive.
+             * @param {Ext.ux.App} this
+             */
+            'deactivate',
+            /**
+             * @event moduleshow
+             * Fires when a module is shown.
+             * @param {Ext.ux.App} this
+             */
+            'moduleshow',
+            /**
              * @event ready
              * Fires when the app is ready.
              * @param {Ext.ux.App} this

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/Module.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/Module.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/Module.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -44,13 +44,6 @@
 Ext.ux.Module = Ext.extend(Ext.Window, {
 
     /**
-     * @cfg {String} activeBtnCls
-     * An optional class to be applied to the taskbar button associated with this module when
-     * the active state of the module window changes.
-     */
-    clsActiveBtn: '',
-
-    /**
      * @cfg {Boolean} closable
      * <p>True to display the 'close' tool button and allow the user to close the window, false to
      * hide the button and disallow closing the window (default to true).</p>
@@ -193,11 +186,13 @@
 
         this.on({
             scope: this,
-            'activate':   this.markActive, //TODO: why call same method twice
-            'beforeshow': this.markActive, //it ends up getting called for both methods
-            'deactivate': this.markInactive,
-            'minimize':   this.minimizeWin,
-            'close':      this.removeWin
+            // fire application wide event so anyone can observe
+            'activate':   function(){this.app.fireEvent('activate', this)}, 
+            'beforeshow': function(){this.app.fireEvent('moduleshow', this)},
+            'show':       function(){this.app.fireEvent('moduleshow', this)},
+            'deactivate': function(){this.app.fireEvent('deactivate', this)},
+            'minimize':   this.minimizeWin
+//           'close':      this.removeWin
         });
     },
 
@@ -211,27 +206,9 @@
         this.resizer.widthIncrement = this.xTickSize;
         this.resizer.heightIncrement = this.yTickSize;
         
-//////////////////////////=================================================        
-
-        //add the module to the taskbar as a button:
-        this.addTaskButton();
-        this.show();
+        this.app.fireEvent('aftercreate', this);
     },
 
-    /**
-     * Add a button to the application bar for this module instance
-     * @private
-     */
-    addTaskButton: function () {
-        /**
-         * The application bar task button associated with this module instance.
-         * @type {Object}
-         * @property
-         */
-        this.taskButton = this.app.view.taskbar.addTaskButton(this);
-        this.animateTarget = this.taskButton.el;
-    },
-
     /* @private */
     onDestroy: function () {
         var id = this.id, m, a, i;
@@ -249,44 +226,6 @@
     },
 
     /**
-     * TODO: may as well move this into the onDestroy method, it does the same thing
-     * @private
-     */
-    removeWin: function () {
-        this.taskButton.destroy();
-    },
-
-    /**
-     * Update the application bar button associated with this module instance
-     * to add the 'active-win' class.
-     * @param {Object} win
-     */
-    markActive: function (win) {
-        // fire application wide event so anyone can observe
-        this.app.fireEvent('activate', this);
-        
-        if (this.activeWindow && this.activeWindow !== win) {
-            this.markInactive(this.activeWindow);
-        }
-        this.app.view.taskbar.setActiveButton(win.taskButton);
-        this.app.view.activeWindow = win;
-        Ext.fly(win.taskButton.el).addClass(this.activeBtnCls);
-        win.minimized = false;
-    },
-
-    /**
-     * Update the application bar button associated with this module instance
-     * to remove the 'active-win' class.
-     * @param {Object} win
-     */
-    markInactive: function (win) {
-        if (win === this.activeWindow) {
-            this.activeWindow = null;
-            Ext.fly(win.taskButton.el).removeClass(this.activeBtnCls);
-        }
-    },
-
-    /**
      * Hides this window
      * @param {Object} win
      */

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/button/TaskButton.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/button/TaskButton.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/button/TaskButton.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -64,39 +64,11 @@
     tooltipTpl: '<h3>{title:ellipsis(20)} ({no})</h3><span class="{cls}">{description:trim}</span></div>',
 
     /* @private */
-    constructor: function (win) {
-        this.win = win;
-
+    constructor: function (config) {
+        Ext.apply(this, config);
         // create the tooltip for the button
         this.createTooltip();
-        
-        Ext.ux.button.TaskButton.superclass.constructor.call(this, {
-            /**
-             * @property {String} iconCls
-             * A css class which sets a background image to be used as the icon for this button
-             */
-            iconCls: win.iconCls,
-
-            id: win.id + '_TaskBarTaskButton',
-            // function called when the button is clicked (used instead of click event)
-            handler : function () {
-                if (win.minimized || win.hidden) {
-                    win.show();
-                } else if (win === win.manager.getActive()) {
-                    win.minimize();
-                } else {
-                    win.toFront();
-                }
-            },
-            pressed: true, // start as pressed
-            scope: this, // scope for the handler
-            text: Ext.util.Format.ellipsis(win.title, this.ellipsis),
-            toggleHandler: function(button, state){
-                //TODO leverage built in toggle support
-                //change the btn class?
-            },
-            tooltip: this.tooltip
-        });
+        Ext.ux.button.TaskButton.superclass.constructor.call(this);
     },
 
     /**

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/ActiveApps.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/ActiveApps.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/ActiveApps.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -3,6 +3,107 @@
  * @extends Ext.ux.Appbar
  */
 Ext.ux.ActiveAppsPanel = Ext.extend(Ext.ux.Appbar, {
+
+    /**
+     * @cfg {String} clsActiveBtn
+     * An optional class to be applied to the taskbar button associated with this module when
+     * the active state of the module window changes.
+     */
+    clsActiveBtn: '',
+
+    /**
+     * @type {Object} The currently active window.
+     * @property
+     */
+    activeWindow: null,
+
+    /* @private */
+    initComponent : function () {
+        Ext.ux.ActiveAppsPanel.superclass.initComponent.call(this);
+
+        this.app.on({
+            activate:    this.markActive,
+            moduleshow:  this.markActive,
+            aftercreate: this.addTaskButton,
+            deactivate:  this.markInactive,
+            scope: this
+        });
+    },
+
+    /**
+     * Add a button to the application bar for this module instance
+     * @param {Object} m The module to get the task button for.
+     */
+    addTaskButton: function (m) {
+        var btn = new Ext.ux.button.TaskButton({
+            /**
+             * @property {String} iconCls
+             * A css class which sets a background image to be used as the icon for this button
+             */
+            iconCls: m.iconCls,
+
+            id: m.id + '_TaskBarTaskButton',
+            // function called when the button is clicked (used instead of click event)
+            handler : function () {
+                if (m.minimized || m.hidden) {
+                    m.show();
+                } else if (m === m.manager.getActive()) {
+                    m.minimize();
+                } else {
+                    m.toFront();
+                }
+            },
+            pressed: true, // start as pressed
+            scope: this, // scope for the handler
+            text: Ext.util.Format.ellipsis(m.title, this.ellipsis),
+            toggleHandler: function(button, state){
+                //TODO leverage built in toggle support
+                //change the btn class?
+            },
+            // give button a reference to it's module
+            win: m
+        });
+
+        m.taskButton = btn;
+        this.addButton(btn);
+        this.doLayout();
+        m.animateTarget = btn.el;
+        //when the module is destroyed we'll go ahead and remove this button
+        m.on('destroy', this.removeButton.createDelegate(this, [btn]));
+        m.show();
+    },
+
+    /**
+     * Update the application bar button associated with this module instance
+     * to add the 'active-win' class.
+     * @param {Object} win
+     */
+    markActive: function (win) {
+        if (this.activeWindow && this.activeWindow !== win) {
+            this.markInactive(this.activeWindow);
+        }
+        this.activeButton = win.taskButton;
+        this.activeWindow = win;
+        Ext.fly(win.taskButton.el).addClass(this.clsActiveBtn);
+        win.minimized = false;
+    },
+
+    /**
+     * Update the application bar button associated with this module instance
+     * to remove the 'active-win' class.
+     * @param {Object} win
+     */
+    markInactive: function (win) {
+        if (win === this.activeWindow) {
+            this.activeWindow = null;
+            Ext.fly(win.taskButton.el).removeClass(this.clsActiveBtn);
+        }
+    }
+
+// ==================================================================================
+// ==================================================================================
+// ==================================================================================
+// ==================================================================================
 /*
     activeButton: null,
     enableScroll: true,
@@ -43,25 +144,6 @@
         return btn;
     },
 
-    removeButton: function (btn) {
-
-        btn.destroy();
-        
-        var s = [];
-        for (var i = 0, len = this.items.length; i < len; i++) {
-            if (this.items[i] !== btn) {
-                s.push(this.items[i]);
-            }
-        }
-        this.items = s;
-        this.delegateUpdates();
-    },
-*/    
-    setActiveButton: function (btn) {
-        this.activeButton = btn;
-//      this.delegateUpdates();
-    }
-/*    
     autoSize: function () {
         var count, ow, aw, each, btns, btn, tw, iw;
        // if (!this.items) return;

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/Appbar.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/Appbar.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/Appbar.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -39,6 +39,14 @@
             })
         }
         return btns;
+    },
+    
+    /**
+     * Destroys the button
+     * @param {Object} btn The button to remove
+     */
+    removeButton: function (btn) {
+        btn.destroy();
     }
 });
 Ext.reg('appbar', Ext.ux.Appbar);
\ No newline at end of file

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/TaskBar.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/TaskBar.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/toolbar/TaskBar.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -191,10 +191,6 @@
                 scope: this
             }
         });
-        
-        this.app.on({
-            activate: this.markActive
-        });
     },
 
     /**
@@ -218,41 +214,6 @@
      */
     onBarRender: function() {
         this.el.addClass("transparent");
-    },
-
-    /**
-     * Called on activate event of **application** 
-     */
-    markActive: function () {
-        console.info('markActive called');
-    },
-    
-    /**
-     * Add a button
-     * @param {Object} cfg button config object
-     */
-    addTaskButton: function (cfg) {
-        var btn = new Ext.ux.button.TaskButton(cfg);
-        this.activeAppsPanel = Ext.getCmp('ux-taskbuttons-panel');
-        this.activeAppsPanel.addButton(btn);
-        this.activeAppsPanel.doLayout();
-        return btn;
-    },
-    
-    /**
-     * Calls activeAppsPanel.removeButton(btn)
-     * @param {Object} btn The button to remove
-     */
-    removeTaskButton: function (btn) {
-        this.activeAppsPanel.removeButton(btn);
-    },
-    
-    /**
-     * Calls activeAppsPanel.setActiveButton(btn)
-     * @param {Object} btn The button to set as active
-     */
-    setActiveButton: function (btn) {
-        this.activeAppsPanel.setActiveButton(btn);
     }
 });
 Ext.reg('taskbar', Ext.ux.TaskBar);
\ No newline at end of file

Modified: mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/view/Desktop.js
===================================================================
--- mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/view/Desktop.js	2008-12-06 10:30:30 UTC (rev 52)
+++ mickael/trunk/ext/v3.0.0-a1/learn/desktop/js/view/Desktop.js	2008-12-06 14:17:25 UTC (rev 53)
@@ -8,12 +8,6 @@
 Ext.ux.gui.Desktop = Ext.extend(Ext.ux.View, {
 
     /**
-     * @type {Object} The currently active window.
-     * @property
-     */
-    activeWindow: null,
-    
-    /**
      * @cfg {Integer} Tick size in horizontal direction. Used in the arrange methods.
      */
     xTickSize: 1,


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/