Author: sshyrkov
Date: Mon Oct 15 17:16:37 2007
New Revision: 18868

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18868&repname=
=3Djahia
Log:
JAHIA-2513: AJAX actions in edit mode: too slow to display on the browser s=
ide-  how to optimize performance? =

http://www.jahia.net/jira/browse/JAHIA-2513
Resolution: $$() function replaced with other logic. It has a performance i=
ssues in the Prototype library versions prior to 1.5.1

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/javascript/workf=
low.js

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/javascript=
/workflow.js
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/webapp/jsp/jahia/javascript/workflow.js&rev=3D18868&repnam=
e=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/javascript/workf=
low.js (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/javascript/workf=
low.js Mon Oct 15 17:16:37 2007
@@ -8,7 +8,8 @@
     initialize: function () {
         var wfStateMethods =3D {
             wfInitState: function(imgElement){
-                if ('img' !=3D imgElement.tagName.toLowerCase() || !imgEle=
ment.alt || imgElement.alt.length =3D=3D 0) {
+                if ('img' !=3D imgElement.tagName.toLowerCase() || !imgEle=
ment.title || imgElement.title.length =3D=3D 0
+                    || !imgElement.className || !imgElement.className.inde=
xOf('wfState') =3D=3D -1) {
                     return;
                 }
                 imgElement =3D $(imgElement);
@@ -24,16 +25,17 @@
                 elem.src =3D jahia.config.contextPath + '/jsp/jahia/engine=
s/images/icons/workflow/' + key + '.png';
             }
         };
-        // extend img elements with new methods
         Element.addMethods(wfStateMethods);
     },
     showState: function () {
         this._loadStateInfo();
     },
     _loadStateInfo: function () {
-        // TODO implement Ajax request to the server
-        var objKeys =3D $$('img.wfState').pluck('title').findAll(function =
(key){
-               return (key && key.length > 0 && key.indexOf('Content') =3D=3D 
0);
+        var imgList =3D $A(document.getElementsByTagName('img')).findAll(f=
unction (imgElem) {
+            return imgElem.className && imgElem.className.indexOf('wfState=
') !=3D -1;
+        }).map(Element.extend);
+        var objKeys =3D imgList.pluck('title').findAll(function (key){
+            return (key && key.length > 0 && key.indexOf('Content') =3D=3D=
 0);
         });
         if (objKeys.length > 0) {
             new Ajax.Request(jahia.config.contextPath + '/ajaxaction/GetEx=
tendedWorkflowState', {
@@ -44,17 +46,19 @@
                     try {
                        result =3D eval(transport.responseText);
                     } catch (e) {
-                       // TODO: display a message?
-                       alert("Error evaluating Ajax call result for retrievi=
ng workflow states\n" + =

-                              "response text: " + transport.responseText + "=
\nerror:" + e);
+                        // TODO: display a message?
+                        alert("Error evaluating Ajax call result for retri=
eving workflow states\n" + =

+                               "response text: " + transport.responseText =
+ "\nerror:" + e);
                     }
                     if (result) {
                         result.each(function (item) {
-                               var imgList =3D $$('img.wfState[title=3D' + 
item.=
key + ']').each(function (elem){
-                                       elem.alt =3D item.state;
-                               }); =

+                            imgList.findAll(function(el) {
+                                return el.title =3D=3D item.key;
+                            }).each(function (elem){
+                                elem.alt =3D item.state;
+                            }); =

                         });
-                        $$('img.wfState').invoke('wfInitState')
+                        imgList.invoke('wfInitState')
                     }
                 },
                 onFailure: function(transport) {

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to