Author: ashish
Date: Fri Aug 8 07:27:05 2008 New Revision: 683980 URL: http://svn.apache.org/viewvc?rev=683980&view=rev Log: Patch from Rishi Solanki. Split the auto completer JS from checkout, and remove all observers from country and state. Special thanks to Mridul Pathak in helping to Rishi in this implementation. Added: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js (with props) Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js?rev=683980&r1=683979&r2=683980&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Fri Aug 8 07:27:05 2008 @@ -104,21 +104,6 @@ Event.observe('processOrderButton', 'click', processOrder); - // Autocompleter for shipping panel - Event.observe($('shipToCountryGeo'), 'focus', getCountryList); - - Event.observe($('shipToCountryGeo'), 'blur', function() { - $('shipToStateProvinceGeo').value = ""; - if ($('shipToCountryGeoId').value == "" || $('shipToCountryGeoId').value == null) { - setShipToCountryGeoId(); - } - }); - Event.observe($('shipToStateProvinceGeo'), 'focus', getAssociatedStateList); - Event.observe($('shipToStateProvinceGeo'), 'blur', function() { - if ($('shipToStateProvinceGeoId').value == "" || $('shipToStateProvinceGeoId').value == null) { - setShipToStateProvinceGeoId(); - } - }); // Get associate states for billing panel Event.observe($('billToCountryGeoId'), 'change', getAssociatedBillingStateList); }); @@ -524,32 +509,6 @@ $('orderSubmitForm').submit(); } -var countryList = []; - -function getCountryList() { - targetField = $('shipToCountryGeo'); - divToPopulate = $('shipToCountries'); - hiddenTarget = $('shipToCountryGeoId'); - new Ajax.Request("getCountryList", { - asynchronous: false, - onSuccess: callAutocompleter - }); -} - -var autoComplete = null; -var stateList = []; - -function getAssociatedStateList() { - targetField = $('shipToStateProvinceGeo'); - divToPopulate = $('shipToStates'); - hiddenTarget = $('shipToStateProvinceGeoId'); - new Ajax.Request("getAssociatedStateList", { - asynchronous: false, - parameters: $('shippingForm').serialize(), - onSuccess: callAutocompleter - }); -} - function getAssociatedBillingStateList() { var optionList = []; new Ajax.Request("getAssociatedStateList", { @@ -565,45 +524,4 @@ $('billToStateProvinceGeoId').update(optionList); } }); -} - -function callAutocompleter (transport) { - var geos = new Hash(); - var data = transport.responseText.evalJSON(true); - if (targetField.id == "shipToStateProvinceGeo") { - stateList = data.stateList; - stateList.each(function(state) { - var stateName = state.split(': '); - geos.set(stateName[1], stateName[0]); - }); - } else { - countryList = data.countryList; - countryList.each(function(country) { - var countryName = country.split(': '); - geos.set(countryName[1], countryName[0]); - }); - } - autoComplete = new Autocompleter.Local(targetField, divToPopulate, $H(geos), { partialSearch: false, afterUpdateElement: setKeyAsParameter }); -} - -function setKeyAsParameter(text, li) { - $(hiddenTarget).value = li.id; -} - -function setShipToCountryGeoId() { - countryList.each(function(country) { - var countryName = country.split(': '); - if ($F('shipToCountryGeo').toUpperCase() == countryName[0].toUpperCase()) { - $('shipToCountryGeoId').value = countryName[1]; - } - }); -} - -function setShipToStateProvinceGeoId() { - stateList.each(function(state) { - var stateName = state.split(': '); - if ($F('shipToStateProvinceGeo').toUpperCase() == stateName[0].toUpperCase()) { - $('shipToStateProvinceGeoId').value = stateName[1]; - } - }); } \ No newline at end of file Added: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js?rev=683980&view=auto ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js (added) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js Fri Aug 8 07:27:05 2008 @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +Event.observe(window, 'load', function() { + // Autocompleter for shipping panel + getCountryList(); + Event.observe('shipToCountryGeo', 'change', function() { + $('shipToStateProvinceGeo').value = ""; + }); +}); + +function getCountryList() { + countryTargetField = $('shipToCountryGeo'); + countryDivToPopulate = $('shipToCountries'); + countryHiddenTarget = $('shipToCountryGeoId'); + new Ajax.Request("getCountryList", { + asynchronous: false, + onSuccess: callCountryAutocompleter + }); +} + +function callCountryAutocompleter(transport) { + var geos = new Hash(); + var data = transport.responseText.evalJSON(true); + countryList = data.countryList; + countryList.each(function(country) { + var countryName = country.split(': '); + geos.set(countryName[1], countryName[0]); + }); + new Autocompleter.Local(countryTargetField, countryDivToPopulate, $H(geos), { partialSearch: false, afterUpdateElement: setKeyAsParameterAndGetStateList}); +} + +function setKeyAsParameterAndGetStateList(text, li) { + countryHiddenTarget.value = li.id; + getAssociatedStateList(); +} + +function getAssociatedStateList() { + stateTargetField = $('shipToStateProvinceGeo'); + stateDivToPopulate = $('shipToStates'); + stateHiddenTarget = $('shipToStateProvinceGeoId'); + new Ajax.Request("getAssociatedStateList", { + asynchronous: false, + parameters: $('shippingForm').serialize(), + onSuccess: callStateAutocompleter + }); +} + +function callStateAutocompleter(transport) { + var geos = new Hash(); + var data = transport.responseText.evalJSON(true); + stateList = data.stateList; + stateList.each(function(state) { + var stateName = state.split(': '); + geos.set(stateName[1], stateName[0]); + }); + new Autocompleter.Local(stateTargetField, stateDivToPopulate, $H(geos), { partialSearch: false, afterUpdateElement: setKeyAsParameter }); +} + +function setKeyAsParameter(text, li) { + stateHiddenTarget.value = li.id; +} \ No newline at end of file Propchange: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml?rev=683980&r1=683979&r2=683980&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml (original) +++ ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml Fri Aug 8 07:27:05 2008 @@ -617,6 +617,7 @@ <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/effects.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/controls.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/checkoutProcess.js" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/geoAutoCompleter.js" global="true"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditShippingAddress.groovy"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditBillingAddress.groovy"/> |
Free forum by Nabble | Edit this page |