ende 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/component.json +4 -2
  3. data/ende.gemspec +1 -0
  4. data/lib/assets/javascripts/aura/extensions/devise.js.coffee +94 -15
  5. data/lib/assets/javascripts/aura/extensions/routes.js.coffee +21 -0
  6. data/lib/assets/javascripts/aura/extensions/states.js.coffee +3 -1
  7. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +19 -21
  8. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +17 -1
  9. data/lib/assets/javascripts/config/initializers/jquery.js.coffee +4 -3
  10. data/lib/assets/javascripts/config/initializers/load_components.js.coffee +19 -0
  11. data/lib/assets/javascripts/ende.js.coffee +3 -1
  12. data/lib/assets/javascripts/widgets/authenticator/main.js.coffee +3 -3
  13. data/lib/assets/javascripts/widgets/viewer/main.js.coffee +189 -120
  14. data/lib/ende/users_controller_extensions.rb +14 -0
  15. data/lib/ende/version.rb +1 -1
  16. data/lib/ende.rb +5 -0
  17. data/vendor/assets/components/KapIT-observe-utils/component.json +16 -0
  18. data/vendor/assets/components/KapIT-observe-utils/lib/observe-utils.js +780 -0
  19. data/vendor/assets/components/chaijs-assertion-error/component.json +18 -0
  20. data/vendor/assets/components/chaijs-assertion-error/index.js +110 -0
  21. data/vendor/assets/components/chaijs-chai/component.json +47 -0
  22. data/vendor/assets/components/chaijs-chai/index.js +1 -0
  23. data/vendor/assets/components/chaijs-chai/lib/chai/assertion.js +130 -0
  24. data/vendor/assets/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
  25. data/vendor/assets/components/chaijs-chai/lib/chai/interface/assert.js +1080 -0
  26. data/vendor/assets/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
  27. data/vendor/assets/components/chaijs-chai/lib/chai/interface/should.js +76 -0
  28. data/vendor/assets/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
  29. data/vendor/assets/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
  30. data/vendor/assets/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
  31. data/vendor/assets/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
  32. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
  33. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
  34. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
  35. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
  36. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
  37. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
  38. data/vendor/assets/components/chaijs-chai/lib/chai/utils/index.js +108 -0
  39. data/vendor/assets/components/chaijs-chai/lib/chai/utils/inspect.js +320 -0
  40. data/vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
  41. data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
  42. data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
  43. data/vendor/assets/components/chaijs-chai/lib/chai/utils/test.js +26 -0
  44. data/vendor/assets/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
  45. data/vendor/assets/components/chaijs-chai/lib/chai/utils/type.js +45 -0
  46. data/vendor/assets/components/chaijs-chai/lib/chai.js +80 -0
  47. data/vendor/assets/components/chaijs-deep-eql/component.json +18 -0
  48. data/vendor/assets/components/chaijs-deep-eql/lib/eql.js +257 -0
  49. data/vendor/assets/components/chaijs-type-detect/component.json +16 -0
  50. data/vendor/assets/components/chaijs-type-detect/lib/type.js +142 -0
  51. data/vendor/assets/components/component-bind/component.json +14 -0
  52. data/vendor/assets/components/component-bind/index.js +24 -0
  53. data/vendor/assets/components/component-delegate/component.json +19 -0
  54. data/vendor/assets/components/component-delegate/index.js +42 -0
  55. data/vendor/assets/components/component-event/component.json +13 -0
  56. data/vendor/assets/components/component-event/index.js +40 -0
  57. data/vendor/assets/components/component-jquery/component.json +14 -0
  58. data/vendor/assets/components/component-jquery/index.js +9601 -0
  59. data/vendor/assets/components/component-link-delegate/component.json +23 -0
  60. data/vendor/assets/components/component-link-delegate/index.js +60 -0
  61. data/vendor/assets/components/component-matches-selector/component.json +20 -0
  62. data/vendor/assets/components/component-matches-selector/index.js +45 -0
  63. data/vendor/assets/components/component-query/component.json +21 -0
  64. data/vendor/assets/components/component-query/index.js +21 -0
  65. data/vendor/assets/components/component-type/component.json +18 -0
  66. data/vendor/assets/components/component-type/index.js +32 -0
  67. data/vendor/assets/components/component-url/component.json +17 -0
  68. data/vendor/assets/components/component-url/index.js +63 -0
  69. data/vendor/assets/components/discore-closest/component.json +14 -0
  70. data/vendor/assets/components/discore-closest/index.js +18 -0
  71. data/vendor/assets/components/indefinido-advisable/component.json +21 -0
  72. data/vendor/assets/components/indefinido-advisable/index.js +1 -0
  73. data/vendor/assets/components/indefinido-advisable/lib/advisable.js +60 -0
  74. data/vendor/assets/components/indefinido-indemma/component.json +40 -0
  75. data/vendor/assets/components/indefinido-indemma/index.js +1 -0
  76. data/vendor/assets/components/indefinido-indemma/lib/extensions/rivets.js +23 -0
  77. data/vendor/assets/components/indefinido-indemma/lib/record/associable.js +217 -0
  78. data/vendor/assets/components/indefinido-indemma/lib/record/maid.js +24 -0
  79. data/vendor/assets/components/indefinido-indemma/lib/record/resource.js +104 -0
  80. data/vendor/assets/components/indefinido-indemma/lib/record/rest.js +36 -0
  81. data/vendor/assets/components/indefinido-indemma/lib/record/restfulable.js +326 -0
  82. data/vendor/assets/components/indefinido-indemma/lib/record/scopable.js +279 -0
  83. data/vendor/assets/components/indefinido-indemma/lib/record/translationable.js +19 -0
  84. data/vendor/assets/components/indefinido-indemma/lib/record/validatable.js +216 -0
  85. data/vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js +30 -0
  86. data/vendor/assets/components/indefinido-indemma/lib/record/validations/confirmation.js +19 -0
  87. data/vendor/assets/components/indefinido-indemma/lib/record/validations/cpf.js +60 -0
  88. data/vendor/assets/components/indefinido-indemma/lib/record/validations/presence.js +19 -0
  89. data/vendor/assets/components/indefinido-indemma/lib/record/validations/remote.js +71 -0
  90. data/vendor/assets/components/indefinido-indemma/lib/record.js +167 -0
  91. data/vendor/assets/components/indefinido-indemma/vendor/sinon.js +4290 -0
  92. data/vendor/assets/components/indefinido-indemma/vendor/stampit.js +392 -0
  93. data/vendor/assets/components/indefinido-observable/component.json +25 -0
  94. data/vendor/assets/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
  95. data/vendor/assets/components/indefinido-observable/index.js +1 -0
  96. data/vendor/assets/components/indefinido-observable/lib/adapters/rivets.js +26 -0
  97. data/vendor/assets/components/indefinido-observable/lib/observable.js +320 -0
  98. data/vendor/assets/components/indefinido-observable/vendor/shims/accessors-legacy.js +92 -0
  99. data/vendor/assets/components/indefinido-observable/vendor/shims/accessors.js +173 -0
  100. data/vendor/assets/components/indefinido-observable/vendor/shims/array.indexOf.js +8 -0
  101. data/vendor/assets/components/indefinido-observable/vendor/shims/object.create.js +77 -0
  102. data/vendor/assets/components/mikeric-rivets/component.json +15 -0
  103. data/vendor/assets/components/mikeric-rivets/dist/rivets.js +1020 -0
  104. data/vendor/assets/components/paulmillr-es6-shim/component.json +17 -0
  105. data/vendor/assets/components/paulmillr-es6-shim/es6-shim.js +985 -0
  106. data/vendor/assets/components/pluma-assimilate/component.json +25 -0
  107. data/vendor/assets/components/pluma-assimilate/dist/assimilate.js +87 -0
  108. data/vendor/assets/components/segmentio-extend/component.json +13 -0
  109. data/vendor/assets/components/segmentio-extend/index.js +15 -0
  110. data/vendor/assets/javascripts/ende/build.js +30346 -0
  111. data/vendor/assets/javascripts/jquery/inview.js +125 -0
  112. data/vendor/assets/javascripts/lennon/lennon.js +184 -0
  113. metadata +114 -3
  114. data/lib/tasks/sprite.thor +0 -62
@@ -0,0 +1,1020 @@
1
+ // Rivets.js
2
+ // version: 0.5.13
3
+ // author: Michael Richards
4
+ // license: MIT
5
+ (function() {
6
+ var Rivets, jQuery,
7
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
8
+ __slice = [].slice,
9
+ __hasProp = {}.hasOwnProperty,
10
+ __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; },
11
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
12
+
13
+ Rivets = {};
14
+
15
+ jQuery = window.jQuery || window.Zepto;
16
+
17
+ if (!String.prototype.trim) {
18
+ String.prototype.trim = function() {
19
+ return this.replace(/^\s+|\s+$/g, '');
20
+ };
21
+ }
22
+
23
+ Rivets.Binding = (function() {
24
+ function Binding(view, el, type, key, keypath, options) {
25
+ var identifier, regexp, value, _ref;
26
+ this.view = view;
27
+ this.el = el;
28
+ this.type = type;
29
+ this.key = key;
30
+ this.keypath = keypath;
31
+ this.options = options != null ? options : {};
32
+ this.update = __bind(this.update, this);
33
+ this.unbind = __bind(this.unbind, this);
34
+ this.bind = __bind(this.bind, this);
35
+ this.publish = __bind(this.publish, this);
36
+ this.sync = __bind(this.sync, this);
37
+ this.set = __bind(this.set, this);
38
+ this.eventHandler = __bind(this.eventHandler, this);
39
+ this.formattedValue = __bind(this.formattedValue, this);
40
+ if (!(this.binder = this.view.binders[type])) {
41
+ _ref = this.view.binders;
42
+ for (identifier in _ref) {
43
+ value = _ref[identifier];
44
+ if (identifier !== '*' && identifier.indexOf('*') !== -1) {
45
+ regexp = new RegExp("^" + (identifier.replace('*', '.+')) + "$");
46
+ if (regexp.test(type)) {
47
+ this.binder = value;
48
+ this.args = new RegExp("^" + (identifier.replace('*', '(.+)')) + "$").exec(type);
49
+ this.args.shift();
50
+ }
51
+ }
52
+ }
53
+ }
54
+ this.binder || (this.binder = this.view.binders['*']);
55
+ if (this.binder instanceof Function) {
56
+ this.binder = {
57
+ routine: this.binder
58
+ };
59
+ }
60
+ this.formatters = this.options.formatters || [];
61
+ this.model = this.key ? this.view.models[this.key] : this.view.models;
62
+ }
63
+
64
+ Binding.prototype.formattedValue = function(value) {
65
+ var args, formatter, id, _i, _len, _ref;
66
+ _ref = this.formatters;
67
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
68
+ formatter = _ref[_i];
69
+ args = formatter.split(/\s+/);
70
+ id = args.shift();
71
+ formatter = this.model[id] instanceof Function ? this.model[id] : this.view.formatters[id];
72
+ if ((formatter != null ? formatter.read : void 0) instanceof Function) {
73
+ value = formatter.read.apply(formatter, [value].concat(__slice.call(args)));
74
+ } else if (formatter instanceof Function) {
75
+ value = formatter.apply(null, [value].concat(__slice.call(args)));
76
+ }
77
+ }
78
+ return value;
79
+ };
80
+
81
+ Binding.prototype.eventHandler = function(fn) {
82
+ var binding, handler;
83
+ handler = (binding = this).view.config.handler;
84
+ return function(ev) {
85
+ return handler.call(fn, this, ev, binding);
86
+ };
87
+ };
88
+
89
+ Binding.prototype.set = function(value) {
90
+ var _ref;
91
+ value = value instanceof Function && !this.binder["function"] ? this.formattedValue(value.call(this.model)) : this.formattedValue(value);
92
+ return (_ref = this.binder.routine) != null ? _ref.call(this, this.el, value) : void 0;
93
+ };
94
+
95
+ Binding.prototype.sync = function() {
96
+ return this.set(this.options.bypass ? this.model[this.keypath] : this.view.config.adapter.read(this.model, this.keypath));
97
+ };
98
+
99
+ Binding.prototype.publish = function() {
100
+ var args, formatter, id, value, _i, _len, _ref, _ref1, _ref2;
101
+ value = Rivets.Util.getInputValue(this.el);
102
+ _ref = this.formatters.slice(0).reverse();
103
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
104
+ formatter = _ref[_i];
105
+ args = formatter.split(/\s+/);
106
+ id = args.shift();
107
+ if ((_ref1 = this.view.formatters[id]) != null ? _ref1.publish : void 0) {
108
+ value = (_ref2 = this.view.formatters[id]).publish.apply(_ref2, [value].concat(__slice.call(args)));
109
+ }
110
+ }
111
+ return this.view.config.adapter.publish(this.model, this.keypath, value);
112
+ };
113
+
114
+ Binding.prototype.bind = function() {
115
+ var dependency, keypath, model, _i, _len, _ref, _ref1, _ref2, _results;
116
+ if ((_ref = this.binder.bind) != null) {
117
+ _ref.call(this, this.el);
118
+ }
119
+ if (this.options.bypass) {
120
+ this.sync();
121
+ } else {
122
+ this.view.config.adapter.subscribe(this.model, this.keypath, this.sync);
123
+ if (this.view.config.preloadData) {
124
+ this.sync();
125
+ }
126
+ }
127
+ if ((_ref1 = this.options.dependencies) != null ? _ref1.length : void 0) {
128
+ _ref2 = this.options.dependencies;
129
+ _results = [];
130
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
131
+ dependency = _ref2[_i];
132
+ if (/^\./.test(dependency)) {
133
+ model = this.model;
134
+ keypath = dependency.substr(1);
135
+ } else {
136
+ dependency = dependency.split('.');
137
+ model = this.view.models[dependency.shift()];
138
+ keypath = dependency.join('.');
139
+ }
140
+ _results.push(this.view.config.adapter.subscribe(model, keypath, this.sync));
141
+ }
142
+ return _results;
143
+ }
144
+ };
145
+
146
+ Binding.prototype.unbind = function() {
147
+ var dependency, keypath, model, _i, _len, _ref, _ref1, _ref2, _results;
148
+ if ((_ref = this.binder.unbind) != null) {
149
+ _ref.call(this, this.el);
150
+ }
151
+ if (!this.options.bypass) {
152
+ this.view.config.adapter.unsubscribe(this.model, this.keypath, this.sync);
153
+ }
154
+ if ((_ref1 = this.options.dependencies) != null ? _ref1.length : void 0) {
155
+ _ref2 = this.options.dependencies;
156
+ _results = [];
157
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
158
+ dependency = _ref2[_i];
159
+ if (/^\./.test(dependency)) {
160
+ model = this.model;
161
+ keypath = dependency.substr(1);
162
+ } else {
163
+ dependency = dependency.split('.');
164
+ model = this.view.models[dependency.shift()];
165
+ keypath = dependency.join('.');
166
+ }
167
+ _results.push(this.view.config.adapter.unsubscribe(model, keypath, this.sync));
168
+ }
169
+ return _results;
170
+ }
171
+ };
172
+
173
+ Binding.prototype.update = function(models) {
174
+ var _ref;
175
+ if (models == null) {
176
+ models = {};
177
+ }
178
+ if (this.key) {
179
+ if (models[this.key]) {
180
+ if (!this.options.bypass) {
181
+ this.view.config.adapter.unsubscribe(this.model, this.keypath, this.sync);
182
+ }
183
+ this.model = models[this.key];
184
+ if (this.options.bypass) {
185
+ this.sync();
186
+ } else {
187
+ this.view.config.adapter.subscribe(this.model, this.keypath, this.sync);
188
+ if (this.view.config.preloadData) {
189
+ this.sync();
190
+ }
191
+ }
192
+ }
193
+ } else {
194
+ this.sync();
195
+ }
196
+ return (_ref = this.binder.update) != null ? _ref.call(this, models) : void 0;
197
+ };
198
+
199
+ return Binding;
200
+
201
+ })();
202
+
203
+ Rivets.ComponentBinding = (function(_super) {
204
+ __extends(ComponentBinding, _super);
205
+
206
+ function ComponentBinding(view, el, type) {
207
+ var attribute, _i, _len, _ref, _ref1;
208
+ this.view = view;
209
+ this.el = el;
210
+ this.type = type;
211
+ this.unbind = __bind(this.unbind, this);
212
+ this.bind = __bind(this.bind, this);
213
+ this.update = __bind(this.update, this);
214
+ this.locals = __bind(this.locals, this);
215
+ this.component = Rivets.components[this.type];
216
+ this.attributes = {};
217
+ this.inflections = {};
218
+ _ref = this.el.attributes || [];
219
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
220
+ attribute = _ref[_i];
221
+ if (_ref1 = attribute.name, __indexOf.call(this.component.attributes, _ref1) >= 0) {
222
+ this.attributes[attribute.name] = attribute.value;
223
+ } else {
224
+ this.inflections[attribute.name] = attribute.value;
225
+ }
226
+ }
227
+ }
228
+
229
+ ComponentBinding.prototype.sync = function() {};
230
+
231
+ ComponentBinding.prototype.locals = function(models) {
232
+ var inverse, key, model, path, result, _i, _len, _ref, _ref1;
233
+ if (models == null) {
234
+ models = this.view.models;
235
+ }
236
+ result = {};
237
+ _ref = this.inflections;
238
+ for (key in _ref) {
239
+ inverse = _ref[key];
240
+ _ref1 = inverse.split('.');
241
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
242
+ path = _ref1[_i];
243
+ result[key] = (result[key] || models)[path];
244
+ }
245
+ }
246
+ for (key in models) {
247
+ model = models[key];
248
+ if (result[key] == null) {
249
+ result[key] = model;
250
+ }
251
+ }
252
+ return result;
253
+ };
254
+
255
+ ComponentBinding.prototype.update = function(models) {
256
+ var _ref;
257
+ return (_ref = this.componentView) != null ? _ref.update(this.locals(models)) : void 0;
258
+ };
259
+
260
+ ComponentBinding.prototype.bind = function() {
261
+ var el, _ref;
262
+ if (this.componentView != null) {
263
+ return (_ref = this.componentView) != null ? _ref.bind() : void 0;
264
+ } else {
265
+ el = this.component.build.call(this.attributes);
266
+ (this.componentView = new Rivets.View(el, this.locals(), this.view.options)).bind();
267
+ return this.el.parentNode.replaceChild(el, this.el);
268
+ }
269
+ };
270
+
271
+ ComponentBinding.prototype.unbind = function() {
272
+ var _ref;
273
+ return (_ref = this.componentView) != null ? _ref.unbind() : void 0;
274
+ };
275
+
276
+ return ComponentBinding;
277
+
278
+ })(Rivets.Binding);
279
+
280
+ Rivets.TextBinding = (function(_super) {
281
+ __extends(TextBinding, _super);
282
+
283
+ function TextBinding(view, el, type, key, keypath, options) {
284
+ this.view = view;
285
+ this.el = el;
286
+ this.type = type;
287
+ this.key = key;
288
+ this.keypath = keypath;
289
+ this.options = options != null ? options : {};
290
+ this.sync = __bind(this.sync, this);
291
+ this.formatters = this.options.formatters || [];
292
+ this.model = this.key ? this.view.models[this.key] : this.view.models;
293
+ }
294
+
295
+ TextBinding.prototype.binder = {
296
+ routine: function(node, value) {
297
+ return node.data = value != null ? value : '';
298
+ }
299
+ };
300
+
301
+ TextBinding.prototype.sync = function() {
302
+ return TextBinding.__super__.sync.apply(this, arguments);
303
+ };
304
+
305
+ return TextBinding;
306
+
307
+ })(Rivets.Binding);
308
+
309
+ Rivets.View = (function() {
310
+ function View(els, models, options) {
311
+ var k, option, v, _base, _i, _len, _ref, _ref1, _ref2;
312
+ this.els = els;
313
+ this.models = models;
314
+ this.options = options != null ? options : {};
315
+ this.update = __bind(this.update, this);
316
+ this.publish = __bind(this.publish, this);
317
+ this.sync = __bind(this.sync, this);
318
+ this.unbind = __bind(this.unbind, this);
319
+ this.bind = __bind(this.bind, this);
320
+ this.select = __bind(this.select, this);
321
+ this.build = __bind(this.build, this);
322
+ this.componentRegExp = __bind(this.componentRegExp, this);
323
+ this.bindingRegExp = __bind(this.bindingRegExp, this);
324
+ if (typeof this.els.length === 'undefined') {
325
+ this.els = [this.els];
326
+ }
327
+ _ref = ['config', 'binders', 'formatters'];
328
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
329
+ option = _ref[_i];
330
+ this[option] = {};
331
+ if (this.options[option]) {
332
+ _ref1 = this.options[option];
333
+ for (k in _ref1) {
334
+ v = _ref1[k];
335
+ this[option][k] = v;
336
+ }
337
+ }
338
+ _ref2 = Rivets[option];
339
+ for (k in _ref2) {
340
+ v = _ref2[k];
341
+ if ((_base = this[option])[k] == null) {
342
+ _base[k] = v;
343
+ }
344
+ }
345
+ }
346
+ this.build();
347
+ }
348
+
349
+ View.prototype.bindingRegExp = function() {
350
+ var prefix;
351
+ prefix = this.config.prefix;
352
+ if (prefix) {
353
+ return new RegExp("^data-" + prefix + "-");
354
+ } else {
355
+ return /^data-/;
356
+ }
357
+ };
358
+
359
+ View.prototype.componentRegExp = function() {
360
+ var _ref, _ref1;
361
+ return new RegExp("^" + ((_ref = (_ref1 = this.config.prefix) != null ? _ref1.toUpperCase() : void 0) != null ? _ref : 'RV') + "-");
362
+ };
363
+
364
+ View.prototype.build = function() {
365
+ var bindingRegExp, buildBinding, componentRegExp, el, parse, skipNodes, _i, _len, _ref,
366
+ _this = this;
367
+ this.bindings = [];
368
+ skipNodes = [];
369
+ bindingRegExp = this.bindingRegExp();
370
+ componentRegExp = this.componentRegExp();
371
+ buildBinding = function(binding, node, type, declaration) {
372
+ var context, ctx, dependencies, key, keypath, options, path, pipe, pipes, splitPath;
373
+ options = {};
374
+ pipes = (function() {
375
+ var _i, _len, _ref, _results;
376
+ _ref = declaration.split('|');
377
+ _results = [];
378
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
379
+ pipe = _ref[_i];
380
+ _results.push(pipe.trim());
381
+ }
382
+ return _results;
383
+ })();
384
+ context = (function() {
385
+ var _i, _len, _ref, _results;
386
+ _ref = pipes.shift().split('<');
387
+ _results = [];
388
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
389
+ ctx = _ref[_i];
390
+ _results.push(ctx.trim());
391
+ }
392
+ return _results;
393
+ })();
394
+ path = context.shift();
395
+ splitPath = path.split(/\.|:/);
396
+ options.formatters = pipes;
397
+ options.bypass = path.indexOf(':') !== -1;
398
+ if (splitPath[0]) {
399
+ key = splitPath.shift();
400
+ } else {
401
+ key = null;
402
+ splitPath.shift();
403
+ }
404
+ keypath = splitPath.join('.');
405
+ if (dependencies = context.shift()) {
406
+ options.dependencies = dependencies.split(/\s+/);
407
+ }
408
+ return _this.bindings.push(new Rivets[binding](_this, node, type, key, keypath, options));
409
+ };
410
+ parse = function(node) {
411
+ var attribute, attributes, binder, childNode, delimiters, identifier, n, parser, regexp, restTokens, startToken, text, token, tokens, type, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _results;
412
+ if (__indexOf.call(skipNodes, node) < 0) {
413
+ if (node.nodeType === Node.TEXT_NODE) {
414
+ parser = Rivets.TextTemplateParser;
415
+ if (delimiters = _this.config.templateDelimiters) {
416
+ if ((tokens = parser.parse(node.data, delimiters)).length) {
417
+ if (!(tokens.length === 1 && tokens[0].type === parser.types.text)) {
418
+ startToken = tokens[0], restTokens = 2 <= tokens.length ? __slice.call(tokens, 1) : [];
419
+ node.data = startToken.value;
420
+ if (startToken.type === 0) {
421
+ node.data = startToken.value;
422
+ } else {
423
+ buildBinding('TextBinding', node, null, startToken.value);
424
+ }
425
+ for (_i = 0, _len = restTokens.length; _i < _len; _i++) {
426
+ token = restTokens[_i];
427
+ text = document.createTextNode(token.value);
428
+ node.parentNode.appendChild(text);
429
+ if (token.type === 1) {
430
+ buildBinding('TextBinding', text, null, token.value);
431
+ }
432
+ }
433
+ }
434
+ }
435
+ }
436
+ } else if (componentRegExp.test(node.tagName)) {
437
+ type = node.tagName.replace(componentRegExp, '').toLowerCase();
438
+ _this.bindings.push(new Rivets.ComponentBinding(_this, node, type));
439
+ } else if (node.attributes != null) {
440
+ _ref = node.attributes;
441
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
442
+ attribute = _ref[_j];
443
+ if (bindingRegExp.test(attribute.name)) {
444
+ type = attribute.name.replace(bindingRegExp, '');
445
+ if (!(binder = _this.binders[type])) {
446
+ _ref1 = _this.binders;
447
+ for (identifier in _ref1) {
448
+ value = _ref1[identifier];
449
+ if (identifier !== '*' && identifier.indexOf('*') !== -1) {
450
+ regexp = new RegExp("^" + (identifier.replace('*', '.+')) + "$");
451
+ if (regexp.test(type)) {
452
+ binder = value;
453
+ }
454
+ }
455
+ }
456
+ }
457
+ binder || (binder = _this.binders['*']);
458
+ if (binder.block) {
459
+ _ref2 = node.childNodes;
460
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
461
+ n = _ref2[_k];
462
+ skipNodes.push(n);
463
+ }
464
+ attributes = [attribute];
465
+ }
466
+ }
467
+ }
468
+ _ref3 = attributes || node.attributes;
469
+ for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
470
+ attribute = _ref3[_l];
471
+ if (bindingRegExp.test(attribute.name)) {
472
+ type = attribute.name.replace(bindingRegExp, '');
473
+ buildBinding('Binding', node, type, attribute.value);
474
+ }
475
+ }
476
+ }
477
+ _ref4 = node.childNodes;
478
+ _results = [];
479
+ for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
480
+ childNode = _ref4[_m];
481
+ _results.push(parse(childNode));
482
+ }
483
+ return _results;
484
+ }
485
+ };
486
+ _ref = this.els;
487
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
488
+ el = _ref[_i];
489
+ parse(el);
490
+ }
491
+ };
492
+
493
+ View.prototype.select = function(fn) {
494
+ var binding, _i, _len, _ref, _results;
495
+ _ref = this.bindings;
496
+ _results = [];
497
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
498
+ binding = _ref[_i];
499
+ if (fn(binding)) {
500
+ _results.push(binding);
501
+ }
502
+ }
503
+ return _results;
504
+ };
505
+
506
+ View.prototype.bind = function() {
507
+ var binding, _i, _len, _ref, _results;
508
+ _ref = this.bindings;
509
+ _results = [];
510
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
511
+ binding = _ref[_i];
512
+ _results.push(binding.bind());
513
+ }
514
+ return _results;
515
+ };
516
+
517
+ View.prototype.unbind = function() {
518
+ var binding, _i, _len, _ref, _results;
519
+ _ref = this.bindings;
520
+ _results = [];
521
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
522
+ binding = _ref[_i];
523
+ _results.push(binding.unbind());
524
+ }
525
+ return _results;
526
+ };
527
+
528
+ View.prototype.sync = function() {
529
+ var binding, _i, _len, _ref, _results;
530
+ _ref = this.bindings;
531
+ _results = [];
532
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
533
+ binding = _ref[_i];
534
+ _results.push(binding.sync());
535
+ }
536
+ return _results;
537
+ };
538
+
539
+ View.prototype.publish = function() {
540
+ var binding, _i, _len, _ref, _results;
541
+ _ref = this.select(function(b) {
542
+ return b.binder.publishes;
543
+ });
544
+ _results = [];
545
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
546
+ binding = _ref[_i];
547
+ _results.push(binding.publish());
548
+ }
549
+ return _results;
550
+ };
551
+
552
+ View.prototype.update = function(models) {
553
+ var binding, key, model, _i, _len, _ref, _results;
554
+ if (models == null) {
555
+ models = {};
556
+ }
557
+ for (key in models) {
558
+ model = models[key];
559
+ this.models[key] = model;
560
+ }
561
+ _ref = this.bindings;
562
+ _results = [];
563
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
564
+ binding = _ref[_i];
565
+ _results.push(binding.update(models));
566
+ }
567
+ return _results;
568
+ };
569
+
570
+ return View;
571
+
572
+ })();
573
+
574
+ Rivets.TextTemplateParser = (function() {
575
+ function TextTemplateParser() {}
576
+
577
+ TextTemplateParser.types = {
578
+ text: 0,
579
+ binding: 1
580
+ };
581
+
582
+ TextTemplateParser.parse = function(template, delimiters) {
583
+ var index, lastIndex, lastToken, length, substring, tokens, value;
584
+ tokens = [];
585
+ length = template.length;
586
+ index = 0;
587
+ lastIndex = 0;
588
+ while (lastIndex < length) {
589
+ index = template.indexOf(delimiters[0], lastIndex);
590
+ if (index < 0) {
591
+ tokens.push({
592
+ type: this.types.text,
593
+ value: template.slice(lastIndex)
594
+ });
595
+ break;
596
+ } else {
597
+ if (index > 0 && lastIndex < index) {
598
+ tokens.push({
599
+ type: this.types.text,
600
+ value: template.slice(lastIndex, index)
601
+ });
602
+ }
603
+ lastIndex = index + 2;
604
+ index = template.indexOf(delimiters[1], lastIndex);
605
+ if (index < 0) {
606
+ substring = template.slice(lastIndex - 2);
607
+ lastToken = tokens[tokens.length - 1];
608
+ if ((lastToken != null ? lastToken.type : void 0) === this.types.text) {
609
+ lastToken.value += substring;
610
+ } else {
611
+ tokens.push({
612
+ type: this.types.text,
613
+ value: substring
614
+ });
615
+ }
616
+ break;
617
+ }
618
+ value = template.slice(lastIndex, index).trim();
619
+ tokens.push({
620
+ type: this.types.binding,
621
+ value: value
622
+ });
623
+ lastIndex = index + 2;
624
+ }
625
+ }
626
+ return tokens;
627
+ };
628
+
629
+ return TextTemplateParser;
630
+
631
+ })();
632
+
633
+ Rivets.Util = {
634
+ bindEvent: function(el, event, handler) {
635
+ if (window.jQuery != null) {
636
+ el = jQuery(el);
637
+ if (el.on != null) {
638
+ return el.on(event, handler);
639
+ } else {
640
+ return el.bind(event, handler);
641
+ }
642
+ } else if (window.addEventListener != null) {
643
+ return el.addEventListener(event, handler, false);
644
+ } else {
645
+ event = 'on' + event;
646
+ return el.attachEvent(event, handler);
647
+ }
648
+ },
649
+ unbindEvent: function(el, event, handler) {
650
+ if (window.jQuery != null) {
651
+ el = jQuery(el);
652
+ if (el.off != null) {
653
+ return el.off(event, handler);
654
+ } else {
655
+ return el.unbind(event, handler);
656
+ }
657
+ } else if (window.removeEventListener != null) {
658
+ return el.removeEventListener(event, handler, false);
659
+ } else {
660
+ event = 'on' + event;
661
+ return el.detachEvent(event, handler);
662
+ }
663
+ },
664
+ getInputValue: function(el) {
665
+ var o, _i, _len, _results;
666
+ if (window.jQuery != null) {
667
+ el = jQuery(el);
668
+ switch (el[0].type) {
669
+ case 'checkbox':
670
+ return el.is(':checked');
671
+ default:
672
+ return el.val();
673
+ }
674
+ } else {
675
+ switch (el.type) {
676
+ case 'checkbox':
677
+ return el.checked;
678
+ case 'select-multiple':
679
+ _results = [];
680
+ for (_i = 0, _len = el.length; _i < _len; _i++) {
681
+ o = el[_i];
682
+ if (o.selected) {
683
+ _results.push(o.value);
684
+ }
685
+ }
686
+ return _results;
687
+ break;
688
+ default:
689
+ return el.value;
690
+ }
691
+ }
692
+ }
693
+ };
694
+
695
+ Rivets.binders = {
696
+ enabled: function(el, value) {
697
+ return el.disabled = !value;
698
+ },
699
+ disabled: function(el, value) {
700
+ return el.disabled = !!value;
701
+ },
702
+ checked: {
703
+ publishes: true,
704
+ bind: function(el) {
705
+ return Rivets.Util.bindEvent(el, 'change', this.publish);
706
+ },
707
+ unbind: function(el) {
708
+ return Rivets.Util.unbindEvent(el, 'change', this.publish);
709
+ },
710
+ routine: function(el, value) {
711
+ var _ref;
712
+ if (el.type === 'radio') {
713
+ return el.checked = ((_ref = el.value) != null ? _ref.toString() : void 0) === (value != null ? value.toString() : void 0);
714
+ } else {
715
+ return el.checked = !!value;
716
+ }
717
+ }
718
+ },
719
+ unchecked: {
720
+ publishes: true,
721
+ bind: function(el) {
722
+ return Rivets.Util.bindEvent(el, 'change', this.publish);
723
+ },
724
+ unbind: function(el) {
725
+ return Rivets.Util.unbindEvent(el, 'change', this.publish);
726
+ },
727
+ routine: function(el, value) {
728
+ var _ref;
729
+ if (el.type === 'radio') {
730
+ return el.checked = ((_ref = el.value) != null ? _ref.toString() : void 0) !== (value != null ? value.toString() : void 0);
731
+ } else {
732
+ return el.checked = !value;
733
+ }
734
+ }
735
+ },
736
+ show: function(el, value) {
737
+ return el.style.display = value ? '' : 'none';
738
+ },
739
+ hide: function(el, value) {
740
+ return el.style.display = value ? 'none' : '';
741
+ },
742
+ html: function(el, value) {
743
+ return el.innerHTML = value != null ? value : '';
744
+ },
745
+ value: {
746
+ publishes: true,
747
+ bind: function(el) {
748
+ return Rivets.Util.bindEvent(el, 'change', this.publish);
749
+ },
750
+ unbind: function(el) {
751
+ return Rivets.Util.unbindEvent(el, 'change', this.publish);
752
+ },
753
+ routine: function(el, value) {
754
+ var o, _i, _len, _ref, _ref1, _ref2, _results;
755
+ if (window.jQuery != null) {
756
+ el = jQuery(el);
757
+ if ((value != null ? value.toString() : void 0) !== ((_ref = el.val()) != null ? _ref.toString() : void 0)) {
758
+ return el.val(value != null ? value : '');
759
+ }
760
+ } else {
761
+ if (el.type === 'select-multiple') {
762
+ if (value != null) {
763
+ _results = [];
764
+ for (_i = 0, _len = el.length; _i < _len; _i++) {
765
+ o = el[_i];
766
+ _results.push(o.selected = (_ref1 = o.value, __indexOf.call(value, _ref1) >= 0));
767
+ }
768
+ return _results;
769
+ }
770
+ } else if ((value != null ? value.toString() : void 0) !== ((_ref2 = el.value) != null ? _ref2.toString() : void 0)) {
771
+ return el.value = value != null ? value : '';
772
+ }
773
+ }
774
+ }
775
+ },
776
+ text: function(el, value) {
777
+ if (el.innerText != null) {
778
+ return el.innerText = value != null ? value : '';
779
+ } else {
780
+ return el.textContent = value != null ? value : '';
781
+ }
782
+ },
783
+ "if": {
784
+ block: true,
785
+ bind: function(el) {
786
+ var attr, declaration;
787
+ if (this.marker == null) {
788
+ attr = ['data', this.view.config.prefix, this.type].join('-').replace('--', '-');
789
+ declaration = el.getAttribute(attr);
790
+ this.marker = document.createComment(" rivets: " + this.type + " " + declaration + " ");
791
+ el.removeAttribute(attr);
792
+ el.parentNode.insertBefore(this.marker, el);
793
+ return el.parentNode.removeChild(el);
794
+ }
795
+ },
796
+ unbind: function() {
797
+ var _ref;
798
+ return (_ref = this.nested) != null ? _ref.unbind() : void 0;
799
+ },
800
+ routine: function(el, value) {
801
+ var key, model, models, options, _ref;
802
+ if (!!value === (this.nested == null)) {
803
+ if (value) {
804
+ models = {};
805
+ _ref = this.view.models;
806
+ for (key in _ref) {
807
+ model = _ref[key];
808
+ models[key] = model;
809
+ }
810
+ options = {
811
+ binders: this.view.options.binders,
812
+ formatters: this.view.options.formatters,
813
+ config: this.view.options.config
814
+ };
815
+ (this.nested = new Rivets.View(el, models, options)).bind();
816
+ return this.marker.parentNode.insertBefore(el, this.marker.nextSibling);
817
+ } else {
818
+ el.parentNode.removeChild(el);
819
+ this.nested.unbind();
820
+ return delete this.nested;
821
+ }
822
+ }
823
+ },
824
+ update: function(models) {
825
+ var _ref;
826
+ return (_ref = this.nested) != null ? _ref.update(models) : void 0;
827
+ }
828
+ },
829
+ unless: {
830
+ block: true,
831
+ bind: function(el) {
832
+ return Rivets.binders["if"].bind.call(this, el);
833
+ },
834
+ unbind: function() {
835
+ return Rivets.binders["if"].unbind.call(this);
836
+ },
837
+ routine: function(el, value) {
838
+ return Rivets.binders["if"].routine.call(this, el, !value);
839
+ },
840
+ update: function(models) {
841
+ return Rivets.binders["if"].update.call(this, models);
842
+ }
843
+ },
844
+ "on-*": {
845
+ "function": true,
846
+ unbind: function(el) {
847
+ if (this.handler) {
848
+ return Rivets.Util.unbindEvent(el, this.args[0], this.handler);
849
+ }
850
+ },
851
+ routine: function(el, value) {
852
+ if (this.handler) {
853
+ Rivets.Util.unbindEvent(el, this.args[0], this.handler);
854
+ }
855
+ return Rivets.Util.bindEvent(el, this.args[0], this.handler = this.eventHandler(value));
856
+ }
857
+ },
858
+ "each-*": {
859
+ block: true,
860
+ bind: function(el) {
861
+ var attr;
862
+ if (this.marker == null) {
863
+ attr = ['data', this.view.config.prefix, this.type].join('-').replace('--', '-');
864
+ this.marker = document.createComment(" rivets: " + this.type + " ");
865
+ this.iterated = [];
866
+ el.removeAttribute(attr);
867
+ el.parentNode.insertBefore(this.marker, el);
868
+ return el.parentNode.removeChild(el);
869
+ }
870
+ },
871
+ unbind: function(el) {
872
+ var view, _i, _len, _ref, _results;
873
+ if (this.iterated != null) {
874
+ _ref = this.iterated;
875
+ _results = [];
876
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
877
+ view = _ref[_i];
878
+ _results.push(view.unbind());
879
+ }
880
+ return _results;
881
+ }
882
+ },
883
+ routine: function(el, collection) {
884
+ var data, i, index, k, key, model, modelName, options, previous, template, v, view, _i, _j, _len, _len1, _ref, _ref1, _ref2, _results;
885
+ modelName = this.args[0];
886
+ collection = collection || [];
887
+ if (this.iterated.length > collection.length) {
888
+ _ref = Array(this.iterated.length - collection.length);
889
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
890
+ i = _ref[_i];
891
+ view = this.iterated.pop();
892
+ view.unbind();
893
+ this.marker.parentNode.removeChild(view.els[0]);
894
+ }
895
+ }
896
+ _results = [];
897
+ for (index = _j = 0, _len1 = collection.length; _j < _len1; index = ++_j) {
898
+ model = collection[index];
899
+ data = {};
900
+ data[modelName] = model;
901
+ if (this.iterated[index] == null) {
902
+ _ref1 = this.view.models;
903
+ for (key in _ref1) {
904
+ model = _ref1[key];
905
+ if (data[key] == null) {
906
+ data[key] = model;
907
+ }
908
+ }
909
+ previous = this.iterated.length ? this.iterated[this.iterated.length - 1].els[0] : this.marker;
910
+ options = {
911
+ binders: this.view.options.binders,
912
+ formatters: this.view.options.formatters,
913
+ config: {}
914
+ };
915
+ _ref2 = this.view.options.config;
916
+ for (k in _ref2) {
917
+ v = _ref2[k];
918
+ options.config[k] = v;
919
+ }
920
+ options.config.preloadData = true;
921
+ template = el.cloneNode(true);
922
+ view = new Rivets.View(template, data, options);
923
+ view.bind();
924
+ this.iterated.push(view);
925
+ _results.push(this.marker.parentNode.insertBefore(template, previous.nextSibling));
926
+ } else if (this.iterated[index].models[modelName] !== model) {
927
+ _results.push(this.iterated[index].update(data));
928
+ } else {
929
+ _results.push(void 0);
930
+ }
931
+ }
932
+ return _results;
933
+ },
934
+ update: function(models) {
935
+ var data, key, model, view, _i, _len, _ref, _results;
936
+ data = {};
937
+ for (key in models) {
938
+ model = models[key];
939
+ if (key !== this.args[0]) {
940
+ data[key] = model;
941
+ }
942
+ }
943
+ _ref = this.iterated;
944
+ _results = [];
945
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
946
+ view = _ref[_i];
947
+ _results.push(view.update(data));
948
+ }
949
+ return _results;
950
+ }
951
+ },
952
+ "class-*": function(el, value) {
953
+ var elClass;
954
+ elClass = " " + el.className + " ";
955
+ if (!value === (elClass.indexOf(" " + this.args[0] + " ") !== -1)) {
956
+ return el.className = value ? "" + el.className + " " + this.args[0] : elClass.replace(" " + this.args[0] + " ", ' ').trim();
957
+ }
958
+ },
959
+ "*": function(el, value) {
960
+ if (value) {
961
+ return el.setAttribute(this.type, value);
962
+ } else {
963
+ return el.removeAttribute(this.type);
964
+ }
965
+ }
966
+ };
967
+
968
+ Rivets.components = {};
969
+
970
+ Rivets.config = {
971
+ preloadData: true,
972
+ handler: function(context, ev, binding) {
973
+ return this.call(context, ev, binding.view.models);
974
+ }
975
+ };
976
+
977
+ Rivets.formatters = {};
978
+
979
+ Rivets.factory = function(exports) {
980
+ exports._ = Rivets;
981
+ exports.binders = Rivets.binders;
982
+ exports.components = Rivets.components;
983
+ exports.formatters = Rivets.formatters;
984
+ exports.config = Rivets.config;
985
+ exports.configure = function(options) {
986
+ var property, value;
987
+ if (options == null) {
988
+ options = {};
989
+ }
990
+ for (property in options) {
991
+ value = options[property];
992
+ Rivets.config[property] = value;
993
+ }
994
+ };
995
+ return exports.bind = function(el, models, options) {
996
+ var view;
997
+ if (models == null) {
998
+ models = {};
999
+ }
1000
+ if (options == null) {
1001
+ options = {};
1002
+ }
1003
+ view = new Rivets.View(el, models, options);
1004
+ view.bind();
1005
+ return view;
1006
+ };
1007
+ };
1008
+
1009
+ if (typeof exports === 'object') {
1010
+ Rivets.factory(exports);
1011
+ } else if (typeof define === 'function' && define.amd) {
1012
+ define(['exports'], function(exports) {
1013
+ Rivets.factory(this.rivets = exports);
1014
+ return exports;
1015
+ });
1016
+ } else {
1017
+ Rivets.factory(this.rivets = {});
1018
+ }
1019
+
1020
+ }).call(this);