[IMP] website: after save reload page with the same scrolling
authorChristophe Matthieu <chm@openerp.com>
Wed, 16 Oct 2013 10:45:45 +0000 (12:45 +0200)
committerChristophe Matthieu <chm@openerp.com>
Wed, 16 Oct 2013 10:45:45 +0000 (12:45 +0200)
bzr revid: chm@openerp.com-20131016104545-e415ixicw2crci2w

addons/website/static/src/js/website.editor.js
addons/website/static/src/js/website.js

index 81fe087..aef3900 100644 (file)
             });
         },
         cancel: function () {
-            window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?|#.*/g, '');
+            website.reload();
         },
     });
 
index 1f4e54b..963a0b1 100644 (file)
         return $.when.apply(null, dones);
     };
     website.reload = function () {
-        window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?|#.*/g, '');
+        location.hash = "scrollTop=" + window.document.body.scrollTop;
+        if (location.search.indexOf("unable_editor") > -1) {
+            window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?/g, '');
+        } else {
+            window.location.reload();
+        }
     };
 
     var all_ready = null;
             website.init_kanban(this);
         });
 
+        setTimeout(function () {
+            if (window.location.hash.indexOf("scrollTop=") > -1) {
+                window.document.body.scrollTop = +location.hash.match(/scrollTop=([0-9]+)/)[1];
+            }
+        },0);
     });
 
     return website;