Browse Source

fix modals' closing on window history navigation

readme-update
Simon Grim 9 years ago
parent
commit
8608a9d235
  1. 22
      js/interface_common.js

22
js/interface_common.js

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
// Post actions: submit, count characters
var window_scrollY = 0;
var _watchHashChangeDontLoadModal = false;
var _watchHashChangeRelaxDontDoIt = window.location.hash === '' ? true : false;
var _minimizedModals = {};
function openModal(modal) {
@ -49,7 +49,10 @@ function openModal(modal) { @@ -49,7 +49,10 @@ function openModal(modal) {
function closeModal() {
closeModalHandler('.modal-wrapper');
window.location.hash = '#';
if (window.location.hash !== '') {
_watchHashChangeRelaxDontDoIt = true;
window.location.hash = '#';
}
window.scroll(window.pageXOffset, window_scrollY);
$('body').css({
'overflow': 'auto',
@ -109,6 +112,7 @@ function minimizeModal(modal, switchMode) { @@ -109,6 +112,7 @@ function minimizeModal(modal, switchMode) {
modal.fadeOut('fast', function () {
minimize(modal, scroll);
_watchHashChangeRelaxDontDoIt = true;
window.location.hash = '#';
window.scroll(window.pageXOffset, window_scrollY);
$('body').css({
@ -133,8 +137,10 @@ function resumeModal(event) { @@ -133,8 +137,10 @@ function resumeModal(event) {
var modal = _minimizedModals[event.data.hashString];
if (modal) {
_minimizedModals[event.data.hashString] = undefined;
_watchHashChangeDontLoadModal = true;
window.location.hash = event.data.hashString;
if (window.location.hash !== event.data.hashString) {
_watchHashChangeRelaxDontDoIt = true;
window.location.hash = event.data.hashString;
}
modal.self.prependTo('body').fadeIn('fast', function () {
// TODO also need reset modal height here maybe and then compute new scroll
if (modal.scroll)
@ -562,8 +568,8 @@ function watchHashChange(e) { @@ -562,8 +568,8 @@ function watchHashChange(e) {
}
}
if (_watchHashChangeDontLoadModal)
_watchHashChangeDontLoadModal = false;
if (_watchHashChangeRelaxDontDoIt)
_watchHashChangeRelaxDontDoIt = false;
else
loadModalFromHash();
}
@ -578,6 +584,10 @@ function loadModalFromHash() { @@ -578,6 +584,10 @@ function loadModalFromHash() {
}
var hashstring = decodeURIComponent(window.location.hash);
if (hashstring === '') {
closeModal();
return;
}
var hashdata = hashstring.split(':');
if (hashdata[0] !== '#web+twister')

Loading…
Cancel
Save