From a26df4085ce656a33bd35168cb2bb905646755b7 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 16 Dec 2011 14:47:38 +0100 Subject: [PATCH] [imp] refactored numpad state bzr revid: nicolas.vanhoren@openerp.com-20111216134738-ogaf88ua4looi93r --- addons/point_of_sale/static/src/js/pos.js | 42 ++++++++++------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 3146ba4af44..e48be7669a8 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -502,21 +502,16 @@ openerp.point_of_sale = function(db) { The numpad handles both the choice of the property currently being modified (quantity, price or discount) and the edition of the corresponding numeric value. */ - var NumpadState = (function() { - __extends(NumpadState, Backbone.Model); - function NumpadState() { - NumpadState.__super__.constructor.apply(this, arguments); - } - - NumpadState.prototype.defaults = { + var NumpadState = Backbone.Model.extend({ + defaults: { buffer: "0", mode: "quantity" - }; - NumpadState.prototype.initialize = function(options) { + }, + initialize: function(options) { this.shop = options.shop; return this.shop.bind('change:selectedOrder', this.reset, this); - }; - NumpadState.prototype.appendNewChar = function(newChar) { + }, + appendNewChar: function(newChar) { var oldBuffer; oldBuffer = this.get('buffer'); if (oldBuffer === '0') { @@ -533,8 +528,8 @@ openerp.point_of_sale = function(db) { }); } return this.updateTarget(); - }; - NumpadState.prototype.deleteLastChar = function() { + }, + deleteLastChar: function() { var tempNewBuffer; tempNewBuffer = (this.get('buffer')).slice(0, -1) || "0"; if (isNaN(tempNewBuffer)) { @@ -544,27 +539,27 @@ openerp.point_of_sale = function(db) { buffer: tempNewBuffer }); return this.updateTarget(); - }; - NumpadState.prototype.switchSign = function() { + }, + switchSign: function() { var oldBuffer; oldBuffer = this.get('buffer'); this.set({ buffer: oldBuffer[0] === '-' ? oldBuffer.substr(1) : "-" + oldBuffer }); return this.updateTarget(); - }; - NumpadState.prototype.changeMode = function(newMode) { + }, + changeMode: function(newMode) { return this.set({ buffer: "0", mode: newMode }); - }; - NumpadState.prototype.reset = function() { + }, + reset: function() { return this.set({ buffer: "0" }); - }; - NumpadState.prototype.updateTarget = function() { + }, + updateTarget: function() { var bufferContent, params; bufferContent = this.get('buffer'); if (bufferContent && !isNaN(bufferContent)) { @@ -572,9 +567,8 @@ openerp.point_of_sale = function(db) { params[this.get('mode')] = parseFloat(bufferContent); return (this.shop.get('selectedOrder')).selected.set(params); } - }; - return NumpadState; - })(); + }, + }); /* --- Views