Commit c270452d4d667e154d40816290e87d32e95cc663
1 parent
6be61ee9
Exists in
master
and in
29 other branches
[shopping-cart] Ajusting l10n and blocking simultaneous actions
Showing
2 changed files
with
12 additions
and
9 deletions
Show diff stats
plugins/shopping_cart/public/cart.js
... | ... | @@ -76,6 +76,7 @@ function Cart(config) { |
76 | 76 | } |
77 | 77 | |
78 | 78 | Cart.prototype.updateQuantity = function(input, itemId, quantity) { |
79 | + if(this.disabled) return alert(shoppingCartPluginL10n.waitLastRequest); | |
79 | 80 | quantity = parseInt(quantity); |
80 | 81 | input.disabled = true; |
81 | 82 | var originalBg = input.style.backgroundImage; |
... | ... | @@ -116,6 +117,7 @@ function Cart(config) { |
116 | 117 | } |
117 | 118 | |
118 | 119 | Cart.addItem = function(itemId, link) { |
120 | + if(this.instance.disabled) return alert(shoppingCartPluginL10n.waitLastRequest); | |
119 | 121 | if ( this.productsLength > 100 ) { |
120 | 122 | // This limit protect the user from losing data on cookie limit. |
121 | 123 | // This is NOT limiting to 100 products, is limiting to 100 kinds of products. |
... | ... | @@ -155,8 +157,8 @@ function Cart(config) { |
155 | 157 | } |
156 | 158 | |
157 | 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 | 164 | Cart.prototype.removeItem = function(itemId) { |
... | ... | @@ -235,8 +237,8 @@ function Cart(config) { |
235 | 237 | } |
236 | 238 | |
237 | 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 | 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 | 2 | <div class="cart-inner"> |
5 | 3 | <div class="cart-content"> |
6 | 4 | <h3><%= _("Basket") %></h3> |
... | ... | @@ -16,7 +14,7 @@ |
16 | 14 | </div> |
17 | 15 | </div> |
18 | 16 | <script> |
19 | - shoppingCartPluginL10n = { | |
17 | + var shoppingCartPluginL10n = { | |
20 | 18 | getProblemConfirmReload: <%= ( |
21 | 19 | _('Ups... I had a problem to load the basket list.') + |
22 | 20 | "\n" + |
... | ... | @@ -24,6 +22,9 @@ |
24 | 22 | ).to_json %>, |
25 | 23 | maxNumberOfItens: <%= ( |
26 | 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 | 30 | </script> | ... | ... |