X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=blobdiff_plain;f=src%2Fyuu%2Fcore.js;h=cf2f282b3b918408520ffb309cabe7009d3f88ab;hp=8b16707c8d1a1c369a5aa19f1161d4d68bc86dc3;hb=f96f0ecc5cd905dba4d20f3a06d154bf2683bff3;hpb=d2962105772fbdc548118bd65cd5bb4934e66085 diff --git a/src/yuu/core.js b/src/yuu/core.js index 8b16707..cf2f282 100644 --- a/src/yuu/core.js +++ b/src/yuu/core.js @@ -1,19 +1,18 @@ /* Copyright 2014 Yukkuri Games Licensed under the terms of the GNU GPL v2 or later - @license http://www.gnu.org/licenses/gpl-2.0.html - @source: http://yukkurigames.com/yuu/ + @license https://www.gnu.org/licenses/gpl-2.0.html + @source: https://yukkurigames.com/yuu/ */ (function (yuu) { "use strict"; - yuu.require = function (m) { try { return require(m); } catch (exc) { return null; } }; - if (!Math.sign) + if (!Object.assign) require("./pre"); var yT = this.yT || require("./yT"); @@ -70,6 +69,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 +91,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 +106,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) { @@ -144,7 +155,7 @@ req[k] = params[k]; req.onload = function () { var status = this.status; - // status === 0 is given by node-webkit for success. + // status === 0 is given by NW.js for success. if ((status >= 200 && status < 300) || status === 0) resolve(this.response); else