preset loader + bugfixes

This commit is contained in:
Sublunar Space 2019-01-03 14:27:31 +01:00
parent 5c624df96f
commit ac264cc82d
2 changed files with 39 additions and 26 deletions

View file

@ -339,14 +339,7 @@
$('#filterreset').on('click', function() { $('#filterreset').on('click', function() {
if ( $("body").attr("use") == "offline" ) { if ( $("body").attr("use") == "offline" ) {
$("#grid").empty(); $("#grid").empty();
$('#caption .stoke').html("resetting...please wait."); if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy');
$.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');
});
} }
$('.actionlistfilter input').prop('checked', false); $('.actionlistfilter input').prop('checked', false);
$('.filteroptions input').prop('checked', false); $('.filteroptions input').prop('checked', false);

View file

@ -40,6 +40,34 @@ SL.Calendar = (function() {
.find('.col-sm-4').remove(); .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. * 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(); NProgress.done();
clearTimeout(timeout); clearTimeout(timeout);
$('#caption .stoke').empty(); $('#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( $("#grid").html(), "grid.html", "skip", "html", "text/html; charset=utf-8");
SL.Calendar.download(Hours.moments, "ephemeris"); SL.Calendar.download(Hours.moments, "ephemeris");
}
} }
} }
@ -385,9 +414,10 @@ SL.Calendar = (function() {
modal(plugin, definitions); modal(plugin, definitions);
} }
}); });
if ( $("body").attr("use") == "download" ) if ( $("body").attr("use") == "download" ) {
SL.Calendar.download( $("#filterList").html(), "filtermenu.html", "skip", "html", "text/html; charset=utf-8"); 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"); 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)); extend(m, eval('module_'+m));
}); });
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
if ( $("body").attr("use") == "offline" ) { loadPreset();
$('#caption .stoke').html("loading preset...please wait."); if ( $("body").attr("use") == "offline" )
$.get("presets/filtermenu.html").done(function(html) {$("#filterList").append(html);}); $("#filterreset").closest('li').before('<li><p class="navbar-btn"><a class="btn btn-default" id="preset" onClick="SL.Calendar.preset()" href="#"><span class="glyphicon glyphicon-open"></span> Load Preset</a></p></li>');
$.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;
});
}
} }
/** /**
@ -642,6 +661,7 @@ SL.Calendar = (function() {
about : about, about : about,
getGeoCode : getGeoCode, getGeoCode : getGeoCode,
reset : resetWindow, reset : resetWindow,
preset : loadPreset,
modules : Module.load, modules : Module.load,
comboFilter : Filter.comboFilter, comboFilter : Filter.comboFilter,
hourInfo : Hour.info, hourInfo : Hour.info,