Revision: 2429
          http://vexi.svn.sourceforge.net/vexi/?rev=2429&view=rev
Author:   clrg
Date:     2007-10-11 19:02:28 -0700 (Thu, 11 Oct 2007)

Log Message:
-----------
Refactor code to use current standards

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t     
2007-10-11 22:08:09 UTC (rev 2428)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t     
2007-10-12 02:02:28 UTC (rev 2429)
@@ -37,20 +37,18 @@
     </ui:box>
     
     /** pop up or down depending on whether option is open */
-    static.buttonActionFunc = function(v)
-    {
-        if (trapee.p_option.enabled)
-        {
-            if (trapee.p_option.popped)
-                 trapee.p_option.popdown = true;
-            else trapee.p_option.popup = true;
+    static.buttonActionFunc = function(v) {
+        var p_opt = trapee.p_option;
+        if (p_opt.enabled) {
+            if (p_opt.popped)
+                 p_opt.popdown = true;
+            else p_opt.popup = true;
         }
         cascade = v;
     }
     
     /** initializes popup button */
-    static.buttonThemeFunc = function(v)
-    {
+    static.buttonThemeFunc = function(v) {
         v.action ++= static.buttonActionFunc;
         v.enabled = trapee.enabled;
         v.p_option = trapee;
@@ -58,8 +56,7 @@
     }
     
     /** update option text when closing popup */
-    static.contentValueFunc = function(v)
-    {
+    static.contentValueFunc = function(v) {
         if (trapee.p_option.popped or trapee.valueset) return;
         cascade = v;
         trapee.valueset = true;
@@ -68,39 +65,37 @@
     }
     
     /** highlight items on mouse enter */
-    static.contentChildAddedFunc = function(v)
-    {
+    static.contentChildAddedFunc = function(v) {
         v.Enter ++= static.enterFunc;
         cascade = v;
     }
     
     /** one time only function to register itemgroup */
-    static.contentFirstChildAddedFunc = function(v)
-    {
-        if (v.group)
-        {
-            trapee.p_option.itemgroup = v.group;
-            trapee.p_option.itemgroup.p_option = trapee.p_option;
-            trapee.p_option.itemgroup.selected ++= static.syncViewFunc;
-            trapee.Children --= callee;
+    static.contentFirstChildAddedFunc = function(v) {
+        var t = trapee;
+        if (v.group) {
+            t.p_option.itemgroup = v.group;
+            t.p_option.itemgroup.p_option = t.p_option;
+            t.p_option.itemgroup.selected ++= static.syncViewFunc;
+            t.Children --= callee;
         }
         cascade = v;
     }
     
     /** popdown post-selection of item */
-    static.contentReleaseFunc = function(v)
-    {
-        trapee.p_option.popdown = true;
-        trapee.p_option.th_output.text = trapee.p_option.showvalue ? 
trapee.value : trapee.text;
-        trapee.valueset = true;
-        trapee.p_option.value = trapee.value;
-        trapee.valueset = false;
+    static.contentReleaseFunc = function(v) {
+        var t = trapee;
+        var p_opt = t.p_option;
+        p_opt.popdown = true;
+        p_opt.th_output.text = p_opt.showvalue ? t.value : t.text;
+        t.valueset = true;
+        p_opt.value = t.value;
+        t.valueset = false;
         cascade = v;
     }
     
     /** initialize content list */
-    static.contentThemeFunc = function(v)
-    {
+    static.contentThemeFunc = function(v) {
         v.p_option = trapee;
         v.value ++= static.contentValueFunc;
         v.Children ++= static.contentChildAddedFunc;
@@ -110,8 +105,7 @@
     }
     
     /** disabled option must be popped down */
-    static.enabledFunc = function(v)
-    {
+    static.enabledFunc = function(v) {
         if (!v) trapee.popdown = true;
         if (trapee.th_button) trapee.th_button.enabled = v;
         cascade = v;
@@ -121,119 +115,104 @@
     static.readFunc = function() { return trapee.th_content[trapname]; }
     
     /** appropriate assign value */
-    static.valueFunc = function(v)
-    {
+    static.valueFunc = function(v) {
+        var t = trapee;
         // FIXME: don't return but deal with it
-        if (trapee.popped or trapee.valueset) return;
-        trapee.valueset = true;
-        trapee.th_content.value = v;
-        trapee.th_output.text = trapee.showvalue ? trapee.th_content.value : 
trapee.th_content.text;
-        trapee.valueset = false;
+        if (t.popped or t.valueset) return;
+        t.valueset = true;
+        t.th_content.value = v;
+        t.th_output.text = t.showvalue ? t.th_content.value : 
t.th_content.text;
+        t.valueset = false;
     }
     
     /** applied to list items */
-    static.enterFunc = function(v)
-    {
+    static.enterFunc = function(v) {
         trapee.selected = true;
         cascade = v;
     }
     
     /** focusable integration */
-    static.keypressFunc = function(v)
-    {
+    static.keypressFunc = function(v) {
+        var t = trapee;
+        var content = t.th_content;
         // open/close on space
-        if (v == ' ')
-        {
-            if (trapee.popped)
-            {
-                trapee.popdown = true;
-                trapee.value = trapee.th_content.value;
-            }
-            else trapee.popup = true;
-        }
+        if (v == ' ') {
+            if (t.popped) {
+                t.popdown = true;
+                t.value = content.value;
+            } else t.popup = true;
+            
         // select next item on arrow down
-        else if (v == "down")
-        {
-            if (trapee.popped)
-            {
+        } else if (v == "down") {
+            if (t.popped) {
                 var i = -1;
-                while (trapee.th_content.numchildren > ++i)
-                    if (trapee.th_content[i].selected) break;
-                if (i == trapee.th_content.numchildren)
-                {
-                    for (i=0; trapee.th_content.numchildren>i; i++)
-                        if (trapee.th_content[i].enabled) { 
trapee.th_content[i].selected = true; return; }
-                }
-                else if (trapee.th_content[i].nextselect)
-                    trapee.th_content[i].nextselect.selected = true;
+                while (content.numchildren > ++i)
+                    if (content[i].selected) break;
+                if (i == content.numchildren) {
+                    for (i=0; content.numchildren>i; i++)
+                        if (content[i].enabled) { content[i].selected = true; 
return; }
+                } else if (content[i].nextselect)
+                    content[i].nextselect.selected = true;
                 
                 // FIXME: cleaner? needs changes to vexi.widget.list
-                //if (trapee.th_content.selected)
-                //    trapee.th_content.selected.nextselect = true;
-                //else if (trapee.th_content[0])
-                //    trapee.th_content[0].selected = true;
-            }
+                //if (content.selected)
+                //    content.selected.nextselect = true;
+                //else if (content[0])
+                //    content[0].selected = true;
+                
             // popup if not already popped
-            else trapee.popup = true;
-        }
+            } else t.popup = true;
+            
         // behaviour for up arrow
-        else if (v == "up")
-        {
+        } else if (v == "up") {
             // select previous item
-            if (trapee.popped)
-            {
-                var i = trapee.th_content.numchildren;
+            if (t.popped) {
+                var i = content.numchildren;
                 while (--i >= 0)
-                    if (trapee.th_content[i].selected) break;
-                if (0 > i)
-                {
-                    for (i=0; trapee.th_content.numchildren>i; i++)
-                        if (trapee.th_content[i].enabled) { 
trapee.th_content[i].selected = true; return; }
+                    if (content[i].selected) break;
+                if (0 > i) {
+                    for (i=0; content.numchildren>i; i++)
+                        if (content[i].enabled) { content[i].selected = true; 
return; }
                 }
-                else if (trapee.th_content[i].prevselect)
-                    trapee.th_content[i].prevselect.selected = true;
+                else if (content[i].prevselect)
+                    content[i].prevselect.selected = true;
                 
                 // FIXME: cleaner? needs changes to vexi.widget.list
-                //if (trapee.th_content.selected)
-                //    trapee.th_content.selected.prevselect = true;
-                //else if (trapee.th_content[0])
-                //    trapee.th_content[0].selected = true;
-            }
+                //if (content.selected)
+                //    content.selected.prevselect = true;
+                //else if (content[0])
+                //    content[0].selected = true;
+                
             // popup if not already popped
-            else trapee.popup = true;
-        } 
+            } else t.popup = true;
+            
         // close positively on enter
-        else if (v == "enter") {
-            trapee.popdown = true;
-            trapee.value = trapee.th_content.value;
-        }
+        } else if (v == "enter") {
+            t.popdown = true;
+            t.value = content.value;
+            
         // behaviour for escape
-        else if (v == "escape")
-        {
-            for (var i=0; trapee.th_content.numchildren > i; i++)
-            {
-                if (trapee.th_content[i].selected)
-                {
-                    trapee.th_content[i].selected = false;
+        } else if (v == "escape") {
+            for (var i=0; content.numchildren > i; i++) {
+                if (content[i].selected) {
+                    content[i].selected = false;
                     break;
                 }
             }
-            trapee.popdown = true;
+            t.popdown = true;
         }
         cascade = v;
     }
     
     /** fire button action when clicked on */
-    static.pressFunc = function(v)
-    {
+    static.pressFunc = function(v) {
         if (!trapee.th_button.mouse.inside)
             trapee.th_button.action = true;
         cascade = v;
     }
     
     /** keeps the selected item within view */
-    static.syncViewFunc = function(v)
-    {
+    static.syncViewFunc = function(v) {
         if (!v) return;
         var s = trapee.p_option.th_scroll;
         if ((s.distanceto(v).y+v.height) > s.height)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to