2013-11-25 22:00:19 +04:00
|
|
|
(function () {
|
|
|
|
|
2014-03-30 05:12:56 +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
|
2014-05-17 02:04:55 +04:00
|
|
|
delete window.pskl_exports;
|
2014-03-30 05:12:56 +04:00
|
|
|
delete window.loadDebugScripts;
|
|
|
|
delete window.done;
|
|
|
|
};
|
|
|
|
|
|
|
|
var prefixPath = function (path) {
|
|
|
|
if (window.pskl && window.pskl.appEngineToken_) {
|
|
|
|
return '../' + path;
|
|
|
|
} else {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
var loadScript = function (src, callback) {
|
2014-03-30 05:12:56 +04:00
|
|
|
src = prefixPath(src);
|
2013-11-25 22:00:19 +04:00
|
|
|
var script = window.document.createElement('script');
|
|
|
|
script.setAttribute('src',src);
|
|
|
|
script.setAttribute('onload',callback);
|
|
|
|
window.document.body.appendChild(script);
|
|
|
|
};
|
|
|
|
|
2014-03-30 05:12:56 +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-11-25 22:00:19 +04:00
|
|
|
if (window.location.href.indexOf("debug") != -1) {
|
2014-05-17 02:04:55 +04:00
|
|
|
window.pskl_exports = {};
|
2013-11-25 22:00:19 +04:00
|
|
|
var scriptIndex = 0;
|
|
|
|
window.loadNextScript = function () {
|
2014-05-17 02:04:55 +04:00
|
|
|
if (scriptIndex == window.pskl_exports.scripts.length) {
|
2014-03-30 05:12:56 +04:00
|
|
|
window.onPiskelReady();
|
2013-11-25 22:00:19 +04:00
|
|
|
} else {
|
2014-05-17 02:04:55 +04:00
|
|
|
loadScript(window.pskl_exports.scripts[scriptIndex], "loadNextScript()");
|
2013-11-25 22:00:19 +04:00
|
|
|
scriptIndex ++;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
loadScript("piskel-script-list.js", "loadNextScript()");
|
2014-03-30 05:12:56 +04:00
|
|
|
|
|
|
|
window.loadStyles = function () {
|
2014-05-17 02:04:55 +04:00
|
|
|
var styles = window.pskl_exports.styles;
|
2014-03-30 05:12:56 +04:00
|
|
|
for (var i = 0 ; i < styles.length ; i++) {
|
|
|
|
loadStyle(styles[i]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
loadScript("piskel-style-list.js", "loadStyles()");
|
2013-11-25 22:00:19 +04:00
|
|
|
} else {
|
|
|
|
var script;
|
|
|
|
if (window.location.href.indexOf("pack") != -1) {
|
2014-05-17 02:04:55 +04:00
|
|
|
script = "js/piskel-packaged.js";
|
2013-11-25 22:00:19 +04:00
|
|
|
} else {
|
2014-05-17 02:04:55 +04:00
|
|
|
script = "js/piskel-packaged-min.js";
|
2013-11-25 22:00:19 +04:00
|
|
|
}
|
2014-05-17 02:04:55 +04:00
|
|
|
loadStyle('css/piskel-style-packaged.css');
|
2014-03-30 05:12:56 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
var loaderInterval = window.setInterval(function () {
|
2014-03-30 05:12:56 +04:00
|
|
|
if (document.querySelectorAll("[data-iframe-loader]").length === 0) {
|
2013-11-25 22:00:19 +04:00
|
|
|
window.clearInterval(loaderInterval);
|
2014-03-30 05:12:56 +04:00
|
|
|
loadScript(script, "onPiskelReady()");
|
2013-11-25 22:00:19 +04:00
|
|
|
} else {
|
|
|
|
console.log("waiting for templates to load ....");
|
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
})();
|