From 1d8e0a5587ac4971a17494770f98c5f9d5090cec Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Sun, 28 Jun 2015 04:03:17 -0400 Subject: [PATCH] Fixed status message behavioral issues Now displays multiple error messages one after the other. Also fixed an issue where when there is a status message being display and another error happens, the status message slides up then down again with the new message. Signed-off-by: Collin J. Doering --- js/default.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/default.js b/js/default.js index 03a5449..2a435b4 100644 --- a/js/default.js +++ b/js/default.js @@ -171,11 +171,8 @@ type: 'GET', dataType: 'html', beforeSend: function (xhr, settings) { - // Remove loading error from page-content and any status message errors + // Remove loading error from page-content $('#page-content').removeClass('loading-error'); - $('#status').slideUp('normal', function () { - $('#status').removeClass('error').removeClass('success'); - }); // Add .loading to #page-content and #nav to facilitate a loading animation $('#page-content, #nav').removeClass('loading-done').addClass('loading'); @@ -191,6 +188,11 @@ // Remove the initial loading gif (if its there) $('#page-content').removeClass('init'); + // Remove any status message errors or successes + $('#status').slideUp('normal', function () { + $('#status').removeClass('error').removeClass('success').children('p.message').remove(); + }); + // Stop animations in the nav and page-content and scroll to the top of the page in a set amount of time setTimeout(function () { // Replace old page-content with new page-content @@ -204,6 +206,7 @@ mj.Hub.Queue(["Typeset", mj.Hub, math_elem[0]]); }); + // Rewrite new URLs within new content inserted into #page-content $('#page-content a').each(function (i) { var href = $(this).attr('href'), external_url_regexp = /https?:\/\/.*/, @@ -245,9 +248,12 @@ */ $('#page-content, #nav').removeClass('loading'); if ($('#page-content.init')[0]) { + // TODO: instead of immediately displaying error, check if the content is stored in local storage $('#page-content').addClass('loading-error').html('

Error initially loading blog.rekahsoft.ca. Check the url! Given "' + page_href + '"

'); + } else if ($('#status.error')[0]) { + $('#status').prepend('

Error retrieving page ' + page_href + '

'); } else { - $('#status > p.message').text('Error retrieving page "' + page_href + '": ' + status); + $('#status').prepend('

Error retrieving page ' + page_href + '

'); $('#status').addClass('error').slideDown(); } @@ -270,7 +276,10 @@ }); $('#status a.close-button').click(function () { - $(this).parent().slideUp(); + $(this).parent().slideUp(function () { + $(this).removeClass('error').removeClass('success'); + $(this).children('p.message').remove(); + }); }); // Callback for when the inital page has completely loaded (including images, etc..)