svn commit: r989599 - in /ofbiz/branches/jquery: applications/product/webapp/catalog/find/keywordsearchbox.ftl framework/images/webapp/images/selectall.js

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

svn commit: r989599 - in /ofbiz/branches/jquery: applications/product/webapp/catalog/find/keywordsearchbox.ftl framework/images/webapp/images/selectall.js

jleroux@apache.org
Author: jleroux
Date: Thu Aug 26 10:55:16 2010
New Revision: 989599

URL: http://svn.apache.org/viewvc?rev=989599&view=rev
Log:
A modified patch from Sascha Rodekamp "selectall.js jquery transformation" (https://issues.apache.org/jira/browse/OFBIZ-3863) - OFBIZ-3863

Fix some issues I reported:
# the quick product access in main catalog page (you enter a productId and then choose the page you want to go) does not work (not sure to what it's related at this stage), not in Opera 10.61
# ajaxUpdateArea is not working in FF (this is maybe due to my environment, many plugins) see https://localhost:8443/catalog/control/ProductStoreFacilities?productStoreId=9000, ok in Opera for the add and update but not the delete, same in Chrome. All work well on trunk demo
# I may have missed something but I did not find any use cases for ajaxUpdateAreaPeriodic OOTB (did not find any use of autoUpdateLink but in templates)
# nor for ajaxSubmitRequestUpdateAreas
# nor for submitFormInBackground
# nor for setSelection

Actually Sascha forgot the keywordsearchbox.ftl file, but it was easy to fix
I have also added the error handling (same than failure in Prototype)

For the parts where there are no use cases, I commit as is as the changes looks good to me

I don't close the issue as there are still some Prototype stuff in selectall.js, notably a patch from Rupert Howell for the dropdown autocomplete stuff, but also some other (easily spotted looking for $)

Also I crossed again an issue I have for a long time in FF with application/x-json, and I guess application/json as well (I'm on Windows but I don't think it's the reason). When I press the Add or Update button when editing a facility at https://localhost:8443/catalog/control/ProductStoreFacilities?productStoreId=9000, the FF download popup window surges and I'm trapped there. Even if the action is correctly executed underneath (I can see it if I refresh the page). I did not find any good solution either using https://addons.mozilla.org/en-US/firefox/addon/10869/ or http://www.spasche.net/openinbrowser/ because they only allow to see the file. I did not find yet a way to bypass the dowload popup window

Modified:
    ofbiz/branches/jquery/applications/product/webapp/catalog/find/keywordsearchbox.ftl
    ofbiz/branches/jquery/framework/images/webapp/images/selectall.js

Modified: ofbiz/branches/jquery/applications/product/webapp/catalog/find/keywordsearchbox.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/applications/product/webapp/catalog/find/keywordsearchbox.ftl?rev=989599&r1=989598&r2=989599&view=diff
==============================================================================
--- ofbiz/branches/jquery/applications/product/webapp/catalog/find/keywordsearchbox.ftl (original)
+++ ofbiz/branches/jquery/applications/product/webapp/catalog/find/keywordsearchbox.ftl Thu Aug 26 10:55:16 2010
@@ -24,11 +24,10 @@ under the License.
          document.forms["keywordsearchform"].elements["SEARCH_CATEGORY_ID"].value=document.forms["advancedsearchform"].elements["DUMMYCAT"].value;
          document.forms["advancedsearchform"].elements["SEARCH_CATEGORY_ID"].value=document.forms["advancedsearchform"].elements["DUMMYCAT"].value;
      }
-     function submitProductJump() {
-         productId = $('productJumpFormProductId').value;
-         $('productJumpFormProductId').value = productId.replace(" ","");
-         $('productJumpForm').action = $('dummyPage').value;
-         $('productJumpForm').submit();
+     function submitProductJump(that) {
+         jQuery('#productJumpForm input[name=productId]').val(jQuery('#productJumpForm input[name=productId]').val().replace(" ",""));
+         jQuery('#productJumpForm').attr('action', jQuery('#dummyPage').val());
+         jQuery('#productJumpForm').submit();
      }
 //]]>
  </script>

Modified: ofbiz/branches/jquery/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/images/webapp/images/selectall.js?rev=989599&r1=989598&r2=989599&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/branches/jquery/framework/images/webapp/images/selectall.js Thu Aug 26 10:55:16 2010
@@ -225,7 +225,7 @@ function confirmActionFormLink(msg, form
     }
 }
 
-// ===== Ajax Functions - based on protoype.js ===== //
+// ===== Ajax Functions - based on jQuery.js ===== //
 
 /** Update an area (HTML container element).
   * @param areaId The id of the HTML container to update
@@ -234,9 +234,15 @@ function confirmActionFormLink(msg, form
 */
 function ajaxUpdateArea(areaId, target, targetParams) {
     waitSpinnerShow();
-    new Ajax.Updater(areaId, target, {parameters: targetParams, evalScripts: true,
-        onSuccess: function(transport) {waitSpinnerHide();},
-        onFailure: function() {waitSpinnerHide();}
+    jQuery.ajax({
+        url: target,
+        type: "POST",
+        data: targetParams,
+        success: function(data) {
+            jQuery("#" + areaId).html(data);
+            waitSpinnerHide();
+        },
+        error: function(data) {waitSpinnerHide()}
     });
 }
 
@@ -249,7 +255,19 @@ function ajaxUpdateAreas(areaCsvString)
     var areaArray = areaCsvString.split(",");
     var numAreas = parseInt(areaArray.length / 3);
     for (var i = 0; i < numAreas * 3; i = i + 3) {
-        jQuery("#" + areaArray[i]).load(areaArray[i + 1], areaArray[i + 2], function () {waitSpinnerHide();});
+        var areaId = areaArray[i];
+        var target = areaArray[i + 1];
+        var targetParams = areaArray[i + 2];
+        jQuery.ajax({
+            url: target,
+            type: "POST",
+            data: targetParams,
+            success: function(data) {
+                jQuery("#" + areaId).html(data);
+                waitSpinnerHide();
+            },
+            error: function(data) {waitSpinnerHide()}
+        });
     }
 }
 
@@ -260,7 +278,23 @@ function ajaxUpdateAreas(areaCsvString)
   * @param interval The update interval, in seconds.
 */
 function ajaxUpdateAreaPeriodic(areaId, target, targetParams, interval) {
-    new Ajax.PeriodicalUpdater(areaId, target, {parameters: targetParams, frequency: interval});
+    jQuery.fjTimer({
+        interval: interval,
+        repeat: true,
+        tick: function(container, timerId){
+            jQuery.ajax({
+                url: target,
+                type: "POST",
+                data: targetParams,
+                success: function(data) {
+                    jQuery("#" + areaId).html(data);
+                    waitSpinnerHide();
+                },
+                error: function(data) {waitSpinnerHide()}
+            });
+            
+        }
+    });
 }
 
 /** Submit request, update multiple areas (HTML container elements).
@@ -273,9 +307,12 @@ function ajaxSubmitRequestUpdateAreas(ta
     updateFunction = function(transport) {
         ajaxUpdateAreas(areaCsvString);
     }
-    new Ajax.Request(target, {
-        parameters: targetParams,
-        onComplete: updateFunction });
+    jQuery.ajax({
+        url: target,
+        type: "POST",
+        data: targetParams,
+        success: updateFunction()
+    });
 }
 
 /** Submit form, update an area (HTML container element).
@@ -286,11 +323,13 @@ function ajaxSubmitRequestUpdateAreas(ta
 function submitFormInBackground(form, areaId, submitUrl) {
     submitFormDisableSubmits(form);
     updateFunction = function() {
-        new Ajax.Updater(areaId, submitUrl);
+        jQuery("#" + areaId).load(submitUrl);
     }
-    new Ajax.Request(form.action, {
-        parameters: form.serialize(true),
-        onComplete: updateFunction });
+    jQuery.ajax({
+        url: jQuery(form).attr("action"),
+        data: jQuery(form).serialize(),
+        success: updateFunction()
+    });
 }
 
 /** Submit form, update multiple areas (HTML container elements).
@@ -328,7 +367,7 @@ function ajaxSubmitFormUpdateAreas(form,
        }
        waitSpinnerHide();
    }
-  
+
    jQuery.ajax({
        type: "POST",
        url: jQuery("#" + form).attr("action"),
@@ -355,7 +394,7 @@ function ajaxAutoCompleter(areaCsvString
           if ((jQuery("#" + div + "_auto")).length < 1) {
               jQuery("<div id='" + div + "_auto'></div>").insertBefore("#" + areaArray[i]);
           }
-          
+
           jQuery("#" + div).autocomplete({
            source: function(request, response) {
                 jQuery.ajax({
@@ -376,7 +415,7 @@ function ajaxAutoCompleter(areaCsvString
 
 function setSelection(text, li) {
     text.value = li.id;
-    var delay = function() { text.fire("lookup:changed"); };
+    var delay = function() { jQuery("#" + text).trigger("lookup:changed"); };
     setTimeout(delay, 100);
 }
 
@@ -387,14 +426,14 @@ function setLookDescription(textFieldId,
             description = description.substring(0, start);
         }
     }
-    var lookupWrapperEl = $(textFieldId).up('.field-lookup');
+    var lookupWrapperEl = jQuery("#" + textFieldId).closest(jQuery('.field-lookup'));
     if (lookupWrapperEl) {
-        var tooltipElement = $(textFieldId + '_lookupDescription');
+        var tooltipElement = jQuery("#" + textFieldId + '_lookupDescription');
         if (!tooltipElement) {
-            tooltipElement = new Element('span', {id : textFieldId + '_lookupDescription', 'class' : 'tooltip'});
+            tooltipElement = jQuery("<span id='" + textFieldId + "_lookupDescription' class='tooltip'></span>");
         }
-        tooltipElement.update(description);
-        lookupWrapperEl.appendChild(tooltipElement);
+        tooltipElement.html(description);
+        tooltipElement.append(lookupWrapperEl);
     }
 }
 
@@ -406,6 +445,7 @@ function setLookDescription(textFieldId,
 */
 
 function ajaxAutoCompleteDropDown(descriptionElement, hiddenElement, data, options) {
+    // TODO is still old fashined :-)
     var update = hiddenElement + "_autoCompleterOptions";
     $(descriptionElement).insert({after: '<div class="autocomplete"' + 'id=' + update + '></div>'});
     new Autocompleter.Local($(descriptionElement), update, $H(data), {autoSelect: options.autoSelect, frequency: options.frequency, minChars: options.minChars, choices: options.choices, partialSearch: options.partialSearch, partialChars: options.partialChars, ignoreCase: options.ignoreCase, fullSearch: options.fullSearch, afterUpdateElement: setKeyAsParameter});
@@ -490,11 +530,11 @@ function ajaxInPlaceEditDisplayField(ele
     jElement.mouseover(function() {
         $(this).css('background-color', 'rgb(255, 255, 153)');
     });
-    
+
     jElement.mouseout(function() {
         $(this).css('background-color', 'transparent');
     });
-    
+
     jElement.editable(function(value, settings){
         // removes all line breaks from the value param, because the parseJSON Function can't work with line breaks
         value = value.replace("\n", " ");
@@ -554,7 +594,6 @@ function submitFormDisableButton(button)
 }
 
 function submitFormEnableButtonByName(formName, buttonName) {
-    // alert("formName=" + formName + " buttonName=" + buttonName);
     var form = document[formName];
     var button = form.elements[buttonName];
     submitFormEnableButton(button);
@@ -589,18 +628,12 @@ function expandAll(expanded) {
 
 //calls ajax request for storing user layout preferences
 function setUserLayoutPreferences(userPrefGroupTypeId, userPrefTypeId, userPrefValue){
-  new Ajax.Request('ajaxSetUserPreference',{
-    method: "post",
-    parameters: {userPrefGroupTypeId: userPrefGroupTypeId, userPrefTypeId: userPrefTypeId, userPrefValue: userPrefValue},
-    onLoading: function(transport){
-    },
-
-    onSuccess: function(transport){
-    },
-
-    onComplete: function(transport){
-    }
- });
+    jQuery.ajax({
+        url:'ajaxSetUserPreference',
+        type: "POST",
+        data: ({userPrefGroupTypeId: userPrefGroupTypeId, userPrefTypeId: userPrefTypeId, userPrefValue: userPrefValue}),
+        success: function(data) {}
+    });
 }
 
 function toggleLeftColumn(){