[imp] added back button + removed backbone history
authorniv-openerp <nicolas.vanhoren@openerp.com>
Fri, 4 Nov 2011 15:43:12 +0000 (16:43 +0100)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Fri, 4 Nov 2011 15:43:12 +0000 (16:43 +0100)
bzr revid: nicolas.vanhoren@openerp.com-20111104154312-uolo3j36lg1zwfxh

addons/point_of_sale/static/src/js/pos.js
addons/point_of_sale/static/src/xml/pos.xml

index 086bc38..2964ad7 100644 (file)
@@ -1131,22 +1131,20 @@ openerp.point_of_sale = function(db) {
         return ShopView;
     })();
     App = (function() {
-        __extends(App, Backbone.Router);
-        function App() {
-            App.__super__.constructor.apply(this, arguments);
+        function App($element) {
+            this.initialize($element);
         }
 
-        App.prototype.routes = {
-            '': 'category',
-            'category/:id': 'category'
-        };
         App.prototype.initialize = function($element) {
             this.shop = new Shop;
             this.shopView = new ShopView({
                 shop: this.shop,
                 el: $element
             });
-            return this.categoryView = new CategoryView;
+            this.categoryView = new CategoryView;
+            this.categoryView.bind("changeCategory", this.category, this);
+            this.category();
+            return this.categoryView;
         };
         App.prototype.category = function(id) {
             var c, products;
@@ -1188,11 +1186,10 @@ openerp.point_of_sale = function(db) {
     db.point_of_sale.PointOfSale = db.web.Widget.extend({
         template: "PointOfSale",
         start: function() {
-            // FIXME: absolutely horrible hack to avoid conflict
-            //        between backbone's history and al's action
-            //        thingie
-            window.location.hash = '';
             var self = this;
+            this.$element.find("#loggedas button").click(function() {
+                self.stop();
+            });
 
             if (pos)
                 throw "It is not possible to instantiate multiple instances"+
@@ -1203,7 +1200,6 @@ openerp.point_of_sale = function(db) {
 
             return pos.ready.then( function() {
                 pos.app = new App(self.$element);
-                return Backbone.history.start();
             });
         },
         stop: function() {
index 32994b0..d4962a6 100644 (file)
@@ -24,6 +24,9 @@
                     <ol id="orders"></ol>
                 </div>
             </div>
+            <div id="loggedas">
+                <button>Back</button>
+            </div>
         </div>
         <div id="content">