diff --git a/index.html b/index.html index fb83623..593ea03 100644 --- a/index.html +++ b/index.html @@ -339,14 +339,7 @@ $('#filterreset').on('click', function() { if ( $("body").attr("use") == "offline" ) { $("#grid").empty(); - $('#caption .stoke').html("resetting...please wait."); - $.get("presets/grid.html").done(function(html) { - $("#grid").append(html); - $('#caption .stoke').empty(); - $('#moduleSelect input:checkbox').prop('checked', true); - $('.planetaryhour').on('click', SL.Calendar.hourInfo); - if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy'); - }); + if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy'); } $('.actionlistfilter input').prop('checked', false); $('.filteroptions input').prop('checked', false); diff --git a/js/SL.Calendar.js b/js/SL.Calendar.js index 284d3e4..bbd6650 100644 --- a/js/SL.Calendar.js +++ b/js/SL.Calendar.js @@ -40,6 +40,34 @@ SL.Calendar = (function() { .find('.col-sm-4').remove(); } + /** + * loadPreset loads precalculated menubar, modals and hour grid + */ + function loadPreset() { + if ( $("body").attr("use") == "offline" ) { + $('#caption .stoke').html("loading preset...please wait."); + $.get("presets/filtermenu.html").done(function(html) { + $("#filterList").empty(); + $("#filterList").append(html); + }); + $.get("presets/modals.html").done(function(html) { + $("#modals").empty(); + $("#modals").append(html); + }); + $.get("presets/grid.html").done(function(html) { + $("#grid").empty(); + $("#grid").append(html); + $('#caption .stoke').empty(); + $('#moduleSelect input:checkbox').prop('checked', true); + $('.planetaryhour').on('click', SL.Calendar.hourInfo); + }); + $.getJSON("presets/ephemeris.json", function(json) { + Hours.moments = json.query; + }); + if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy'); + } + } + /** * resetWindow function simulates a resizing of the browser window. Needed hack for a display glitch in the modals. */ @@ -262,9 +290,10 @@ SL.Calendar = (function() { NProgress.done(); clearTimeout(timeout); $('#caption .stoke').empty(); - if ( $("body").attr("use") == "download" ) + if ( $("body").attr("use") == "download" ) { SL.Calendar.download( $("#grid").html(), "grid.html", "skip", "html", "text/html; charset=utf-8"); SL.Calendar.download(Hours.moments, "ephemeris"); + } } } @@ -385,9 +414,10 @@ SL.Calendar = (function() { modal(plugin, definitions); } }); - if ( $("body").attr("use") == "download" ) - SL.Calendar.download( $("#filterList").html(), "filtermenu.html", "skip", "html", "text/html; charset=utf-8"); - SL.Calendar.download( $("#modals").html(), "modals.html", "skip", "html", "text/html; charset=utf-8"); + if ( $("body").attr("use") == "download" ) { + SL.Calendar.download( $("#filterList").html(), "filtermenu.html", "skip", "html", "text/html; charset=utf-8"); + SL.Calendar.download( $("#modals").html(), "modals.html", "skip", "html", "text/html; charset=utf-8"); + } } /** @@ -522,20 +552,9 @@ SL.Calendar = (function() { extend(m, eval('module_'+m)); }); $('[data-toggle="tooltip"]').tooltip(); - if ( $("body").attr("use") == "offline" ) { - $('#caption .stoke').html("loading preset...please wait."); - $.get("presets/filtermenu.html").done(function(html) {$("#filterList").append(html);}); - $.get("presets/modals.html").done(function(html) {$("#modals").append(html);}); - $.get("presets/grid.html").done(function(html) { - $("#grid").append(html); - $('#caption .stoke').empty(); - $('#moduleSelect input:checkbox').prop('checked', true); - $('.planetaryhour').on('click', SL.Calendar.hourInfo); - }); - $.getJSON("presets/ephemeris.json", function(json) { - Hours.moments = json.query; - }); - } + loadPreset(); + if ( $("body").attr("use") == "offline" ) + $("#filterreset").closest('li').before('