click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r928318 - /click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java
Date Sun, 28 Mar 2010 01:56:13 GMT
Author: sabob
Date: Sun Mar 28 01:56:13 2010
New Revision: 928318

URL: http://svn.apache.org/viewvc?rev=928318&view=rev
Log:
ajax friendly menu setup

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java?rev=928318&r1=928317&r2=928318&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java Sun Mar 28 01:56:13
2010
@@ -904,19 +904,28 @@ public class Menu extends AbstractContro
             jsImport = new JsImport("/click/menu-fix-ie6.js");
             jsImport.setConditionalComment(JsImport.IF_LESS_THAN_IE7);
             headElements.add(jsImport);
+        }
+
+        // Note, the addLoadEvent script is recreated and checked if it
+        // is contained in the headElement.
+        String menuId = getId();
+        JsScript script = new JsScript();
+        script.setId(menuId + "_setup");
+        if (!headElements.contains(script)) {
+            // Script must be executed as soon as browser dom is ready
+            script.setExecuteOnDomReady(true);
 
             HtmlStringBuffer buffer = new HtmlStringBuffer();
-            buffer.append("addLoadEvent( function() {\n");
             buffer.append(" if(typeof Click != 'undefined' && typeof Click.menu !=
'undefined') {\n");
             buffer.append("   if(typeof Click.menu.fixHiddenMenu != 'undefined') {\n");
             buffer.append("     Click.menu.fixHiddenMenu(\"").append(id).append("\");\n");
             buffer.append("     Click.menu.fixHover(\"").append(id).append("\");\n");
             buffer.append("   }\n");
             buffer.append(" }\n");
-            buffer.append("});\n");
-            JsScript jsScript = new JsScript(buffer.toString());
-            headElements.add(jsScript);
+            script.setContent(buffer.toString());
+            headElements.add(script);
         }
+
         return headElements;
     }
 



Mime
View raw message