diff --git a/js/privatebin.js b/js/privatebin.js index 6ed88f0..5963592 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1118,6 +1118,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { var deleteUrl = controller.scriptLocation() + '?pasteid=' + data.id + '&deletetoken=' + data.deletetoken; controller.showStatus(''); controller.errorMessage.addClass('hidden'); + history.pushState({type: 'newpaste'}, '', url); $('#pastelink').html( i18n._( @@ -1152,6 +1153,26 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { }); }, + /** + * handle history (pop) state changes + * + * currently this does only handle redirects to the home page. + * + * @name controller.historyChange + * @function + * @param {Event} event + */ + historyChange: function(event) + { + if (event.originalEvent.state === null && // no state object passed + this.scriptLocation() === event.originalEvent.target.location.href && // target location is home page + this.scriptLocation() === window.location.href // and we are not already on the home page + ) { + // redirect to home page + window.location.href = this.scriptLocation(); + } + }, + /** * check if a URL shortener was defined and create HTML containing a link to it * @@ -1619,6 +1640,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { this.passwordModal.on('shown.bs.modal', $.proxy(this.passwordDecrypt.focus, this)); this.passwordModal.on('hidden.bs.modal', $.proxy(this.decryptPasswordModal, this)); this.passwordForm.submit($.proxy(this.submitPasswordModal, this)); + + $(window).on('popstate', $.proxy(this.historyChange, this)); }, /** diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 8938112..aa61a02 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -69,7 +69,7 @@ if ($MARKDOWN): - +