Commit c270452d4d667e154d40816290e87d32e95cc663

Authored by Rodrigo Souto
1 parent 6be61ee9

[shopping-cart] Ajusting l10n and blocking simultaneous actions

plugins/shopping_cart/public/cart.js
@@ -76,6 +76,7 @@ function Cart(config) { @@ -76,6 +76,7 @@ function Cart(config) {
76 } 76 }
77 77
78 Cart.prototype.updateQuantity = function(input, itemId, quantity) { 78 Cart.prototype.updateQuantity = function(input, itemId, quantity) {
  79 + if(this.disabled) return alert(shoppingCartPluginL10n.waitLastRequest);
79 quantity = parseInt(quantity); 80 quantity = parseInt(quantity);
80 input.disabled = true; 81 input.disabled = true;
81 var originalBg = input.style.backgroundImage; 82 var originalBg = input.style.backgroundImage;
@@ -116,6 +117,7 @@ function Cart(config) { @@ -116,6 +117,7 @@ function Cart(config) {
116 } 117 }
117 118
118 Cart.addItem = function(itemId, link) { 119 Cart.addItem = function(itemId, link) {
  120 + if(this.instance.disabled) return alert(shoppingCartPluginL10n.waitLastRequest);
119 if ( this.productsLength > 100 ) { 121 if ( this.productsLength > 100 ) {
120 // This limit protect the user from losing data on cookie limit. 122 // This limit protect the user from losing data on cookie limit.
121 // This is NOT limiting to 100 products, is limiting to 100 kinds of products. 123 // This is NOT limiting to 100 products, is limiting to 100 kinds of products.
@@ -155,8 +157,8 @@ function Cart(config) { @@ -155,8 +157,8 @@ function Cart(config) {
155 } 157 }
156 158
157 Cart.removeItem = function(itemId) { 159 Cart.removeItem = function(itemId) {
158 - var message = this.instance.cartElem.getAttribute('data-l10nRemoveItem');  
159 - if( confirm(message) ) this.instance.removeItem(itemId); 160 + if(this.instance.disabled) return alert(shoppingCartPluginL10n.waitLastRequest);
  161 + if( confirm(shoppingCartPluginL10n.removeItem) ) this.instance.removeItem(itemId);
160 } 162 }
161 163
162 Cart.prototype.removeItem = function(itemId) { 164 Cart.prototype.removeItem = function(itemId) {
@@ -235,8 +237,8 @@ function Cart(config) { @@ -235,8 +237,8 @@ function Cart(config) {
235 } 237 }
236 238
237 Cart.clean = function(link) { 239 Cart.clean = function(link) {
238 - var message = this.instance.cartElem.getAttribute('data-l10nCleanCart');  
239 - if( confirm(message) ) link.parentNode.parentNode.parentNode.cartObj.clean(); 240 + if(this.instance.disabled) return alert(shoppingCartPluginL10n.waitLastRequest);
  241 + if( confirm(shoppingCartPluginL10n.cleanCart) ) link.parentNode.parentNode.parentNode.cartObj.clean();
240 } 242 }
241 243
242 Cart.prototype.clean = function() { 244 Cart.prototype.clean = function() {
plugins/shopping_cart/views/cart.html.erb
1 -<div id="cart1" class="cart" style="display:none"  
2 - data-l10nRemoveItem="<%=_('Are you sure you want to remove this item?')%>"  
3 - data-l10nCleanCart="<%=_('Are you sure you want to clean your basket?')%>"> 1 +<div id="cart1" class="cart" style="display:none">
4 <div class="cart-inner"> 2 <div class="cart-inner">
5 <div class="cart-content"> 3 <div class="cart-content">
6 <h3><%= _("Basket") %></h3> 4 <h3><%= _("Basket") %></h3>
@@ -16,7 +14,7 @@ @@ -16,7 +14,7 @@
16 </div> 14 </div>
17 </div> 15 </div>
18 <script> 16 <script>
19 - shoppingCartPluginL10n = { 17 + var shoppingCartPluginL10n = {
20 getProblemConfirmReload: <%= ( 18 getProblemConfirmReload: <%= (
21 _('Ups... I had a problem to load the basket list.') + 19 _('Ups... I had a problem to load the basket list.') +
22 "\n" + 20 "\n" +
@@ -24,6 +22,9 @@ @@ -24,6 +22,9 @@
24 ).to_json %>, 22 ).to_json %>,
25 maxNumberOfItens: <%= ( 23 maxNumberOfItens: <%= (
26 _('Sorry, you can\'t have more then 100 kinds of items on this basket.') 24 _('Sorry, you can\'t have more then 100 kinds of items on this basket.')
27 - ).to_json %> 25 + ).to_json %>,
  26 + waitLastRequest: <%= _('Oops, you must wait your last request to finish first!').to_json %>,
  27 + removeItem: <%= _('Are you sure you want to remove this item?').to_json %>,
  28 + cleanCart: <%= _('Are you sure you want to clean your basket?').to_json %>
28 } 29 }
29 </script> 30 </script>