diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2018-03-22 11:37:07 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-22 11:37:07 +0300 |
commit | 4b980cb01006ecb11115c0cd18c7db78e45db5c2 (patch) | |
tree | 9e31b2091f8e13bf5ed68c31a782f531becda87e | |
parent | 871c866f0d08a24e280f8a9ca427debe58c853fd (diff) |
fix back button navigation (#183)
now backbutton when document is opened takes you back to the files app
from where the document was opened.
-rw-r--r-- | js/viewer/viewer.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/js/viewer/viewer.js b/js/viewer/viewer.js index 8bdf3950..a1ae922c 100644 --- a/js/viewer/viewer.js +++ b/js/viewer/viewer.js @@ -107,6 +107,22 @@ var odfViewer = { $('#app-content #controls').addClass('hidden'); $('#app-content').append($iframe); + window.location.assign(window.location.href + '#richdocuments'); + + window.addEventListener('hashchange', function(e) { + // handle double hash (eg: ##richdocuments) + var hash = window.location.hash.replace(/#/g, ''); + // unload + if (hash !== 'richdocuments') { + odfViewer.onClose(); + } + // load + else if (hash === 'richdocuments' && $('#richdocumentsframe').length === 0) { + $('#app-content #controls').addClass('hidden'); + $('#app-navigation').addClass('hidden'); + $('#app-content').append($iframe); + } + }); }, onClose: function() { |