Преглед изворни кода

[editor] Fixed save URL, changed from hashtag to pushstate

Enrico Berti пре 10 година
родитељ
комит
0827a48

+ 6 - 5
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -463,7 +463,7 @@
           $.post("/notebook/api/historify", {
             notebook: ko.mapping.toJSON(notebook, SPARK_MAPPING)
           }, function(data){
-            if (vm.editorMode && data && data.status == 0 && data.id && typeof history.pushState != 'undefined'){
+            if (vm.editorMode && data && data.status == 0 && data.id){
               history.pushState(null, null, '/notebook/editor?editor=' + data.id);
             }
           });
@@ -921,10 +921,11 @@
         if (data.status == 0) {
           self.id(data.id);
           $(document).trigger("info", data.message);
-          if (vm.editorMode && window.location.search.indexOf("editor") == -1) {
-            window.location.hash = '#editor=' + data.id;
-          } else if (window.location.search.indexOf("notebook") == -1) {
-            window.location.hash = '#notebook=' + data.id;
+          if (vm.editorMode){
+            history.pushState(null, null, '/notebook/editor?editor=' + data.id);
+          }
+          else {
+            history.pushState(null, null, '/notebook/notebook?notebook=' + data.id);
           }
         }
         else {

+ 0 - 9
desktop/libs/notebook/src/notebook/templates/editor.mako

@@ -26,15 +26,6 @@
 
 ${ commonheader(_('Editor'), editor_type, user, "68px") | n,unicode }
 
-<script type="text/javascript">
-  if (window.location.hash != "") {
-    if (window.location.hash.indexOf("editor") > -1) {
-      location.href = "/notebook/editor?" + window.location.hash.substr(1).replace(/(<([^>]+)>)/ig, "");
-    }
-  }
-</script>
-
-
 ${ editorComponents.includes() }
 ${ editorComponents.topBar('editor', editor_type) }
 ${ editorComponents.commonHTML() }

+ 0 - 8
desktop/libs/notebook/src/notebook/templates/notebook.mako

@@ -26,14 +26,6 @@
 
 ${ commonheader(_('Notebook'), app_name, user, "68px") | n,unicode }
 
-<script type="text/javascript">
-  if (window.location.hash != "") {
-    if (window.location.hash.indexOf("notebook") > -1) {
-      location.href = "/notebook/notebook?" + window.location.hash.substr(1).replace(/(<([^>]+)>)/ig, "");
-    }
-  }
-</script>
-
 ${ editorComponents.includes() }
 ${ editorComponents.topBar('notebook') }
 <%editorComponents:commonHTML>