svn commit: r1001161 - /ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1001161 - /ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl

jleroux@apache.org
Author: jleroux
Date: Sat Sep 25 08:14:28 2010
New Revision: 1001161

URL: http://svn.apache.org/viewvc?rev=1001161&view=rev
Log:
As soon as possible I will rewrite the asmselect stuff to be handled directly from widgets and templates. BTW, I have abandoned the idea to adapt to templates where an id was not used.

It was easier to begin like that and fortunately there were not much cases to handle. The parts which are more thoughtful is when you have to handle a relation between 2 widgets (dependent dropdowns, here is another way to see it, look into Webtools/Geo Management/Link Zones for an example)

Modified:
    ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl

Modified: ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl?rev=1001161&r1=1001160&r2=1001161&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl (original)
+++ ofbiz/branches/jquery/framework/common/webcommon/includes/setMultipleSelectJs.ftl Sat Sep 25 08:14:28 2010
@@ -16,47 +16,34 @@ KIND, either express or implied.  See th
 specific language governing permissions and limitations
 under the License.
 -->
+<#if asm_multipleSelect?exists> <#-- we check only this var and suppose the others are also present -->
 <script type="text/javascript">
 jQuery(document).ready(function() {
+    multiple = jQuery("#${asm_multipleSelect?if_exists}");
 
-  widget = jQuery("#${asm_multipleSelect?if_exists}");
-  ftl = jQuery("select[name='${asm_multipleSelect?if_exists}']");
-  isWidget = widget.length;
-  isFtl = ftl.length;
-
-<#if asm_title?exists>
-  // set the dropdown "title" if exists
-  if (isWidget) widget.attr('title', '${asm_title}');
-  if (isFtl) ftl.attr('title', '${asm_title}');
-</#if>
-  // use asmSelect in Widget Forms
-  if (isWidget) {                    
-      widget.asmSelect({
-        addItemTarget: 'top',
-        sortable: ${asm_sortable!'false'},
-        removeLabel: '${uiLabelMap.CommonRemove!'Remove'}'
+  <#if asm_title?exists>
+    // set the dropdown "title" if exists
+    multiple.attr('title', '${asm_title}');
+  </#if>
+  
+    // use asmSelect in Widget Forms
+    multiple.asmSelect({
+      addItemTarget: 'top',
+      sortable: ${asm_sortable!'false'},
+      removeLabel: '${uiLabelMap.CommonRemove!'Remove'}'
+      //, debugMode: true
     });
-  }
-  // use asmSelect in Freemarker Templates
-  else if (isFtl) {    
-      ftl.asmSelect({
-        addItemTarget: 'top',
-        sortable: ${asm_sortable!'false'},
-        removeLabel: '${uiLabelMap.CommonRemove!'Remove'}'
-        //,debugMode: true
-      });
-  }
-    
-<#if asm_relatedField?exists> <#-- can be used without related field -->
-  // track possible relatedField changes
-  // on initial focus or if the field value changes, select related multi values.
-  // FIXME : not sure why focus does not work here, must be added as event/action in the multipleSelectForm.relatedField
+      
+  <#if asm_relatedField?exists> <#-- can be used without related field -->
+    // track possible relatedField changes
+    // on initial focus or if the field value changes, select related multi values.
+    // FIXME : not sure why focus does not work here, must be added as event/action in the multipleSelectForm.relatedField
     jQuery("#${asm_relatedField}").bind('change focus', function() {
       typeValue = jQuery('#${asm_typeField}').val();
       selectMultipleRelatedValues('${asm_requestName}', '${asm_paramKey}', '${asm_relatedField}', '${asm_multipleSelect}', '${asm_type}', typeValue, '${asm_responseName}');
     });
-</#if>
-});
+  </#if>
+  });
 </script>
 
 <style type="text/css">
@@ -68,4 +55,5 @@ jQuery(document).ready(function() {
 .asmListItem {
   width: ${asm_asmListItemPercentOfForm!95}%;
 }
-</style>
\ No newline at end of file
+</style>
+</#if>