dou-rails 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,783 +1,902 @@
1
- /*! dou - v0.0.2 - 2014-02-25
2
- * https://github.com/heartyoh/dou
3
- * Copyright (c) 2014 Hearty, Oh.; Licensed MIT */
4
- (function() {
5
- define(['./compose'], function(compose) {
6
- "use strict";
7
- var advice;
8
- advice = {
9
- around: function(base, wrapped) {
10
- return function() {
11
- var args, el, i, l, _i, _len;
12
- l = arguments.length;
13
- args = new Array(l + 1);
14
- args[0] = base.bind(this);
15
- for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
16
- el = args[i];
17
- args[i + 1] = arguments[i];
18
- }
19
- return wrapped.apply(this, args);
20
- };
21
- },
22
- before: function(base, before) {
23
- var beforeFn;
24
- beforeFn = typeof before === 'function' ? before : before.obj[before.fnName];
25
- return function() {
26
- beforeFn.apply(this, arguments);
27
- return base.apply(this, arguments);
28
- };
29
- },
30
- after: function(base, after) {
31
- var afterFn;
32
- afterFn = (typeof after === 'function' ? after : after.obj[after.fnName]);
33
- return function() {
34
- var res;
35
- res = (base.unbound || base).apply(this, arguments);
36
- afterFn.apply(this, arguments);
37
- return res;
38
- };
39
- },
40
- withAdvice: function() {
41
- return ['before', 'after', 'around'].forEach(function(m) {
42
- return this[m] = function(method, fn) {
43
- return compose.unlockProperty(this, method, function() {
44
- if (typeof this[method] === 'function') {
45
- this[method] = advice[m](this[method], fn);
46
- } else {
47
- this[method] = fn;
48
- }
49
- return this[method];
50
- });
51
- };
52
- }, this);
53
- }
54
- };
55
- return advice;
56
- });
57
-
58
- }).call(this);
59
-
60
- (function() {
61
- var __hasProp = {}.hasOwnProperty;
1
+ /*! Dou v0.0.3 | (c) Hatio, Lab. | MIT License */
2
+ (function(context) {
3
+ var factories = {}, loaded = {};
4
+ var isArray = Array.isArray || function(obj) {
5
+ return obj.constructor == Array;
6
+ };
62
7
 
63
- define(['./utils', './debug'], function(utils, debug) {
64
- "use strict";
65
- var canWriteProtect, dontLock, e, mixin, setPropertyWritability, unlockProperty;
66
- canWriteProtect = debug.enabled && !utils.isEnumerable(Object, 'getOwnPropertyDescriptor');
67
- dontLock = ['mixedIn', 'mixingIn'];
68
- if (canWriteProtect) {
69
- try {
70
- Object.getOwnPropertyDescriptor(Object, 'keys');
71
- } catch (_error) {
72
- e = _error;
73
- canWriteProtect = false;
74
- }
8
+ var map = Array.map || function(arr, fn, scope) {
9
+ for (var i = 0, len = arr.length, result = []; i < len; i++) {
10
+ result.push(fn.call(scope, arr[i]));
75
11
  }
76
- setPropertyWritability = function(obj, isWritable) {
77
- var desc, key, props;
78
- if (!canWriteProtect) {
79
- return;
80
- }
81
- props = Object.create(null);
82
- for (key in obj) {
83
- if (!__hasProp.call(obj, key)) continue;
84
- if (dontLock.indexOf(key < 0)) {
85
- desc = Object.getOwnPropertyDescriptor(obj, key);
86
- desc.writable = isWritable;
87
- props[key] = desc;
88
- }
89
- }
90
- return Object.defineProperties(obj, props);
91
- };
92
- unlockProperty = function(obj, prop, op) {
93
- var writable;
94
- if (!canWriteProtect || !obj.hasOwnProperty(prop)) {
95
- return op.call(obj);
96
- }
97
- writable = Object.getOwnPropertyDescriptor(obj, prop).writable;
98
- Object.defineProperties(obj, prop, {
99
- writable: true
100
- });
101
- op.call(obj);
102
- return Object.defineProperties(obj, prop, {
103
- writable: writable
104
- });
105
- };
106
- mixin = function(base, mixins) {
107
- var _i, _len;
108
- if (!(mixins instanceof Array)) {
109
- return this.mixin(base, [mixins]);
110
- }
111
- base.mixedIn = base.hasOwnProperty('mixedIn') ? base.mixedIn : [];
112
- base.mixingIn = base.hasOwnProperty('mixingIn') ? base.mixingIn : [];
113
- setPropertyWritability(base, false);
114
- for (_i = 0, _len = mixins.length; _i < _len; _i++) {
115
- mixin = mixins[_i];
116
- if (!(base.mixedIn.indexOf(mixin) === -1)) {
117
- continue;
118
- }
119
- if (base.mixingIn.indexOf(mixin) > -1) {
120
- throw new Error('found cyclic dependencies between ' + base.mixingIn);
121
- }
122
- base.mixingIn.push(mixin);
123
- mixin.call(base);
124
- base.mixingIn.pop();
125
- base.mixedIn.push(mixin);
126
- }
127
- return setPropertyWritability(base, true);
128
- };
129
- return {
130
- mixin: mixin,
131
- unlockProperty: unlockProperty
132
- };
133
- });
134
-
135
- }).call(this);
12
+ return result;
13
+ };
136
14
 
137
- (function() {
138
- var __hasProp = {}.hasOwnProperty;
15
+ function define() {
16
+ var args = Array.prototype.slice.call(arguments), dependencies = [], id, factory;
17
+ if (typeof args[0] == 'string') {
18
+ id = args.shift();
19
+ }
20
+ if (isArray(args[0])) {
21
+ dependencies = args.shift();
22
+ }
23
+ factory = args.shift();
24
+ factories[id] = [dependencies, factory];
25
+ }
139
26
 
140
- define([], function() {
141
- "use strict";
142
- var ALL, byName, byNameContains, byType, byValue, byValueCoerced, custom, defaultActionsFilter, defaultEventNamesFilter, filterEventLogsByAction, filterEventLogsByName, global, hideAllEventLogs, logFilter, retrieveLogFilter, saveLogFilter, search, showAllEventLogs, tests, traverse;
143
- global = typeof window === 'undefined' ? {} : window;
144
- traverse = function(comparator, clue, options) {
145
- var obj, path, prop, _results;
146
- options = options || {};
147
- obj = options.obj || global;
148
- path = options.path || (obj === global ? 'global' : '');
149
- _results = [];
150
- for (prop in obj) {
151
- if (!__hasProp.call(obj, prop)) continue;
152
- if ((tests[comparator] || comparator)(clue, obj, prop)) {
153
- console.log("" + path + "." + prop + " -> (" + (typeof obj[prop]) + ")", obj[prop]);
154
- }
155
- if (obj[prop] && typeof obj[prop] === 'object' && obj[prop] !== obj) {
156
- _results.push(traverse(comparator, clue, {
157
- obj: obj[prop],
158
- path: "" + path + "." + prop
159
- }));
160
- } else {
161
- _results.push(void 0);
162
- }
27
+ function require(id) {
28
+ function resolve(dep) {
29
+ var relativeParts = id.split('/'), depParts = dep.split('/'), relative = false;
30
+ relativeParts.pop();
31
+ while (depParts[0] == '..' && relativeParts.length) {
32
+ relativeParts.pop();
33
+ depParts.shift();
34
+ relative = true;
163
35
  }
164
- return _results;
165
- };
166
- search = function(comparator, expected, clue, options) {
167
- if (!expected || typeof clue === expected) {
168
- return traverse(comparator, clue, options);
169
- } else {
170
- return console.error("" + clue + " must be " + expected);
36
+ if (depParts[0] == '.') {
37
+ depParts.shift();
38
+ relative = true;
171
39
  }
172
- };
173
- tests = {
174
- name: function(clue, obj, prop) {
175
- return clue === prop;
176
- },
177
- nameContains: function(clue, obj, prop) {
178
- return prop.indexOf(clue) > -1;
179
- },
180
- type: function(clue, obj, prop) {
181
- return obj[prop] instanceof clue;
182
- },
183
- value: function(clue, obj, prop) {
184
- return obj[prop] === clue;
185
- },
186
- valueCoerced: function(clue, obj, prop) {
187
- return obj[prop] == clue;
188
- }
189
- };
190
- byName = function(clue, options) {
191
- return search('name', 'string', clue, options);
192
- };
193
- byNameContains = function(clue, options) {
194
- return search('nameContains', 'string', clue, options);
195
- };
196
- byType = function(clue, options) {
197
- return search('type', 'function', clue, options);
198
- };
199
- byValue = function(clue, options) {
200
- return search('value', null, clue, options);
201
- };
202
- byValueCoerced = function(clue, options) {
203
- return search('valueCoerced', null, clue, options);
204
- };
205
- custom = function(comparator, options) {
206
- return traverse(comparator, null, options);
207
- };
208
- filterEventLogsByAction = function() {
209
- var actions;
210
- actions = [].slice.call(arguments);
211
- logFilter.eventNames.length || (logFilter.eventNames = ALL);
212
- logFilter.actions = actions.length ? actions : ALL;
213
- return saveLogFilter();
214
- };
215
- filterEventLogsByName = function() {
216
- var eventNames;
217
- eventNames = [].slice.call(arguments);
218
- logFilter.actions.length || (logFilter.actions = ALL);
219
- logFilter.eventNames = eventNames.length ? eventNames : ALL;
220
- return saveLogFilter();
221
- };
222
- hideAllEventLogs = function() {
223
- logFilter.actions = [];
224
- logFilter.eventNames = [];
225
- return saveLogFilter();
226
- };
227
- showAllEventLogs = function() {
228
- logFilter.actions = ALL;
229
- logFilter.eventNames = ALL;
230
- return saveLogFilter();
231
- };
232
- saveLogFilter = function() {
233
- if (global.localStorage) {
234
- global.localStorage.setItem('logFilter_eventNames', logFilter.eventNames);
235
- return global.localStorage.setItem('logFilter_actions', logFilter.actions);
236
- }
237
- };
238
- retrieveLogFilter = function() {
239
- var key, result, value;
240
- result = {
241
- eventNames: (global.localStorage && global.localStorage.getItem('logFilter_eventNames')) || defaultEventNamesFilter,
242
- actions: (global.localStorage && global.localStorage.getItem('logFilter_actions')) || defaultActionsFilter
243
- };
244
- for (key in result) {
245
- if (!__hasProp.call(result, key)) continue;
246
- value = result[key];
247
- if (typeof value === 'string' && value !== ALL) {
248
- result[key] = value.split('.');
249
- }
250
- }
251
- return result;
252
- };
253
- ALL = 'all';
254
- defaultEventNamesFilter = [];
255
- defaultActionsFilter = [];
256
- logFilter = retrieveLogFilter();
257
- return {
258
- enable: function(enable) {
259
- this.enabled = !!enable;
260
- if (enable && global.console) {
261
- console.info('Booting in DEBUG mode');
262
- console.info('You can configure event logging with DEBUG.events.logAll()/logNone()/logByName()/logByAction()');
263
- }
264
- return global.DEBUG = this;
265
- },
266
- find: {
267
- byName: byName,
268
- byNameContains: byNameContains,
269
- byType: byType,
270
- byValue: byValue,
271
- byValueCoerced: byValueCoerced,
272
- custom: custom
273
- },
274
- events: {
275
- logFilter: logFilter,
276
- logByAction: filterEventLogsByAction,
277
- logByName: filterEventLogsByName,
278
- logAll: showAllEventLogs,
279
- logNone: hideAllEventLogs
40
+ if (relative) {
41
+ depParts = relativeParts.concat(depParts);
280
42
  }
281
- };
282
- });
283
-
284
- }).call(this);
285
-
286
- (function() {
287
- var __hasProp = {}.hasOwnProperty,
288
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
289
-
290
- define(['./compose'], function(compose) {
291
- "use strict";
292
- var define;
293
- define = function(options) {
294
- var Component;
295
- if (options["extends"]) {
296
- Component = (function(_super) {
297
- __extends(Component, _super);
298
-
299
- function Component() {
300
- return Component.__super__.constructor.apply(this, arguments);
301
- }
302
-
303
- return Component;
304
-
305
- })(options["extends"]);
306
- } else {
307
- Component = (function() {
308
- function Component() {}
309
-
310
- return Component;
43
+ return depParts.join('/');
44
+ }
311
45
 
312
- })();
313
- }
314
- if (options.mixins) {
315
- compose.mixin(Component.prototype, options.mixins);
46
+ var unresolved, factory, dependencies;
47
+ if (typeof loaded[id] == 'undefined') {
48
+ unresolved = factories[id];
49
+ if (unresolved) {
50
+ dependencies = unresolved[0];
51
+ factory = unresolved[1];
52
+ loaded[id] = factory.apply(undefined, map(dependencies, function(id) {
53
+ return require(resolve(id));
54
+ }));
316
55
  }
317
- if (options.name) {
318
- Component.name = options.name;
319
- }
320
- return Component;
321
- };
322
- return {
323
- define: define
324
- };
325
- });
56
+ }
326
57
 
327
- }).call(this);
58
+ return loaded[id];
59
+ }
328
60
 
329
- (function() {
330
- define(['./utils'], function(utils) {
331
- "use strict";
332
- var Event, eventSplitter, eventsApi, implementation, listenMethods, method, slice, triggerEvents;
333
- slice = [].slice;
334
- Event = {
335
- withEvent: function() {
336
- var method, _i, _len, _ref, _results;
337
- _ref = ['on', 'off', 'once', 'trigger'];
338
- _results = [];
339
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
340
- method = _ref[_i];
341
- _results.push(this[method] = Event[method]);
342
- }
343
- return _results;
344
- },
345
- on: function(name, callback, context) {
346
- var events;
347
- if (!eventsApi(this, 'on', name, [callback, context]) || !callback) {
348
- return this;
349
- }
350
- this._events || (this._events = {});
351
- events = this._events[name] || (this._events[name] = []);
352
- events.push({
353
- callback: callback,
354
- context: context,
355
- ctx: context || this
356
- });
357
- return this;
358
- },
359
- once: function(name, callback, context) {
360
- var once, self;
361
- if (!eventsApi(this, 'once', name, [callback, context]) || !callback) {
362
- return this;
363
- }
364
- self = this;
365
- once = utils.once(function() {
366
- self.off(name, once);
367
- return callback.apply(this, arguments);
368
- });
369
- once._callback = callback;
370
- return this.on(name, once, context);
371
- },
372
- off: function(name, callback, context) {
373
- var ev, events, i, j, names, retain, _i, _j, _len, _len1;
374
- if (!this._events || !eventsApi(this, 'off', name, [callback, context])) {
375
- return this;
376
- }
377
- if (!name && !callback && !context) {
378
- this._events = void 0;
379
- return this;
380
- }
381
- names = name ? [name] : Object.keys(this._events);
382
- for (i = _i = 0, _len = names.length; _i < _len; i = ++_i) {
383
- name = names[i];
384
- if ((events = this._events[name])) {
385
- this._events[name] = retain = [];
386
- if (callback || context) {
387
- for (j = _j = 0, _len1 = events.length; _j < _len1; j = ++_j) {
388
- ev = events[j];
389
- if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || (context && context !== ev.context)) {
390
- retain.push(ev);
391
- }
392
- }
61
+ (function () {
62
+ var __slice = [].slice, __hasProp = {}.hasOwnProperty;
63
+ define('build/js/utils', [], function () {
64
+ 'use strict';
65
+ var DEFAULT_INTERVAL, idCounter;
66
+ DEFAULT_INTERVAL = 100;
67
+ idCounter = 0;
68
+ return {
69
+ merge: function () {
70
+ var extenders, key, other, target, val, _i, _len;
71
+ target = arguments[0], extenders = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
72
+ if (!target || typeof target === !'object') {
73
+ target = {};
74
+ }
75
+ for (_i = 0, _len = extenders.length; _i < _len; _i++) {
76
+ other = extenders[_i];
77
+ for (key in other) {
78
+ if (!__hasProp.call(other, key))
79
+ continue;
80
+ val = other[key];
81
+ if (typeof val !== 'object') {
82
+ target[key] = val;
83
+ } else {
84
+ target[key] = this.merge(target[key], val);
85
+ }
86
+ }
87
+ }
88
+ return target;
89
+ },
90
+ push: function (base, extra, protect) {
91
+ var key, val;
92
+ if (!base || !extra) {
93
+ return base;
94
+ }
95
+ for (key in extra) {
96
+ if (!__hasProp.call(extra, key))
97
+ continue;
98
+ val = extra[key];
99
+ if (base[key] && protect) {
100
+ throw new Error('utils.push attempted to overwrite "' + key + '" while running in protected mode');
101
+ }
102
+ if (typeof base[key] === 'object' && typeof extra[key] === 'object') {
103
+ this.push(base[key], extra[key]);
104
+ } else {
105
+ base[key] = extra[key];
106
+ }
107
+ }
108
+ return base;
109
+ },
110
+ isEnumerable: function (obj, property) {
111
+ return Object.keys(obj).indexOf(property) > -1;
112
+ },
113
+ compose: function () {
114
+ var funcs;
115
+ funcs = arguments;
116
+ return function () {
117
+ var args, i, _i, _ref;
118
+ args = arguments;
119
+ for (i = _i = _ref = funcs.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) {
120
+ args = funcs[i].apply(this, args);
121
+ }
122
+ return args[0];
123
+ };
124
+ },
125
+ uniqueArray: function (array) {
126
+ var a, item, u, _i, _len;
127
+ u = {};
128
+ a = [];
129
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
130
+ item = array[_i];
131
+ if (u.hasOwnProperty(item)) {
132
+ continue;
133
+ }
134
+ a.push(item);
135
+ u[item] = 1;
136
+ }
137
+ return a;
138
+ },
139
+ debounce: function (func, wait, immediate) {
140
+ var result, timeout;
141
+ if (typeof wait !== 'number') {
142
+ wait = DEFAULT_INTERVAL;
143
+ }
144
+ timeout = 0;
145
+ result = null;
146
+ return function () {
147
+ var args, callNow, context, later;
148
+ context = this;
149
+ args = arguments;
150
+ later = function () {
151
+ timeout = null;
152
+ if (!immediate) {
153
+ return result = func.apply(context, args);
154
+ }
155
+ };
156
+ callNow = immediate && !timeout;
157
+ clearTimeout(timeout);
158
+ timeout = setTimeout(later, wait);
159
+ if (callNow) {
160
+ result = func.apply(context, args);
161
+ }
162
+ return result;
163
+ };
164
+ },
165
+ throttle: function (func, wait) {
166
+ var args, context, more, result, throttling, timeout, whenDone;
167
+ if (typeof wait !== 'number') {
168
+ wait = DEFAULT_INTERVAL;
169
+ }
170
+ context = args = timeout = throttling = more = result = null;
171
+ whenDone = this.debounce(function () {
172
+ return more = throttling = false;
173
+ }, wait);
174
+ return function () {
175
+ var later;
176
+ context = this;
177
+ args = arguments;
178
+ later = function () {
179
+ timeout = null;
180
+ if (more) {
181
+ result = func.apply(context, args);
182
+ }
183
+ return whenDone();
184
+ };
185
+ if (!timeout) {
186
+ timeout = setTimeout(later, wait);
187
+ }
188
+ if (throttling) {
189
+ more = true;
190
+ } else {
191
+ throttling = true;
192
+ result = func.apply(context, args);
193
+ }
194
+ whenDone();
195
+ return result;
196
+ };
197
+ },
198
+ countThen: function (num, base) {
199
+ return function () {
200
+ if (!--num) {
201
+ return base.apply(this, arguments);
202
+ }
203
+ };
204
+ },
205
+ delegate: function (rules) {
206
+ return function (e, data) {
207
+ var parent, selector, target;
208
+ target = $(e.target);
209
+ parent = null;
210
+ for (selector in rules) {
211
+ if (!__hasProp.call(rules, selector))
212
+ continue;
213
+ if (!e.isPropagationStopped() && (parent = target.closest(selector)).length) {
214
+ data = data || {};
215
+ data.el = parent[0];
216
+ return rules[selector].apply(this, [
217
+ e,
218
+ data
219
+ ]);
220
+ }
221
+ }
222
+ };
223
+ },
224
+ once: function (func) {
225
+ var ran, result;
226
+ ran = false;
227
+ result = null;
228
+ return function () {
229
+ if (ran) {
230
+ return result;
231
+ }
232
+ result = func.apply(this, arguments);
233
+ ran = true;
234
+ return result;
235
+ };
236
+ },
237
+ uniqueId: function (prefix) {
238
+ var id;
239
+ id = ++idCounter + '';
240
+ if (prefix) {
241
+ return prefix + id;
242
+ } else {
243
+ return id;
244
+ }
393
245
  }
394
- if (!retain.length) {
395
- delete this._events[name];
246
+ };
247
+ });
248
+ }.call(this));
249
+ (function () {
250
+ var __hasProp = {}.hasOwnProperty;
251
+ define('build/js/debug', [], function () {
252
+ 'use strict';
253
+ var ALL, byName, byNameContains, byType, byValue, byValueCoerced, custom, defaultActionsFilter, defaultEventNamesFilter, filterEventLogsByAction, filterEventLogsByName, global, hideAllEventLogs, logFilter, retrieveLogFilter, saveLogFilter, search, showAllEventLogs, tests, traverse;
254
+ global = typeof window === 'undefined' ? {} : window;
255
+ traverse = function (comparator, clue, options) {
256
+ var obj, path, prop, _results;
257
+ options = options || {};
258
+ obj = options.obj || global;
259
+ path = options.path || (obj === global ? 'global' : '');
260
+ _results = [];
261
+ for (prop in obj) {
262
+ if (!__hasProp.call(obj, prop))
263
+ continue;
264
+ if ((tests[comparator] || comparator)(clue, obj, prop)) {
265
+ console.log('' + path + '.' + prop + ' -> (' + typeof obj[prop] + ')', obj[prop]);
266
+ }
267
+ if (obj[prop] && typeof obj[prop] === 'object' && obj[prop] !== obj) {
268
+ _results.push(traverse(comparator, clue, {
269
+ obj: obj[prop],
270
+ path: '' + path + '.' + prop
271
+ }));
272
+ } else {
273
+ _results.push(void 0);
274
+ }
396
275
  }
397
- }
398
- }
399
- return this;
400
- },
401
- trigger: function(name) {
402
- var allEvents, args, events;
403
- if (!this._events) {
404
- return this;
405
- }
406
- args = slice.call(arguments, 1);
407
- if (!eventsApi(this, 'trigger', name, args)) {
408
- return this;
409
- }
410
- events = this._events[name];
411
- allEvents = this._events.all;
412
- if (events) {
413
- triggerEvents(events, args);
414
- }
415
- if (allEvents) {
416
- triggerEvents(allEvents, arguments);
417
- }
418
- return this;
419
- },
420
- stopListening: function(obj, name, callback) {
421
- var id, listeningTo, remove;
422
- listeningTo = this._listeningTo;
423
- if (!listeningTo) {
424
- return this;
425
- }
426
- remove = !name && !callback;
427
- if (!callback && typeof name === 'object') {
428
- callback = this;
429
- }
430
- if (obj) {
431
- (listeningTo = {})[obj._listenId] = obj;
432
- }
433
- for (id in listeningTo) {
434
- obj = listeningTo[id];
435
- obj.off(name, callback, this);
436
- if (remove || _.isEmpty(obj._events)) {
437
- delete this._listeningTo[id];
438
- }
439
- }
440
- return this;
441
- }
442
- };
443
- eventSplitter = /\s+/;
444
- eventsApi = function(obj, action, name, rest) {
445
- var key, names, val, _i, _len;
446
- if (!name) {
447
- return true;
448
- }
449
- if (typeof name === 'object') {
450
- for (key in name) {
451
- val = name[key];
452
- obj[action].apply(obj, [key, val].concat(rest));
453
- }
454
- return false;
455
- }
456
- if (eventSplitter.test(name)) {
457
- names = name.split(eventSplitter);
458
- for (_i = 0, _len = names.length; _i < _len; _i++) {
459
- val = names[_i];
460
- obj[action].apply(obj, [val].concat(rest));
461
- }
462
- return false;
463
- }
464
- return true;
465
- };
466
- triggerEvents = function(events, args) {
467
- var ev, _i, _len, _results;
468
- _results = [];
469
- for (_i = 0, _len = events.length; _i < _len; _i++) {
470
- ev = events[_i];
471
- _results.push(ev.callback.apply(ev.ctx, args));
472
- }
473
- return _results;
474
- };
475
- listenMethods = {
476
- listenTo: 'on',
477
- listenToOnce: 'once'
478
- };
479
- for (method in listenMethods) {
480
- implementation = listenMethods[method];
481
- Event[method] = function(obj, name, callback) {
482
- var id, listeningTo;
483
- listeningTo = this._listeningTo || (this._listeningTo = {});
484
- id = obj._listenId || (obj._listenId = utils.uniqueId('l'));
485
- listeningTo[id] = obj;
486
- if (!callback && typeof name === 'object') {
487
- callback = this;
488
- }
489
- obj[implementation](name, callback, this);
490
- return this;
491
- };
492
- }
493
- return Event;
494
- });
495
-
496
- }).call(this);
497
-
498
- (function() {
499
- var __hasProp = {}.hasOwnProperty;
500
-
501
- define(['./compose', './property'], function(compose, withProperty) {
502
- "use strict";
503
- return function() {
504
- compose.mixin(this, withProperty);
505
- this.initialize = function(attrs) {
506
- var cloned, key, val, _ref;
507
- attrs || (attrs = {});
508
- cloned = {};
509
- for (key in attrs) {
510
- if (!__hasProp.call(attrs, key)) continue;
511
- val = attrs[key];
512
- cloned[key] = val;
513
- }
514
- _ref = this.defaults;
515
- for (key in _ref) {
516
- if (!__hasProp.call(_ref, key)) continue;
517
- val = _ref[key];
518
- if (!cloned.hasOwnProperty(key)) {
519
- cloned[key] = val;
520
- }
521
- }
522
- this.set(cloned);
523
- return this;
524
- };
525
- return this.despose = function() {};
526
- };
527
- });
528
-
529
- }).call(this);
530
-
531
- (function() {
532
- var __hasProp = {}.hasOwnProperty;
533
-
534
- define(['./utils', './compose', './event'], function(utils, compose, event) {
535
- "use strict";
536
- return function() {
537
- compose.mixin(this, event.withEvent);
538
- this.set = function(key, val) {
539
- var after, attrs, before, _ref, _ref1;
540
- if (!key) {
541
- return this;
542
- }
543
- if (arguments.length > 1 && typeof arguments[0] === 'string') {
544
- attrs = {};
545
- attrs[key] = val;
546
- return this.set(attrs);
547
- }
548
- this.attrs || (this.attrs = {});
549
- attrs = key;
550
- after = {};
551
- before = {};
552
- _ref = this.attrs;
553
- for (key in _ref) {
554
- if (!__hasProp.call(_ref, key)) continue;
555
- val = _ref[key];
556
- before[key] = val;
557
- }
558
- utils.push(this.attrs, attrs);
559
- _ref1 = this.attrs;
560
- for (key in _ref1) {
561
- if (!__hasProp.call(_ref1, key)) continue;
562
- val = _ref1[key];
563
- if (val !== before[key]) {
564
- after[key] = val;
565
- } else {
566
- delete before[key];
567
- }
568
- }
569
- if (Object.keys(after).length !== 0) {
570
- this.trigger('change', {
571
- before: before,
572
- after: after
573
- }, true);
574
- }
575
- return this;
576
- };
577
- return this.get = function(attr) {
578
- return this.attrs && this.attrs[attr];
579
- };
580
- };
581
- });
582
-
583
- }).call(this);
584
-
585
- (function() {
586
- define(['./compose', './property'], function(compose, withProperty) {
587
- "use strict";
588
- return function() {
589
- compose.mixin(this, withProperty);
590
- this.serialize = function() {
591
- return ["type: " + this.name, "id: " + this.id, "props: " + (JSON.stringify(this.attrs))].join(',');
592
- };
593
- return this.deserialize = function() {};
594
- };
595
- });
596
-
597
- }).call(this);
598
-
599
- (function() {
600
- var __slice = [].slice,
601
- __hasProp = {}.hasOwnProperty;
602
-
603
- define([], function() {
604
- "use strict";
605
- var DEFAULT_INTERVAL, idCounter;
606
- DEFAULT_INTERVAL = 100;
607
- idCounter = 0;
608
- return {
609
- merge: function() {
610
- var extenders, key, other, target, val, _i, _len;
611
- target = arguments[0], extenders = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
612
- if (!target || typeof target === !"object") {
613
- target = {};
614
- }
615
- for (_i = 0, _len = extenders.length; _i < _len; _i++) {
616
- other = extenders[_i];
617
- for (key in other) {
618
- if (!__hasProp.call(other, key)) continue;
619
- val = other[key];
620
- if (typeof val !== "object") {
621
- target[key] = val;
276
+ return _results;
277
+ };
278
+ search = function (comparator, expected, clue, options) {
279
+ if (!expected || typeof clue === expected) {
280
+ return traverse(comparator, clue, options);
622
281
  } else {
623
- target[key] = this.merge(target[key], val);
282
+ return console.error('' + clue + ' must be ' + expected);
624
283
  }
625
- }
626
- }
627
- return target;
628
- },
629
- push: function(base, extra, protect) {
630
- var key, val;
631
- if (!base || !extra) {
632
- return base;
633
- }
634
- for (key in extra) {
635
- if (!__hasProp.call(extra, key)) continue;
636
- val = extra[key];
637
- if (base[key] && protect) {
638
- throw new Error("utils.push attempted to overwrite \"" + key + "\" while running in protected mode");
639
- }
640
- if (typeof base[key] === "object" && typeof extra[key] === "object") {
641
- this.push(base[key], extra[key]);
642
- } else {
643
- base[key] = extra[key];
644
- }
645
- }
646
- return base;
647
- },
648
- isEnumerable: function(obj, property) {
649
- return Object.keys(obj).indexOf(property) > -1;
650
- },
651
- compose: function() {
652
- var funcs;
653
- funcs = arguments;
654
- return function() {
655
- var args, i, _i, _ref;
656
- args = arguments;
657
- for (i = _i = _ref = funcs.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) {
658
- args = funcs[i].apply(this, args);
659
- }
660
- return args[0];
661
- };
662
- },
663
- uniqueArray: function(array) {
664
- var a, item, u, _i, _len;
665
- u = {};
666
- a = [];
667
- for (_i = 0, _len = array.length; _i < _len; _i++) {
668
- item = array[_i];
669
- if (u.hasOwnProperty(item)) {
670
- continue;
671
- }
672
- a.push(item);
673
- u[item] = 1;
674
- }
675
- return a;
676
- },
677
- debounce: function(func, wait, immediate) {
678
- var result, timeout;
679
- if (typeof wait !== 'number') {
680
- wait = DEFAULT_INTERVAL;
681
- }
682
- timeout = 0;
683
- result = null;
684
- return function() {
685
- var args, callNow, context, later;
686
- context = this;
687
- args = arguments;
688
- later = function() {
689
- timeout = null;
690
- if (!immediate) {
691
- return result = func.apply(context, args);
284
+ };
285
+ tests = {
286
+ name: function (clue, obj, prop) {
287
+ return clue === prop;
288
+ },
289
+ nameContains: function (clue, obj, prop) {
290
+ return prop.indexOf(clue) > -1;
291
+ },
292
+ type: function (clue, obj, prop) {
293
+ return obj[prop] instanceof clue;
294
+ },
295
+ value: function (clue, obj, prop) {
296
+ return obj[prop] === clue;
297
+ },
298
+ valueCoerced: function (clue, obj, prop) {
299
+ return obj[prop] == clue;
692
300
  }
693
- };
694
- callNow = immediate && !timeout;
695
- clearTimeout(timeout);
696
- timeout = setTimeout(later, wait);
697
- if (callNow) {
698
- result = func.apply(context, args);
699
- }
700
- return result;
701
- };
702
- },
703
- throttle: function(func, wait) {
704
- var args, context, more, result, throttling, timeout, whenDone;
705
- if (typeof wait !== 'number') {
706
- wait = DEFAULT_INTERVAL;
707
- }
708
- context = args = timeout = throttling = more = result = null;
709
- whenDone = this.debounce(function() {
710
- return more = throttling = false;
711
- }, wait);
712
- return function() {
713
- var later;
714
- context = this;
715
- args = arguments;
716
- later = function() {
717
- timeout = null;
718
- if (more) {
719
- result = func.apply(context, args);
301
+ };
302
+ byName = function (clue, options) {
303
+ return search('name', 'string', clue, options);
304
+ };
305
+ byNameContains = function (clue, options) {
306
+ return search('nameContains', 'string', clue, options);
307
+ };
308
+ byType = function (clue, options) {
309
+ return search('type', 'function', clue, options);
310
+ };
311
+ byValue = function (clue, options) {
312
+ return search('value', null, clue, options);
313
+ };
314
+ byValueCoerced = function (clue, options) {
315
+ return search('valueCoerced', null, clue, options);
316
+ };
317
+ custom = function (comparator, options) {
318
+ return traverse(comparator, null, options);
319
+ };
320
+ filterEventLogsByAction = function () {
321
+ var actions;
322
+ actions = [].slice.call(arguments);
323
+ logFilter.eventNames.length || (logFilter.eventNames = ALL);
324
+ logFilter.actions = actions.length ? actions : ALL;
325
+ return saveLogFilter();
326
+ };
327
+ filterEventLogsByName = function () {
328
+ var eventNames;
329
+ eventNames = [].slice.call(arguments);
330
+ logFilter.actions.length || (logFilter.actions = ALL);
331
+ logFilter.eventNames = eventNames.length ? eventNames : ALL;
332
+ return saveLogFilter();
333
+ };
334
+ hideAllEventLogs = function () {
335
+ logFilter.actions = [];
336
+ logFilter.eventNames = [];
337
+ return saveLogFilter();
338
+ };
339
+ showAllEventLogs = function () {
340
+ logFilter.actions = ALL;
341
+ logFilter.eventNames = ALL;
342
+ return saveLogFilter();
343
+ };
344
+ saveLogFilter = function () {
345
+ if (global.localStorage) {
346
+ global.localStorage.setItem('logFilter_eventNames', logFilter.eventNames);
347
+ return global.localStorage.setItem('logFilter_actions', logFilter.actions);
720
348
  }
721
- return whenDone();
722
- };
723
- if (!timeout) {
724
- timeout = setTimeout(later, wait);
725
- }
726
- if (throttling) {
727
- more = true;
728
- } else {
729
- throttling = true;
730
- result = func.apply(context, args);
731
- }
732
- whenDone();
733
- return result;
734
- };
735
- },
736
- countThen: function(num, base) {
737
- return function() {
738
- if (!--num) {
739
- return base.apply(this, arguments);
740
- }
741
- };
742
- },
743
- delegate: function(rules) {
744
- return function(e, data) {
745
- var parent, selector, target;
746
- target = $(e.target);
747
- parent = null;
748
- for (selector in rules) {
749
- if (!__hasProp.call(rules, selector)) continue;
750
- if (!e.isPropagationStopped() && (parent = target.closest(selector)).length) {
751
- data = data || {};
752
- data.el = parent[0];
753
- return rules[selector].apply(this, [e, data]);
349
+ };
350
+ retrieveLogFilter = function () {
351
+ var key, result, value;
352
+ result = {
353
+ eventNames: global.localStorage && global.localStorage.getItem('logFilter_eventNames') || defaultEventNamesFilter,
354
+ actions: global.localStorage && global.localStorage.getItem('logFilter_actions') || defaultActionsFilter
355
+ };
356
+ for (key in result) {
357
+ if (!__hasProp.call(result, key))
358
+ continue;
359
+ value = result[key];
360
+ if (typeof value === 'string' && value !== ALL) {
361
+ result[key] = value.split('.');
362
+ }
754
363
  }
755
- }
756
- };
757
- },
758
- once: function(func) {
759
- var ran, result;
760
- ran = false;
761
- result = null;
762
- return function() {
763
- if (ran) {
764
364
  return result;
765
- }
766
- result = func.apply(this, arguments);
767
- ran = true;
768
- return result;
769
- };
770
- },
771
- uniqueId: function(prefix) {
772
- var id;
773
- id = (++idCounter) + '';
774
- if (prefix) {
775
- return prefix + id;
776
- } else {
777
- return id;
365
+ };
366
+ ALL = 'all';
367
+ defaultEventNamesFilter = [];
368
+ defaultActionsFilter = [];
369
+ logFilter = retrieveLogFilter();
370
+ return {
371
+ enable: function (enable) {
372
+ this.enabled = !!enable;
373
+ if (enable && global.console) {
374
+ console.info('Booting in DEBUG mode');
375
+ console.info('You can configure event logging with DEBUG.events.logAll()/logNone()/logByName()/logByAction()');
376
+ }
377
+ return global.DEBUG = this;
378
+ },
379
+ find: {
380
+ byName: byName,
381
+ byNameContains: byNameContains,
382
+ byType: byType,
383
+ byValue: byValue,
384
+ byValueCoerced: byValueCoerced,
385
+ custom: custom
386
+ },
387
+ events: {
388
+ logFilter: logFilter,
389
+ logByAction: filterEventLogsByAction,
390
+ logByName: filterEventLogsByName,
391
+ logAll: showAllEventLogs,
392
+ logNone: hideAllEventLogs
393
+ }
394
+ };
395
+ });
396
+ }.call(this));
397
+ (function () {
398
+ var __hasProp = {}.hasOwnProperty;
399
+ define('build/js/compose', [
400
+ './utils',
401
+ './debug'
402
+ ], function (utils, debug) {
403
+ 'use strict';
404
+ var canWriteProtect, dontLock, e, mixin, setPropertyWritability, unlockProperty;
405
+ canWriteProtect = debug.enabled && !utils.isEnumerable(Object, 'getOwnPropertyDescriptor');
406
+ dontLock = [
407
+ 'mixedIn',
408
+ 'mixingIn'
409
+ ];
410
+ if (canWriteProtect) {
411
+ try {
412
+ Object.getOwnPropertyDescriptor(Object, 'keys');
413
+ } catch (_error) {
414
+ e = _error;
415
+ canWriteProtect = false;
416
+ }
778
417
  }
779
- }
780
- };
781
- });
418
+ setPropertyWritability = function (obj, isWritable) {
419
+ var desc, key, props;
420
+ if (!canWriteProtect) {
421
+ return;
422
+ }
423
+ props = Object.create(null);
424
+ for (key in obj) {
425
+ if (!__hasProp.call(obj, key))
426
+ continue;
427
+ if (dontLock.indexOf(key < 0)) {
428
+ desc = Object.getOwnPropertyDescriptor(obj, key);
429
+ desc.writable = isWritable;
430
+ props[key] = desc;
431
+ }
432
+ }
433
+ return Object.defineProperties(obj, props);
434
+ };
435
+ unlockProperty = function (obj, prop, op) {
436
+ var writable;
437
+ if (!canWriteProtect || !obj.hasOwnProperty(prop)) {
438
+ return op.call(obj);
439
+ }
440
+ writable = Object.getOwnPropertyDescriptor(obj, prop).writable;
441
+ Object.defineProperties(obj, prop, { writable: true });
442
+ op.call(obj);
443
+ return Object.defineProperties(obj, prop, { writable: writable });
444
+ };
445
+ mixin = function (base, mixins) {
446
+ var _i, _len;
447
+ if (!(mixins instanceof Array)) {
448
+ return this.mixin(base, [mixins]);
449
+ }
450
+ base.mixedIn = base.hasOwnProperty('mixedIn') ? base.mixedIn : [];
451
+ base.mixingIn = base.hasOwnProperty('mixingIn') ? base.mixingIn : [];
452
+ setPropertyWritability(base, false);
453
+ for (_i = 0, _len = mixins.length; _i < _len; _i++) {
454
+ mixin = mixins[_i];
455
+ if (!(base.mixedIn.indexOf(mixin) === -1)) {
456
+ continue;
457
+ }
458
+ if (base.mixingIn.indexOf(mixin) > -1) {
459
+ throw new Error('found cyclic dependencies between ' + base.mixingIn);
460
+ }
461
+ base.mixingIn.push(mixin);
462
+ mixin.call(base);
463
+ base.mixingIn.pop();
464
+ base.mixedIn.push(mixin);
465
+ }
466
+ return setPropertyWritability(base, true);
467
+ };
468
+ return {
469
+ mixin: mixin,
470
+ unlockProperty: unlockProperty
471
+ };
472
+ });
473
+ }.call(this));
474
+ (function () {
475
+ define('build/js/advice', ['./compose'], function (compose) {
476
+ 'use strict';
477
+ var advice;
478
+ advice = {
479
+ around: function (base, wrapped) {
480
+ return function () {
481
+ var args, el, i, l, _i, _len;
482
+ l = arguments.length;
483
+ args = new Array(l + 1);
484
+ args[0] = base.bind(this);
485
+ for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
486
+ el = args[i];
487
+ args[i + 1] = arguments[i];
488
+ }
489
+ return wrapped.apply(this, args);
490
+ };
491
+ },
492
+ before: function (base, before) {
493
+ var beforeFn;
494
+ beforeFn = typeof before === 'function' ? before : before.obj[before.fnName];
495
+ return function () {
496
+ beforeFn.apply(this, arguments);
497
+ return base.apply(this, arguments);
498
+ };
499
+ },
500
+ after: function (base, after) {
501
+ var afterFn;
502
+ afterFn = typeof after === 'function' ? after : after.obj[after.fnName];
503
+ return function () {
504
+ var res;
505
+ res = (base.unbound || base).apply(this, arguments);
506
+ afterFn.apply(this, arguments);
507
+ return res;
508
+ };
509
+ },
510
+ withAdvice: function () {
511
+ return [
512
+ 'before',
513
+ 'after',
514
+ 'around'
515
+ ].forEach(function (m) {
516
+ return this[m] = function (method, fn) {
517
+ return compose.unlockProperty(this, method, function () {
518
+ if (typeof this[method] === 'function') {
519
+ this[method] = advice[m](this[method], fn);
520
+ } else {
521
+ this[method] = fn;
522
+ }
523
+ return this[method];
524
+ });
525
+ };
526
+ }, this);
527
+ }
528
+ };
529
+ return advice;
530
+ });
531
+ }.call(this));
532
+ (function () {
533
+ define('build/js/event', ['./utils'], function (utils) {
534
+ 'use strict';
535
+ var Event, eventSplitter, eventsApi, implementation, listenMethods, method, slice, triggerEvents;
536
+ slice = [].slice;
537
+ Event = {
538
+ withEvent: function () {
539
+ var method, _i, _len, _ref, _results;
540
+ _ref = [
541
+ 'on',
542
+ 'off',
543
+ 'once',
544
+ 'trigger'
545
+ ];
546
+ _results = [];
547
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
548
+ method = _ref[_i];
549
+ _results.push(this[method] = Event[method]);
550
+ }
551
+ return _results;
552
+ },
553
+ on: function (name, callback, context) {
554
+ var events;
555
+ if (!eventsApi(this, 'on', name, [
556
+ callback,
557
+ context
558
+ ]) || !callback) {
559
+ return this;
560
+ }
561
+ this._events || (this._events = {});
562
+ events = this._events[name] || (this._events[name] = []);
563
+ events.push({
564
+ callback: callback,
565
+ context: context,
566
+ ctx: context || this
567
+ });
568
+ return this;
569
+ },
570
+ once: function (name, callback, context) {
571
+ var once, self;
572
+ if (!eventsApi(this, 'once', name, [
573
+ callback,
574
+ context
575
+ ]) || !callback) {
576
+ return this;
577
+ }
578
+ self = this;
579
+ once = utils.once(function () {
580
+ self.off(name, once);
581
+ return callback.apply(this, arguments);
582
+ });
583
+ once._callback = callback;
584
+ return this.on(name, once, context);
585
+ },
586
+ off: function (name, callback, context) {
587
+ var ev, events, i, j, names, retain, _i, _j, _len, _len1;
588
+ if (!this._events || !eventsApi(this, 'off', name, [
589
+ callback,
590
+ context
591
+ ])) {
592
+ return this;
593
+ }
594
+ if (!name && !callback && !context) {
595
+ this._events = void 0;
596
+ return this;
597
+ }
598
+ names = name ? [name] : Object.keys(this._events);
599
+ for (i = _i = 0, _len = names.length; _i < _len; i = ++_i) {
600
+ name = names[i];
601
+ if (events = this._events[name]) {
602
+ this._events[name] = retain = [];
603
+ if (callback || context) {
604
+ for (j = _j = 0, _len1 = events.length; _j < _len1; j = ++_j) {
605
+ ev = events[j];
606
+ if (callback && callback !== ev.callback && callback !== ev.callback._callback || context && context !== ev.context) {
607
+ retain.push(ev);
608
+ }
609
+ }
610
+ }
611
+ if (!retain.length) {
612
+ delete this._events[name];
613
+ }
614
+ }
615
+ }
616
+ return this;
617
+ },
618
+ trigger: function (name) {
619
+ var allEvents, args, events;
620
+ if (!this._events) {
621
+ return this;
622
+ }
623
+ args = slice.call(arguments, 1);
624
+ if (!eventsApi(this, 'trigger', name, args)) {
625
+ return this;
626
+ }
627
+ events = this._events[name];
628
+ allEvents = this._events.all;
629
+ if (events) {
630
+ triggerEvents(events, args);
631
+ }
632
+ if (allEvents) {
633
+ triggerEvents(allEvents, arguments);
634
+ }
635
+ return this;
636
+ },
637
+ stopListening: function (obj, name, callback) {
638
+ var id, listeningTo, remove;
639
+ listeningTo = this._listeningTo;
640
+ if (!listeningTo) {
641
+ return this;
642
+ }
643
+ remove = !name && !callback;
644
+ if (!callback && typeof name === 'object') {
645
+ callback = this;
646
+ }
647
+ if (obj) {
648
+ (listeningTo = {})[obj._listenId] = obj;
649
+ }
650
+ for (id in listeningTo) {
651
+ obj = listeningTo[id];
652
+ obj.off(name, callback, this);
653
+ if (remove || _.isEmpty(obj._events)) {
654
+ delete this._listeningTo[id];
655
+ }
656
+ }
657
+ return this;
658
+ }
659
+ };
660
+ eventSplitter = /\s+/;
661
+ eventsApi = function (obj, action, name, rest) {
662
+ var key, names, val, _i, _len;
663
+ if (!name) {
664
+ return true;
665
+ }
666
+ if (typeof name === 'object') {
667
+ for (key in name) {
668
+ val = name[key];
669
+ obj[action].apply(obj, [
670
+ key,
671
+ val
672
+ ].concat(rest));
673
+ }
674
+ return false;
675
+ }
676
+ if (eventSplitter.test(name)) {
677
+ names = name.split(eventSplitter);
678
+ for (_i = 0, _len = names.length; _i < _len; _i++) {
679
+ val = names[_i];
680
+ obj[action].apply(obj, [val].concat(rest));
681
+ }
682
+ return false;
683
+ }
684
+ return true;
685
+ };
686
+ triggerEvents = function (events, args) {
687
+ var ev, _i, _len, _results;
688
+ _results = [];
689
+ for (_i = 0, _len = events.length; _i < _len; _i++) {
690
+ ev = events[_i];
691
+ _results.push(ev.callback.apply(ev.ctx, args));
692
+ }
693
+ return _results;
694
+ };
695
+ listenMethods = {
696
+ listenTo: 'on',
697
+ listenToOnce: 'once'
698
+ };
699
+ for (method in listenMethods) {
700
+ implementation = listenMethods[method];
701
+ Event[method] = function (obj, name, callback) {
702
+ var id, listeningTo;
703
+ listeningTo = this._listeningTo || (this._listeningTo = {});
704
+ id = obj._listenId || (obj._listenId = utils.uniqueId('l'));
705
+ listeningTo[id] = obj;
706
+ if (!callback && typeof name === 'object') {
707
+ callback = this;
708
+ }
709
+ obj[implementation](name, callback, this);
710
+ return this;
711
+ };
712
+ }
713
+ return Event;
714
+ });
715
+ }.call(this));
716
+ (function () {
717
+ var __hasProp = {}.hasOwnProperty;
718
+ define('build/js/property', [
719
+ './utils',
720
+ './compose',
721
+ './event'
722
+ ], function (utils, compose, event) {
723
+ 'use strict';
724
+ return function () {
725
+ compose.mixin(this, event.withEvent);
726
+ this.set = function (key, val) {
727
+ var after, attrs, before, _ref, _ref1;
728
+ if (!key) {
729
+ return this;
730
+ }
731
+ if (arguments.length > 1 && typeof arguments[0] === 'string') {
732
+ attrs = {};
733
+ attrs[key] = val;
734
+ return this.set(attrs);
735
+ }
736
+ this.attrs || (this.attrs = {});
737
+ attrs = key;
738
+ after = {};
739
+ before = {};
740
+ _ref = this.attrs;
741
+ for (key in _ref) {
742
+ if (!__hasProp.call(_ref, key))
743
+ continue;
744
+ val = _ref[key];
745
+ before[key] = val;
746
+ }
747
+ utils.push(this.attrs, attrs);
748
+ _ref1 = this.attrs;
749
+ for (key in _ref1) {
750
+ if (!__hasProp.call(_ref1, key))
751
+ continue;
752
+ val = _ref1[key];
753
+ if (val !== before[key]) {
754
+ after[key] = val;
755
+ } else {
756
+ delete before[key];
757
+ }
758
+ }
759
+ if (Object.keys(after).length !== 0) {
760
+ this.trigger('change', {
761
+ before: before,
762
+ after: after
763
+ }, true);
764
+ }
765
+ return this;
766
+ };
767
+ return this.get = function (attr) {
768
+ return this.attrs && this.attrs[attr];
769
+ };
770
+ };
771
+ });
772
+ }.call(this));
773
+ (function () {
774
+ var __hasProp = {}.hasOwnProperty;
775
+ define('build/js/lifecycle', [
776
+ './compose',
777
+ './property'
778
+ ], function (compose, withProperty) {
779
+ 'use strict';
780
+ return function () {
781
+ compose.mixin(this, withProperty);
782
+ this.initialize = function (attrs) {
783
+ var cloned, key, val, _ref;
784
+ attrs || (attrs = {});
785
+ cloned = {};
786
+ for (key in attrs) {
787
+ if (!__hasProp.call(attrs, key))
788
+ continue;
789
+ val = attrs[key];
790
+ cloned[key] = val;
791
+ }
792
+ _ref = this.defaults;
793
+ for (key in _ref) {
794
+ if (!__hasProp.call(_ref, key))
795
+ continue;
796
+ val = _ref[key];
797
+ if (!cloned.hasOwnProperty(key)) {
798
+ cloned[key] = val;
799
+ }
800
+ }
801
+ this.set(cloned);
802
+ return this;
803
+ };
804
+ return this.despose = function () {
805
+ };
806
+ };
807
+ });
808
+ }.call(this));
809
+ (function () {
810
+ define('build/js/serialize', [
811
+ './compose',
812
+ './property'
813
+ ], function (compose, withProperty) {
814
+ 'use strict';
815
+ return function () {
816
+ compose.mixin(this, withProperty);
817
+ this.serialize = function () {
818
+ return [
819
+ 'type: ' + this.name,
820
+ 'id: ' + this.id,
821
+ 'props: ' + JSON.stringify(this.attrs)
822
+ ].join(',');
823
+ };
824
+ return this.deserialize = function () {
825
+ };
826
+ };
827
+ });
828
+ }.call(this));
829
+ (function () {
830
+ var __hasProp = {}.hasOwnProperty, __extends = function (child, parent) {
831
+ for (var key in parent) {
832
+ if (__hasProp.call(parent, key))
833
+ child[key] = parent[key];
834
+ }
835
+ function ctor() {
836
+ this.constructor = child;
837
+ }
838
+ ctor.prototype = parent.prototype;
839
+ child.prototype = new ctor();
840
+ child.__super__ = parent.prototype;
841
+ return child;
842
+ };
843
+ define('build/js/dou', ['./compose'], function (compose) {
844
+ 'use strict';
845
+ var define;
846
+ define = function (options) {
847
+ var Component;
848
+ if (options['extends']) {
849
+ Component = function (_super) {
850
+ __extends(Component, _super);
851
+ function Component() {
852
+ return Component.__super__.constructor.apply(this, arguments);
853
+ }
854
+ return Component;
855
+ }(options['extends']);
856
+ } else {
857
+ Component = function () {
858
+ function Component() {
859
+ }
860
+ return Component;
861
+ }();
862
+ }
863
+ if (options.mixins) {
864
+ compose.mixin(Component.prototype, options.mixins);
865
+ }
866
+ if (options.name) {
867
+ Component.name = options.name;
868
+ }
869
+ return Component;
870
+ };
871
+ return { define: define };
872
+ });
873
+ }.call(this));
874
+ (function () {
875
+ define('build/js/index', [
876
+ './advice',
877
+ './compose',
878
+ './debug',
879
+ './event',
880
+ './lifecycle',
881
+ './property',
882
+ './serialize',
883
+ './utils',
884
+ './dou'
885
+ ], function (advice, compose, debug, event, lifecycle, property, serialize, utils, dou) {
886
+ 'use strict';
887
+ return {
888
+ advice: advice,
889
+ compose: compose,
890
+ debug: debug,
891
+ event: event,
892
+ lifecycle: lifecycle,
893
+ property: property,
894
+ serialize: serialize,
895
+ utils: utils,
896
+ dou: dou
897
+ };
898
+ });
899
+ }.call(this));
782
900
 
783
- }).call(this);
901
+ context.dou = require('lib/index');
902
+ }(this));