Change how HTML links are handled.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 10 Sep 2014 15:43:17 +0000 (17:43 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 10 Sep 2014 15:43:17 +0000 (17:43 +0200)
Now, require target=_blank for links that open a new page,
and don't require yuu-href-internal.

Show separate error messages for browser vs. standalone running.

Add email contact link.

src/index.html
src/yuu/core.js
src/yuu/data/yuu.css
src/yuu/director.js

index 1fedd23..dd3f3fd 100644 (file)
       </pre>
     </div>
     <div id="yuu-fatal-error" class="yuu-overlay">
-      <p>There was a serious problem. You'll have to restart. Sorry
-      about that.</p>
-      <p id="yuu-fatal-error-message"></p>
       <p>
+        There was a serious problem. You'll have to restart. Sorry
+        about that.
+      </p>
+      <p id="yuu-fatal-error-message"></p>
+      <p class=standalone>
+        If this problem persists,
+        <a target=_blank href="https://yukkurigames.com/support.html">check our
+          support page</a>. If it doesn't help,
+          <a href="mailto:yuuSPAM@MAPSyukkurigames.com"
+             onclick="this.href=this.href.replace(/[A-Z]/g, '')">email us</a>.
+        Please include a screenshot of the problem, the rest of the
+        text in this error message, and
+        <a target=_blank href="chrome://gpu">information about your
+          system's GPU</a>.
+      </p>
+      <p class=browser>
         Supported browsers include recent versions of
-        <a href="http://www.mozilla.org/firefox/">Mozilla Firefox</a>
-        and <a href="http://www.google.com/chrome/">Google Chrome</a>
+        <a target=_blank href="http://www.mozilla.org/firefox/">Mozilla Firefox</a>
+        and <a target=_blank href="http://www.google.com/chrome/">Google Chrome</a>
         on most desktop computers,
-        <a href="https://www.google.com/intl/en/chrome/browser/mobile/android.html">Chrome
+        <a target=_blank href="https://www.google.com/intl/en/chrome/browser/mobile/android.html">Chrome
           for Android</a>, and Safari on Mac OS X 10.7 and later
-        <a href="https://discussions.apple.com/thread/3300585?start=0">if
+        <a target=_blank href="https://discussions.apple.com/thread/3300585?start=0">if
           you enable WebGL manually</a>.
       </p>
+      <p class=browser>
+        If you are running one of these browsers and still have a problem,
+        <a target=_blank href="https://yukkurigames.com/support.html">check our
+          support page</a>. If it doesn't help,
+        <a href="mailto:yuuSPAM@MAPSyukkurigames.com"
+           onclick="this.href=this.href.replace(/[A-Z]/g, '')">email us</a>.
+        Please include a screenshot of the problem and the rest of
+        the text in this error message.
+      </p>
       <h2>Error Log</h2>
       <pre id="yuu-fatal-error-stack">
       </pre>
          data-yuu-animation="yuu-from-top"
          data-yuu-dismiss-key="escape">
       <div data-yuu-command="dismiss" tabindex=0></div>
-      <h1><a href="http://yukkurigames.com/pwl6/">Pixel Witch Lesson #6</a></h1>
+      <h1><a target=_blank href="http://yukkurigames.com/pwl6/">Pixel Witch Lesson #6</a></h1>
       <dl>
         <dt>Designed &amp; Implemented</dt>
         <dd>Joe Wreschnig</dd>
         <dt>Additional Programming</dt>
         <dd>
           Brandon Jones &amp; Colin MacKenzie IV
-          (<a href="http://glmatrix.net/">glMatrix</a>)
+          (<a target=_blank href="http://glmatrix.net/">glMatrix</a>)
         </dd>
         <dd>
           Christoph Burgmer
-          (<a href="https://github.com/cburgmer/ayepromise">ayepromise</a>)
+          (<a target=_blank href="https://github.com/cburgmer/ayepromise">ayepromise</a>)
         </dd>
         <dd>
           Ian McEwan, Ashima Arts
-          (<a href="https://github.com/ashima/webgl-noise">WebGL Noise</a>)
+          (<a target=_blank href="https://github.com/ashima/webgl-noise">WebGL Noise</a>)
         </dd>
         <dd>
           Jorik Tangelder
-          (<a href="http://eightmedia.github.io/hammer.js/">Hammer.js</a>)
+          (<a target=_blank href="http://eightmedia.github.io/hammer.js/">Hammer.js</a>)
         </dd>
         <dt>Fonts</dt>
         <dd>
           Carrois Type Design
-          (<a href="http://www.carrois.com/en/fira-3-1/">Fira</a>)
+          (<a target=_blank href="http://www.carrois.com/en/fira-3-1/">Fira</a>)
         </dd>
         <dd>
           Dave Gandy
-          (<a href="http://fortawesome.github.io/">Font Awesome</a>)
+          (<a target=_blank href="http://fortawesome.github.io/">Font Awesome</a>)
         </dd>
         <dt>Special Thanks</dt>
         <dd>Amelia Gorman</dd>
         <dd>Jessicatz Fairymeadow</dd>
-        <dd><a href="http://www.kenney.nl/">Kenney.nl</a></dd>
+        <dd><a target=_blank href="http://www.kenney.nl/">Kenney.nl</a></dd>
         <dd>
           Richard
-          <a href="http://www.clockguy.com/SiteRelated/SiteReferencePages/ClockChimeTunes.html">"The Clock Guy"</a>
+          <a target=_blank href="http://www.clockguy.com/SiteRelated/SiteReferencePages/ClockChimeTunes.html">"The Clock Guy"</a>
           Oliver
         </dd>
       </dl>
       <div style="text-align: center">
         <p>
           Copyright &copy;2014
-          <a href="http://yukkurigames.com/">Yukkuri Games</a>
+          <a target=_blank href="http://yukkurigames.com/">Yukkuri Games</a>
           and others
         </p>
         <p>
           This program is free software; you can redistribute it and/or
           modify it under the terms of the GNU General Public License as
           published by the Free Software Foundation; either 
-          <a href="http://www.gnu.org/licenses/gpl-2.0.html">version
+          <a target=_blank href="http://www.gnu.org/licenses/gpl-2.0.html">version
             2 of the License</a>, or (at your option)
-          <a href="https://www.gnu.org/copyleft/gpl.html">any later version</a>.
+          <a target=_blank href="https://www.gnu.org/copyleft/gpl.html">any later version</a>.
         </p>
       </div>
       <hr>
         </p>
         <hr>
         <ul class="link-footer">
-          <li><a href="http://yukkurigames.com/pwl6/">Pixel Witch Lesson #6</a>
-          <li><a href="http://yukkurigames.com/">Yukkuri Games</a>
+          <li><a target=_blank href="http://yukkurigames.com/pwl6/">Pixel Witch Lesson #6</a>
+          <li><a target=_blank href="http://yukkurigames.com/">Yukkuri Games</a>
+          <li><a href="mailto:yuuSPAM@MAPSyukkurigames.com"
+                 onclick="this.href=this.href.replace(/[A-Z]/g, '')">Email Us</a>
         </ul>
       </div>
     </noscript>
index 25d3ed2..22a1fb4 100644 (file)
@@ -70,6 +70,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" });
                 wkdoc.hidden = false;
                 wkdoc.dispatchEvent(ev);
             });
+            win.on('new-win-policy', function (frame, url, policy) {
+                if (url.startsWith('chrome'))
+                    policy.forceNewPopup();
+                else
+                    policy.forceDownload();
+            });
         }
 
         return new Promise(function (resolve) {
index 37eb3fd..86b933f 100644 (file)
@@ -363,3 +363,7 @@ dt {
 dd {
     margin-left: 0;
 }
+
+body.standalone .browser, body.browser .standalone {
+    display: none;
+}
index 385a3e7..e1c0b53 100644 (file)
                 }
             }, elements);
 
-            yf.each(function (a) {
-                a.onclick = function (event) {
-                    yuu.openURL(this.href);
-                    yuu.stopPropagation(event, true);
-                };
-            }, element.querySelectorAll("a[href]:not([yuu-href-internal])"));
-
             this._director = director;
 
             element.className = className + " " + this.animation;