Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
6 Views

Patch for JQM sidebar.js supporting file - invalid toggle function in original

This is for v3400.

This patch corrects the toggle function and makes the open/close work reliably in all conditions and avoids generating a type exception when a DOM node is not found. The toggle logic in the original truth table is incorrect and makes the sidebar get stuck. This version simplifies the logic and ensures correct behavior without edge conditions.

Old version: Assumes it knew when a toggle was required before knowing the open state and then only compared the toggle state if the bar was open. This is an invalid logic path and misses the times that the bar should be closed.

New version: Either the bar is open or not. If the open state does not match the requested state, we toggle.

--- xdk/components/server/ui-builder/ui-builder_repo/resources/toolbar/layout/supporting/sidebar/js/sidebar.js    2015-04-13 11:00:19.000000000 -0400
+++ xdk-fixed/components/server/ui-builder/ui-builder_repo/resources/toolbar/layout/supporting/sidebar/js/sidebar.js        2016-02-28 19:55:13.775920290 -0500
@@ -32,7 +32,7 @@
      * toggle_sidebar
      * @param domNode_query -- a single jQuery wrapped domNode
      */
-    uib_sb.toggle_sidebar = function(domNode_query)
+    uib_sb.toggle_sidebar = function(domNode_query,completef)
     {
         ["leftbar", "rightbar", "topbar", "botbar"].forEach(function(cname) {
             if (domNode_query.hasClass(cname)) {
@@ -40,7 +40,7 @@
                 else {
                     close_other_sidebars(domNode_query).done(function()
                     {
-                        dispatch_sidebar(domNode_query, perform_toggle_sidebar);
+                        dispatch_sidebar(domNode_query, perform_toggle_sidebar,[completef,null]);
                     });
                 }
             }
@@ -340,14 +340,15 @@

     function perform_open_close_sidebar(domNode_query, property, partner_selector, partner_property, partner_base, completef, open, dur)
     {
-        var should_toggle =  (domNode_query.hasClass("reveal")) ? (domNode_query.css('visibility') == "visible") : (domNode_query.css(property) == "0px");
-        if(open){ should_toggle = !should_toggle; }
-        if(should_toggle){ perform_toggle_sidebar(domNode_query, property, partner_selector, partner_property, partner_base, completef, dur); }
+        var is_open =  (domNode_query.hasClass("reveal")) ? (domNode_query.css('visibility') == "visible") : (domNode_query.css(property) == "0px");
+        if(open!=is_open){ perform_toggle_sidebar(domNode_query, property, partner_selector, partner_property, partner_base, completef, dur); }
         else if(completef){ completef(); }
     }

     function dquote(str)
     {
+       if(typeof(str)=='undefined')
+               return "{}";
         return str.replace(/'/g, "\"");
     }

 

Tags (2)
0 Kudos
1 Reply
Highlighted
Beginner
6 Views

Sorry - I think there was a version mismatch in the last diff so the line numbers may be off. I have redone the diff. Here it is. This is for XDK v3400.

Same comment as before. The old logic does not properly handle toggling.

--- xdk/components/server/ui-builder/ui-builder_repo/resources/toolbar/layout/supporting/sidebar/js/sidebar.js  2016-06-03 16:25:42.000000000 -0400
+++ xdk-3400-fixed/components/server/ui-builder/ui-builder_repo/resources/toolbar/layout/supporting/sidebar/js/sidebar.js       2016-06-26 04:30:56.575025439 -0400
@@ -35,7 +33,7 @@
      * toggle_sidebar
      * @param domNode_query -- a single jQuery wrapped domNode
      */
-    uib_sb.toggle_sidebar = function(domNode_query)
+    uib_sb.toggle_sidebar = function(domNode_query,completef)
     {
         ["leftbar", "rightbar", "topbar", "botbar"].forEach(function(cname) {
             if (domNode_query.hasClass(cname)) {
@@ -43,7 +41,7 @@
                 else {
                     close_other_sidebars(domNode_query).done(function()
                     {
-                        dispatch_sidebar(domNode_query, perform_toggle_sidebar);
+                        dispatch_sidebar(domNode_query, perform_toggle_sidebar,[completef,null]);
                     });
                 }
             }
@@ -344,14 +341,15 @@

     function perform_open_close_sidebar(domNode_query, property, partner_selector, partner_property, partner_base, completef, open, dur)
     {
-        var should_toggle =  (domNode_query.hasClass("reveal")) ? (domNode_query.css('visibility') == "visible") : (domNode_query.css(property) == "0px");
-        if(open){ should_toggle = !should_toggle; }
-        if(should_toggle){ perform_toggle_sidebar(domNode_query, property, partner_selector, partner_property, partner_base, completef, dur); }
+        var is_open =  (domNode_query.hasClass("reveal")) ? (domNode_query.css('visibility') == "visible") : (domNode_query.css(property) == "0px");
+        if(open!=is_open){ perform_toggle_sidebar(domNode_query, property, partner_selector, partner_property, partner_base, completef, dur); }
         else if(completef){ completef(); }
     }

     function dquote(str)
     {
+       if(typeof(str)=='undefined')
+               return "{}";
         return str.replace(/'/g, "\"");
     }
     uib_sb.dquote = dquote;

 

0 Kudos