2013-08-11 03:26:38 +04:00
|
|
|
(function () {
|
2013-12-23 18:04:13 +04:00
|
|
|
|
|
|
|
window.onPiskelReady = function () {
|
|
|
|
var loadingMask = document.getElementById('loading-mask');
|
|
|
|
loadingMask.style.opacity = 0;
|
|
|
|
window.setTimeout(function () {loadingMask.parentNode.removeChild(loadingMask);}, 600)
|
|
|
|
pskl.app.init();
|
|
|
|
// cleanup
|
|
|
|
delete window.exports;
|
|
|
|
delete window.loadDebugScripts;
|
|
|
|
delete window.done;
|
|
|
|
};
|
|
|
|
|
2013-12-19 02:22:25 +04:00
|
|
|
var prefixPath = function (path) {
|
|
|
|
if (window.pskl && window.pskl.appEngineToken_) {
|
|
|
|
return '../' + path;
|
|
|
|
} else {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
};
|
2013-08-11 03:26:38 +04:00
|
|
|
|
|
|
|
var loadScript = function (src, callback) {
|
2013-12-19 02:22:25 +04:00
|
|
|
src = prefixPath(src);
|
2013-08-11 03:26:38 +04:00
|
|
|
var script = window.document.createElement('script');
|
|
|
|
script.setAttribute('src',src);
|
|
|
|
script.setAttribute('onload',callback);
|
|
|
|
window.document.body.appendChild(script);
|
|
|
|
};
|
|
|
|
|
2013-12-19 02:22:25 +04:00
|
|
|
var loadStyle = function (src) {
|
|
|
|
src = prefixPath(src);
|
|
|
|
var link = document.createElement('link');
|
|
|
|
link.setAttribute('href', src);
|
|
|
|
link.setAttribute('rel', 'stylesheet');
|
|
|
|
link.setAttribute('type', 'text/css');
|
|
|
|
document.head.appendChild(link);
|
|
|
|
};
|
|
|
|
|
2013-08-11 03:26:38 +04:00
|
|
|
if (window.location.href.indexOf("debug") != -1) {
|
|
|
|
window.exports = {};
|
|
|
|
var scriptIndex = 0;
|
|
|
|
window.loadNextScript = function () {
|
2013-09-28 23:10:12 +04:00
|
|
|
if (scriptIndex == window.exports.scripts.length) {
|
2013-12-23 18:04:13 +04:00
|
|
|
window.onPiskelReady();
|
2013-08-11 03:26:38 +04:00
|
|
|
} else {
|
2013-09-28 23:10:12 +04:00
|
|
|
loadScript(window.exports.scripts[scriptIndex], "loadNextScript()");
|
2013-08-11 03:26:38 +04:00
|
|
|
scriptIndex ++;
|
|
|
|
}
|
|
|
|
};
|
2013-08-11 12:45:56 +04:00
|
|
|
loadScript("piskel-script-list.js", "loadNextScript()");
|
2013-12-19 02:22:25 +04:00
|
|
|
|
|
|
|
window.loadStyles = function () {
|
|
|
|
var styles = window.exports.styles;
|
|
|
|
for (var i = 0 ; i < styles.length ; i++) {
|
|
|
|
loadStyle(styles[i]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
loadScript("piskel-style-list.js", "loadStyles()");
|
2013-08-11 03:26:38 +04:00
|
|
|
} else {
|
|
|
|
var script;
|
|
|
|
if (window.location.href.indexOf("pack") != -1) {
|
|
|
|
script = "build/piskel-packaged.js";
|
|
|
|
} else {
|
|
|
|
script = "build/piskel-packaged-min.js";
|
|
|
|
}
|
2013-12-19 02:22:25 +04:00
|
|
|
loadStyle('build/piskel-style-packaged.css');
|
|
|
|
|
2013-08-11 03:26:38 +04:00
|
|
|
var loaderInterval = window.setInterval(function () {
|
2013-12-06 01:12:48 +04:00
|
|
|
if (document.querySelectorAll("[data-iframe-loader]").length === 0) {
|
2013-08-11 03:26:38 +04:00
|
|
|
window.clearInterval(loaderInterval);
|
2013-12-23 18:04:13 +04:00
|
|
|
loadScript(script, "onPiskelReady()");
|
2013-08-11 03:26:38 +04:00
|
|
|
} else {
|
|
|
|
console.log("waiting for templates to load ....");
|
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
})();
|