Update the history when a paste is created
Fixes https://github.com/PrivateBin/PrivateBin/issues/167
This commit is contained in:
parent
afdfcba304
commit
ca51a80803
|
@ -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));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-YW9b0ChcI/zuJwUZxdQW3zb/LO999he3fOtiio2MhickC7YyrzgvIcgvFMUYZjJ79tYiNzDLmMAZKRMvqoQoGw==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
Loading…
Reference in New Issue