details:   /erp/erp/devel/pi/rev/7a639aeffca4
changeset: 4653:7a639aeffca4
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Wed Aug 19 18:31:21 2009 +0200
summary:   Fixed bug 9506: Now disableToolBarButton works ok in IE8

diffstat:

 src/org/openbravo/erpCommon/security/Login_F1.html |   2 +-
 web/js/appStatus.js                                |  60 ++++----------------
 web/js/utils.js                                    |  29 +++++++++-
 3 files changed, 41 insertions(+), 50 deletions(-)

diffs (145 lines):

diff -r dd0c37d56c35 -r 7a639aeffca4 
src/org/openbravo/erpCommon/security/Login_F1.html
--- a/src/org/openbravo/erpCommon/security/Login_F1.html        Wed Aug 19 
21:36:24 2009 +0530
+++ b/src/org/openbravo/erpCommon/security/Login_F1.html        Wed Aug 19 
18:31:21 2009 +0200
@@ -76,7 +76,7 @@
       clearForm();
     } catch (e) {}
     setWindowElementFocus('firstElement');
-    if (!revisionControl('4462')) alert("Your browser's cache has outdated 
files. Please clean it and reload the page.");
+    if (!revisionControl('4653')) alert("Your browser's cache has outdated 
files. Please clean it and reload the page.");
   }
 
   function onResizeDo() {
diff -r dd0c37d56c35 -r 7a639aeffca4 web/js/appStatus.js
--- a/web/js/appStatus.js       Wed Aug 19 21:36:24 2009 +0530
+++ b/web/js/appStatus.js       Wed Aug 19 18:31:21 2009 +0200
@@ -31,17 +31,7 @@
     img = getObjChild(link);
     if (link.className.indexOf('Main_ToolBar_Button') != -1 && 
link.className.indexOf('Main_ToolBar_Button_disabled') == -1) {
       link.className = link.className.replace('Main_ToolBar_Button', 
'Main_ToolBar_Button_disabled');
-      if (navigator.userAgent.toUpperCase().indexOf("MSIE") == -1) {
-        link.setAttribute('onclick', 'return true; tmp_water_mark; ' + 
link.getAttribute('onclick'));
-      } else {
-        var link_onclick = link.getAttribute('onclick').toString();
-        link_onclick = link_onclick.replace("function anonymous()","");
-        link_onclick = link_onclick.replace("{\n","");
-        link_onclick = link_onclick.replace("\n","");
-        link_onclick = link_onclick.replace("}","");
-        link_onclick = 'return true; tmp_water_mark; ' + link_onclick;
-        link['onclick']=new Function(link_onclick);
-      }
+      disableAttributeWithFunction(link, "obj", "onclick");
       link.setAttribute('id', link.getAttribute('id') + '_disabled');
       img.className = img.className + ('_disabled tmp_water_mark');
     }
@@ -59,17 +49,7 @@
     img = getObjChild(link);
     if (link.className.indexOf('Main_ToolBar_Button_disabled') != -1) {
       link.className = link.className.replace('Main_ToolBar_Button_disabled', 
'Main_ToolBar_Button');
-      if (navigator.userAgent.toUpperCase().indexOf("MSIE") == -1) {
-        link.setAttribute('onclick', 
link.getAttribute('onclick').replace('return true; tmp_water_mark; ', ''));
-      } else {
-        var link_onclick = link.getAttribute('onclick').toString();
-        link_onclick = link_onclick.replace("function anonymous()","");
-        link_onclick = link_onclick.replace("{\n","");
-        link_onclick = link_onclick.replace("\n","");
-        link_onclick = link_onclick.replace("}","");
-        link_onclick = link_onclick.replace('return true; tmp_water_mark; ', 
'');
-        link['onclick']=new Function(link_onclick);
-      }
+      enableAttributeWithFunction(link, "obj", "onclick");
       link.setAttribute('id', link.getAttribute('id').replace('_disabled', 
''));
       img.className = img.className.replace('_disabled tmp_water_mark', '');
     }
@@ -80,35 +60,19 @@
 }
 
 function disableAttributeWithFunction(element, type, attribute) {
-  if (type == 'obj') { var obj = element }
-  if (type == 'id') { var obj = document.getElementById(id); }
-  if (navigator.userAgent.toUpperCase().indexOf("MSIE") == -1) {
-    obj.setAttribute(attribute, 'return true; tmp_water_mark; ' + 
obj.getAttribute(attribute));
-  } else {
-    var obj_attribute = obj.getAttribute(attribute).toString();
-    obj_attribute = obj_attribute.replace("function anonymous()","");
-    obj_attribute = obj_attribute.replace("{\n","");
-    obj_attribute = obj_attribute.replace("\n","");
-    obj_attribute = obj_attribute.replace("}","");
-    obj_attribute = 'return true; tmp_water_mark; ' + obj_attribute;
-    obj[attribute]=new Function(obj_attribute);
-  }
+  if (type == 'obj') { var obj = element; }
+  if (type == 'id') { var obj = document.getElementById(element); }
+  var attribute_text = getObjAttribute(obj, attribute);
+  attribute_text = 'return true; tmp_water_mark; ' + attribute_text;
+  setObjAttribute(obj, attribute, attribute_text);
 }
 
 function enableAttributeWithFunction(element, type, attribute) {
-  if (type == 'obj') { var obj = element }
-  if (type == 'id') { var obj = document.getElementById(id); }
-  if (navigator.userAgent.toUpperCase().indexOf("MSIE") == -1) {
-    obj.setAttribute(attribute, obj.getAttribute(attribute).replace('return 
true; tmp_water_mark; ', ''));
-  } else {
-    var obj_attribute = obj.getAttribute(attribute).toString();
-    obj_attribute = obj_attribute.replace("function anonymous()","");
-    obj_attribute = obj_attribute.replace("{\n","");
-    obj_attribute = obj_attribute.replace("\n","");
-    obj_attribute = obj_attribute.replace("}","");
-    obj_attribute = obj_attribute.replace('return true; tmp_water_mark; ', '');
-    obj[attribute]=new Function(obj_attribute);
-  }
+  if (type == 'obj') { var obj = element; }
+  if (type == 'id') { var obj = document.getElementById(element); }
+  var attribute_text = getObjAttribute(obj, attribute);
+  attribute_text = attribute_text.replace('return true; tmp_water_mark; ', '')
+  setObjAttribute(obj, attribute, attribute_text);
 }
 
 function disableButton(id) {
diff -r dd0c37d56c35 -r 7a639aeffca4 web/js/utils.js
--- a/web/js/utils.js   Wed Aug 19 21:36:24 2009 +0530
+++ b/web/js/utils.js   Wed Aug 19 18:31:21 2009 +0200
@@ -62,7 +62,7 @@
 * Return a number that would be checked at the Login screen to know if the 
file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '4462';
+  var number = '4653';
   return number;
 }
 
@@ -80,6 +80,33 @@
 }
 
 
+function getObjAttribute(obj, attribute) {
+  attribute = attribute.toLowerCase();
+  var attribute_text = "";
+  if (navigator.userAgent.toUpperCase().indexOf("MSIE") == -1) {
+    attribute_text = obj.getAttribute(attribute);
+  } else {
+    attribute_text = obj.getAttribute(attribute).toString();
+    attribute_text = attribute_text.replace("function anonymous()","");
+    attribute_text = attribute_text.replace("function " + attribute + "()","");
+    attribute_text = attribute_text.replace("{\n","");
+    attribute_text = attribute_text.replace("\n","");
+    attribute_text = attribute_text.replace("}","");
+  }
+  return attribute_text;
+}
+
+function setObjAttribute(obj, attribute, attribute_text) {
+  attribute = attribute.toLowerCase();
+  attribute_text = attribute_text.toString();
+  if (navigator.userAgent.toUpperCase().indexOf("MSIE") == -1) {
+    obj.setAttribute(attribute, attribute_text);
+  } else {
+    obj[attribute]=new Function(attribute_text);
+  }
+}
+
+
 /**
 * Set the focus on the first visible control in the form
 * @param {Form} form Optional- Defines the form containing the field, where we 
want to set the focus. If is not present, the first form of the page will be 
used.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to