| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
(function (context) { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
context['global'] = context |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
var modules = {} |
| 19 |
, old = context['$'] |
| 20 |
, oldRequire = context['require'] |
| 21 |
, oldProvide = context['provide'] |
| 22 |
|
| 23 |
function require (identifier) { |
| 24 |
|
| 25 |
var module = modules['$' + identifier] || window[identifier] |
| 26 |
if (!module) throw new Error("Ender Error: Requested module '" + identifier + "' has not been defined.") |
| 27 |
return module |
| 28 |
} |
| 29 |
|
| 30 |
function provide (name, what) { |
| 31 |
return (modules['$' + name] = what) |
| 32 |
} |
| 33 |
|
| 34 |
context['provide'] = provide |
| 35 |
context['require'] = require |
| 36 |
|
| 37 |
function aug(o, o2) { |
| 38 |
for (var k in o2) k != 'noConflict' && k != '_VERSION' && (o[k] = o2[k]) |
| 39 |
return o |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
function Ender(s, r) { |
| 49 |
var elements |
| 50 |
, i |
| 51 |
|
| 52 |
this.selector = s |
| 53 |
|
| 54 |
if (typeof s == 'undefined') { |
| 55 |
elements = [] |
| 56 |
this.selector = '' |
| 57 |
} else if (typeof s == 'string' || s.nodeName || (s.length && 'item' in s) || s == window) { |
| 58 |
elements = ender._select(s, r) |
| 59 |
} else { |
| 60 |
elements = isFinite(s.length) ? s : [s] |
| 61 |
} |
| 62 |
this.length = elements.length |
| 63 |
for (i = this.length; i--;) this[i] = elements[i] |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
Ender.prototype['forEach'] = function (fn, opt_scope) { |
| 72 |
var i, l |
| 73 |
|
| 74 |
|
| 75 |
for (i = 0, l = this.length; i < l; ++i) i in this && fn.call(opt_scope || this[i], this[i], i, this) |
| 76 |
|
| 77 |
return this |
| 78 |
} |
| 79 |
|
| 80 |
Ender.prototype.$ = ender |
| 81 |
|
| 82 |
|
| 83 |
function ender(s, r) { |
| 84 |
return new Ender(s, r) |
| 85 |
} |
| 86 |
|
| 87 |
ender['_VERSION'] = '0.4.3-dev' |
| 88 |
|
| 89 |
ender.fn = Ender.prototype |
| 90 |
|
| 91 |
ender.ender = function (o, chain) { |
| 92 |
aug(chain ? Ender.prototype : ender, o) |
| 93 |
} |
| 94 |
|
| 95 |
ender._select = function (s, r) { |
| 96 |
if (typeof s == 'string') return (r || document).querySelectorAll(s) |
| 97 |
if (s.nodeName) return [s] |
| 98 |
return s |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
ender.noConflict = function (callback) { |
| 104 |
context['$'] = old |
| 105 |
if (callback) { |
| 106 |
context['provide'] = oldProvide |
| 107 |
context['require'] = oldRequire |
| 108 |
callback(require, provide, this) |
| 109 |
} |
| 110 |
return this |
| 111 |
} |
| 112 |
|
| 113 |
if (typeof module !== 'undefined' && module.exports) module.exports = ender |
| 114 |
|
| 115 |
context['ender'] = context['$'] = context['ender'] || ender |
| 116 |
|
| 117 |
}(this)); |