Skip to content
This repository
Browse code

Pushing a bunch of updates

  • Loading branch information...
commit 5dff979f67118bfc4b4a40769414188f2fc109f0 1 parent d01077f
Paul Bouchon authored December 16, 2012
3  demo/index.html
@@ -122,10 +122,11 @@ <h1 class="sectionTitle"><span class="accent">4.</span> Holler stuff</h1>
122 122
     <script>
123 123
       var hollerConfig = {
124 124
         host: "http://127.0.0.1",
125  
-        port: "8099"
  125
+        port: "1337"
126 126
       }
127 127
     </script>
128 128
     <script type="text/javascript" src="../dist/holler-client.min.js"></script>
  129
+
129 130
     <script src="http://code.jquery.com/jquery.min.js"></script>
130 131
     <script src="js/jquery.fitvids.js"></script>
131 132
     <script>
523  dist/holler-client.concat.js
... ...
@@ -0,0 +1,523 @@
  1
+/**
  2
+ * alertify
  3
+ * An unobtrusive customizable JavaScript notification system
  4
+ *
  5
+ * @author Fabien Doiron <fabien.doiron@gmail.com>
  6
+ * @copyright Fabien Doiron 2012
  7
+ * @license MIT <http://opensource.org/licenses/mit-license.php>
  8
+ * @link http://fabien-d.github.com/alertify.js/
  9
+ * @module alertify
  10
+ * @version 0.2.12
  11
+ */
  12
+
  13
+/*global define setTimeout*/
  14
+(function (global, undefined) {
  15
+  "use strict";
  16
+
  17
+  var document = global.document,
  18
+      Alertify;
  19
+
  20
+  Alertify = function () {
  21
+
  22
+    var _alertify = {},
  23
+        dialogs   = {},
  24
+        isopen    = false,
  25
+        keys      = { ENTER: 13, ESC: 27, SPACE: 32 },
  26
+        queue     = [],
  27
+        $, elCallee, elCover, elDialog, elLog;
  28
+
  29
+    /**
  30
+     * Markup pieces
  31
+     * @type {Object}
  32
+     */
  33
+    dialogs = {
  34
+      buttons : {
  35
+        holder : "<nav class=\"alertify-buttons\">{{buttons}}</nav>",
  36
+        submit : "<button type=\"submit\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\" />{{ok}}</button>",
  37
+        ok     : "<a href=\"#\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\">{{ok}}</a>",
  38
+        cancel : "<a href=\"#\" class=\"alertify-button alertify-button-cancel\" id=\"alertify-cancel\">{{cancel}}</a>"
  39
+      },
  40
+      input   : "<input type=\"text\" class=\"alertify-text\" id=\"alertify-text\">",
  41
+      message : "<p class=\"alertify-message\">{{message}}</p>",
  42
+      log     : "<article class=\"alertify-log{{class}}\">{{message}}</article>"
  43
+    };
  44
+
  45
+    /**
  46
+     * Shorthand for document.getElementById()
  47
+     *
  48
+     * @param  {String} id    A specific element ID
  49
+     * @return {Object}       HTML element
  50
+     */
  51
+    $ = function (id) {
  52
+      return document.getElementById(id);
  53
+    };
  54
+
  55
+    /**
  56
+     * Alertify private object
  57
+     * @type {Object}
  58
+     */
  59
+    _alertify = {
  60
+
  61
+      /**
  62
+       * Labels object
  63
+       * @type {Object}
  64
+       */
  65
+      labels : {
  66
+        ok     : "OK",
  67
+        cancel : "Cancel"
  68
+      },
  69
+
  70
+      /**
  71
+       * Delay number
  72
+       * @type {Number}
  73
+       */
  74
+      delay : 5000,
  75
+
  76
+      /**
  77
+       * Set the proper button click events
  78
+       *
  79
+       * @param {Function} fn    [Optional] Callback function
  80
+       *
  81
+       * @return {undefined}
  82
+       */
  83
+      addListeners : function (fn) {
  84
+        var btnReset  = $("alertify-resetFocus"),
  85
+            btnOK     = $("alertify-ok")     || undefined,
  86
+            btnCancel = $("alertify-cancel") || undefined,
  87
+            input     = $("alertify-text")   || undefined,
  88
+            form      = $("alertify-form")   || undefined,
  89
+            hasOK     = (typeof btnOK !== "undefined"),
  90
+            hasCancel = (typeof btnCancel !== "undefined"),
  91
+            hasInput  = (typeof input !== "undefined"),
  92
+            val       = "",
  93
+            self      = this,
  94
+            ok, cancel, common, key, reset;
  95
+
  96
+        // ok event handler
  97
+        ok = function (event) {
  98
+          if (typeof event.preventDefault !== "undefined") event.preventDefault();
  99
+          common(event);
  100
+          if (typeof input !== "undefined") val = input.value;
  101
+          if (typeof fn === "function") fn(true, val);
  102
+        };
  103
+
  104
+        // cancel event handler
  105
+        cancel = function (event) {
  106
+          if (typeof event.preventDefault !== "undefined") event.preventDefault();
  107
+          common(event);
  108
+          if (typeof fn === "function") fn(false);
  109
+        };
  110
+
  111
+        // common event handler (keyup, ok and cancel)
  112
+        common = function (event) {
  113
+          self.hide();
  114
+          self.unbind(document.body, "keyup", key);
  115
+          self.unbind(btnReset, "focus", reset);
  116
+          if (hasInput) self.unbind(form, "submit", ok);
  117
+          if (hasOK) self.unbind(btnOK, "click", ok);
  118
+          if (hasCancel) self.unbind(btnCancel, "click", cancel);
  119
+        };
  120
+
  121
+        // keyup handler
  122
+        key = function (event) {
  123
+          var keyCode = event.keyCode;
  124
+          if (keyCode === keys.SPACE && !hasInput) ok(event);
  125
+          if (keyCode === keys.ESC && hasCancel) cancel(event);
  126
+        };
  127
+
  128
+        // reset focus to first item in the dialog
  129
+        reset = function (event) {
  130
+          if (hasInput) input.focus();
  131
+          else if (hasCancel) btnCancel.focus();
  132
+          else btnOK.focus();
  133
+        };
  134
+
  135
+        // handle reset focus link
  136
+        // this ensures that the keyboard focus does not
  137
+        // ever leave the dialog box until an action has
  138
+        // been taken
  139
+        this.bind(btnReset, "focus", reset);
  140
+        // handle OK click
  141
+        if (hasOK) this.bind(btnOK, "click", ok);
  142
+        // handle Cancel click
  143
+        if (hasCancel) this.bind(btnCancel, "click", cancel);
  144
+        // listen for keys, Cancel => ESC
  145
+        this.bind(document.body, "keyup", key);
  146
+        // bind form submit
  147
+        if (hasInput) this.bind(form, "submit", ok);
  148
+        // set focus on OK button or the input text
  149
+        global.setTimeout(function () {
  150
+          if (input) {
  151
+            input.focus();
  152
+            input.select();
  153
+          }
  154
+          else btnOK.focus();
  155
+        }, 50);
  156
+      },
  157
+
  158
+      /**
  159
+       * Bind events to elements
  160
+       *
  161
+       * @param  {Object}   el       HTML Object
  162
+       * @param  {Event}    event    Event to attach to element
  163
+       * @param  {Function} fn       Callback function
  164
+       *
  165
+       * @return {undefined}
  166
+       */
  167
+      bind : function (el, event, fn) {
  168
+        if (typeof el.addEventListener === "function") {
  169
+          el.addEventListener(event, fn, false);
  170
+        } else if (el.attachEvent) {
  171
+          el.attachEvent("on" + event, fn);
  172
+        }
  173
+      },
  174
+
  175
+      /**
  176
+       * Build the proper message box
  177
+       *
  178
+       * @param  {Object} item    Current object in the queue
  179
+       *
  180
+       * @return {String}         An HTML string of the message box
  181
+       */
  182
+      build : function (item) {
  183
+        var html    = "",
  184
+            type    = item.type,
  185
+            message = item.message,
  186
+            css     = item.cssClass || "";
  187
+
  188
+        html += "<div class=\"alertify-dialog\">";
  189
+
  190
+        if (type === "prompt") html += "<form id=\"alertify-form\">";
  191
+
  192
+        html += "<article class=\"alertify-inner\">";
  193
+        html += dialogs.message.replace("{{message}}", message);
  194
+
  195
+        if (type === "prompt") html += dialogs.input;
  196
+
  197
+        html += dialogs.buttons.holder;
  198
+        html += "</article>";
  199
+
  200
+        if (type === "prompt") html += "</form>";
  201
+
  202
+        html += "<a id=\"alertify-resetFocus\" class=\"alertify-resetFocus\" href=\"#\">Reset Focus</a>";
  203
+        html += "</div>";
  204
+
  205
+        switch (type) {
  206
+        case "confirm":
  207
+          html = html.replace("{{buttons}}", dialogs.buttons.cancel + dialogs.buttons.ok);
  208
+          html = html.replace("{{ok}}", this.labels.ok).replace("{{cancel}}", this.labels.cancel);
  209
+          break;
  210
+        case "prompt":
  211
+          html = html.replace("{{buttons}}", dialogs.buttons.cancel + dialogs.buttons.submit);
  212
+          html = html.replace("{{ok}}", this.labels.ok).replace("{{cancel}}", this.labels.cancel);
  213
+          break;
  214
+        case "alert":
  215
+          html = html.replace("{{buttons}}", dialogs.buttons.ok);
  216
+          html = html.replace("{{ok}}", this.labels.ok);
  217
+          break;
  218
+        default:
  219
+          break;
  220
+        }
  221
+
  222
+        elDialog.className = "alertify alertify-show alertify-" + type + " " + css;
  223
+        elCover.className  = "alertify-cover";
  224
+        return html;
  225
+      },
  226
+
  227
+      /**
  228
+       * Close the log messages
  229
+       *
  230
+       * @param  {Object} elem    HTML Element of log message to close
  231
+       * @param  {Number} wait    [optional] Time (in ms) to wait before automatically hiding the message
  232
+       *
  233
+       * @return {undefined}
  234
+       */
  235
+      close : function (elem, wait) {
  236
+        var timer = (wait && !isNaN(wait)) ? +wait : this.delay; // Unary Plus: +"2" === 2
  237
+        this.bind(elem, "click", function () {
  238
+          elLog.removeChild(elem);
  239
+        });
  240
+        setTimeout(function () {
  241
+          if (typeof elem !== "undefined" && elem.parentNode === elLog) elLog.removeChild(elem);
  242
+        }, timer);
  243
+      },
  244
+
  245
+      /**
  246
+       * Create a dialog box
  247
+       *
  248
+       * @param  {String}   message        The message passed from the callee
  249
+       * @param  {String}   type           Type of dialog to create
  250
+       * @param  {Function} fn             [Optional] Callback function
  251
+       * @param  {String}   placeholder    [Optional] Default value for prompt input field
  252
+       * @param  {String}   cssClass       [Optional] Class(es) to append to dialog box
  253
+       *
  254
+       * @return {Object}
  255
+       */
  256
+      dialog : function (message, type, fn, placeholder, cssClass) {
  257
+        // set the current active element
  258
+        // this allows the keyboard focus to be resetted
  259
+        // after the dialog box is closed
  260
+        elCallee = document.activeElement;
  261
+        // check to ensure the alertify dialog element
  262
+        // has been successfully created
  263
+        var check = function () {
  264
+          if (elDialog && elDialog.scrollTop !== null) return;
  265
+          else check();
  266
+        };
  267
+        // error catching
  268
+        if (typeof message !== "string") throw new Error("message must be a string");
  269
+        if (typeof type !== "string") throw new Error("type must be a string");
  270
+        if (typeof fn !== "undefined" && typeof fn !== "function") throw new Error("fn must be a function");
  271
+        // initialize alertify if it hasn't already been done
  272
+        if (typeof this.init === "function") {
  273
+          this.init();
  274
+          check();
  275
+        }
  276
+
  277
+        queue.push({ type: type, message: message, callback: fn, placeholder: placeholder, cssClass: cssClass });
  278
+        if (!isopen) this.setup();
  279
+
  280
+        return this;
  281
+      },
  282
+
  283
+      /**
  284
+       * Extend the log method to create custom methods
  285
+       *
  286
+       * @param  {String} type    Custom method name
  287
+       *
  288
+       * @return {Function}
  289
+       */
  290
+      extend : function (type) {
  291
+        if (typeof type !== "string") throw new Error("extend method must have exactly one paramter");
  292
+        return function (message, wait) {
  293
+          this.log(message, type, wait);
  294
+          return this;
  295
+        };
  296
+      },
  297
+
  298
+      /**
  299
+       * Hide the dialog and rest to defaults
  300
+       *
  301
+       * @return {undefined}
  302
+       */
  303
+      hide : function () {
  304
+        // remove reference from queue
  305
+        queue.splice(0,1);
  306
+        // if items remaining in the queue
  307
+        if (queue.length > 0) this.setup();
  308
+        else {
  309
+          isopen = false;
  310
+          elDialog.className = "alertify alertify-hide alertify-hidden";
  311
+          elCover.className  = "alertify-cover alertify-hidden";
  312
+          // set focus to the last element or body
  313
+          // after the dialog is closed
  314
+          elCallee.focus();
  315
+        }
  316
+      },
  317
+
  318
+      /**
  319
+       * Initialize Alertify
  320
+       * Create the 2 main elements
  321
+       *
  322
+       * @return {undefined}
  323
+       */
  324
+      init : function () {
  325
+        // ensure legacy browsers support html5 tags
  326
+        document.createElement("nav");
  327
+        document.createElement("article");
  328
+        document.createElement("section");
  329
+        // cover
  330
+        elCover = document.createElement("div");
  331
+        elCover.setAttribute("id", "alertify-cover");
  332
+        elCover.className = "alertify-cover alertify-hidden";
  333
+        document.body.appendChild(elCover);
  334
+        // main element
  335
+        elDialog = document.createElement("section");
  336
+        elDialog.setAttribute("id", "alertify");
  337
+        elDialog.className = "alertify alertify-hidden";
  338
+        document.body.appendChild(elDialog);
  339
+        // log element
  340
+        elLog = document.createElement("section");
  341
+        elLog.setAttribute("id", "alertify-logs");
  342
+        elLog.className = "alertify-logs";
  343
+        document.body.appendChild(elLog);
  344
+        // set tabindex attribute on body element
  345
+        // this allows script to give it focus
  346
+        // after the dialog is closed
  347
+        document.body.setAttribute("tabindex", "0");
  348
+        // clean up init method
  349
+        delete this.init;
  350
+      },
  351
+
  352
+      /**
  353
+       * Show a new log message box
  354
+       *
  355
+       * @param  {String} message    The message passed from the callee
  356
+       * @param  {String} type       [Optional] Optional type of log message
  357
+       * @param  {Number} wait       [Optional] Time (in ms) to wait before auto-hiding the log
  358
+       *
  359
+       * @return {Object}
  360
+       */
  361
+      log : function (message, type, wait) {
  362
+        // check to ensure the alertify dialog element
  363
+        // has been successfully created
  364
+        var check = function () {
  365
+          if (elLog && elLog.scrollTop !== null) return;
  366
+          else check();
  367
+        };
  368
+        // initialize alertify if it hasn't already been done
  369
+        if (typeof this.init === "function") {
  370
+          this.init();
  371
+          check();
  372
+        }
  373
+        this.notify(message, type, wait);
  374
+        return this;
  375
+      },
  376
+
  377
+      /**
  378
+       * Add new log message
  379
+       * If a type is passed, a class name "alertify-log-{type}" will get added.
  380
+       * This allows for custom look and feel for various types of notifications.
  381
+       *
  382
+       * @param  {String} message    The message passed from the callee
  383
+       * @param  {String} type       [Optional] Type of log message
  384
+       * @param  {Number} wait       [Optional] Time (in ms) to wait before auto-hiding
  385
+       *
  386
+       * @return {undefined}
  387
+       */
  388
+      notify : function (message, type, wait) {
  389
+        var log = document.createElement("article");
  390
+        log.className = "alertify-log" + ((typeof type === "string" && type !== "") ? " alertify-log-" + type : "");
  391
+        log.innerHTML = message;
  392
+        // prepend child
  393
+        elLog.insertBefore(log, elLog.firstChild);
  394
+        // triggers the CSS animation
  395
+        setTimeout(function() { log.className = log.className + " alertify-log-show"; }, 50);
  396
+        this.close(log, wait);
  397
+      },
  398
+
  399
+      /**
  400
+       * Set properties
  401
+       *
  402
+       * @param {Object} args     Passing parameters
  403
+       *
  404
+       * @return {undefined}
  405
+       */
  406
+      set : function (args) {
  407
+        var k;
  408
+        // error catching
  409
+        if (typeof args !== "object" && args instanceof Array) throw new Error("args must be an object");
  410
+        // set parameters
  411
+        for (k in args) {
  412
+          if (args.hasOwnProperty(k)) {
  413
+            this[k] = args[k];
  414
+          }
  415
+        }
  416
+      },
  417
+
  418
+      /**
  419
+       * Initiate all the required pieces for the dialog box
  420
+       *
  421
+       * @return {undefined}
  422
+       */
  423
+      setup : function () {
  424
+        var item = queue[0];
  425
+
  426
+        isopen = true;
  427
+        elDialog.innerHTML = this.build(item);
  428
+        if (typeof item.placeholder === "string" && item.placeholder !== "") $("alertify-text").value = item.placeholder;
  429
+        this.addListeners(item.callback);
  430
+      },
  431
+
  432
+      /**
  433
+       * Unbind events to elements
  434
+       *
  435
+       * @param  {Object}   el       HTML Object
  436
+       * @param  {Event}    event    Event to detach to element
  437
+       * @param  {Function} fn       Callback function
  438
+       *
  439
+       * @return {undefined}
  440
+       */
  441
+      unbind : function (el, event, fn) {
  442
+        if (typeof el.removeEventListener === "function") {
  443
+          el.removeEventListener(event, fn, false);
  444
+        } else if (el.detachEvent) {
  445
+          el.detachEvent("on" + event, fn);
  446
+        }
  447
+      }
  448
+    };
  449
+
  450
+    return {
  451
+      alert   : function (message, fn, cssClass) { _alertify.dialog(message, "alert", fn, "", cssClass); return this; },
  452
+      confirm : function (message, fn, cssClass) { _alertify.dialog(message, "confirm", fn, "", cssClass); return this; },
  453
+      extend  : _alertify.extend,
  454
+      init    : _alertify.init,
  455
+      log     : function (message, type, wait) { _alertify.log(message, type, wait); return this; },
  456
+      prompt  : function (message, fn, placeholder, cssClass) { _alertify.dialog(message, "prompt", fn, placeholder, cssClass); return this; },
  457
+      success : function (message, wait) { _alertify.log(message, "success", wait); return this; },
  458
+      error   : function (message, wait) { _alertify.log(message, "error", wait); return this; },
  459
+      set     : function (args) { _alertify.set(args); },
  460
+      labels  : _alertify.labels
  461
+    };
  462
+  };
  463
+
  464
+  // AMD and window support
  465
+  if (typeof define === "function") {
  466
+    define([], function () { return new Alertify(); });
  467
+  } else {
  468
+    if (typeof global.alertify === "undefined") {
  469
+      global.alertify = new Alertify();
  470
+    }
  471
+  }
  472
+
  473
+}(this));
  474
+// 
  475
+// name         : holler-client.js
  476
+// description  : Connects to a Faye server & subscribes to notifications
  477
+// 
  478
+
  479
+
  480
+(function (args) {
  481
+  // grab host & port
  482
+  var h     = window.hollerConfig,
  483
+      port  = h && h.port ? h.port : "1337",
  484
+      host  = h && h.host ? h.host : "http://127.0.0.1";
  485
+
  486
+  // load alertify css
  487
+  // TODO : a better way to do this, this is brittle & ugly
  488
+  var style = document.createElement('style');
  489
+  style.type = 'text/css';
  490
+  style.innerHTML = ".alertify-show, .alertify-log { -webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1); /* older webkit */ -webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -moz-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -ms-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -o-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); /* easeOutBack */ } .alertify-hide { -webkit-transition: all 250ms cubic-bezier(0.600, 0, 0.735, 0.045); /* older webkit */ -webkit-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -moz-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -ms-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -o-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); /* easeInBack */ } .alertify-cover { position: fixed; z-index: 99999; top: 0; right: 0; bottom: 0; left: 0; } .alertify { position: fixed; z-index: 99999; top: 50px; left: 50%; width: 550px; margin-left: -275px; } .alertify-hidden { top: -50px; visibility: hidden; } .alertify-logs { position: fixed; z-index: 5000; bottom: 10px; right: 10px; width: 300px; } .alertify-log { display: block; margin-top: 10px; position: relative; right: -300px; } .alertify-log-show { right: 0; } .alertify-dialog { padding: 25px; } .alertify-resetFocus { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } .alertify-inner { text-align: center; } .alertify-text { margin-bottom: 15px; width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-size: 100%; } .alertify-buttons { } .alertify-button { /* line-height and font-size for input button */ line-height: 1.5; font-size: 100%; display: inline-block; cursor: pointer; margin-left: 5px; } @media only screen and (max-width: 680px) { .alertify, .alertify-logs { width: 90%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .alertify { left: 5%; margin: 0; } } /** * Default Look and Feel */ .alertify, .alertify-log { font-family: sans-serif; } .alertify { background: #FFF; border: 10px solid #333; /* browsers that don't support rgba */ border: 10px solid rgba(0,0,0,.7); border-radius: 8px; box-shadow: 0 3px 3px rgba(0,0,0,.3); -webkit-background-clip: padding; /* Safari 4? Chrome 6? */ -moz-background-clip: padding; /* Firefox 3.6 */ background-clip: padding-box; /* Firefox 4, Safari 5, Opera 10, IE 9 */ } .alertify-text { border: 1px solid #CCC; padding: 10px; border-radius: 4px; } .alertify-button { border-radius: 4px; color: #FFF; font-weight: bold; padding: 6px 15px; text-decoration: none; text-shadow: 1px 1px 0 rgba(0,0,0,.5); box-shadow: inset 0 1px 0 0 rgba(255,255,255,.5); background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -ms-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -o-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); } .alertify-button:hover, .alertify-button:focus { outline: none; box-shadow: 0 0 15px #2B72D5; background-image: -webkit-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -moz-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -ms-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -o-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); } .alertify-button:active { position: relative; top: 1px; } .alertify-button-cancel { background-color: #FE1A00; border: 1px solid #D83526; } .alertify-button-ok { background-color: #5CB811; border: 1px solid #3B7808; } .alertify-log { background: #1F1F1F; background: rgba(0,0,0,.9); padding: 15px; border-radius: 4px; color: #FFF; text-shadow: -1px -1px 0 rgba(0,0,0,.5); } .alertify-log-error { background: #FE1A00; background: rgba(254,26,0,.9); } .alertify-log-success { background: #5CB811; background: rgba(92,184,17,.9); }";
  491
+  document.getElementsByTagName('head')[0].appendChild(style);
  492
+
  493
+  // quick n dirt dynamic js loader
  494
+  var loadScript = function(src, callback) {
  495
+    var head = document.getElementsByTagName('head')[0];
  496
+    if(head){
  497
+      var script = document.createElement('script');  
  498
+      script.setAttribute('src',src);
  499
+      script.setAttribute('type','text/javascript');
  500
+      var loadFunction = function(){
  501
+        if (this.readyState == 'complete' || this.readyState == 'loaded'){
  502
+          callback(); 
  503
+        }
  504
+      };
  505
+      script.onreadystatechange = loadFunction;
  506
+      script.onload = callback;
  507
+      head.appendChild(script);
  508
+    }
  509
+  };
  510
+
  511
+  // load faye js deps
  512
+  loadScript(host+":"+port+"/faye/client.js", function(){
  513
+    // when done, connect to client
  514
+    var client = new Faye.Client(host+":"+port+'/faye',{
  515
+      timeout: 120,
  516
+      retry: 5
  517
+    });
  518
+    // subscribe to notification channel
  519
+    var subscription = client.subscribe('/holler',function(obj) {
  520
+      alertify.log(obj.message, obj.type);
  521
+    });
  522
+  });
  523
+}(this));
2  dist/holler-client.min.js 100755 → 100644
... ...
@@ -1 +1 @@
1  
-(function(e,t){"use strict";var n=e.document,r;r=function(){var r={},i={},s=!1,o={ENTER:13,ESC:27,SPACE:32},u=[],a,f,l,c,h;return i={buttons:{holder:'<nav class="alertify-buttons">{{buttons}}</nav>',submit:'<button type="submit" class="alertify-button alertify-button-ok" id="alertify-ok" />{{ok}}</button>',ok:'<a href="#" class="alertify-button alertify-button-ok" id="alertify-ok">{{ok}}</a>',cancel:'<a href="#" class="alertify-button alertify-button-cancel" id="alertify-cancel">{{cancel}}</a>'},input:'<input type="text" class="alertify-text" id="alertify-text">',message:'<p class="alertify-message">{{message}}</p>',log:'<article class="alertify-log{{class}}">{{message}}</article>'},a=function(e){return n.getElementById(e)},r={labels:{ok:"OK",cancel:"Cancel"},delay:5e3,addListeners:function(r){var i=a("alertify-resetFocus"),s=a("alertify-ok")||t,u=a("alertify-cancel")||t,f=a("alertify-text")||t,l=a("alertify-form")||t,c=typeof s!="undefined",h=typeof u!="undefined",p=typeof f!="undefined",d="",v=this,m,g,y,b,w;m=function(e){typeof e.preventDefault!="undefined"&&e.preventDefault(),y(e),typeof f!="undefined"&&(d=f.value),typeof r=="function"&&r(!0,d)},g=function(e){typeof e.preventDefault!="undefined"&&e.preventDefault(),y(e),typeof r=="function"&&r(!1)},y=function(e){v.hide(),v.unbind(n.body,"keyup",b),v.unbind(i,"focus",w),p&&v.unbind(l,"submit",m),c&&v.unbind(s,"click",m),h&&v.unbind(u,"click",g)},b=function(e){var t=e.keyCode;t===o.SPACE&&!p&&m(e),t===o.ESC&&h&&g(e)},w=function(e){p?f.focus():h?u.focus():s.focus()},this.bind(i,"focus",w),c&&this.bind(s,"click",m),h&&this.bind(u,"click",g),this.bind(n.body,"keyup",b),p&&this.bind(l,"submit",m),e.setTimeout(function(){f?(f.focus(),f.select()):s.focus()},50)},bind:function(e,t,n){typeof e.addEventListener=="function"?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},build:function(e){var t="",n=e.type,r=e.message;t+='<div class="alertify-dialog">',n==="prompt"&&(t+='<form id="alertify-form">'),t+='<article class="alertify-inner">',t+=i.message.replace("{{message}}",r),n==="prompt"&&(t+=i.input),t+=i.buttons.holder,t+="</article>",n==="prompt"&&(t+="</form>"),t+='<a id="alertify-resetFocus" class="alertify-resetFocus" href="#">Reset Focus</a>',t+="</div>";switch(n){case"confirm":t=t.replace("{{buttons}}",i.buttons.cancel+i.buttons.ok),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"prompt":t=t.replace("{{buttons}}",i.buttons.cancel+i.buttons.submit),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"alert":t=t.replace("{{buttons}}",i.buttons.ok),t=t.replace("{{ok}}",this.labels.ok);break;default:}return c.className="alertify alertify-show alertify-"+n,l.className="alertify-cover",t},close:function(e,t){var n=t&&!isNaN(t)?+t:this.delay;this.bind(e,"click",function(){h.removeChild(e)}),setTimeout(function(){typeof e!="undefined"&&e.parentNode===h&&h.removeChild(e)},n)},dialog:function(e,t,r,i){f=n.activeElement;var o=function(){if(c&&c.scrollTop!==null)return;o()};if(typeof e!="string")throw new Error("message must be a string");if(typeof t!="string")throw new Error("type must be a string");if(typeof r!="undefined"&&typeof r!="function")throw new Error("fn must be a function");return typeof this.init=="function"&&(this.init(),o()),u.push({type:t,message:e,callback:r,placeholder:i}),s||this.setup(),this},extend:function(e){return function(t,n){this.log(t,e,n)}},hide:function(){u.splice(0,1),u.length>0?this.setup():(s=!1,c.className="alertify alertify-hide alertify-hidden",l.className="alertify-cover alertify-hidden",f.focus())},init:function(){n.createElement("nav"),n.createElement("article"),n.createElement("section"),l=n.createElement("div"),l.setAttribute("id","alertify-cover"),l.className="alertify-cover alertify-hidden",n.body.appendChild(l),c=n.createElement("section"),c.setAttribute("id","alertify"),c.className="alertify alertify-hidden",n.body.appendChild(c),h=n.createElement("section"),h.setAttribute("id","alertify-logs"),h.className="alertify-logs",n.body.appendChild(h),n.body.setAttribute("tabindex","0"),delete this.init},log:function(e,t,n){var r=function(){if(h&&h.scrollTop!==null)return;r()};return typeof this.init=="function"&&(this.init(),r()),this.notify(e,t,n),this},notify:function(e,t,r){var i=n.createElement("article");i.className="alertify-log"+(typeof t=="string"&&t!==""?" alertify-log-"+t:""),i.innerHTML=e,h.insertBefore(i,h.firstChild),setTimeout(function(){i.className=i.className+" alertify-log-show"},50),this.close(i,r)},set:function(e){var t;if(typeof e!="object"&&e instanceof Array)throw new Error("args must be an object");for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])},setup:function(){var e=u[0];s=!0,c.innerHTML=this.build(e),typeof e.placeholder=="string"&&(a("alertify-text").value=e.placeholder),this.addListeners(e.callback)},unbind:function(e,t,n){typeof e.removeEventListener=="function"?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}},{alert:function(e,t){return r.dialog(e,"alert",t),this},confirm:function(e,t){return r.dialog(e,"confirm",t),this},extend:r.extend,init:r.init,log:function(e,t,n){return r.log(e,t,n),this},prompt:function(e,t,n){return r.dialog(e,"prompt",t,n),this},success:function(e,t){return r.log(e,"success",t),this},error:function(e,t){return r.log(e,"error",t),this},set:function(e){r.set(e)},labels:r.labels}},typeof define=="function"?define([],function(){return new r}):typeof e.alertify=="undefined"&&(e.alertify=new r)})(this),function(e){var t=hollerConfig&&hollerConfig.port?hollerConfig.port:"1337",n=hollerConfig&&hollerConfig.host?hollerConfig.host:"http://127.0.0.1",r=function(e,t){var n=document.getElementsByTagName("head")[0];if(n){var r=document.createElement("script");r.setAttribute("src",e),r.setAttribute("type","text/javascript");var i=function(){(this.readyState=="complete"||this.readyState=="loaded")&&t()};r.onreadystatechange=i,r.onload=t,n.appendChild(r)}},i=document.createElement("style");i.type="text/css",i.innerHTML=".alertify-show, .alertify-log { -webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1); /* older webkit */ -webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -moz-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -ms-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -o-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); /* easeOutBack */ } .alertify-hide { -webkit-transition: all 250ms cubic-bezier(0.600, 0, 0.735, 0.045); /* older webkit */ -webkit-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -moz-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -ms-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -o-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); /* easeInBack */ } .alertify-cover { position: fixed; z-index: 99999; top: 0; right: 0; bottom: 0; left: 0; } .alertify { position: fixed; z-index: 99999; top: 50px; left: 50%; width: 550px; margin-left: -275px; } .alertify-hidden { top: -50px; visibility: hidden; } .alertify-logs { position: fixed; z-index: 5000; bottom: 10px; right: 10px; width: 300px; } .alertify-log { display: block; margin-top: 10px; position: relative; right: -300px; } .alertify-log-show { right: 0; } .alertify-dialog { padding: 25px; } .alertify-resetFocus { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } .alertify-inner { text-align: center; } .alertify-text { margin-bottom: 15px; width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-size: 100%; } .alertify-buttons { } .alertify-button { /* line-height and font-size for input button */ line-height: 1.5; font-size: 100%; display: inline-block; cursor: pointer; margin-left: 5px; } @media only screen and (max-width: 680px) { .alertify, .alertify-logs { width: 90%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .alertify { left: 5%; margin: 0; } } /** * Default Look and Feel */ .alertify, .alertify-log { font-family: sans-serif; } .alertify { background: #FFF; border: 10px solid #333; /* browsers that don't support rgba */ border: 10px solid rgba(0,0,0,.7); border-radius: 8px; box-shadow: 0 3px 3px rgba(0,0,0,.3); -webkit-background-clip: padding; /* Safari 4? Chrome 6? */ -moz-background-clip: padding; /* Firefox 3.6 */ background-clip: padding-box; /* Firefox 4, Safari 5, Opera 10, IE 9 */ } .alertify-text { border: 1px solid #CCC; padding: 10px; border-radius: 4px; } .alertify-button { border-radius: 4px; color: #FFF; font-weight: bold; padding: 6px 15px; text-decoration: none; text-shadow: 1px 1px 0 rgba(0,0,0,.5); box-shadow: inset 0 1px 0 0 rgba(255,255,255,.5); background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -ms-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -o-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); } .alertify-button:hover, .alertify-button:focus { outline: none; box-shadow: 0 0 15px #2B72D5; background-image: -webkit-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -moz-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -ms-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -o-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); } .alertify-button:active { position: relative; top: 1px; } .alertify-button-cancel { background-color: #FE1A00; border: 1px solid #D83526; } .alertify-button-ok { background-color: #5CB811; border: 1px solid #3B7808; } .alertify-log { background: #1F1F1F; background: rgba(0,0,0,.9); padding: 15px; border-radius: 4px; color: #FFF; text-shadow: -1px -1px 0 rgba(0,0,0,.5); } .alertify-log-error { background: #FE1A00; background: rgba(254,26,0,.9); } .alertify-log-success { background: #5CB811; background: rgba(92,184,17,.9); }",document.getElementsByTagName("head")[0].appendChild(i),r(n+":"+t+"/faye/client.js",function(){var e=new Faye.Client(n+":"+t+"/faye",{timeout:120,retry:5}),r=e.subscribe("/telepathy",function(e){alertify.log(e.message,e.type)})})}(this);
  1
+(function(e,t){"use strict";var n=e.document,r;r=function(){var r={},i={},s=!1,o={ENTER:13,ESC:27,SPACE:32},u=[],a,f,l,c,h;return i={buttons:{holder:'<nav class="alertify-buttons">{{buttons}}</nav>',submit:'<button type="submit" class="alertify-button alertify-button-ok" id="alertify-ok" />{{ok}}</button>',ok:'<a href="#" class="alertify-button alertify-button-ok" id="alertify-ok">{{ok}}</a>',cancel:'<a href="#" class="alertify-button alertify-button-cancel" id="alertify-cancel">{{cancel}}</a>'},input:'<input type="text" class="alertify-text" id="alertify-text">',message:'<p class="alertify-message">{{message}}</p>',log:'<article class="alertify-log{{class}}">{{message}}</article>'},a=function(e){return n.getElementById(e)},r={labels:{ok:"OK",cancel:"Cancel"},delay:5e3,addListeners:function(r){var i=a("alertify-resetFocus"),s=a("alertify-ok")||t,u=a("alertify-cancel")||t,f=a("alertify-text")||t,l=a("alertify-form")||t,c=typeof s!="undefined",h=typeof u!="undefined",p=typeof f!="undefined",d="",v=this,m,g,y,b,w;m=function(e){typeof e.preventDefault!="undefined"&&e.preventDefault(),y(e),typeof f!="undefined"&&(d=f.value),typeof r=="function"&&r(!0,d)},g=function(e){typeof e.preventDefault!="undefined"&&e.preventDefault(),y(e),typeof r=="function"&&r(!1)},y=function(e){v.hide(),v.unbind(n.body,"keyup",b),v.unbind(i,"focus",w),p&&v.unbind(l,"submit",m),c&&v.unbind(s,"click",m),h&&v.unbind(u,"click",g)},b=function(e){var t=e.keyCode;t===o.SPACE&&!p&&m(e),t===o.ESC&&h&&g(e)},w=function(e){p?f.focus():h?u.focus():s.focus()},this.bind(i,"focus",w),c&&this.bind(s,"click",m),h&&this.bind(u,"click",g),this.bind(n.body,"keyup",b),p&&this.bind(l,"submit",m),e.setTimeout(function(){f?(f.focus(),f.select()):s.focus()},50)},bind:function(e,t,n){typeof e.addEventListener=="function"?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},build:function(e){var t="",n=e.type,r=e.message,s=e.cssClass||"";t+='<div class="alertify-dialog">',n==="prompt"&&(t+='<form id="alertify-form">'),t+='<article class="alertify-inner">',t+=i.message.replace("{{message}}",r),n==="prompt"&&(t+=i.input),t+=i.buttons.holder,t+="</article>",n==="prompt"&&(t+="</form>"),t+='<a id="alertify-resetFocus" class="alertify-resetFocus" href="#">Reset Focus</a>',t+="</div>";switch(n){case"confirm":t=t.replace("{{buttons}}",i.buttons.cancel+i.buttons.ok),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"prompt":t=t.replace("{{buttons}}",i.buttons.cancel+i.buttons.submit),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"alert":t=t.replace("{{buttons}}",i.buttons.ok),t=t.replace("{{ok}}",this.labels.ok);break;default:}return c.className="alertify alertify-show alertify-"+n+" "+s,l.className="alertify-cover",t},close:function(e,t){var n=t&&!isNaN(t)?+t:this.delay;this.bind(e,"click",function(){h.removeChild(e)}),setTimeout(function(){typeof e!="undefined"&&e.parentNode===h&&h.removeChild(e)},n)},dialog:function(e,t,r,i,o){f=n.activeElement;var a=function(){if(c&&c.scrollTop!==null)return;a()};if(typeof e!="string")throw new Error("message must be a string");if(typeof t!="string")throw new Error("type must be a string");if(typeof r!="undefined"&&typeof r!="function")throw new Error("fn must be a function");return typeof this.init=="function"&&(this.init(),a()),u.push({type:t,message:e,callback:r,placeholder:i,cssClass:o}),s||this.setup(),this},extend:function(e){if(typeof e!="string")throw new Error("extend method must have exactly one paramter");return function(t,n){return this.log(t,e,n),this}},hide:function(){u.splice(0,1),u.length>0?this.setup():(s=!1,c.className="alertify alertify-hide alertify-hidden",l.className="alertify-cover alertify-hidden",f.focus())},init:function(){n.createElement("nav"),n.createElement("article"),n.createElement("section"),l=n.createElement("div"),l.setAttribute("id","alertify-cover"),l.className="alertify-cover alertify-hidden",n.body.appendChild(l),c=n.createElement("section"),c.setAttribute("id","alertify"),c.className="alertify alertify-hidden",n.body.appendChild(c),h=n.createElement("section"),h.setAttribute("id","alertify-logs"),h.className="alertify-logs",n.body.appendChild(h),n.body.setAttribute("tabindex","0"),delete this.init},log:function(e,t,n){var r=function(){if(h&&h.scrollTop!==null)return;r()};return typeof this.init=="function"&&(this.init(),r()),this.notify(e,t,n),this},notify:function(e,t,r){var i=n.createElement("article");i.className="alertify-log"+(typeof t=="string"&&t!==""?" alertify-log-"+t:""),i.innerHTML=e,h.insertBefore(i,h.firstChild),setTimeout(function(){i.className=i.className+" alertify-log-show"},50),this.close(i,r)},set:function(e){var t;if(typeof e!="object"&&e instanceof Array)throw new Error("args must be an object");for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])},setup:function(){var e=u[0];s=!0,c.innerHTML=this.build(e),typeof e.placeholder=="string"&&e.placeholder!==""&&(a("alertify-text").value=e.placeholder),this.addListeners(e.callback)},unbind:function(e,t,n){typeof e.removeEventListener=="function"?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}},{alert:function(e,t,n){return r.dialog(e,"alert",t,"",n),this},confirm:function(e,t,n){return r.dialog(e,"confirm",t,"",n),this},extend:r.extend,init:r.init,log:function(e,t,n){return r.log(e,t,n),this},prompt:function(e,t,n,i){return r.dialog(e,"prompt",t,n,i),this},success:function(e,t){return r.log(e,"success",t),this},error:function(e,t){return r.log(e,"error",t),this},set:function(e){r.set(e)},labels:r.labels}},typeof define=="function"?define([],function(){return new r}):typeof e.alertify=="undefined"&&(e.alertify=new r)})(this),function(e){var t=window.hollerConfig,n=t&&t.port?t.port:"1337",r=t&&t.host?t.host:"http://127.0.0.1",i=document.createElement("style");i.type="text/css",i.innerHTML=".alertify-show, .alertify-log { -webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1); /* older webkit */ -webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -moz-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -ms-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); -o-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); /* easeOutBack */ } .alertify-hide { -webkit-transition: all 250ms cubic-bezier(0.600, 0, 0.735, 0.045); /* older webkit */ -webkit-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -moz-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -ms-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); -o-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); /* easeInBack */ } .alertify-cover { position: fixed; z-index: 99999; top: 0; right: 0; bottom: 0; left: 0; } .alertify { position: fixed; z-index: 99999; top: 50px; left: 50%; width: 550px; margin-left: -275px; } .alertify-hidden { top: -50px; visibility: hidden; } .alertify-logs { position: fixed; z-index: 5000; bottom: 10px; right: 10px; width: 300px; } .alertify-log { display: block; margin-top: 10px; position: relative; right: -300px; } .alertify-log-show { right: 0; } .alertify-dialog { padding: 25px; } .alertify-resetFocus { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } .alertify-inner { text-align: center; } .alertify-text { margin-bottom: 15px; width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-size: 100%; } .alertify-buttons { } .alertify-button { /* line-height and font-size for input button */ line-height: 1.5; font-size: 100%; display: inline-block; cursor: pointer; margin-left: 5px; } @media only screen and (max-width: 680px) { .alertify, .alertify-logs { width: 90%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .alertify { left: 5%; margin: 0; } } /** * Default Look and Feel */ .alertify, .alertify-log { font-family: sans-serif; } .alertify { background: #FFF; border: 10px solid #333; /* browsers that don't support rgba */ border: 10px solid rgba(0,0,0,.7); border-radius: 8px; box-shadow: 0 3px 3px rgba(0,0,0,.3); -webkit-background-clip: padding; /* Safari 4? Chrome 6? */ -moz-background-clip: padding; /* Firefox 3.6 */ background-clip: padding-box; /* Firefox 4, Safari 5, Opera 10, IE 9 */ } .alertify-text { border: 1px solid #CCC; padding: 10px; border-radius: 4px; } .alertify-button { border-radius: 4px; color: #FFF; font-weight: bold; padding: 6px 15px; text-decoration: none; text-shadow: 1px 1px 0 rgba(0,0,0,.5); box-shadow: inset 0 1px 0 0 rgba(255,255,255,.5); background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -ms-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: -o-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); background-image: linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0)); } .alertify-button:hover, .alertify-button:focus { outline: none; box-shadow: 0 0 15px #2B72D5; background-image: -webkit-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -moz-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -ms-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: -o-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); background-image: linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0)); } .alertify-button:active { position: relative; top: 1px; } .alertify-button-cancel { background-color: #FE1A00; border: 1px solid #D83526; } .alertify-button-ok { background-color: #5CB811; border: 1px solid #3B7808; } .alertify-log { background: #1F1F1F; background: rgba(0,0,0,.9); padding: 15px; border-radius: 4px; color: #FFF; text-shadow: -1px -1px 0 rgba(0,0,0,.5); } .alertify-log-error { background: #FE1A00; background: rgba(254,26,0,.9); } .alertify-log-success { background: #5CB811; background: rgba(92,184,17,.9); }",document.getElementsByTagName("head")[0].appendChild(i);var s=function(e,t){var n=document.getElementsByTagName("head")[0];if(n){var r=document.createElement("script");r.setAttribute("src",e),r.setAttribute("type","text/javascript");var i=function(){(this.readyState=="complete"||this.readyState=="loaded")&&t()};r.onreadystatechange=i,r.onload=t,n.appendChild(r)}};s(r+":"+n+"/faye/client.js",function(){var e=new Faye.Client(r+":"+n+"/faye",{timeout:120,retry:5}),t=e.subscribe("/holler",function(e){alertify.log(e.message,e.type)})})}(this);
0  dist/holler.concat.js
No changes.
1  dist/holler.min.js
... ...
@@ -1 +0,0 @@
1  
-;
10  grunt.js
@@ -6,14 +6,20 @@ module.exports = function(grunt) {
6 6
     lint: {
7 7
       files: ['src/*.js']
8 8
     },
  9
+    concat: {
  10
+      dist: {
  11
+        src: ['src/alertify.js', 'src/holler-client.js'],
  12
+        dest: 'dist/<%= pkg.name %>-client.concat.js'
  13
+      }
  14
+    },
9 15
     min: {
10 16
       dist: {
11  
-        src: ['src/holler-client.js'],
  17
+        src: '<%= concat.dist.dest %>',
12 18
         dest: 'dist/<%= pkg.name %>-client.min.js'
13 19
       }
14 20
     }
15 21
   });
16 22
 
17  
-  grunt.registerTask('default', ['lint', 'min']);
  23
+  grunt.registerTask('default', ['lint', 'concat', 'min']);
18 24
 
19 25
 };
473  src/alertify.js
... ...
@@ -0,0 +1,473 @@
  1
+/**
  2
+ * alertify
  3
+ * An unobtrusive customizable JavaScript notification system
  4
+ *
  5
+ * @author Fabien Doiron <fabien.doiron@gmail.com>
  6
+ * @copyright Fabien Doiron 2012
  7
+ * @license MIT <http://opensource.org/licenses/mit-license.php>
  8
+ * @link http://fabien-d.github.com/alertify.js/
  9
+ * @module alertify
  10
+ * @version 0.2.12
  11
+ */
  12
+
  13
+/*global define setTimeout*/
  14
+(function (global, undefined) {
  15
+  "use strict";
  16
+
  17
+  var document = global.document,
  18
+      Alertify;
  19
+
  20
+  Alertify = function () {
  21
+
  22
+    var _alertify = {},
  23
+        dialogs   = {},
  24
+        isopen    = false,
  25
+        keys      = { ENTER: 13, ESC: 27, SPACE: 32 },
  26
+        queue     = [],
  27
+        $, elCallee, elCover, elDialog, elLog;
  28
+
  29
+    /**
  30
+     * Markup pieces
  31
+     * @type {Object}
  32
+     */
  33
+    dialogs = {
  34
+      buttons : {
  35
+        holder : "<nav class=\"alertify-buttons\">{{buttons}}</nav>",
  36
+        submit : "<button type=\"submit\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\" />{{ok}}</button>",
  37
+        ok     : "<a href=\"#\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\">{{ok}}</a>",
  38
+        cancel : "<a href=\"#\" class=\"alertify-button alertify-button-cancel\" id=\"alertify-cancel\">{{cancel}}</a>"
  39
+      },
  40
+      input   : "<input type=\"text\" class=\"alertify-text\" id=\"alertify-text\">",
  41
+      message : "<p class=\"alertify-message\">{{message}}</p>",
  42
+      log     : "<article class=\"alertify-log{{class}}\">{{message}}</article>"
  43
+    };
  44
+
  45
+    /**
  46
+     * Shorthand for document.getElementById()
  47
+     *
  48
+     * @param  {String} id    A specific element ID
  49
+     * @return {Object}       HTML element
  50
+     */
  51
+    $ = function (id) {
  52
+      return document.getElementById(id);
  53
+    };
  54
+
  55
+    /**
  56
+     * Alertify private object
  57
+     * @type {Object}
  58
+     */
  59
+    _alertify = {
  60
+
  61
+      /**
  62
+       * Labels object
  63
+       * @type {Object}
  64
+       */
  65
+      labels : {
  66
+        ok     : "OK",
  67
+        cancel : "Cancel"
  68
+      },
  69
+
  70
+      /**
  71
+       * Delay number
  72
+       * @type {Number}
  73
+       */
  74
+      delay : 5000,
  75
+
  76
+      /**
  77
+       * Set the proper button click events
  78
+       *
  79
+       * @param {Function} fn    [Optional] Callback function
  80
+       *
  81
+       * @return {undefined}
  82
+       */
  83
+      addListeners : function (fn) {
  84
+        var btnReset  = $("alertify-resetFocus"),
  85
+            btnOK     = $("alertify-ok")     || undefined,
  86
+            btnCancel = $("alertify-cancel") || undefined,
  87
+            input     = $("alertify-text")   || undefined,
  88
+            form      = $("alertify-form")   || undefined,
  89
+            hasOK     = (typeof btnOK !== "undefined"),
  90
+            hasCancel = (typeof btnCancel !== "undefined"),
  91
+            hasInput  = (typeof input !== "undefined"),
  92
+            val       = "",
  93
+            self      = this,
  94
+            ok, cancel, common, key, reset;
  95
+
  96
+        // ok event handler
  97
+        ok = function (event) {
  98
+          if (typeof event.preventDefault !== "undefined") event.preventDefault();
  99
+          common(event);
  100
+          if (typeof input !== "undefined") val = input.value;
  101
+          if (typeof fn === "function") fn(true, val);
  102
+        };
  103
+
  104
+        // cancel event handler
  105
+        cancel = function (event) {
  106
+          if (typeof event.preventDefault !== "undefined") event.preventDefault();
  107
+          common(event);
  108
+          if (typeof fn === "function") fn(false);
  109
+        };
  110
+
  111
+        // common event handler (keyup, ok and cancel)
  112
+        common = function (event) {
  113
+          self.hide();
  114
+          self.unbind(document.body, "keyup", key);
  115
+          self.unbind(btnReset, "focus", reset);
  116
+          if (hasInput) self.unbind(form, "submit", ok);
  117
+          if (hasOK) self.unbind(btnOK, "click", ok);
  118
+          if (hasCancel) self.unbind(btnCancel, "click", cancel);
  119
+        };
  120
+
  121
+        // keyup handler
  122
+        key = function (event) {
  123
+          var keyCode = event.keyCode;
  124
+          if (keyCode === keys.SPACE && !hasInput) ok(event);
  125
+          if (keyCode === keys.ESC && hasCancel) cancel(event);
  126
+        };
  127
+
  128
+        // reset focus to first item in the dialog
  129
+        reset = function (event) {
  130
+          if (hasInput) input.focus();
  131
+          else if (hasCancel) btnCancel.focus();
  132
+          else btnOK.focus();
  133
+        };
  134
+
  135
+        // handle reset focus link
  136
+        // this ensures that the keyboard focus does not
  137
+        // ever leave the dialog box until an action has
  138
+        // been taken
  139
+        this.bind(btnReset, "focus", reset);
  140
+        // handle OK click
  141
+        if (hasOK) this.bind(btnOK, "click", ok);
  142
+        // handle Cancel click
  143
+        if (hasCancel) this.bind(btnCancel, "click", cancel);
  144
+        // listen for keys, Cancel => ESC
  145
+        this.bind(document.body, "keyup", key);
  146
+        // bind form submit
  147
+        if (hasInput) this.bind(form, "submit", ok);
  148
+        // set focus on OK button or the input text
  149
+        global.setTimeout(function () {
  150
+          if (input) {
  151
+            input.focus();
  152
+            input.select();
  153
+          }
  154
+          else btnOK.focus();
  155
+        }, 50);
  156
+      },
  157
+
  158
+      /**
  159
+       * Bind events to elements
  160
+       *
  161
+       * @param  {Object}   el       HTML Object
  162
+       * @param  {Event}    event    Event to attach to element
  163
+       * @param  {Function} fn       Callback function
  164
+       *
  165
+       * @return {undefined}
  166
+       */
  167
+      bind : function (el, event, fn) {
  168
+        if (typeof el.addEventListener === "function") {
  169
+          el.addEventListener(event, fn, false);
  170
+        } else if (el.attachEvent) {
  171
+          el.attachEvent("on" + event, fn);
  172
+        }
  173
+      },
  174
+
  175
+      /**
  176
+       * Build the proper message box
  177
+       *
  178
+       * @param  {Object} item    Current object in the queue
  179
+       *
  180
+       * @return {String}         An HTML string of the message box
  181
+       */
  182
+      build : function (item) {
  183
+        var html    = "",
  184
+            type    = item.type,
  185
+            message = item.message,
  186
+            css     = item.cssClass || "";
  187
+
  188
+        html += "<div class=\"alertify-dialog\">";
  189
+
  190
+        if (type === "prompt") html += "<form id=\"alertify-form\">";
  191
+
  192
+        html += "<article class=\"alertify-inner\">";
  193
+        html += dialogs.message.replace("{{message}}", message);
  194
+
  195
+        if (type === "prompt") html += dialogs.input;
  196
+
  197
+        html += dialogs.buttons.holder;
  198
+        html += "</article>";
  199
+
  200
+        if (type === "prompt") html += "</form>";
  201
+
  202
+        html += "<a id=\"alertify-resetFocus\" class=\"alertify-resetFocus\" href=\"#\">Reset Focus</a>";
  203
+        html += "</div>";
  204
+
  205
+        switch (type) {
  206
+        case "confirm":
  207
+          html = html.replace("{{buttons}}", dialogs.buttons.cancel + dialogs.buttons.ok);
  208
+          html = html.replace("{{ok}}", this.labels.ok).replace("{{cancel}}", this.labels.cancel);
  209
+          break;
  210
+        case "prompt":
  211
+          html = html.replace("{{buttons}}", dialogs.buttons.cancel + dialogs.buttons.submit);
  212
+          html = html.replace("{{ok}}", this.labels.ok).replace("{{cancel}}", this.labels.cancel);
  213
+          break;
  214
+        case "alert":
  215
+          html = html.replace("{{buttons}}", dialogs.buttons.ok);
  216
+          html = html.replace("{{ok}}", this.labels.ok);
  217
+          break;
  218
+        default:
  219
+          break;
  220
+        }
  221
+
  222
+        elDialog.className = "alertify alertify-show alertify-" + type + " " + css;
  223
+        elCover.className  = "alertify-cover";
  224
+        return html;
  225
+      },
  226
+
  227
+      /**
  228
+       * Close the log messages
  229
+       *
  230
+       * @param  {Object} elem    HTML Element of log message to close
  231
+       * @param  {Number} wait    [optional] Time (in ms) to wait before automatically hiding the message
  232
+       *
  233
+       * @return {undefined}
  234
+       */
  235
+      close : function (elem, wait) {
  236
+        var timer = (wait && !isNaN(wait)) ? +wait : this.delay; // Unary Plus: +"2" === 2
  237
+        this.bind(elem, "click", function () {
  238
+          elLog.removeChild(elem);
  239
+        });
  240
+        setTimeout(function () {
  241
+          if (typeof elem !== "undefined" && elem.parentNode === elLog) elLog.removeChild(elem);
  242
+        }, timer);
  243
+      },
  244
+
  245
+      /**
  246
+       * Create a dialog box
  247
+       *
  248
+       * @param  {String}   message        The message passed from the callee
  249
+       * @param  {String}   type           Type of dialog to create
  250
+       * @param  {Function} fn             [Optional] Callback function
  251
+       * @param  {String}   placeholder    [Optional] Default value for prompt input field
  252
+       * @param  {String}   cssClass       [Optional] Class(es) to append to dialog box
  253
+       *
  254
+       * @return {Object}
  255
+       */
  256
+      dialog : function (message, type, fn, placeholder, cssClass) {
  257
+        // set the current active element
  258
+        // this allows the keyboard focus to be resetted
  259
+        // after the dialog box is closed
  260
+        elCallee = document.activeElement;
  261
+        // check to ensure the alertify dialog element
  262
+        // has been successfully created
  263
+        var check = function () {
  264
+          if (elDialog && elDialog.scrollTop !== null) return;
  265
+          else check();
  266
+        };
  267
+        // error catching
  268
+        if (typeof message !== "string") throw new Error("message must be a string");
  269
+        if (typeof type !== "string") throw new Error("type must be a string");
  270
+        if (typeof fn !== "undefined" && typeof fn !== "function") throw new Error("fn must be a function");
  271
+        // initialize alertify if it hasn't already been done
  272
+        if (typeof this.init === "function") {
  273
+          this.init();
  274
+          check();
  275
+        }
  276
+
  277
+        queue.push({ type: type, message: message, callback: fn, placeholder: placeholder, cssClass: cssClass });
  278
+        if (!isopen) this.setup();
  279
+
  280
+        return this;
  281
+      },
  282
+
  283
+      /**
  284
+       * Extend the log method to create custom methods
  285
+       *
  286
+       * @param  {String} type    Custom method name
  287
+       *
  288
+       * @return {Function}
  289
+       */
  290
+      extend : function (type) {
  291
+        if (typeof type !== "string") throw new Error("extend method must have exactly one paramter");
  292
+        return function (message, wait) {
  293
+          this.log(message, type, wait);
  294
+          return this;
  295
+        };
  296
+      },
  297
+
  298
+      /**
  299
+       * Hide the dialog and rest to defaults
  300
+       *
  301
+       * @return {undefined}
  302
+       */
  303
+      hide : function () {
  304
+        // remove reference from queue
  305
+        queue.splice(0,1);
  306
+        // if items remaining in the queue
  307
+        if (queue.length > 0) this.setup();
  308
+        else {
  309
+          isopen = false;
  310
+          elDialog.className = "alertify alertify-hide alertify-hidden";
  311
+          elCover.className  = "alertify-cover alertify-hidden";
  312
+          // set focus to the last element or body
  313
+          // after the dialog is closed
  314
+          elCallee.focus();
  315
+        }
  316
+      },
  317
+
  318
+      /**
  319
+       * Initialize Alertify
  320
+       * Create the 2 main elements
  321
+       *
  322
+       * @return {undefined}
  323
+       */
  324
+      init : function () {
  325
+        // ensure legacy browsers support html5 tags
  326
+        document.createElement("nav");
  327
+        document.createElement("article");
  328
+        document.createElement("section");
  329
+        // cover
  330
+        elCover = document.createElement("div");
  331
+        elCover.setAttribute("id", "alertify-cover");
  332
+        elCover.className = "alertify-cover alertify-hidden";
  333
+        document.body.appendChild(elCover);
  334
+        // main element
  335
+        elDialog = document.createElement("section");
  336
+        elDialog.setAttribute("id", "alertify");
  337
+        elDialog.className = "alertify alertify-hidden";
  338
+        document.body.appendChild(elDialog);
  339
+        // log element
  340
+        elLog = document.createElement("section");
  341
+        elLog.setAttribute("id", "alertify-logs");
  342
+        elLog.className = "alertify-logs";
  343
+        document.body.appendChild(elLog);
  344
+        // set tabindex attribute on body element
  345
+        // this allows script to give it focus
  346
+        // after the dialog is closed
  347
+        document.body.setAttribute("tabindex", "0");
  348
+        // clean up init method
  349
+        delete this.init;
  350
+      },
  351
+
  352
+      /**
  353
+       * Show a new log message box
  354
+       *
  355
+       * @param  {String} message    The message passed from the callee
  356
+       * @param  {String} type       [Optional] Optional type of log message
  357
+       * @param  {Number} wait       [Optional] Time (in ms) to wait before auto-hiding the log
  358
+       *
  359
+       * @return {Object}
  360
+       */
  361
+      log : function (message, type, wait) {
  362
+        // check to ensure the alertify dialog element
  363
+        // has been successfully created
  364
+        var check = function () {
  365
+          if (elLog && elLog.scrollTop !== null) return;
  366
+          else check();
  367
+        };
  368
+        // initialize alertify if it hasn't already been done
  369
+        if (typeof this.init === "function") {
  370
+          this.init();
  371
+          check();
  372
+        }
  373
+        this.notify(message, type, wait);
  374
+        return this;
  375
+      },
  376
+
  377
+      /**
  378
+       * Add new log message
  379
+       * If a type is passed, a class name "alertify-log-{type}" will get added.
  380
+       * This allows for custom look and feel for various types of notifications.
  381
+       *
  382
+       * @param  {String} message    The message passed from the callee
  383
+       * @param  {String} type       [Optional] Type of log message
  384
+       * @param  {Number} wait       [Optional] Time (in ms) to wait before auto-hiding
  385
+       *
  386
+       * @return {undefined}
  387
+       */
  388
+      notify : function (message, type, wait) {
  389
+        var log = document.createElement("article");
  390
+        log.className = "alertify-log" + ((typeof type === "string" && type !== "") ? " alertify-log-" + type : "");
  391
+        log.innerHTML = message;
  392
+        // prepend child
  393
+        elLog.insertBefore(log, elLog.firstChild);
  394
+        // triggers the CSS animation
  395
+        setTimeout(function() { log.className = log.className + " alertify-log-show"; }, 50);
  396
+        this.close(log, wait);
  397
+      },
  398
+
  399
+      /**
  400
+       * Set properties
  401
+       *
  402
+       * @param {Object} args     Passing parameters
  403
+       *
  404
+       * @return {undefined}
  405
+       */
  406
+      set : function (args) {
  407
+        var k;
  408
+        // error catching
  409
+        if (typeof args !== "object" && args instanceof Array) throw new Error("args must be an object");
  410
+        // set parameters
  411
+        for (k in args) {
  412
+          if (args.hasOwnProperty(k)) {
  413
+            this[k] = args[k];
  414
+          }
  415
+        }
  416
+      },
  417
+
  418
+      /**
  419
+       * Initiate all the required pieces for the dialog box
  420
+       *
  421
+       * @return {undefined}
  422
+       */
  423
+      setup : function () {
  424
+        var item = queue[0];
  425
+
  426
+        isopen = true;
  427
+        elDialog.innerHTML = this.build(item);
  428
+        if (typeof item.placeholder === "string" && item.placeholder !== "") $("alertify-text").value = item.placeholder;
  429
+        this.addListeners(item.callback);
  430
+      },
  431
+
  432
+      /**
  433
+       * Unbind events to elements
  434
+       *
  435
+       * @param  {Object}   el       HTML Object
  436
+       * @param  {Event}    event    Event to detach to element
  437
+       * @param  {Function} fn       Callback function
  438
+       *
  439
+       * @return {undefined}
  440
+       */
  441
+      unbind : function (el, event, fn) {
  442
+        if (typeof el.removeEventListener === "function") {
  443
+          el.removeEventListener(event, fn, false);
  444
+        } else if (el.detachEvent) {
  445
+          el.detachEvent("on" + event, fn);
  446
+        }
  447
+      }
  448
+    };
  449
+
  450
+    return {
  451
+      alert   : function (message, fn, cssClass) { _alertify.dialog(message, "alert", fn, "", cssClass); return this; },
  452
+      confirm : function (message, fn, cssClass) { _alertify.dialog(message, "confirm", fn, "", cssClass); return this; },
  453
+      extend  : _alertify.extend,
  454
+      init    : _alertify.init,
  455
+      log     : function (message, type, wait) { _alertify.log(message, type, wait); return this; },
  456
+      prompt  : function (message, fn, placeholder, cssClass) { _alertify.dialog(message, "prompt", fn, placeholder, cssClass); return this; },
  457
+      success : function (message, wait) { _alertify.log(message, "success", wait); return this; },
  458
+      error   : function (message, wait) { _alertify.log(message, "error", wait); return this; },
  459
+      set     : function (args) { _alertify.set(args); },
  460
+      labels  : _alertify.labels
  461
+    };
  462
+  };
  463
+
  464
+  // AMD and window support
  465
+  if (typeof define === "function") {
  466
+    define([], function () { return new Alertify(); });
  467
+  } else {
  468
+    if (typeof global.alertify === "undefined") {
  469
+      global.alertify = new Alertify();
  470
+    }
  471
+  }
  472
+
  473
+}(this));
493  src/holler-client.js
... ...
@@ -1,475 +1,22 @@
1  
-/*global setTimeout:true, define:true*/
2  
-/**
3  
- * alertify
4  
- * An unobtrusive customizable JavaScript notification system
5  
- *
6  
- * @author Fabien Doiron <fabien.doiron@gmail.com>
7  
- * @copyright Fabien Doiron 2012
8  
- * @license MIT <http://opensource.org/licenses/mit-license.php>
9  
- * @link http://www.github.com/fabien-d
10  
- * @module alertify
11  
- * @version 0.2.12
12  
- */
13  
-(function (global, undefined) {
14  
-  "use strict";
  1
+// 
  2
+// name         : holler-client.js
  3
+// description  : Connects to a Faye server & subscribes to notifications
  4
+// 
15 5
 
16  
-  var document = global.document,
17  
-      Alertify;
18 6
 
19  
-  Alertify = function () {
20  
-
21  
-    var _alertify = {},
22  
-        dialogs   = {},
23  
-        isopen    = false,
24  
-        keys      = { ENTER: 13, ESC: 27, SPACE: 32 },
25  
-        queue     = [],
26  
-        $, elCallee, elCover, elDialog, elLog;
27  
-
28  
-    /**
29  
-     * Markup pieces
30  
-     * @type {Object}
31  
-     */
32  
-    dialogs = {
33  
-      buttons : {
34  
-        holder : "<nav class=\"alertify-buttons\">{{buttons}}</nav>",
35  
-        submit : "<button type=\"submit\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\" />{{ok}}</button>",
36  
-        ok     : "<a href=\"#\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\">{{ok}}</a>",
37  
-        cancel : "<a href=\"#\" class=\"alertify-button alertify-button-cancel\" id=\"alertify-cancel\">{{cancel}}</a>"
38  
-      },
39  
-      input   : "<input type=\"text\" class=\"alertify-text\" id=\"alertify-text\">",
40  
-      message : "<p class=\"alertify-message\">{{message}}</p>",
41  
-      log     : "<article class=\"alertify-log{{class}}\">{{message}}</article>"
42  
-    };
43  
-
44  
-    /**
45  
-     * Shorthand for document.getElementById()
46  
-     *
47  
-     * @param  {String} id    A specific element ID
48  
-     * @return {Object}       HTML element
49  
-     */
50  
-    $ = function (id) {
51  
-      return document.getElementById(id);
52  
-    };
53  
-
54  
-    /**
55  
-     * Alertify private object
56  
-     * @type {Object}
57  
-     */
58  
-    _alertify = {
59  
-
60  
-      /**
61  
-       * Labels object
62  
-       * @type {Object}
63  
-       */
64  
-      labels : {
65  
-        ok     : "OK",
66  
-        cancel : "Cancel"
67  
-      },
68  
-
69  
-      /**
70  
-       * Delay number
71  
-       * @type {Number}
72  
-       */
73  
-      delay : 5000,
74  
-
75  
-      /**
76  
-       * Set the proper button click events
77  
-       *
78  
-       * @param {Function} fn    [Optional] Callback function
79  
-       *
80  
-       * @return {undefined}
81  
-       */
82  
-      addListeners : function (fn) {
83  
-        var btnReset  = $("alertify-resetFocus"),
84  
-            btnOK     = $("alertify-ok")     || undefined,
85  
-            btnCancel = $("alertify-cancel") || undefined,
86  
-            input     = $("alertify-text")   || undefined,
87  
-            form      = $("alertify-form")   || undefined,
88  
-            hasOK     = (typeof btnOK !== "undefined"),
89  
-            hasCancel = (typeof btnCancel !== "undefined"),
90  
-            hasInput  = (typeof input !== "undefined"),
91  
-            val       = "",
92  
-            self      = this,
93  
-            ok, cancel, common, key, reset;
94  
-
95  
-        // ok event handler
96  
-        ok = function (event) {
97  
-          if (typeof event.preventDefault !== "undefined") event.preventDefault();