[IMP] Proper hash update for Ace
authorddm <ddm@openerp.com>
Wed, 18 Sep 2013 14:52:43 +0000 (16:52 +0200)
committerddm <ddm@openerp.com>
Wed, 18 Sep 2013 14:52:43 +0000 (16:52 +0200)
bzr revid: ddm@openerp.com-20130918145243-sf3kdfy8o6xe6qb0

addons/website/static/src/js/website.ace.js

index 93285ae..9516468 100644 (file)
         },
         displaySelectedView: function () {
             this.displayView(this.selectedViewId());
+            this.updateHash();
         },
         formatXml: function () {
             var xml = new website.ace.XmlDocument(this.aceEditor.getValue());
                 return $.Deferred().fail("Malformed XML document");
             }
         },
-        reloadPage: function () {
+        updateHash: function () {
             window.location.hash = hash + "?view=" + this.selectedViewId();
+        },
+        reloadPage: function () {
+            this.updateHash();
             window.location.reload();
         },
         displayError: function (error) {
         },
         open: function () {
             this.$el.removeClass('oe_ace_closed').addClass('oe_ace_open');
-            var hash = window.location.hash;
-            var indexOfView = hash.indexOf("?view=");
+            var curentHash = window.location.hash;
+            var indexOfView = curentHash.indexOf("?view=");
             if (indexOfView >= 0) {
-                var viewId = parseInt(hash.substring(indexOfView + 6, hash.length), 10);
+                var viewId = parseInt(curentHash.substring(indexOfView + 6, curentHash.length), 10);
                 this.$('#ace-view-list').val(viewId).change();
-                window.location.hash = hash.substring(0, indexOfView);
+            } else {
+                window.location.hash = hash;
             }
         },
         close: function () {