ende 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +4 -2
- data/ende.gemspec +1 -0
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +94 -15
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +21 -0
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +3 -1
- data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +19 -21
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +17 -1
- data/lib/assets/javascripts/config/initializers/jquery.js.coffee +4 -3
- data/lib/assets/javascripts/config/initializers/load_components.js.coffee +19 -0
- data/lib/assets/javascripts/ende.js.coffee +3 -1
- data/lib/assets/javascripts/widgets/authenticator/main.js.coffee +3 -3
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +189 -120
- data/lib/ende/users_controller_extensions.rb +14 -0
- data/lib/ende/version.rb +1 -1
- data/lib/ende.rb +5 -0
- data/vendor/assets/components/KapIT-observe-utils/component.json +16 -0
- data/vendor/assets/components/KapIT-observe-utils/lib/observe-utils.js +780 -0
- data/vendor/assets/components/chaijs-assertion-error/component.json +18 -0
- data/vendor/assets/components/chaijs-assertion-error/index.js +110 -0
- data/vendor/assets/components/chaijs-chai/component.json +47 -0
- data/vendor/assets/components/chaijs-chai/index.js +1 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/assertion.js +130 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/interface/assert.js +1080 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/interface/should.js +76 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/index.js +108 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/inspect.js +320 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/test.js +26 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/type.js +45 -0
- data/vendor/assets/components/chaijs-chai/lib/chai.js +80 -0
- data/vendor/assets/components/chaijs-deep-eql/component.json +18 -0
- data/vendor/assets/components/chaijs-deep-eql/lib/eql.js +257 -0
- data/vendor/assets/components/chaijs-type-detect/component.json +16 -0
- data/vendor/assets/components/chaijs-type-detect/lib/type.js +142 -0
- data/vendor/assets/components/component-bind/component.json +14 -0
- data/vendor/assets/components/component-bind/index.js +24 -0
- data/vendor/assets/components/component-delegate/component.json +19 -0
- data/vendor/assets/components/component-delegate/index.js +42 -0
- data/vendor/assets/components/component-event/component.json +13 -0
- data/vendor/assets/components/component-event/index.js +40 -0
- data/vendor/assets/components/component-jquery/component.json +14 -0
- data/vendor/assets/components/component-jquery/index.js +9601 -0
- data/vendor/assets/components/component-link-delegate/component.json +23 -0
- data/vendor/assets/components/component-link-delegate/index.js +60 -0
- data/vendor/assets/components/component-matches-selector/component.json +20 -0
- data/vendor/assets/components/component-matches-selector/index.js +45 -0
- data/vendor/assets/components/component-query/component.json +21 -0
- data/vendor/assets/components/component-query/index.js +21 -0
- data/vendor/assets/components/component-type/component.json +18 -0
- data/vendor/assets/components/component-type/index.js +32 -0
- data/vendor/assets/components/component-url/component.json +17 -0
- data/vendor/assets/components/component-url/index.js +63 -0
- data/vendor/assets/components/discore-closest/component.json +14 -0
- data/vendor/assets/components/discore-closest/index.js +18 -0
- data/vendor/assets/components/indefinido-advisable/component.json +21 -0
- data/vendor/assets/components/indefinido-advisable/index.js +1 -0
- data/vendor/assets/components/indefinido-advisable/lib/advisable.js +60 -0
- data/vendor/assets/components/indefinido-indemma/component.json +40 -0
- data/vendor/assets/components/indefinido-indemma/index.js +1 -0
- data/vendor/assets/components/indefinido-indemma/lib/extensions/rivets.js +23 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/associable.js +217 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/maid.js +24 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/resource.js +104 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/rest.js +36 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/restfulable.js +326 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/scopable.js +279 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/translationable.js +19 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/validatable.js +216 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js +30 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/confirmation.js +19 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/cpf.js +60 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/presence.js +19 -0
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/remote.js +71 -0
- data/vendor/assets/components/indefinido-indemma/lib/record.js +167 -0
- data/vendor/assets/components/indefinido-indemma/vendor/sinon.js +4290 -0
- data/vendor/assets/components/indefinido-indemma/vendor/stampit.js +392 -0
- data/vendor/assets/components/indefinido-observable/component.json +25 -0
- data/vendor/assets/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
- data/vendor/assets/components/indefinido-observable/index.js +1 -0
- data/vendor/assets/components/indefinido-observable/lib/adapters/rivets.js +26 -0
- data/vendor/assets/components/indefinido-observable/lib/observable.js +320 -0
- data/vendor/assets/components/indefinido-observable/vendor/shims/accessors-legacy.js +92 -0
- data/vendor/assets/components/indefinido-observable/vendor/shims/accessors.js +173 -0
- data/vendor/assets/components/indefinido-observable/vendor/shims/array.indexOf.js +8 -0
- data/vendor/assets/components/indefinido-observable/vendor/shims/object.create.js +77 -0
- data/vendor/assets/components/mikeric-rivets/component.json +15 -0
- data/vendor/assets/components/mikeric-rivets/dist/rivets.js +1020 -0
- data/vendor/assets/components/paulmillr-es6-shim/component.json +17 -0
- data/vendor/assets/components/paulmillr-es6-shim/es6-shim.js +985 -0
- data/vendor/assets/components/pluma-assimilate/component.json +25 -0
- data/vendor/assets/components/pluma-assimilate/dist/assimilate.js +87 -0
- data/vendor/assets/components/segmentio-extend/component.json +13 -0
- data/vendor/assets/components/segmentio-extend/index.js +15 -0
- data/vendor/assets/javascripts/ende/build.js +30346 -0
- data/vendor/assets/javascripts/jquery/inview.js +125 -0
- data/vendor/assets/javascripts/lennon/lennon.js +184 -0
- metadata +114 -3
- data/lib/tasks/sprite.thor +0 -62
@@ -0,0 +1,257 @@
|
|
1
|
+
/*!
|
2
|
+
* deep-eql
|
3
|
+
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*!
|
8
|
+
* Module dependencies
|
9
|
+
*/
|
10
|
+
|
11
|
+
var type = require('type-detect');
|
12
|
+
|
13
|
+
/*!
|
14
|
+
* Buffer.isBuffer browser shim
|
15
|
+
*/
|
16
|
+
|
17
|
+
var Buffer;
|
18
|
+
try { Buffer = require('buffer').Buffer; }
|
19
|
+
catch(ex) {
|
20
|
+
Buffer = {};
|
21
|
+
Buffer.isBuffer = function() { return false; }
|
22
|
+
}
|
23
|
+
|
24
|
+
/*!
|
25
|
+
* Primary Export
|
26
|
+
*/
|
27
|
+
|
28
|
+
module.exports = deepEqual;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Assert super-strict (egal) equality between
|
32
|
+
* two objects of any type.
|
33
|
+
*
|
34
|
+
* @param {Mixed} a
|
35
|
+
* @param {Mixed} b
|
36
|
+
* @param {Array} memoised (optional)
|
37
|
+
* @return {Boolean} equal match
|
38
|
+
*/
|
39
|
+
|
40
|
+
function deepEqual(a, b, m) {
|
41
|
+
if (sameValue(a, b)) {
|
42
|
+
return true;
|
43
|
+
} else if ('date' === type(a)) {
|
44
|
+
return dateEqual(a, b);
|
45
|
+
} else if ('regexp' === type(a)) {
|
46
|
+
return regexpEqual(a, b);
|
47
|
+
} else if (Buffer.isBuffer(a)) {
|
48
|
+
return bufferEqual(a, b);
|
49
|
+
} else if ('arguments' === type(a)) {
|
50
|
+
return argumentsEqual(a, b, m);
|
51
|
+
} else if (!typeEqual(a, b)) {
|
52
|
+
return false;
|
53
|
+
} else if (('object' !== type(a) && 'object' !== type(b))
|
54
|
+
&& ('array' !== type(a) && 'array' !== type(b))) {
|
55
|
+
return sameValue(a, b);
|
56
|
+
} else {
|
57
|
+
return objectEqual(a, b, m);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
/*!
|
62
|
+
* Strict (egal) equality test. Ensures that NaN always
|
63
|
+
* equals NaN and `-0` does not equal `+0`.
|
64
|
+
*
|
65
|
+
* @param {Mixed} a
|
66
|
+
* @param {Mixed} b
|
67
|
+
* @return {Boolean} equal match
|
68
|
+
*/
|
69
|
+
|
70
|
+
function sameValue(a, b) {
|
71
|
+
if (a === b) return a !== 0 || 1 / a === 1 / b;
|
72
|
+
return a !== a && b !== b;
|
73
|
+
}
|
74
|
+
|
75
|
+
/*!
|
76
|
+
* Compare the types of two given objects and
|
77
|
+
* return if they are equal. Note that an Array
|
78
|
+
* has a type of `array` (not `object`) and arguments
|
79
|
+
* have a type of `arguments` (not `array`/`object`).
|
80
|
+
*
|
81
|
+
* @param {Mixed} a
|
82
|
+
* @param {Mixed} b
|
83
|
+
* @return {Boolean} result
|
84
|
+
*/
|
85
|
+
|
86
|
+
function typeEqual(a, b) {
|
87
|
+
return type(a) === type(b);
|
88
|
+
}
|
89
|
+
|
90
|
+
/*!
|
91
|
+
* Compare two Date objects by asserting that
|
92
|
+
* the time values are equal using `saveValue`.
|
93
|
+
*
|
94
|
+
* @param {Date} a
|
95
|
+
* @param {Date} b
|
96
|
+
* @return {Boolean} result
|
97
|
+
*/
|
98
|
+
|
99
|
+
function dateEqual(a, b) {
|
100
|
+
if ('date' !== type(b)) return false;
|
101
|
+
return sameValue(a.getTime(), b.getTime());
|
102
|
+
}
|
103
|
+
|
104
|
+
/*!
|
105
|
+
* Compare two regular expressions by converting them
|
106
|
+
* to string and checking for `sameValue`.
|
107
|
+
*
|
108
|
+
* @param {RegExp} a
|
109
|
+
* @param {RegExp} b
|
110
|
+
* @return {Boolean} result
|
111
|
+
*/
|
112
|
+
|
113
|
+
function regexpEqual(a, b) {
|
114
|
+
if ('regexp' !== type(b)) return false;
|
115
|
+
return sameValue(a.toString(), b.toString());
|
116
|
+
}
|
117
|
+
|
118
|
+
/*!
|
119
|
+
* Assert deep equality of two `arguments` objects.
|
120
|
+
* Unfortunately, these must be sliced to arrays
|
121
|
+
* prior to test to ensure no bad behavior.
|
122
|
+
*
|
123
|
+
* @param {Arguments} a
|
124
|
+
* @param {Arguments} b
|
125
|
+
* @param {Array} memoize (optional)
|
126
|
+
* @return {Boolean} result
|
127
|
+
*/
|
128
|
+
|
129
|
+
function argumentsEqual(a, b, m) {
|
130
|
+
if ('arguments' !== type(b)) return false;
|
131
|
+
a = [].slice.call(a);
|
132
|
+
b = [].slice.call(b);
|
133
|
+
return deepEqual(a, b, m);
|
134
|
+
}
|
135
|
+
|
136
|
+
/*!
|
137
|
+
* Get enumerable properties of a given object.
|
138
|
+
*
|
139
|
+
* @param {Object} a
|
140
|
+
* @return {Array} property names
|
141
|
+
*/
|
142
|
+
|
143
|
+
function enumerable(a) {
|
144
|
+
var res = [];
|
145
|
+
for (var key in a) res.push(key);
|
146
|
+
return res;
|
147
|
+
}
|
148
|
+
|
149
|
+
/*!
|
150
|
+
* Simple equality for flat iterable objects
|
151
|
+
* such as Arrays or Node.js buffers.
|
152
|
+
*
|
153
|
+
* @param {Iterable} a
|
154
|
+
* @param {Iterable} b
|
155
|
+
* @return {Boolean} result
|
156
|
+
*/
|
157
|
+
|
158
|
+
function iterableEqual(a, b) {
|
159
|
+
if (a.length !== b.length) return false;
|
160
|
+
|
161
|
+
var i = 0;
|
162
|
+
var match = true;
|
163
|
+
|
164
|
+
for (; i < a.length; i++) {
|
165
|
+
if (a[i] !== b[i]) {
|
166
|
+
match = false;
|
167
|
+
break;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
return match;
|
172
|
+
}
|
173
|
+
|
174
|
+
/*!
|
175
|
+
* Extension to `iterableEqual` specifically
|
176
|
+
* for Node.js Buffers.
|
177
|
+
*
|
178
|
+
* @param {Buffer} a
|
179
|
+
* @param {Mixed} b
|
180
|
+
* @return {Boolean} result
|
181
|
+
*/
|
182
|
+
|
183
|
+
function bufferEqual(a, b) {
|
184
|
+
if (!Buffer.isBuffer(b)) return false;
|
185
|
+
return iterableEqual(a, b);
|
186
|
+
}
|
187
|
+
|
188
|
+
/*!
|
189
|
+
* Block for `objectEqual` ensuring non-existing
|
190
|
+
* values don't get in.
|
191
|
+
*
|
192
|
+
* @param {Mixed} object
|
193
|
+
* @return {Boolean} result
|
194
|
+
*/
|
195
|
+
|
196
|
+
function isValue(a) {
|
197
|
+
return a !== null && a !== undefined;
|
198
|
+
}
|
199
|
+
|
200
|
+
/*!
|
201
|
+
* Recursively check the equality of two objects.
|
202
|
+
* Once basic sameness has been established it will
|
203
|
+
* defer to `deepEqual` for each enumerable key
|
204
|
+
* in the object.
|
205
|
+
*
|
206
|
+
* @param {Mixed} a
|
207
|
+
* @param {Mixed} b
|
208
|
+
* @return {Boolean} result
|
209
|
+
*/
|
210
|
+
|
211
|
+
function objectEqual(a, b, m) {
|
212
|
+
if (!isValue(a) || !isValue(b)) {
|
213
|
+
return false;
|
214
|
+
}
|
215
|
+
|
216
|
+
if (a.prototype !== b.prototype) {
|
217
|
+
return false;
|
218
|
+
}
|
219
|
+
|
220
|
+
var i;
|
221
|
+
if (m) {
|
222
|
+
for (i = 0; i < m.length; i++) {
|
223
|
+
if ((m[i][0] === a && m[i][1] === b)
|
224
|
+
|| (m[i][0] === b && m[i][1] === a)) {
|
225
|
+
return true;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
} else {
|
229
|
+
m = [];
|
230
|
+
}
|
231
|
+
|
232
|
+
try {
|
233
|
+
var ka = enumerable(a);
|
234
|
+
var kb = enumerable(b);
|
235
|
+
} catch (ex) {
|
236
|
+
return false;
|
237
|
+
}
|
238
|
+
|
239
|
+
ka.sort();
|
240
|
+
kb.sort();
|
241
|
+
|
242
|
+
if (!iterableEqual(ka, kb)) {
|
243
|
+
return false;
|
244
|
+
}
|
245
|
+
|
246
|
+
m.push([ a, b ]);
|
247
|
+
|
248
|
+
var key;
|
249
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
250
|
+
key = ka[i];
|
251
|
+
if (!deepEqual(a[key], b[key], m)) {
|
252
|
+
return false;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
return true;
|
257
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "type-detect",
|
3
|
+
"repo": "chaijs/type-detect",
|
4
|
+
"version": "0.1.1",
|
5
|
+
"description": "Improved typeof detection for node.js and the browser.",
|
6
|
+
"license": "MIT",
|
7
|
+
"keywords": [],
|
8
|
+
"main": "lib/type.js",
|
9
|
+
"scripts": [
|
10
|
+
"lib/type.js"
|
11
|
+
],
|
12
|
+
"dependencies": {},
|
13
|
+
"development": {
|
14
|
+
"chaijs/simple-assert": "*"
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
/*!
|
2
|
+
* type-detect
|
3
|
+
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*!
|
8
|
+
* Primary Exports
|
9
|
+
*/
|
10
|
+
|
11
|
+
var exports = module.exports = getType;
|
12
|
+
|
13
|
+
/*!
|
14
|
+
* Detectable javascript natives
|
15
|
+
*/
|
16
|
+
|
17
|
+
var natives = {
|
18
|
+
'[object Array]': 'array'
|
19
|
+
, '[object RegExp]': 'regexp'
|
20
|
+
, '[object Function]': 'function'
|
21
|
+
, '[object Arguments]': 'arguments'
|
22
|
+
, '[object Date]': 'date'
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* ### typeOf (obj)
|
27
|
+
*
|
28
|
+
* Use several different techniques to determine
|
29
|
+
* the type of object being tested.
|
30
|
+
*
|
31
|
+
*
|
32
|
+
* @param {Mixed} object
|
33
|
+
* @return {String} object type
|
34
|
+
* @api public
|
35
|
+
*/
|
36
|
+
|
37
|
+
function getType (obj) {
|
38
|
+
var str = Object.prototype.toString.call(obj);
|
39
|
+
if (natives[str]) return natives[str];
|
40
|
+
if (obj === null) return 'null';
|
41
|
+
if (obj === undefined) return 'undefined';
|
42
|
+
if (obj === Object(obj)) return 'object';
|
43
|
+
return typeof obj;
|
44
|
+
}
|
45
|
+
|
46
|
+
exports.Library = Library;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* ### Library
|
50
|
+
*
|
51
|
+
* Create a repository for custom type detection.
|
52
|
+
*
|
53
|
+
* ```js
|
54
|
+
* var lib = new type.Library;
|
55
|
+
* ```
|
56
|
+
*
|
57
|
+
*/
|
58
|
+
|
59
|
+
function Library () {
|
60
|
+
this.tests = {};
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* #### .of (obj)
|
65
|
+
*
|
66
|
+
* Expose replacement `typeof` detection to the library.
|
67
|
+
*
|
68
|
+
* ```js
|
69
|
+
* if ('string' === lib.of('hello world')) {
|
70
|
+
* // ...
|
71
|
+
* }
|
72
|
+
* ```
|
73
|
+
*
|
74
|
+
* @param {Mixed} object to test
|
75
|
+
* @return {String} type
|
76
|
+
*/
|
77
|
+
|
78
|
+
Library.prototype.of = getType;
|
79
|
+
|
80
|
+
/**
|
81
|
+
* #### .define (type, test)
|
82
|
+
*
|
83
|
+
* Add a test to for the `.test()` assertion.
|
84
|
+
*
|
85
|
+
* Can be defined as a regular expression:
|
86
|
+
*
|
87
|
+
* ```js
|
88
|
+
* lib.define('int', /^[0-9]+$/);
|
89
|
+
* ```
|
90
|
+
*
|
91
|
+
* ... or as a function:
|
92
|
+
*
|
93
|
+
* ```js
|
94
|
+
* lib.define('bln', function (obj) {
|
95
|
+
* if ('boolean' === lib.of(obj)) return true;
|
96
|
+
* var blns = [ 'yes', 'no', 'true', 'false', 1, 0 ];
|
97
|
+
* if ('string' === lib.of(obj)) obj = obj.toLowerCase();
|
98
|
+
* return !! ~blns.indexOf(obj);
|
99
|
+
* });
|
100
|
+
* ```
|
101
|
+
*
|
102
|
+
* @param {String} type
|
103
|
+
* @param {RegExp|Function} test
|
104
|
+
* @api public
|
105
|
+
*/
|
106
|
+
|
107
|
+
Library.prototype.define = function (type, test) {
|
108
|
+
if (arguments.length === 1) return this.tests[type];
|
109
|
+
this.tests[type] = test;
|
110
|
+
return this;
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* #### .test (obj, test)
|
115
|
+
*
|
116
|
+
* Assert that an object is of type. Will first
|
117
|
+
* check natives, and if that does not pass it will
|
118
|
+
* use the user defined custom tests.
|
119
|
+
*
|
120
|
+
* ```js
|
121
|
+
* assert(lib.test('1', 'int'));
|
122
|
+
* assert(lib.test('yes', 'bln'));
|
123
|
+
* ```
|
124
|
+
*
|
125
|
+
* @param {Mixed} object
|
126
|
+
* @param {String} type
|
127
|
+
* @return {Boolean} result
|
128
|
+
* @api public
|
129
|
+
*/
|
130
|
+
|
131
|
+
Library.prototype.test = function (obj, type) {
|
132
|
+
if (type === getType(obj)) return true;
|
133
|
+
var test = this.tests[type];
|
134
|
+
|
135
|
+
if (test && 'regexp' === getType(test)) {
|
136
|
+
return test.test(obj);
|
137
|
+
} else if (test && 'function' === getType(test)) {
|
138
|
+
return test(obj);
|
139
|
+
} else {
|
140
|
+
throw new ReferenceError('Type test "' + type + '" not defined or invalid.');
|
141
|
+
}
|
142
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* Slice reference.
|
4
|
+
*/
|
5
|
+
|
6
|
+
var slice = [].slice;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Bind `obj` to `fn`.
|
10
|
+
*
|
11
|
+
* @param {Object} obj
|
12
|
+
* @param {Function|String} fn or string
|
13
|
+
* @return {Function}
|
14
|
+
* @api public
|
15
|
+
*/
|
16
|
+
|
17
|
+
module.exports = function(obj, fn){
|
18
|
+
if ('string' == typeof fn) fn = obj[fn];
|
19
|
+
if ('function' != typeof fn) throw new Error('bind() requires a function');
|
20
|
+
var args = [].slice.call(arguments, 2);
|
21
|
+
return function(){
|
22
|
+
return fn.apply(obj, args.concat(slice.call(arguments)));
|
23
|
+
}
|
24
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "delegate",
|
3
|
+
"repo": "component/delegate",
|
4
|
+
"description": "Event delegation component",
|
5
|
+
"version": "0.2.1",
|
6
|
+
"keywords": [
|
7
|
+
"event",
|
8
|
+
"events",
|
9
|
+
"delegate",
|
10
|
+
"delegation"
|
11
|
+
],
|
12
|
+
"dependencies": {
|
13
|
+
"discore/closest": "*",
|
14
|
+
"component/event": "*"
|
15
|
+
},
|
16
|
+
"scripts": [
|
17
|
+
"index.js"
|
18
|
+
]
|
19
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Module dependencies.
|
3
|
+
*/
|
4
|
+
|
5
|
+
var closest = require('closest')
|
6
|
+
, event = require('event');
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Delegate event `type` to `selector`
|
10
|
+
* and invoke `fn(e)`. A callback function
|
11
|
+
* is returned which may be passed to `.unbind()`.
|
12
|
+
*
|
13
|
+
* @param {Element} el
|
14
|
+
* @param {String} selector
|
15
|
+
* @param {String} type
|
16
|
+
* @param {Function} fn
|
17
|
+
* @param {Boolean} capture
|
18
|
+
* @return {Function}
|
19
|
+
* @api public
|
20
|
+
*/
|
21
|
+
|
22
|
+
exports.bind = function(el, selector, type, fn, capture){
|
23
|
+
return event.bind(el, type, function(e){
|
24
|
+
var target = e.target || e.srcElement;
|
25
|
+
e.delegateTarget = closest(target, selector, true, el);
|
26
|
+
if (e.delegateTarget) fn.call(el, e);
|
27
|
+
}, capture);
|
28
|
+
};
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Unbind event `type`'s callback `fn`.
|
32
|
+
*
|
33
|
+
* @param {Element} el
|
34
|
+
* @param {String} type
|
35
|
+
* @param {Function} fn
|
36
|
+
* @param {Boolean} capture
|
37
|
+
* @api public
|
38
|
+
*/
|
39
|
+
|
40
|
+
exports.unbind = function(el, type, fn, capture){
|
41
|
+
event.unbind(el, type, fn, capture);
|
42
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* Bind `el` event `type` to `fn`.
|
4
|
+
*
|
5
|
+
* @param {Element} el
|
6
|
+
* @param {String} type
|
7
|
+
* @param {Function} fn
|
8
|
+
* @param {Boolean} capture
|
9
|
+
* @return {Function}
|
10
|
+
* @api public
|
11
|
+
*/
|
12
|
+
|
13
|
+
exports.bind = function(el, type, fn, capture){
|
14
|
+
if (el.addEventListener) {
|
15
|
+
el.addEventListener(type, fn, capture || false);
|
16
|
+
} else {
|
17
|
+
el.attachEvent('on' + type, fn);
|
18
|
+
}
|
19
|
+
return fn;
|
20
|
+
};
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Unbind `el` event `type`'s callback `fn`.
|
24
|
+
*
|
25
|
+
* @param {Element} el
|
26
|
+
* @param {String} type
|
27
|
+
* @param {Function} fn
|
28
|
+
* @param {Boolean} capture
|
29
|
+
* @return {Function}
|
30
|
+
* @api public
|
31
|
+
*/
|
32
|
+
|
33
|
+
exports.unbind = function(el, type, fn, capture){
|
34
|
+
if (el.removeEventListener) {
|
35
|
+
el.removeEventListener(type, fn, capture || false);
|
36
|
+
} else {
|
37
|
+
el.detachEvent('on' + type, fn);
|
38
|
+
}
|
39
|
+
return fn;
|
40
|
+
};
|