mirror of
https://github.com/scratchfoundation/scratchx.git
synced 2024-11-25 00:58:05 -05:00
Simplify page switching method
This commit is contained in:
parent
a69d55e995
commit
a473ebf565
1 changed files with 7 additions and 9 deletions
|
@ -107,11 +107,9 @@ swfobject.embedSWF('Scratch.swf', 'editor', '100%', '100%', '11.7.0', 'libs/expr
|
||||||
function showPage(path) {
|
function showPage(path) {
|
||||||
var toHide = "body > main, body > main > article, #editor";
|
var toHide = "body > main, body > main > article, #editor";
|
||||||
var toShow = "#" + path;
|
var toShow = "#" + path;
|
||||||
if (path != "editor") {
|
|
||||||
toShow += ", body > main";
|
|
||||||
}
|
|
||||||
|
|
||||||
$(toHide).hide();
|
$(toHide).hide();
|
||||||
|
$("body > main, body > main > article").has(toShow).show();
|
||||||
$(toShow).show();
|
$(toShow).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +118,9 @@ $("[data-staticlink]").click(function(e) {
|
||||||
showPage(e.target.attributes['data-staticlink'].value)
|
showPage(e.target.attributes['data-staticlink'].value)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var initialID = "home";
|
||||||
$(function (){
|
function initPage() {
|
||||||
if (window.location.hash) {
|
if (window.location.hash) initialID = window.location.hash.substr(1);
|
||||||
showPage(window.location.hash.substr(1));
|
showPage(initialID);
|
||||||
}
|
}
|
||||||
});
|
$(initPage);
|
||||||
|
|
Loading…
Reference in a new issue