text: // Generated by CoffeeScript 1.7.1
  
  /*
      A Simple jQuery shortcuts library
  
      The MIT License (MIT)
  
      Copyright (c) 2014 SSSamuel
  
      Permission is hereby granted, free of charge, to any person obtaining a copy
      of this software and associated documentation files (the "Software"), to deal
      in the Software without restriction, including without limitation the rights
      to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      copies of the Software, and to permit persons to whom the Software is
      furnished to do so, subject to the following conditions:
  
      The above copyright notice and this permission notice shall be included in all
      copies or substantial portions of the Software.
  
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      SOFTWARE.
  
      － NinjaKey->constructor
          @param
              :key shortcuts String/Array
                  now support:
                      a-z,A-Z,0-9
                  special keys:
                      alt,ctrl/command,shift
                      home,left,up,right,down,enter,esc,space,backspace,del
                  example:
                      ctrl+alt+a, ctrl+enter, Ctrl+Shift+A
                  !! NOT SUPPORT
  
              :selector String
                  support jquery selector string
  
              :callback
                  selector will build a jQuery object，which will be callback `this`
          @ return
              obj -> NinjaKey
  
  
      - NinjaKey::kill
          kill ninja!
  
      @ 2014-05-16
      @ samuel - samuel.m.shen@gmail.com
      @ version 0.0.1
   */
  
  (function() {
    var $, NinjaKey, NinjaKey_id_pool, macCheck;
  
    $ = jQuery;
  
    NinjaKey_id_pool = {};
  
    macCheck = (function() {
      if (typeof navigator === "undefined" || navigator === null) {
        return {};
      }
      if (/Mac/.test(navigator.appVersion)) {
        return {
          mac: true
        };
      } else {
        return {};
      }
    })();
  
    NinjaKey = (function() {
      var idGenerator, parseKey;
  
      idGenerator = function() {
        var _r;
        while (true) {
          _r = 'ninja' + 'xxxxxxxxx'.replace(/[x]/g, function() {
            var num;
            num = Math.random() * 16 | 0;
            return num.toString(16);
          });
          if (!NinjaKey_id_pool.hasOwnProperty(_r)) {
            break;
          }
        }
        return _r;
      };
  
      parseKey = function(keys) {
        var conditions, fnKey, fnKeyStatus, gFunc, key, key_condition, keycodeMap, _i, _j, _key, _len, _len1;
        keycodeMap = {
          'HOME': 36,
          'LEFT': 37,
          'UP': 38,
          'RIGHT': 39,
          'DOWN': 40,
          'ENTER': 13,
          'ESC': 27,
          'SPACE': 32,
          'BACKSPACE': 8,
          'DEL': 46
        };
        conditions = [];
        for (_i = 0, _len = keys.length; _i < _len; _i++) {
          key = keys[_i];
          if (key) {
            key = key.split('+');
            key_condition = [];
            fnKey = key;
            fnKeyStatus = [0, 0, 0];
            for (_j = 0, _len1 = fnKey.length; _j < _len1; _j++) {
              _key = fnKey[_j];
              _key = _key.toLowerCase();
              if (_key === 'ctrl' || _key === 'command' || _key === 'cmd') {
                fnKeyStatus[0] = 1;
              } else if (_key === 'alt') {
                fnKeyStatus[1] = 1;
              } else if (_key === 'shift') {
                fnKeyStatus[2] = 1;
              } else {
                _key = _key.toUpperCase();
                if (!keycodeMap.hasOwnProperty(_key)) {
                  key_condition.push('e.which===' + _key.charCodeAt(0));
                } else {
                  key_condition.push('e.which===' + keycodeMap[_key]);
                }
              }
            }
            if (!macCheck.mac) {
              if (fnKeyStatus[0] === 1) {
                key_condition.push('e.ctrlKey');
              } else {
                key_condition.push('!e.ctrlKey');
              }
            } else {
              if (fnKeyStatus[0] === 1) {
                key_condition.push('e.metaKey');
              } else {
                key_condition.push('!e.metaKey');
              }
            }
            if (fnKeyStatus[1] === 1) {
              key_condition.push('e.altKey');
            } else {
              key_condition.push('!e.altKey');
            }
            if (fnKeyStatus[2] === 1) {
              key_condition.push('e.shiftKey');
            } else {
              key_condition.push('!e.shiftKey');
            }
            conditions.push('(' + key_condition.join(' && ') + ')');
          }
        }
        gFunc = 'return ' + (conditions.join(' || ') || false) + ';';
        return new Function('e', gFunc);
      };
  
      function NinjaKey(key, elem, callback) {
        var _passion;
        key = {}.toString.call(key) === '[object Array]' ? key : [key];
        this.__id__ = idGenerator();
        _passion = parseKey(key);
        if (typeof elem !== 'string') {
          callback = elem;
          elem = document;
        }
        $(document).on('keydown.' + this.__id__, function(e) {
          if (_passion(e)) {
            if (callback != null) {
              callback.call($(elem));
            }
            return false;
          }
        });
      }
  
      NinjaKey.prototype.kill = function() {
        return $(document).off('keydown.' + this.__id__);
      };
  
      return NinjaKey;
  
    })();
  
    window.NinjaKey = function(key, elem, callback) {
      return new NinjaKey(key, elem, callback);
    };
  
  }).call(this);
  
  //# sourceMappingURL=jQuery.ninjakey.map
  