Version Notes
- Fixed validation issue with password
- Fixed javascript exception
Version 1.2.7 released
2013/03/31
Version number: 1.2.7
Stability: stable
Compatibility: 1.5, 1.6, 1.6.0.0, 1.6.1, 1.6.2.0, 1.7
Download this release
Release Info
Developer | Sergiy Stotskiy |
Extension | FI_Checkout |
Version | 1.2.7 |
Comparing to | |
See all releases |
Code changes from version 1.2.6 to 1.2.7
app/design/frontend/default/default/template/freaks/checkout/block/info.phtml
CHANGED
@@ -23,7 +23,7 @@ $isLocationAsOneField = $this->helper('fi_checkout')->isLocationAsOneField();
|
|
23 |
<?php if ($this->helper('fi_checkout')->canShowPasswordField()): ?>
|
24 |
<div class="field">
|
25 |
<label><?php echo $this->helper('checkout')->__('Password') ?>*</label>
|
26 |
-
<input type="password" class="input-text validate-password non-storable" name="user[password]" />
|
27 |
</div>
|
28 |
<?php elseif ($this->helper('fi_checkout')->isPasswordAsTelephone()): ?>
|
29 |
<span class="note">* <?php echo $this->__('Telephone number will be your password.') ?></span>
|
23 |
<?php if ($this->helper('fi_checkout')->canShowPasswordField()): ?>
|
24 |
<div class="field">
|
25 |
<label><?php echo $this->helper('checkout')->__('Password') ?>*</label>
|
26 |
+
<input type="password" class="input-text required-entry validate-password non-storable" name="user[password]" />
|
27 |
</div>
|
28 |
<?php elseif ($this->helper('fi_checkout')->isPasswordAsTelephone()): ?>
|
29 |
<span class="note">* <?php echo $this->__('Telephone number will be your password.') ?></span>
|
package.xml
CHANGED
@@ -1,29 +1,25 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>FI_Checkout</name>
|
4 |
-
<version>1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/MIT">MIT License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>0 Step Checkout provide One Page Checkout functionality for Magento, combine all the steps for checkout (including shopping cart) into one page only. It will made the checkout process much simpler. </summary>
|
10 |
<description>0 Step Checkout provide One Page Checkout functionality for Magento, combine all the steps for checkout (including shopping cart) into one page only. It will made the checkout process much simpler. To get more information please visit http://ex.freaksidea.com/0-step-checkout-magento.html</description>
|
11 |
-
<notes>-
|
12 |
-
- Fixed
|
13 |
-
- Refactored PHP code, implemented new model which handles all session's changes.
|
14 |
-
- Implemented ability to specify default shipping method.
|
15 |
-
- Implemented ability to specify default payment method.
|
16 |
-
- Added possibility to specify which sections should be updated when shipping/payment method is changed
|
17 |

|
18 |
-
Version 1.2.
|
19 |
2013/03/31
|
20 |
-
Version number: 1.2.
|
21 |
Stability: stable
|
22 |
Compatibility: 1.5, 1.6, 1.6.0.0, 1.6.1, 1.6.2.0, 1.7</notes>
|
23 |
<authors><author><name>Sergiy Stotskiy</name><user>sergiy_stotskiy</user><email>sergiy.stotskiy@freaksidea.com</email></author></authors>
|
24 |
-
<date>2013-04-
|
25 |
-
<time>
|
26 |
-
<contents><target name="magecommunity"><dir name="FI"><dir name="Checkout"><dir name="Block"><dir name="Block"><file name="Info.php" hash="1fd221f5b1c6e0314532b06ebe3e937f"/></dir><file name="Block.php" hash="e96feb1510b4bdc5ba4513e7f98490cf"/><file name="Links.php" hash="79996dab004b214d93362aecf2f45b83"/><file name="Newsletter.php" hash="19d5938be8caac3eb661fb1f45af66f3"/><dir name="Payment"><file name="Methods.php" hash="c42b6ba6678ab68312fba904cc01e2c1"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7f03a1c3fd7d84a8dcf2b7b9c2c30aca"/></dir><dir name="Model"><file name="Observer.php" hash="e8e5db2033b58b953bf1ad456022fb12"/><file name="Order.php" hash="c11f5e4d2402f1d910ee869fb4e2274c"/><file name="Page.php" hash="2d8eb0a98862271c6d4f654ccf639a50"/><dir name="Resource"><file name="Countries.php" hash="0913ec95198690e5cb81ec8fe4208307"/></dir><dir name="Source"><file name="PaymentMethods.php" hash="151bcf53d0a59172f8a72299133b4555"/><file name="ShippingMethods.php" hash="c682744b99466d3046b53a8d5a63e965"/></dir><file name="Source.php" hash="d68bc03d7e145b866ece607042cb5a35"/><file name="Subscriber.php" hash="e0d4206673e616a136322537264f03cf"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="2281102415ca74f1d8a033b676a67f1f"/></dir><dir name="etc"><file name="config.xml" hash="baa0ff5e90bf38822e235806ff2985d2"/><file name="system.xml" hash="328d2c8415444ff7f989ba2e62267f67"/></dir><dir name="sql"><dir name="fi_checkout_setup"><file name="mysql4-install-1.0.0.php" hash="1f0f6b7d41cff2569cde4c724f2909b4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="freaks"><file name="checkout.xml" hash="3aea61220fc540242b57c2d5d943b897"/></dir></dir><dir name="template"><dir name="freaks"><file name="autocomplete.phtml" hash="bce316a1d37a91ed952bdb3fb87998bc"/><dir name="checkout"><file name="agreements.phtml" hash="72495b7d2cf6632a9ac9d266d045a3d8"/><dir name="block"><file name="info.phtml" hash="
|
27 |
<compatible/>
|
28 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
29 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>FI_Checkout</name>
|
4 |
+
<version>1.2.7</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/MIT">MIT License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>0 Step Checkout provide One Page Checkout functionality for Magento, combine all the steps for checkout (including shopping cart) into one page only. It will made the checkout process much simpler. </summary>
|
10 |
<description>0 Step Checkout provide One Page Checkout functionality for Magento, combine all the steps for checkout (including shopping cart) into one page only. It will made the checkout process much simpler. To get more information please visit http://ex.freaksidea.com/0-step-checkout-magento.html</description>
|
11 |
+
<notes>- Fixed validation issue with password
|
12 |
+
- Fixed javascript exception
|
|
|
|
|
|
|
|
|
13 |

|
14 |
+
Version 1.2.7 released
|
15 |
2013/03/31
|
16 |
+
Version number: 1.2.7
|
17 |
Stability: stable
|
18 |
Compatibility: 1.5, 1.6, 1.6.0.0, 1.6.1, 1.6.2.0, 1.7</notes>
|
19 |
<authors><author><name>Sergiy Stotskiy</name><user>sergiy_stotskiy</user><email>sergiy.stotskiy@freaksidea.com</email></author></authors>
|
20 |
+
<date>2013-04-27</date>
|
21 |
+
<time>20:10:42</time>
|
22 |
+
<contents><target name="magecommunity"><dir name="FI"><dir name="Checkout"><dir name="Block"><dir name="Block"><file name="Info.php" hash="1fd221f5b1c6e0314532b06ebe3e937f"/></dir><file name="Block.php" hash="e96feb1510b4bdc5ba4513e7f98490cf"/><file name="Links.php" hash="79996dab004b214d93362aecf2f45b83"/><file name="Newsletter.php" hash="19d5938be8caac3eb661fb1f45af66f3"/><dir name="Payment"><file name="Methods.php" hash="c42b6ba6678ab68312fba904cc01e2c1"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7f03a1c3fd7d84a8dcf2b7b9c2c30aca"/></dir><dir name="Model"><file name="Observer.php" hash="e8e5db2033b58b953bf1ad456022fb12"/><file name="Order.php" hash="c11f5e4d2402f1d910ee869fb4e2274c"/><file name="Page.php" hash="2d8eb0a98862271c6d4f654ccf639a50"/><dir name="Resource"><file name="Countries.php" hash="0913ec95198690e5cb81ec8fe4208307"/></dir><dir name="Source"><file name="PaymentMethods.php" hash="151bcf53d0a59172f8a72299133b4555"/><file name="ShippingMethods.php" hash="c682744b99466d3046b53a8d5a63e965"/></dir><file name="Source.php" hash="d68bc03d7e145b866ece607042cb5a35"/><file name="Subscriber.php" hash="e0d4206673e616a136322537264f03cf"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="2281102415ca74f1d8a033b676a67f1f"/></dir><dir name="etc"><file name="config.xml" hash="baa0ff5e90bf38822e235806ff2985d2"/><file name="system.xml" hash="328d2c8415444ff7f989ba2e62267f67"/></dir><dir name="sql"><dir name="fi_checkout_setup"><file name="mysql4-install-1.0.0.php" hash="1f0f6b7d41cff2569cde4c724f2909b4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="freaks"><file name="checkout.xml" hash="3aea61220fc540242b57c2d5d943b897"/></dir></dir><dir name="template"><dir name="freaks"><file name="autocomplete.phtml" hash="bce316a1d37a91ed952bdb3fb87998bc"/><dir name="checkout"><file name="agreements.phtml" hash="72495b7d2cf6632a9ac9d266d045a3d8"/><dir name="block"><file name="info.phtml" hash="31cd761ee41a4ed8264dea42ffaab6ee"/></dir><file name="block.phtml" hash="1c172112b2272a41a6ffce4985c791d0"/><dir name="centinel"><file name="authentication.phtml" hash="fe87fdc373fe0cdbcc25141f5e2696c7"/><file name="complete.phtml" hash="83f6e30a7445f8b8b8c343e9fa02b983"/></dir><file name="coupon.phtml" hash="b70b6766d72d16c2357f29453a386b98"/><file name="link.phtml" hash="e12f971b4ab1cb43bb252bada257f2af"/><file name="newsletter.phtml" hash="ecd6f19fcf11b41bedcf18cf0cdbee44"/><file name="payment.phtml" hash="df9c32da22ab3994433a757f8b164b4c"/><file name="payment_methods.phtml" hash="422e71395d2e99ffa74dd9649046a28b"/><dir name="shipping"><file name="available.phtml" hash="d48bc2c689d7e5b3fa68bcbaddfae4b4"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FI_Checkout.xml" hash="0843e490529db978b5c4a16aa9b820d9"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="js"><file name="freaks_checkout.js" hash="f6e9c5e945f5b73d6b894725d0fe7d14"/></dir><dir name="css"><file name="freaks.css" hash="1b66a0f2df69524c4af78385711024c4"/></dir><dir name="images"><dir name="fi"><file name="button.jpg" hash="fcdf2df5b1c714a7c39c61a1be387033"/><file name="loader-old.gif" hash="cf46f7db4c452ea2a94d33eabca8ba93"/><file name="loader.gif" hash="7b9776076d5fceef4993b55c9383dedd"/><file name="popup_arrow-blue.gif" hash="051e0d2ab1f2ef9df98c347b1d7c1a24"/><file name="popup_arrow-white.gif" hash="86a112b675b3a9ed5168d4309170d732"/><file name="select-loader-old.gif" hash="55ded965cfe6095ed8c49f9f980de32a"/><file name="select-loader.gif" hash="a045769166b4cad098ffe7d5aefe95e9"/><file name="select-tip.gif" hash="196ba8fe47100e603ffdd731b6d47d90"/></dir></dir></dir></dir></dir></target></contents>
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
25 |
</package>
|
skin/frontend/default/default/js/freaks_checkout.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6 |
* @author Sergiy Stotskiy <sergiy.stotskiy@freaksidea.com>
|
7 |
* @copyright Copyright (c) 2012 Sergiy Stotskiy (http://freaksidea.com)
|
8 |
*/
|
9 |
-
;(function(e){var g=typeof window.localStorage!=="undefined";function h(k,i){var j;if(typeof k==="string"&&typeof i==="string"){localStorage[k]=i;return true}else{if(typeof k==="object"&&typeof i==="undefined"){for(j in k){if(k.hasOwnProperty(j)){localStorage[j]=k[j]}}return true}}return false}function b(m,i){var j,k,l;j=new Date();j.setTime(j.getTime()+31536000000);k="; expires="+j.toGMTString();if(typeof m==="string"&&typeof i==="string"){document.cookie=m+"="+i+k+"; path=/";return true}else{if(typeof m==="object"&&typeof i==="undefined"){for(l in m){if(m.hasOwnProperty(l)){document.cookie=l+"="+m[l]+k+"; path=/"}}return true}}return false}function d(i){return localStorage[i]}function c(o){var m,j,k,l;m=o+"=";j=document.cookie.split(";");for(k=0;k<j.length;k++){l=j[k];while(l.charAt(0)===" "){l=l.substring(1,l.length)}if(l.indexOf(m)===0){return l.substring(m.length,l.length)}}return null}function f(j){try{delete localStorage[j]}catch(i){localStorage[j]=""}}function a(i){return b(i,"",-1)}e.Storage={set:g?h:b,get:g?d:c,remove:g?f:a}})(Object);Element.prototype.triggerEvent=function(a){if(document.createEvent){var b=document.createEvent("HTMLEvents");b.initEvent(a,true,true);return this.dispatchEvent(b)}if(document.createEventObject){var b=document.createEventObject();return this.fireEvent("on"+a,b)}};var FreaksTabs=Class.create();FreaksTabs.prototype={initialize:function(c,b){this.onChangeTab=null;this.forms={};this.params=Object.extend({currentClassName:"current",contentTagName:"div"},b||{});if(!c){return false}this.tabsBlock=$(c);var a=this;this.tabsBlock.observe("click",function(f){var d=Event.element(f);if(d.nodeName.toLowerCase()!="a"){return true}a.setCurrentTab(d.href.substr(d.href.lastIndexOf("#")+1));Event.stop(f)})},setCurrentTab:function(c){var b=this.getTab(c);if(b.button&&b.content&&b.button!=this.getCurrentTab()){var a={button:this.getCurrentTab(),content:this.getCurrentContent()};a.content.hide();a.button.removeClassName(this.params.currentClassName);$(b.button.parentNode).addClassName(this.params.currentClassName);$(b.content).show();if(this.onChangeTab&&this.onChangeTab.call){this.onChangeTab({prev:a,current:b})}}},getCurrentTab:function(){if(this.tabsBlock){return this.tabsBlock.select("."+this.params.currentClassName)[0]}return null},getCurrentContent:function(){var a=this.getCurrentTab().firstDescendant(),b=a.href.substr(a.href.lastIndexOf("#")+1);return $(this.tabsBlock.parentNode).select(this.params.contentTagName+"."+b)[0]},getTab:function(c){var a=$(this.tabsBlock.parentNode).select(this.params.contentTagName+"."+c)[0],b="";this.tabsBlock.select("a").each(function(d){var f=d.href.substr(d.href.lastIndexOf("#")+1);if(f==c){b=d;return false}});return{button:b,content:a}},setTabForm:function(b,a){this.forms[b]=a;return this},getTabForm:function(a){return this.forms[a]},getTabForms:function(){return this.forms},getCurrentForm:function(){var b=this.getCurrentTab();if(!b){return null}var a=b.firstDescendant(),c=a.href.substr(a.href.lastIndexOf("#")+1);return this.forms[c]}};RestorableForm=Class.create();RestorableForm.Storage=Object.Storage;RestorableForm.prototype=new VarienForm();RestorableForm.prototype.initialize=(function(a){return function(c,b){a.call(this,c,b);this.formId=c;if(this.form){this.restoreValues();this.form.observe("submit",this.submit.bindAsEventListener(this));this.embededForms={};this.hasEmbededForms=false;this.responsePopup=null}}})(VarienForm.prototype.initialize);RestorableForm.prototype.getKey=function(a){return this.formId+"-"+a};RestorableForm.prototype.clearValues=function(c){var b=c.length,a="";while(b--){a=this.getKey(c[b]);if(RestorableForm.Storage.get(a)){RestorableForm.Storage.remove(a)}}return this};RestorableForm.prototype.restoreValues=function(){var a=this,b=function(d){var c=$(this),f=c&&c.nodeName&&c.nodeName.toLowerCase();if(f!="input"&&f!="select"&&f!="textarea"){c=c.select("input")[0]}RestorableForm.Storage.set(a.getKey(c.name),c.value)};Form.getElements(this.form).each(function(d){if(d.hasClassName("non-storable")){return true}var c=RestorableForm.Storage.get(a.getKey(d.name));if(c){if(d.type=="radio"||d.type=="checkbox"){if(d.value==c){d.checked=true}}else{d.value=c}}if(d.type=="radio"||d.type=="checkbox"){d.up().observe("click",b)}else{d.observe("change",b)}});return this};RestorableForm.prototype.submit=function(c,b){var g=this.isValid();if(g){var h=this,a=this.form,d=function(k){var j=h.getKey(k.name);if(RestorableForm.Storage.get(j)){RestorableForm.Storage.remove(j)}},f=function(j){if(j.disabled||(j.type=="radio"||j.type=="checkbox")&&!j.checked){return}var k=a[j.name];if(!k){k=new Element("input");k.type="hidden";k.name=j.name;a.appendChild(k)}k.value=j.value};Form.getElements(this.form).each(d);if(this.hasEmbededForms){for(var e in this.embededForms){var i=this.embededForms[e];Form.getElements(i.form).each(d).each(f)}}if(c){this.request()}else{this.form.submit()}}return g};RestorableForm.prototype.request=function(){return new Ajax.Request(this.form.getAttribute("action"),{method:this.form.getAttribute("method"),parameters:Form.serialize(this.form,true),onComplete:(function(b){try{var a=b.responseText.evalJSON()}catch(c){return}if(a.redirect){location.href=a.redirect}else{if(a.error_message){var d=this.form.previous("ul.messages");if(d){d.up().removeChild(d)}this.form.insert({before:a.error_message});this.form.up(1).scrollTo()}}this.form.fire("form:has_response",a)}).bind(this)})};RestorableForm.prototype.isValid=function(){var b=this.validator&&this.validator.validate();if(b&&this.hasEmbededForms){for(var c in this.embededForms){var a=this.embededForms[c];b=b&&a.validator&&a.validator.validate();if(!b){break}}}return b};RestorableForm.prototype.addEmbededForm=function(a){if(a.form){this.hasEmbededForms=true;this.embededForms[a.form.id]=a}return this};RestorableForm.prototype.getEmbededForms=function(){return this.embededForms};RestorableForm.prototype.getEmbededForm=function(a){return this.embededForms[a]};var fiSelectBox=Class.create({initialize:function(a){this.element=$(a);if(this.element){this.clearInputValueIfNotInList();this.render();this.addSelectObserver(true)}},clearInputValueIfNotInList:function(){var b=$(this.element).previous('input[type="text"]'),a=b.value.strip().replace(/"/g,'\\"');if(this.element.select("option").length&&!this.element.select('option:contains("'+a+'")').length){b.value=""}},addSelectObserver:function(a){var b=function(d,c){var f=$(this).previous('input[type="text"]');if(this.selectedIndex>=0&&this.value!=0){f.value=this.options[this.selectedIndex].innerHTML}else{if(!c){f.value=""}}if(!c){f.fire("fiSelectBox:change",{event:d})}};this.element.observe("change",b);b.call(this.element,null,a);return this},render:function(a){if(a){var b=this.element;b.insert({after:a});this.element=b.next();b.up().removeChild(b);this.addSelectObserver()}if(!this.element.getElementsByTagName("option").length){this.element.disabled=true;this.element.hide()}else{this.element.disabled=false;this.element.show()}return this},addChangeListener:function(a){if(this.element){var b=this.element.previous('input[type="text"]');b.observe("fiSelectBox:change",a.bind(this))}return this},dependsOn:function(b,d,c){d=d||"value";c=c||"input-loading";var e={},a=this;b&&b.observe("change",function(g){var f=a.element.previous('input[type="text"]');e[d]=this.value;f.addClassName(c);f.value="";f.disabled=true;new Ajax.Request(this.parentNode.getAttribute("data-action"),{method:"get",parameters:e,onComplete:function(h){f.removeClassName(c);f.disabled=false;a.render(h.responseText)}})});return this}});var FreaksAutocompleter=Class.create(Ajax.Autocompleter,{startIndicator:function(){if(this.options.indicator){this.element.addClassName(this.options.indicator)}},stopIndicator:function(){if(this.options.indicator){this.element.removeClassName(this.options.indicator)}},showResults:function(){this.hasFocus=true;this.changed=false;this.startIndicator();this.options.parameters=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.element.value);if(this.options.defaultParams){this.options.parameters+="&"+this.options.defaultParams}new Ajax.Request(this.url,this.options);setTimeout(this.stopIndicator.bind(this),1500)},addChangeListener:function(a){Event.observe(this.element,"change",(function(c){if(this.changeTimeout){clearTimeout(this.changeTimeout)}var b=this;this.changeTimeout=setTimeout(function(){a.call(b,c)},100)}).bindAsEventListener(this));return this},addShowResults:function(a){Event.observe(this.element.next(a),"click",(function(b){Event.stop(b);this.showResults()}).bindAsEventListener(this));return this},updateElement:function(d){var c="";if(this.options.select){var a=$(d).select("."+this.options.select)||[];if(a.length>0){c=Element.collectTextNodes(a[0],this.options.select)}}else{c=Element.collectTextNodesIgnoreClass(d,"informal")}var b=this.element.value.split(/\s*,\s*/);if(c!=b[b.length-2]){b[b.length-1]=c}this.element.value=b.join(", ");this.oldElementValue=this.element.value;this.element.focus();this.element.triggerEvent("change")}});var fiCheckoutViewModel=Class.create({initialize:function(a){this.updateUrl="";this.sections={};this.requests={};this.createSections(a)},isActive:function(){return this.getUrl()!=null},createSections:function(b){for(var a in b){if(b[a]){this.sections[a]=b[a]}}return this},findUrl:function(){var a="";for(var b in this.sections){var c=this.sections[b];if(a=c.getAttribute("data-action")){break}}return a},getUrl:function(){if(this.updateUrl){return this.updateUrl}return this.updateUrl=this.findUrl()},updateView:function(d){for(var b in this.sections){var a=d[b],c=this.sections[b];if(a){if(c.nodeName.toLowerCase()=="table"){c.insert({after:a});this.sections[b]=c.next();c.up().removeChild(c);c=this.sections[b]}else{c.update(a)}}c.up().removeClassName("loading");c.setStyle({height:"",visibility:"visible"})}},ajaxCallback:function(b){var a=b.responseText;try{a=a.evalJSON();this.updateView(a);$(document).fire("fiCheckout:updated",{viewModel:this})}catch(c){}},waiting:function(b){var a=[];if(b){var c=this.sections[b];c.setStyle({height:c.getHeight()+"px",visibility:"hidden"});$(c.parentNode).addClassName("loading");a.push(b)}else{for(var b in this.sections){var c=this.sections[b];c.setStyle({height:c.getHeight()+"px",visibility:"hidden"});$(c.parentNode).addClassName("loading");a.push(b)}}return a},request:function(b,a){return new Ajax.Request(this.getUrl(),{method:"post",parameters:b,onComplete:a?a.bind(this):this.ajaxCallback.bind(this),onFailure:function(){location.href=location.href}})},sendOnceFor:function(a,b){if(this.requests[a]){this.requests[a].transport.abort()}this.requests[a]=this.request(b,function(){delete this.requests[a];this.ajaxCallback.apply(this,arguments)});return this.requests[a]},getSection:function(a){return this.sections[a]||null},updateSection:function(b,d){var c=b.split(","),a=c.length;while(a--){this.waiting(c[a])}d=d||{};d.type=b;return this.sendOnceFor(b,d)},updateAll:function(b){var a=this.waiting();b=b||{};b.type=a.join(",");return this.sendOnceFor(b.type,b)},processing:function(b){var a=this.disableButton(b);if(a){a.previous(".process").show()}},stopProcessing:function(b){var a=$(b);if(a){a.previous(".process").hide()}},disableButton:function(b){var a=$(b);if(a){a.addClassName("disabled");a.disabled=true;a.up("ul").select("li").each(function(c){if(c!=a.parentNode){c.setStyle({visibility:"hidden"})}})}return a},enableButton:function(b){var a=$(b);if(a){a.removeClassName("disabled");a.disabled=false;a.up("ul").select("li").each(function(c){if(c!=a.parentNode){c.setStyle({visibility:"visible"})}})}return a},getChangeListener:function(){var a=this;return function(){var b=["country_id","region","postcode","city"],d=b.length,c=this.element||this,f={};if(c.value.strip()&&c.value!="0"){f[c.name]=c.value;while(d--){var e=c.form["user[address]["+b[d]+"]"];if(e&&e.value){f[e.name]=e.value}}a.updateAll(f);a.disableButton("place-order")}}}});fiCheckoutViewModel.isElement=function(b,a){var c=b&&b.nodeName.toLowerCase();return c=="input"&&b.type==a};var fiPaymentViewModel=Class.create({initialize:function(a){this.element=a;this.currentMethod="";this.restore()},getCurrentMethod:function(){return this.currentMethod},getCurrentMethodElement:function(){return this.element&&this.element.select('input[type="radio"]:checked')[0]},findCurrentMethod:function(){var a=this.getCurrentMethodElement();return a?a.value:""},getAdditionalForm:function(){return $("payment_form_"+this.currentMethod)},enableFormElements:function(d,a){var c=Form.getElements(d),b=c.length;while(b--){c[b].disabled=!a}d[a?"show":"hide"]();return this},showAdditionalForm:function(a){var b=this.getAdditionalForm();if(b){this.enableFormElements(b,a)}return this},setMethod:function(b){this.currentMethod=b;var a=this.getAdditionalForm();$(a||document.body).fire("payment-method:switched",{method_code:b});return this},switchMethod:function(a){this.showAdditionalForm(false);this.setMethod(a);this.showAdditionalForm(true)},restore:function(){var a=this;if(this.element){this.switchMethod(this.findCurrentMethod());this.element.select(".form-list").each(function(b){a.enableFormElements(b,b.offsetWidth!=0)})}return this}});var fiCentinelViewModel=Class.create({initialize:function(c){this.element=c;this.isValid=false;if(this.element){var b=this.element.up().select("a.popup-close")[0],a=this;b.observe("click",function(d){$(this).up().hide();Event.stop(d);a.element.fire("fiCentinel:cancel")})}},validate:function(b,c){var a=this;a.element.setStyle({visibility:"hidden"});a.element.up().addClassName("loading");a.element.up().setStyle({display:"block"});return new Ajax.Request(b,{method:"post",parameters:c,onComplete:function(f){try{var d=f.responseText.evalJSON()}catch(g){return}a.element.update(d.html);a.element.setStyle({visibility:"visible"});a.element.up().removeClassName("loading");if(d.url){a.process(d.url)}else{a.success()}}})},idle:function(){this.element.up().hide()},process:function(a){var b=this.element.select("iframe")[0];b.src=a;return this},moveElement:function(a,b){if(this.element){this.element.up().setStyle({top:a+"px",left:b+"px"})}return this},isSuccessfull:function(){return this.isValid},resetValidation:function(){this.isValid=false;return this},success:function(){if(this.element){setTimeout((function(){this.element.up().hide()}).bind(this),2000);this.isValid=true;this.element.fire("fiCentinel:success")}}});var fiPage=Class.create({addFieldPopup:function(a,c){if(!a.form){return false}var b=$(a.form[c]);if(!b||!b.next(".popup")){return false}b.observe("focus",function(){$(this).next(".popup").show()});b.observe("blur",function(){$(this).next(".popup").hide()});return b},createTabs:function(d,h,a){var c=new FreaksTabs(d),e="";c.onChangeTab=function(j){if(j.prev.content.hasClassName("new-user")&&!j.current.content.hasClassName("new-user")){j.prev.content.show().addClassName("hidden-tab");j.prev.content.next("div.overlay").setStyle({display:"block"})}else{j.current.content.removeClassName("hidden-tab");j.current.content.next("div.overlay").hide()}var k=$(j.prev.content),i=k.select("ul.messages")[0];i&&i.hide()};for(var b in h){c.setTabForm(b,new RestorableForm(h[b]))}var f=c.getCurrentForm();if(f&&a){for(var g in a){f.addEmbededForm(a[g])}}if(e=(location.hash||" ").substr(1)){c.setCurrentTab(e)}return c},createDiscount:function(b){var a=new VarienForm(b);a.submit=function(c){if(c){$(this.form.coupon_code).removeClassName("required-entry");$(this.form.remove).value="1"}else{$(this.form.coupon_code).addClassName("required-entry");$(this.form.remove).value="0"}return VarienForm.prototype.submit.call(this)};if(a.form){a.form.select("button").each(function(c){c.observe("click",function(){a.submit(this.name=="cancel")})})}},createForms:function(c){var b=c.length,a={};while(b--){a[c[b]]=new RestorableForm(c[b])}return a},clearStorage:function(b,a){var d="",c="";for(d in b){c=b[d];if(c.clearValues&&!c.form){c.clearValues(a)}}},getLocationBox:function(d,a,c){var b=null;if(d){b=new FreaksAutocompleter(d.previous("input[id]"),d,d.parentNode.getAttribute("data-action"),{paramName:"location",indicator:"input-loading",minChars:2,onShow:function(e,f){Effect.Appear(f,{duration:0.15})}});b.addShowResults("a.select-tip")}else{if(c){b=new fiSelectBox($(c[a.box]));b.dependsOn($(c[a.dependsOn]),"country_id","input-loading")}}return b},observeAddressFields:function(a,e,d){if(!d){return}var b=a.length,c="";while(b--){c=$(d["user[address]["+a[b]+"]"]);if(c){c.observe("change",e)}}},createCheckout:function(c,b){var a=this;var d=c.getCurrentForm().getEmbededForm("payment-form");$$('form[name="user_info"]').each(function(j){var h=j.select("div.shipping-methods")[0];var f=h?h.getAttribute("data-update-sections"):null;var g=new fiCheckoutViewModel({shipping:h,payment:d.form,totals:b});if(f){h.observe("click",function(m){var l=Event.element(m);if(!fiCheckoutViewModel.isElement(l,"radio")){return true}this.updateSection(f,{shipping_method:l.value});this.disableButton("place-order")}.bindAsEventListener(g))}if(g.isActive()){var k=g.getChangeListener();var i=a.getLocationBox(j.select("div.autocomplete")[0],{box:"user[address][region_id]",dependsOn:"user[address][country_id]"},j);i&&i.addChangeListener(k);a.observeAddressFields(["country_id","postcode"],k,j)}var e=d&&d.form?d.form.getAttribute("data-update-sections"):null;if(e){d.form.observe("click",function(l){var m=Event.element(l);if(!fiCheckoutViewModel.isElement(m,"radio")){return true}params={};params[m.name]=m.value;this.updateSection(e,params);this.disableButton("place-order")}.bindAsEventListener(g))}});$(document).observe("fiCheckout:updated",function(e){d.restoreValues();e.memo.viewModel.enableButton("place-order")})},wakeUpPayment:function(d,c){var a=new fiPaymentViewModel(d),e=new fiCentinelViewModel(c);if(a.element){a.element.observe("click",function(g){var f=Event.element(g);if(!fiCheckoutViewModel.isElement(f,"radio")){return true}if(a.getCurrentMethod()!=f.value){a.switchMethod(f.value);e.idle()}});$(document).observe("fiCheckout:updated",function(){a.restore()})}if(e.element){var b=function(){fiCheckoutViewModel.prototype.enableButton("place-order")};e.element.observe("fiCentinel:success",b);e.element.observe("fiCentinel:cancel",b)}return{payment:a,centinel:e}},send:function(b,d,c,a){if(!b){return false}var f=d.getCurrentForm()&&d.getCurrentForm().getEmbededForm("payment-form");b.observe("click",function(i){var k=c.payment.getCurrentMethodElement(),g=true,h="";if(k){h=k.getAttribute("data-action");if(h&&!c.centinel.isSuccessfull()){var j=Form.serialize(c.payment.getAdditionalForm(),true);j[k.name]=k.value;if(f.validator.validate()){c.centinel.validate(h,j);fiCheckoutViewModel.prototype.disableButton(this)}g=false}}if(g&&d.getCurrentForm().submit(true)){fiCheckoutViewModel.prototype.processing(this)}});var e=d.getCurrentForm();if(e.form){e.form.observe("form:has_response",function(h){fiCheckoutViewModel.prototype.stopProcessing(b);var g=h.memo;if(g.error_message){c.centinel.resetValidation();fiCheckoutViewModel.prototype.enableButton(b)}if(!g.update_section){return true}content.up().show();content.update(g.update_section.html);try{g.update_section.html.evalScripts()}catch(i){content.select("iframe").each(function(j){if(!j.offsetWidth){j.observe("load",j.show.bind(j))}})}})}return true}});Validator.prototype.test=(function(a){return function(c,d){var b=a.apply(this,arguments);if(this.options.onElementValidate){this.options.onElementValidate.call(this,b,d)}return b}})(Validator.prototype.test);Object.extend(Validation.get("validate-state").options,{onElementValidate:function(a,b){var c=$(b).previous('input[type="text"]');if(a){c.removeClassName("validation-failed").addClassName("validation-passed")}else{c.addClassName("validation-failed").revemoClassName("validation-passed")}}});$(document).observe("dom:loaded",function(){var e=new fiPage(),a=e.createForms(["payment-form","shipping-method-load"]),f=new VarienForm("checkout-login-form");a["checkout-agreements"]=new VarienForm("checkout-agreements");a["newsletter-form"]=new VarienForm("newsletter-form");var c=e.createTabs($$("#checkout-block ul.infos-menus")[0],{"new-user":"new-user-form","registered-user":"registered-user-form"},a);e.createDiscount("discount-coupon-form");e.createCheckout(c,$("shopping-cart-totals-table"));var d=$$("#payment-popup div.popup-content")[0],b=e.wakeUpPayment($("payment-methods"),d);e.send($("place-order"),c,b,d);window.CentinelAuthenticateController=b.centinel});
|
6 |
* @author Sergiy Stotskiy <sergiy.stotskiy@freaksidea.com>
|
7 |
* @copyright Copyright (c) 2012 Sergiy Stotskiy (http://freaksidea.com)
|
8 |
*/
|
9 |
+
;(function(e){var g=typeof window.localStorage!=="undefined";function h(k,i){var j;if(typeof k==="string"&&typeof i==="string"){localStorage[k]=i;return true}else{if(typeof k==="object"&&typeof i==="undefined"){for(j in k){if(k.hasOwnProperty(j)){localStorage[j]=k[j]}}return true}}return false}function b(m,i){var j,k,l;j=new Date();j.setTime(j.getTime()+31536000000);k="; expires="+j.toGMTString();if(typeof m==="string"&&typeof i==="string"){document.cookie=m+"="+i+k+"; path=/";return true}else{if(typeof m==="object"&&typeof i==="undefined"){for(l in m){if(m.hasOwnProperty(l)){document.cookie=l+"="+m[l]+k+"; path=/"}}return true}}return false}function d(i){return localStorage[i]}function c(o){var m,j,k,l;m=o+"=";j=document.cookie.split(";");for(k=0;k<j.length;k++){l=j[k];while(l.charAt(0)===" "){l=l.substring(1,l.length)}if(l.indexOf(m)===0){return l.substring(m.length,l.length)}}return null}function f(j){try{delete localStorage[j]}catch(i){localStorage[j]=""}}function a(i){return b(i,"",-1)}e.Storage={set:g?h:b,get:g?d:c,remove:g?f:a}})(Object);Element.prototype.triggerEvent=function(a){if(document.createEvent){var b=document.createEvent("HTMLEvents");b.initEvent(a,true,true);return this.dispatchEvent(b)}if(document.createEventObject){var b=document.createEventObject();return this.fireEvent("on"+a,b)}};var FreaksTabs=Class.create();FreaksTabs.prototype={initialize:function(c,b){this.onChangeTab=null;this.forms={};this.params=Object.extend({currentClassName:"current",contentTagName:"div"},b||{});if(!c){return false}this.tabsBlock=$(c);var a=this;this.tabsBlock.observe("click",function(f){var d=Event.element(f);if(d.nodeName.toLowerCase()!="a"){return true}a.setCurrentTab(d.href.substr(d.href.lastIndexOf("#")+1));Event.stop(f)})},setCurrentTab:function(c){var b=this.getTab(c);if(b.button&&b.content&&b.button!=this.getCurrentTab()){var a={button:this.getCurrentTab(),content:this.getCurrentContent()};a.content.hide();a.button.removeClassName(this.params.currentClassName);$(b.button.parentNode).addClassName(this.params.currentClassName);$(b.content).show();if(this.onChangeTab&&this.onChangeTab.call){this.onChangeTab({prev:a,current:b})}}},getCurrentTab:function(){if(this.tabsBlock){return this.tabsBlock.select("."+this.params.currentClassName)[0]}return null},getCurrentContent:function(){var a=this.getCurrentTab().firstDescendant(),b=a.href.substr(a.href.lastIndexOf("#")+1);return $(this.tabsBlock.parentNode).select(this.params.contentTagName+"."+b)[0]},getTab:function(c){var a=$(this.tabsBlock.parentNode).select(this.params.contentTagName+"."+c)[0],b="";this.tabsBlock.select("a").each(function(d){var f=d.href.substr(d.href.lastIndexOf("#")+1);if(f==c){b=d;return false}});return{button:b,content:a}},setTabForm:function(b,a){this.forms[b]=a;return this},getTabForm:function(a){return this.forms[a]},getTabForms:function(){return this.forms},getCurrentForm:function(){var b=this.getCurrentTab();if(!b){return null}var a=b.firstDescendant(),c=a.href.substr(a.href.lastIndexOf("#")+1);return this.forms[c]}};RestorableForm=Class.create();RestorableForm.Storage=Object.Storage;RestorableForm.prototype=new VarienForm();RestorableForm.prototype.initialize=(function(a){return function(c,b){a.call(this,c,b);this.formId=c;if(this.form){this.restoreValues();this.form.observe("submit",this.submit.bindAsEventListener(this));this.embededForms={};this.hasEmbededForms=false;this.responsePopup=null}}})(VarienForm.prototype.initialize);RestorableForm.prototype.getKey=function(a){return this.formId+"-"+a};RestorableForm.prototype.clearValues=function(c){var b=c.length,a="";while(b--){a=this.getKey(c[b]);if(RestorableForm.Storage.get(a)){RestorableForm.Storage.remove(a)}}return this};RestorableForm.prototype.restoreValues=function(){var a=this,b=function(d){var c=$(this),f=c&&c.nodeName&&c.nodeName.toLowerCase();if(f!="input"&&f!="select"&&f!="textarea"){c=c.select("input")[0]}RestorableForm.Storage.set(a.getKey(c.name),c.value)};Form.getElements(this.form).each(function(d){if(d.hasClassName("non-storable")){return true}var c=RestorableForm.Storage.get(a.getKey(d.name));if(c){if(d.type=="radio"||d.type=="checkbox"){if(d.value==c){d.checked=true}}else{d.value=c}}if(d.type=="radio"||d.type=="checkbox"){d.up().observe("click",b)}else{d.observe("change",b)}});return this};RestorableForm.prototype.submit=function(c,b){var g=this.isValid();if(g){var h=this,a=this.form,d=function(k){var j=h.getKey(k.name);if(RestorableForm.Storage.get(j)){RestorableForm.Storage.remove(j)}},f=function(j){if(j.disabled||(j.type=="radio"||j.type=="checkbox")&&!j.checked){return}var k=a[j.name];if(!k){k=new Element("input");k.type="hidden";k.name=j.name;a.appendChild(k)}k.value=j.value};Form.getElements(this.form).each(d);if(this.hasEmbededForms){for(var e in this.embededForms){var i=this.embededForms[e];Form.getElements(i.form).each(d).each(f)}}if(c){this.request()}else{this.form.submit()}}return g};RestorableForm.prototype.request=function(){return new Ajax.Request(this.form.getAttribute("action"),{method:this.form.getAttribute("method"),parameters:Form.serialize(this.form,true),onComplete:(function(b){try{var a=b.responseText.evalJSON()}catch(c){return}if(a.redirect){location.href=a.redirect}else{if(a.error_message){var d=this.form.previous("ul.messages");if(d){d.up().removeChild(d)}this.form.insert({before:a.error_message});this.form.up(1).scrollTo()}}this.form.fire("form:has_response",a)}).bind(this)})};RestorableForm.prototype.isValid=function(){var b=this.validator&&this.validator.validate();if(b&&this.hasEmbededForms){for(var c in this.embededForms){var a=this.embededForms[c];b=b&&a.validator&&a.validator.validate();if(!b){break}}}return b};RestorableForm.prototype.addEmbededForm=function(a){if(a.form){this.hasEmbededForms=true;this.embededForms[a.form.id]=a}return this};RestorableForm.prototype.getEmbededForms=function(){return this.embededForms};RestorableForm.prototype.getEmbededForm=function(a){return this.embededForms[a]};var fiSelectBox=Class.create({initialize:function(a){this.element=$(a);if(this.element){this.clearInputValueIfNotInList();this.render();this.addSelectObserver(true)}},clearInputValueIfNotInList:function(){var b=$(this.element).previous('input[type="text"]'),a=b.value.strip().replace(/"/g,'\\"');if(this.element.select("option").length&&!this.element.select('option:contains("'+a+'")').length){b.value=""}},addSelectObserver:function(a){var b=function(d,c){var f=$(this).previous('input[type="text"]');if(this.selectedIndex>=0&&this.value!=0){f.value=this.options[this.selectedIndex].innerHTML}else{if(!c){f.value=""}}if(!c){f.fire("fiSelectBox:change",{event:d})}};this.element.observe("change",b);b.call(this.element,null,a);return this},render:function(a){if(a){var b=this.element;b.insert({after:a});this.element=b.next();b.up().removeChild(b);this.addSelectObserver()}if(!this.element.getElementsByTagName("option").length){this.element.disabled=true;this.element.hide()}else{this.element.disabled=false;this.element.show()}return this},addChangeListener:function(a){if(this.element){var b=this.element.previous('input[type="text"]');b.observe("fiSelectBox:change",a.bind(this))}return this},dependsOn:function(b,d,c){d=d||"value";c=c||"input-loading";var e={},a=this;b&&b.observe("change",function(g){var f=a.element.previous('input[type="text"]');e[d]=this.value;f.addClassName(c);f.value="";f.disabled=true;new Ajax.Request(this.parentNode.getAttribute("data-action"),{method:"get",parameters:e,onComplete:function(h){f.removeClassName(c);f.disabled=false;a.render(h.responseText)}})});return this}});var FreaksAutocompleter=Class.create(Ajax.Autocompleter,{startIndicator:function(){if(this.options.indicator){this.element.addClassName(this.options.indicator)}},stopIndicator:function(){if(this.options.indicator){this.element.removeClassName(this.options.indicator)}},showResults:function(){this.hasFocus=true;this.changed=false;this.startIndicator();this.options.parameters=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.element.value);if(this.options.defaultParams){this.options.parameters+="&"+this.options.defaultParams}new Ajax.Request(this.url,this.options);setTimeout(this.stopIndicator.bind(this),1500)},addChangeListener:function(a){Event.observe(this.element,"change",(function(c){if(this.changeTimeout){clearTimeout(this.changeTimeout)}var b=this;this.changeTimeout=setTimeout(function(){a.call(b,c)},100)}).bindAsEventListener(this));return this},addShowResults:function(a){Event.observe(this.element.next(a),"click",(function(b){Event.stop(b);this.showResults()}).bindAsEventListener(this));return this},updateElement:function(d){var c="";if(this.options.select){var a=$(d).select("."+this.options.select)||[];if(a.length>0){c=Element.collectTextNodes(a[0],this.options.select)}}else{c=Element.collectTextNodesIgnoreClass(d,"informal")}var b=this.element.value.split(/\s*,\s*/);if(c!=b[b.length-2]){b[b.length-1]=c}this.element.value=b.join(", ");this.oldElementValue=this.element.value;this.element.focus();this.element.triggerEvent("change")}});var fiCheckoutViewModel=Class.create({initialize:function(a){this.updateUrl="";this.sections={};this.requests={};this.createSections(a)},isActive:function(){return this.getUrl()!=null},createSections:function(b){for(var a in b){if(b[a]){this.sections[a]=b[a]}}return this},findUrl:function(){var a="";for(var b in this.sections){var c=this.sections[b];if(a=c.getAttribute("data-action")){break}}return a},getUrl:function(){if(this.updateUrl){return this.updateUrl}return this.updateUrl=this.findUrl()},updateView:function(d){for(var b in this.sections){var a=d[b],c=this.sections[b];if(a){if(c.nodeName.toLowerCase()=="table"){c.insert({after:a});this.sections[b]=c.next();c.up().removeChild(c);c=this.sections[b]}else{c.update(a)}}c.up().removeClassName("loading");c.setStyle({height:"",visibility:"visible"})}},ajaxCallback:function(b){var a=b.responseText;try{a=a.evalJSON();this.updateView(a);$(document).fire("fiCheckout:updated",{viewModel:this})}catch(c){}},waiting:function(b){var a=[];if(b){var c=this.sections[b];c.setStyle({height:c.getHeight()+"px",visibility:"hidden"});$(c.parentNode).addClassName("loading");a.push(b)}else{for(var b in this.sections){var c=this.sections[b];c.setStyle({height:c.getHeight()+"px",visibility:"hidden"});$(c.parentNode).addClassName("loading");a.push(b)}}return a},request:function(b,a){return new Ajax.Request(this.getUrl(),{method:"post",parameters:b,onComplete:a?a.bind(this):this.ajaxCallback.bind(this),onFailure:function(){location.href=location.href}})},sendOnceFor:function(a,b){if(this.requests[a]){this.requests[a].transport.abort()}this.requests[a]=this.request(b,function(){delete this.requests[a];this.ajaxCallback.apply(this,arguments)});return this.requests[a]},getSection:function(a){return this.sections[a]||null},updateSection:function(b,d){var c=b.split(","),a=c.length;while(a--){this.waiting(c[a])}d=d||{};d.type=b;return this.sendOnceFor(b,d)},updateAll:function(b){var a=this.waiting();b=b||{};b.type=a.join(",");return this.sendOnceFor(b.type,b)},processing:function(b){var a=this.disableButton(b);if(a){a.previous(".process").show()}},stopProcessing:function(b){var a=$(b);if(a){a.previous(".process").hide()}},disableButton:function(b){var a=$(b);if(a){a.addClassName("disabled");a.disabled=true;a.up("ul").select("li").each(function(c){if(c!=a.parentNode){c.setStyle({visibility:"hidden"})}})}return a},enableButton:function(b){var a=$(b);if(a){a.removeClassName("disabled");a.disabled=false;a.up("ul").select("li").each(function(c){if(c!=a.parentNode){c.setStyle({visibility:"visible"})}})}return a},getChangeListener:function(){var a=this;return function(){var b=["country_id","region","postcode","city"],d=b.length,c=this.element||this,f={};if(c.value.strip()&&c.value!="0"){f[c.name]=c.value;while(d--){var e=c.form["user[address]["+b[d]+"]"];if(e&&e.value){f[e.name]=e.value}}a.updateAll(f);a.disableButton("place-order")}}}});fiCheckoutViewModel.isElement=function(b,a){var c=b&&b.nodeName.toLowerCase();return c=="input"&&b.type==a};var fiPaymentViewModel=Class.create({initialize:function(a){this.element=a;this.currentMethod="";this.restore()},getCurrentMethod:function(){return this.currentMethod},getCurrentMethodElement:function(){return this.element&&this.element.select('input[type="radio"]:checked')[0]},findCurrentMethod:function(){var a=this.getCurrentMethodElement();return a?a.value:""},getAdditionalForm:function(){return $("payment_form_"+this.currentMethod)},enableFormElements:function(d,a){var c=Form.getElements(d),b=c.length;while(b--){c[b].disabled=!a}d[a?"show":"hide"]();return this},showAdditionalForm:function(a){var b=this.getAdditionalForm();if(b){this.enableFormElements(b,a)}return this},setMethod:function(b){this.currentMethod=b;var a=this.getAdditionalForm();$(a||document.body).fire("payment-method:switched",{method_code:b});return this},switchMethod:function(a){this.showAdditionalForm(false);this.setMethod(a);this.showAdditionalForm(true)},restore:function(){var a=this;if(this.element){this.switchMethod(this.findCurrentMethod());this.element.select(".form-list").each(function(b){a.enableFormElements(b,b.offsetWidth!=0)})}return this}});var fiCentinelViewModel=Class.create({initialize:function(c){this.element=c;this.isValid=false;if(this.element){var b=this.element.up().select("a.popup-close")[0],a=this;b.observe("click",function(d){$(this).up().hide();Event.stop(d);a.element.fire("fiCentinel:cancel")})}},validate:function(b,c){var a=this;a.element.setStyle({visibility:"hidden"});a.element.up().addClassName("loading");a.element.up().setStyle({display:"block"});return new Ajax.Request(b,{method:"post",parameters:c,onComplete:function(f){try{var d=f.responseText.evalJSON()}catch(g){return}a.element.update(d.html);a.element.setStyle({visibility:"visible"});a.element.up().removeClassName("loading");if(d.url){a.process(d.url)}else{a.success()}}})},idle:function(){this.element.up().hide()},process:function(a){var b=this.element.select("iframe")[0];b.src=a;return this},moveElement:function(a,b){if(this.element){this.element.up().setStyle({top:a+"px",left:b+"px"})}return this},isSuccessfull:function(){return this.isValid},resetValidation:function(){this.isValid=false;return this},success:function(){if(this.element){setTimeout((function(){this.element.up().hide()}).bind(this),2000);this.isValid=true;this.element.fire("fiCentinel:success")}}});var fiPage=Class.create({addFieldPopup:function(a,c){if(!a.form){return false}var b=$(a.form[c]);if(!b||!b.next(".popup")){return false}b.observe("focus",function(){$(this).next(".popup").show()});b.observe("blur",function(){$(this).next(".popup").hide()});return b},createTabs:function(d,h,a){var c=new FreaksTabs(d),e="";c.onChangeTab=function(j){if(j.prev.content.hasClassName("new-user")&&!j.current.content.hasClassName("new-user")){j.prev.content.show().addClassName("hidden-tab");j.prev.content.next("div.overlay").setStyle({display:"block"})}else{j.current.content.removeClassName("hidden-tab");j.current.content.next("div.overlay").hide()}var k=$(j.prev.content),i=k.select("ul.messages")[0];i&&i.hide()};for(var b in h){c.setTabForm(b,new RestorableForm(h[b]))}var f=c.getCurrentForm();if(f&&a){for(var g in a){f.addEmbededForm(a[g])}}if(e=(location.hash||" ").substr(1)){c.setCurrentTab(e)}return c},createDiscount:function(b){var a=new VarienForm(b);a.submit=function(c){if(c){$(this.form.coupon_code).removeClassName("required-entry");$(this.form.remove).value="1"}else{$(this.form.coupon_code).addClassName("required-entry");$(this.form.remove).value="0"}return VarienForm.prototype.submit.call(this)};if(a.form){a.form.select("button").each(function(c){c.observe("click",function(){a.submit(this.name=="cancel")})})}},createForms:function(c){var b=c.length,a={};while(b--){a[c[b]]=new RestorableForm(c[b])}return a},clearStorage:function(b,a){var d="",c="";for(d in b){c=b[d];if(c.clearValues&&!c.form){c.clearValues(a)}}},getLocationBox:function(d,a,c){var b=null;if(d){b=new FreaksAutocompleter(d.previous("input[id]"),d,d.parentNode.getAttribute("data-action"),{paramName:"location",indicator:"input-loading",minChars:2,onShow:function(e,f){Effect.Appear(f,{duration:0.15})}});b.addShowResults("a.select-tip")}else{if(c){b=new fiSelectBox($(c[a.box]));b.dependsOn($(c[a.dependsOn]),"country_id","input-loading")}}return b},observeAddressFields:function(a,e,d){if(!d){return}var b=a.length,c="";while(b--){c=$(d["user[address]["+a[b]+"]"]);if(c){c.observe("change",e)}}},createCheckout:function(c,b){var a=this;var d=c.getCurrentForm().getEmbededForm("payment-form");$$('form[name="user_info"]').each(function(j){var h=j.select("div.shipping-methods")[0];var f=h?h.getAttribute("data-update-sections"):null;var g=new fiCheckoutViewModel({shipping:h,payment:d.form,totals:b});if(f){h.observe("click",function(m){var l=Event.element(m);if(!fiCheckoutViewModel.isElement(l,"radio")){return true}this.updateSection(f,{shipping_method:l.value});this.disableButton("place-order")}.bindAsEventListener(g))}if(g.isActive()){var k=g.getChangeListener();var i=a.getLocationBox(j.select("div.autocomplete")[0],{box:"user[address][region_id]",dependsOn:"user[address][country_id]"},j);i&&i.addChangeListener(k);a.observeAddressFields(["country_id","postcode"],k,j)}var e=d&&d.form?d.form.getAttribute("data-update-sections"):null;if(e){d.form.observe("click",function(l){var m=Event.element(l);if(!fiCheckoutViewModel.isElement(m,"radio")){return true}params={};params[m.name]=m.value;this.updateSection(e,params);this.disableButton("place-order")}.bindAsEventListener(g))}});$(document).observe("fiCheckout:updated",function(e){d.restoreValues();e.memo.viewModel.enableButton("place-order")})},wakeUpPayment:function(d,c){var a=new fiPaymentViewModel(d),e=new fiCentinelViewModel(c);if(a.element){a.element.observe("click",function(g){var f=Event.element(g);if(!fiCheckoutViewModel.isElement(f,"radio")){return true}if(a.getCurrentMethod()!=f.value){a.switchMethod(f.value);e.idle()}});$(document).observe("fiCheckout:updated",function(){a.restore()})}if(e.element){var b=function(){fiCheckoutViewModel.prototype.enableButton("place-order")};e.element.observe("fiCentinel:success",b);e.element.observe("fiCentinel:cancel",b)}return{payment:a,centinel:e}},send:function(a,c,b,f){if(!a){return false}var e=c.getCurrentForm()&&c.getCurrentForm().getEmbededForm("payment-form");a.observe("click",function(i){var k=b.payment.getCurrentMethodElement(),g=true,h="";if(k){h=k.getAttribute("data-action");if(h&&!b.centinel.isSuccessfull()){var j=Form.serialize(b.payment.getAdditionalForm(),true);j[k.name]=k.value;if(e.validator.validate()){b.centinel.validate(h,j);fiCheckoutViewModel.prototype.disableButton(this)}g=false}}if(g&&c.getCurrentForm().submit(true)){fiCheckoutViewModel.prototype.processing(this)}});var d=c.getCurrentForm();if(d.form){d.form.observe("form:has_response",function(h){fiCheckoutViewModel.prototype.stopProcessing(a);var g=h.memo;if(g.error_message){b.centinel.resetValidation();fiCheckoutViewModel.prototype.enableButton(a)}if(!g.update_section){return true}f.up().show();f.update(g.update_section.html);try{g.update_section.html.evalScripts()}catch(i){f.select("iframe").each(function(j){if(!j.offsetWidth){j.observe("load",j.show.bind(j))}})}})}return true}});Validator.prototype.test=(function(a){return function(c,d){var b=a.apply(this,arguments);if(this.options.onElementValidate){this.options.onElementValidate.call(this,b,d)}return b}})(Validator.prototype.test);Object.extend(Validation.get("validate-state").options,{onElementValidate:function(a,b){var c=$(b).previous('input[type="text"]');if(a){c.removeClassName("validation-failed").addClassName("validation-passed")}else{c.addClassName("validation-failed").revemoClassName("validation-passed")}}});$(document).observe("dom:loaded",function(){var e=new fiPage(),a=e.createForms(["payment-form","shipping-method-load"]),f=new VarienForm("checkout-login-form");a["checkout-agreements"]=new VarienForm("checkout-agreements");a["newsletter-form"]=new VarienForm("newsletter-form");var c=e.createTabs($$("#checkout-block ul.infos-menus")[0],{"new-user":"new-user-form","registered-user":"registered-user-form"},a);e.createDiscount("discount-coupon-form");e.createCheckout(c,$("shopping-cart-totals-table"));var d=$$("#payment-popup div.popup-content")[0],b=e.wakeUpPayment($("payment-methods"),d);e.send($("place-order"),c,b,d);window.CentinelAuthenticateController=b.centinel});
|