Browse Source

Implement the dialog; explicit start

Herbert Vojčík 9 years ago
parent
commit
4d00a22550
3 changed files with 38 additions and 3 deletions
  1. 1 1
      README.md
  2. 4 2
      index.html
  3. 33 0
      lib/idestarter.js

+ 1 - 1
README.md

@@ -8,4 +8,4 @@ Include as devDependency in your Amber project:
 bower install amber-ide-starter-dialog --save-dev
 ```
 
-and include `require(['amber-ide-starter-dialog']);` in your index.html.
+and include `require(['amber-ide-starter-dialog'], function (s) { s.start(); });` in your index.html.

+ 4 - 2
index.html

@@ -11,8 +11,10 @@
 
 <body>
 <script type='text/javascript'>
-    require.config({paths:{jquery:"bower_components/jquery/dist/jquery"}});
-    require(['amber-ide-starter-dialog']);
+    require.config({paths: {jquery: "bower_components/jquery/dist/jquery"}});
+    require(['amber-ide-starter-dialog'], function (s) {
+        s.start();
+    });
 </script>
 </body>
 

+ 33 - 0
lib/idestarter.js

@@ -0,0 +1,33 @@
+define(["jquery", "mousetrap", "jquery.blockUI"], function ($, mouseTrap) {
+    var exports = {
+        html: "<p><em>Esc</em> to escape; <em>Shift Shift Ctrl Shift</em> to show again</p>" +
+            "<p><button class=\"unblockUI\" onclick=\"require('amber/helpers').globals.Browser._open()\">legacy IDE</button>" +
+            "<button class=\"unblockUI\" onclick=\"require('amber/helpers').popupHelios()\">Helios IDE</button></p>",
+        keystroke: "shift shift ctrl shift",
+        start: function () {
+            $(document).ready(openMe);
+        }
+    };
+
+    function openMe() {
+        $.blockUI({message: exports.html});
+        $(".unblockUI").on("click", closeMe);
+        $(document).on("keyup", escapeBinding);
+        mouseTrap.unbind(exports.keystroke);
+    }
+
+    function closeMe() {
+        $.unblockUI();
+        $(".unblockUI").off("click", closeMe);
+        $(document).off("keyup", escapeBinding);
+        mouseTrap.bind(exports.keystroke, openMe);
+    }
+
+    function escapeBinding(event) {
+        if (event.keyCode == 27) { //esc
+            closeMe();
+        }
+    }
+
+    return exports;
+});