diff --git a/public_html/media/js/comment-edit.js b/public_html/media/js/comment-edit.js index c8a3d920..9b58d8b5 100644 --- a/public_html/media/js/comment-edit.js +++ b/public_html/media/js/comment-edit.js @@ -12,7 +12,6 @@ $(function() .bindOnce('comment-submit', 'submit', function(e) { e.preventDefault(); - rememberLastSearchQuery(); var formDom = $(this); if (formDom.hasClass('inactive')) @@ -50,7 +49,7 @@ $(function() formDom.find('.preview').hide(); var cb = function() { - $.get(window.location.href).success(function(data) + getHtml(window.location.href).success(function(data) { $('.comments-wrapper').replaceWith($(data).find('.comments-wrapper')); $('body').trigger('dom-update'); @@ -99,7 +98,7 @@ $(function() if (formDom.length == 0) { - $.get($(this).attr('href')).success(function(data) + getHtml($(this).attr('href')).success(function(data) { var otherForm = $(data).find('form.edit-comment'); otherForm.hide(); diff --git a/public_html/media/js/core.js b/public_html/media/js/core.js index 4518b525..2dd25ad7 100644 --- a/public_html/media/js/core.js +++ b/public_html/media/js/core.js @@ -50,6 +50,12 @@ function postJSON(data) return $.ajax(data); }; +function getHtml(data) +{ + rememberLastSearchQuery(); + return $.get(data); +} + $.fn.hasAttr = function(name) { return this.attr(name) !== undefined; @@ -71,6 +77,18 @@ $.fn.bindOnce = function(name, eventName, callback) //basic event listeners $(function() { + $(window).on('beforeunload', function() + { + rememberLastSearchQuery(); + }); + if (window.history && window.history.pushState) + { + $(window).on('popstate', function() + { + rememberLastSearchQuery(); + }); + } + $('body').bind('dom-update', function() { //event confirmations @@ -93,9 +111,7 @@ $(function() { if (e.isPropagationStopped()) return; - e.preventDefault(); - rememberLastSearchQuery(); var aDom = $(this); if (aDom.hasClass('inactive')) @@ -125,7 +141,6 @@ $(function() $('form.simple-action').bindOnce('simple-action', 'submit', function(e) { e.preventDefault(); - rememberLastSearchQuery(); var formDom = $(this); if (formDom.hasClass('inactive')) @@ -149,7 +164,6 @@ $(function() { if (data.message) alert(data.message); - console.log(data); disableExitConfirmation(); formDom.find(':input').attr('readonly', false); formDom.removeClass('inactive'); @@ -184,10 +198,6 @@ $(function() }); }); }); - - - //try to remember last search query - window.onbeforeunload = rememberLastSearchQuery; }); diff --git a/public_html/media/js/paginator-endless.js b/public_html/media/js/paginator-endless.js index c9bdcc36..69808fa8 100644 --- a/public_html/media/js/paginator-endless.js +++ b/public_html/media/js/paginator-endless.js @@ -15,7 +15,7 @@ function scrolled() if (pageNext != null && pageNext != pageDone) { $(document).data('page-done', pageNext); - $.get(pageNext).success(function(response) + getHtml(pageNext).success(function(response) { var dom = $(response); var nextPage = dom.find('.paginator .next:not(.disabled) a').attr('href'); diff --git a/public_html/media/js/post-view.js b/public_html/media/js/post-view.js index 0e9f93e3..47038816 100644 --- a/public_html/media/js/post-view.js +++ b/public_html/media/js/post-view.js @@ -67,7 +67,7 @@ $(function() $('.comments.unit a.simple-action').data('callback', function() { - $.get(window.location.href).success(function(data) + getHtml(window.location.href).success(function(data) { $('.comments-wrapper').replaceWith($(data).find('.comments-wrapper')); $('body').trigger('dom-update'); @@ -76,7 +76,7 @@ $(function() $('#sidebar a.simple-action').data('callback', function() { - $.get(window.location.href).success(function(data) + getHtml(window.location.href).success(function(data) { $('#sidebar').replaceWith($(data).find('#sidebar')); $('body').trigger('dom-update'); @@ -89,7 +89,6 @@ $(function() $('form.edit-post').submit(function(e) { e.preventDefault(); - rememberLastSearchQuery(); var formDom = $(this); if (formDom.hasClass('inactive')) @@ -111,7 +110,7 @@ $(function() { disableExitConfirmation(); - $.get(window.location.href).success(function(data) + getHtml(window.location.href).success(function(data) { $('#sidebar').replaceWith($(data).find('#sidebar')); $('#revision').replaceWith($(data).find('#revision'));