You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2013/10/14 18:02:10 UTC

svn commit: r1531953 - /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js

Author: weber
Date: Mon Oct 14 16:02:10 2013
New Revision: 1531953

URL: http://svn.apache.org/r1531953
Log:
TOBAGO-1322 - Input elements behind Popup are not reenabled if popup was reloaded before closing

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js?rev=1531953&r1=1531952&r2=1531953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js Mon Oct 14 16:02:10 2013
@@ -113,6 +113,36 @@ Tobago.Popup.init = function (elements) 
   }
 };
 
+Tobago.Popup.getDisabledElements = function(popupId) {
+  var data = jQuery("body").data("tobago-popups-disabled-elements");
+  if (data) {
+    // data is Array of {id: popupId, elements: jQueryObject}
+    for (var i = 0; i < data.length; i++) {
+      if (data[i].id == popupId) {
+        return data[i].elements;
+      }
+    }
+  }
+  return undefined;
+};
+
+Tobago.Popup.storeDisabledElements = function(popupId, elements) {
+  var jBody = jQuery("body");
+  var data = jBody.data("tobago-popups-disabled-elements");
+  if (!data) {
+    data = new Array();
+    jBody.data("tobago-popups-disabled-elements", data);
+  }
+  // data is Array of {id: popupId, elements: jQueryObject}
+  for (var i = 0; i < data.length; i++) {
+    if (data[i].id == popupId) {
+      data[i].elements = elements;
+      return;
+    }
+  }
+  data.push({id: popupId, elements: elements});
+};
+
 /**
  * Locks the parent page of a popup when it is opened
  */
@@ -121,7 +151,7 @@ Tobago.Popup.lockBehind = function (popu
   // store their ids in a data attribute of the popup
   var id = popup.id;
   // The attribute might be set by the last call, this may happen, when opening a non-modal popup on a modal popup.
-  if (jQuery(popup).data('tobago-disabledElements') == null) {
+  if (Tobago.Popup.getDisabledElements(popup.id) === undefined) {
     var disabledElements = jQuery();
     var firstPopupElement = null;
 //    var pageElements = jQuery(document.forms[0].elements);
@@ -149,7 +179,7 @@ Tobago.Popup.lockBehind = function (popu
         jQuery.merge(disabledElements, jQuery(element)); // store it for reactivation
       }
     });
-    jQuery(popup).data('tobago-disabledElements', disabledElements);
+    Tobago.Popup.storeDisabledElements(popup.id, disabledElements);
 
     // find the first element in the popup for the focus
     if (firstPopupElement != null) {
@@ -205,13 +235,12 @@ Tobago.Popup.unlockBehind = function (po
   }
   popups.each(function() {
     // re-enable all elements and anchors on page stored in the attribute
-    var popup = jQuery(this);
-    var disabledElements = popup.data('tobago-disabledElements');
+    var disabledElements = Tobago.Popup.getDisabledElements(this.id);
     if (disabledElements != null) {
       disabledElements.each(function() {
         jQuery(this).prop({disabled: false});
       });
-      jQuery(popup).removeData('tobago-disabledElements');
+      Tobago.Popup.storeDisabledElements(this.id, undefined);
     }
   });
 };