From d0eabc16f6a857faf4f2e65e3582c348016baede Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Mon, 7 Dec 2015 10:56:27 +0100 Subject: [PATCH] Tentative fix for offline copy problem --- .../delta/js/Clipperz/PM/UI/MainController.js | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/frontend/delta/js/Clipperz/PM/UI/MainController.js b/frontend/delta/js/Clipperz/PM/UI/MainController.js index 4d2df25..f1a3a12 100644 --- a/frontend/delta/js/Clipperz/PM/UI/MainController.js +++ b/frontend/delta/js/Clipperz/PM/UI/MainController.js @@ -1044,9 +1044,31 @@ Clipperz.log("THE BROWSER IS OFFLINE"); //========================================================================= + historyReplaceState: function (args) { + if (window.document.origin != null) { + window.history.replaceState.apply(window.history, arguments); + } + }, + + historyPushState: function (args) { + if (window.document.origin != null) { + window.history.pushState.apply(window.history, arguments); + } + }, + + historyState: function (args) { + if (window.document.origin != null) { + return window.history.state.apply(window.history, arguments); + } + }, + + //========================================================================= + runApplication: function (anUser) { - window.history.replaceState({selectedCardInfo: null}, "", window.location.toString()); - window.history.pushState({selectedCardInfo: null}, "", window.location.toString()); // Hack to support filters undo with no other actions +// window.history.replaceState({selectedCardInfo: null}, "", window.location.toString()); + this.historyReplaceState({selectedCardInfo: null}, "", window.location.toString()); +// window.history.pushState({selectedCardInfo: null}, "", window.location.toString()); // Hack to support filters undo with no other actions + this.historyPushState({selectedCardInfo: null}, "", window.location.toString()); // Hack to support filters undo with no other actions this.moveInPage(this.currentPage(), 'mainPage'); MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'enableLock'); this.resetLockTimeout(); @@ -1170,11 +1192,11 @@ Clipperz.log("THE BROWSER IS OFFLINE"); this.moveOutPage(fromPage, toPage); }, - historyGoBack: function (anEvent) { - anEvent.preventDefault(); - anEvent.stopPropagation(); - this.goBack(); - }, +// historyGoBack: function (anEvent) { +// anEvent.preventDefault(); +// anEvent.stopPropagation(); +// this.goBack(); +// }, currentPage: function () { return this.pageStack()[0]; @@ -1596,7 +1618,8 @@ Clipperz.log("THE BROWSER IS OFFLINE"); selectCard_handler: function (someInfo, shouldUpdateCardDetail) { this.selectCard(someInfo, shouldUpdateCardDetail); - window.history.pushState({selectedCardInfo: someInfo}, "", window.location.toString()); +// window.history.pushState({selectedCardInfo: someInfo}, "", window.location.toString()); + this.historyPushState({selectedCardInfo: someInfo}, "", window.location.toString()); // console.log("pushing state"); }, @@ -2014,7 +2037,8 @@ Clipperz.log("THE BROWSER IS OFFLINE"); goBackToMainPage_handler: function (anEvent) { this.goBackToMainPage(anEvent); - window.history.pushState({selectedCardInfo: null}, "", window.location.toString()); +// window.history.pushState({selectedCardInfo: null}, "", window.location.toString()); + this.historyPushState({selectedCardInfo: null}, "", window.location.toString()); }, //============================================================================ @@ -2353,10 +2377,12 @@ Clipperz.log("THE BROWSER IS OFFLINE"); handleOnpopstate: function (anEvent) { if (this.filter().type != 'ALL') { this.selectAllCards(); - window.history.pushState(window.history.state, "", window.location.toString()); +// window.history.pushState(window.history.state, "", window.location.toString()); + this.historyPushState(this.historyState, "", window.location.toString()); } else if(anEvent.state) { if (this.isPageInEditMode()) { - window.history.pushState({selectedCardInfo: this.selectedCardInfo()}, "", window.location.toString()); +// window.history.pushState({selectedCardInfo: this.selectedCardInfo()}, "", window.location.toString()); + this.historyPushState({selectedCardInfo: this.selectedCardInfo()}, "", window.location.toString()); this.cancelCardEdits(this.selectedCardReference()); } else { if (anEvent.state['selectedCardInfo']) {