X-Git-Url: https://git.yukkurigames.com/?a=blobdiff_plain;f=src%2Fyuu%2Fcore.js;h=e770f863847fd857c6a8255b6fac3131b74b9257;hb=9ceff62f76f5ae2049cac00465d7756b0bc3cb9b;hp=25d3ed2a52710ffb2da77e3445aaefae85420908;hpb=f274a6a50b184cc031636e7ef8da89d0da696cc5;p=pwl6.git diff --git a/src/yuu/core.js b/src/yuu/core.js index 25d3ed2..e770f86 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) { @@ -145,7 +160,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