X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=blobdiff_plain;f=src%2Fyuu%2Fcore.js;h=1d64e98d193c170d56a0f84c73f05dac5dfcb003;hp=8b16707c8d1a1c369a5aa19f1161d4d68bc86dc3;hb=a965227dd5fcb2b549b2df1d5ce1420926b44909;hpb=d2962105772fbdc548118bd65cd5bb4934e66085 diff --git a/src/yuu/core.js b/src/yuu/core.js index 8b16707..1d64e98 100644 --- a/src/yuu/core.js +++ b/src/yuu/core.js @@ -7,6 +7,10 @@ (function (yuu) { "use strict"; + yuu.isSafari = function (ua) { + return /^((?!chrome).)*safari/i.test(ua || navigator.userAgent) + || navigator.standalone; + }; yuu.require = function (m) { try { return require(m); } @@ -70,6 +74,9 @@ /** Initialize Yuu and call all registered hooks */ + document.body.className += (navigator.standalone || gui) + ? " standalone" : " browser"; + if (gui) { var win = gui.Window.get(); var nativeMenuBar = new gui.Menu({ type: "menubar" }); @@ -89,6 +96,14 @@ wkdoc.hidden = false; wkdoc.dispatchEvent(ev); }); + win.on('new-win-policy', function (frame, url, policy) { + if (url.startsWith('chrome')) { + policy.forceNewPopup(); + } else { + policy.ignore(); + gui.Shell.openExternal(url); + } + }); } return new Promise(function (resolve) { @@ -96,9 +111,10 @@ initOptions = options || {}; yuu.log("messages", "Initializing Yuu engine."); var promises = []; - yf.each(function (hook) { - promises.push(hook.call(yuu, initOptions)); - }, initHooks); + // initHooks can be pushed to while iterating, so iterate + // by index, not a foreach loop. + for (var i = 0; i < initHooks.length; ++i) + promises.push(initHooks[i].call(yuu, initOptions)); initHooks = null; // Bust future registerInitHook calls. yuu.log("messages", "Initialization hooks complete."); if (gui) {