serenade 0.4.2 → 0.5.0
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.
- data/lib/assets/javascripts/serenade.js +323 -196
- data/lib/serenade/version.rb +1 -1
- metadata +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
|
-
* Serenade.js JavaScript Framework v0.
|
3
|
-
* Revision:
|
2
|
+
* Serenade.js JavaScript Framework v0.5.0
|
3
|
+
* Revision: bcda813708
|
4
4
|
* http://github.com/elabs/serenade.js
|
5
5
|
*
|
6
6
|
* Copyright 2011, Jonas Nicklas, Elabs AB
|
@@ -13,7 +13,7 @@ var parser = {trace: function trace() { },
|
|
13
13
|
yy: {},
|
14
14
|
symbols_: {"error":2,"Root":3,"ChildList":4,"ElementIdentifier":5,"AnyIdentifier":6,"#":7,".":8,"Element":9,"[":10,"]":11,"PropertyList":12,"WHITESPACE":13,"Text":14,"INDENT":15,"OUTDENT":16,"TextList":17,"Bound":18,"STRING_LITERAL":19,"Child":20,"TERMINATOR":21,"IfInstruction":22,"Instruction":23,"Helper":24,"Property":25,"=":26,"!":27,":":28,"-":29,"VIEW":30,"COLLECTION":31,"UNLESS":32,"IN":33,"IDENTIFIER":34,"IF":35,"ElseInstruction":36,"ELSE":37,"@":38,"$accept":0,"$end":1},
|
15
15
|
terminals_: {2:"error",7:"#",8:".",10:"[",11:"]",13:"WHITESPACE",15:"INDENT",16:"OUTDENT",19:"STRING_LITERAL",21:"TERMINATOR",26:"=",27:"!",28:":",29:"-",30:"VIEW",31:"COLLECTION",32:"UNLESS",33:"IN",34:"IDENTIFIER",35:"IF",37:"ELSE",38:"@"},
|
16
|
-
productions_: [0,[3,0],[3,1],[5,1],[5,3],[5,2],[5,2],[5,3],[9,1],[9,3],[9,4],[9,3],[9,4],[17,1],[17,3],[14,1],[14,1],[4,1],[4,3],[20,1],[20,1],[20,1],[20,1],[20,1],[12,1],[12,3],[25,3],[25,3],[25,4],[25,4],[25,3],[25,3],[23,5],[23,5],[23,5],[23,5],[23,4],[24,3],[24,3],[24,4],[22,5],[22,4],[22,2],[36,6],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[18,2],[18,1]],
|
16
|
+
productions_: [0,[3,0],[3,1],[5,1],[5,3],[5,2],[5,2],[5,3],[9,1],[9,3],[9,4],[9,3],[9,4],[17,1],[17,3],[14,1],[14,1],[4,1],[4,3],[20,1],[20,1],[20,1],[20,1],[20,1],[12,1],[12,3],[25,3],[25,3],[25,4],[25,4],[25,3],[25,3],[23,5],[23,5],[23,5],[23,5],[23,5],[23,4],[24,3],[24,3],[24,4],[22,5],[22,4],[22,2],[36,6],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[18,2],[18,1]],
|
17
17
|
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
18
18
|
|
19
19
|
var $0 = $$.length - 1;
|
@@ -158,69 +158,74 @@ case 32:this.$ = {
|
|
158
158
|
};
|
159
159
|
break;
|
160
160
|
case 33:this.$ = {
|
161
|
+
children: [],
|
162
|
+
type: 'view',
|
163
|
+
argument: $$[$0],
|
164
|
+
bound: true
|
165
|
+
};
|
166
|
+
break;
|
167
|
+
case 34:this.$ = {
|
161
168
|
children: [],
|
162
169
|
type: 'collection',
|
163
170
|
argument: $$[$0]
|
164
171
|
};
|
165
172
|
break;
|
166
|
-
case
|
173
|
+
case 35:this.$ = {
|
167
174
|
children: [],
|
168
175
|
type: 'unless',
|
169
176
|
argument: $$[$0]
|
170
177
|
};
|
171
178
|
break;
|
172
|
-
case
|
179
|
+
case 36:this.$ = {
|
173
180
|
children: [],
|
174
181
|
type: 'in',
|
175
182
|
argument: $$[$0]
|
176
183
|
};
|
177
184
|
break;
|
178
|
-
case
|
185
|
+
case 37:this.$ = (function () {
|
179
186
|
$$[$0-3].children = $$[$0-1];
|
180
187
|
return $$[$0-3];
|
181
188
|
}());
|
182
189
|
break;
|
183
|
-
case
|
190
|
+
case 38:this.$ = {
|
184
191
|
command: $$[$0],
|
185
192
|
"arguments": [],
|
186
193
|
children: [],
|
187
194
|
type: 'helper'
|
188
195
|
};
|
189
196
|
break;
|
190
|
-
case
|
197
|
+
case 39:this.$ = (function () {
|
191
198
|
$$[$0-2]["arguments"].push($$[$0]);
|
192
199
|
return $$[$0-2];
|
193
200
|
}());
|
194
201
|
break;
|
195
|
-
case
|
202
|
+
case 40:this.$ = (function () {
|
196
203
|
$$[$0-3].children = $$[$0-1];
|
197
204
|
return $$[$0-3];
|
198
205
|
}());
|
199
206
|
break;
|
200
|
-
case
|
207
|
+
case 41:this.$ = {
|
201
208
|
children: [],
|
202
209
|
type: 'if',
|
203
210
|
argument: $$[$0]
|
204
211
|
};
|
205
212
|
break;
|
206
|
-
case
|
213
|
+
case 42:this.$ = (function () {
|
207
214
|
$$[$0-3].children = $$[$0-1];
|
208
215
|
return $$[$0-3];
|
209
216
|
}());
|
210
217
|
break;
|
211
|
-
case
|
218
|
+
case 43:this.$ = (function () {
|
212
219
|
$$[$0-1]["else"] = $$[$0];
|
213
220
|
return $$[$0-1];
|
214
221
|
}());
|
215
222
|
break;
|
216
|
-
case
|
223
|
+
case 44:this.$ = {
|
217
224
|
"arguments": [],
|
218
225
|
children: $$[$0-1],
|
219
226
|
type: 'else'
|
220
227
|
};
|
221
228
|
break;
|
222
|
-
case 44:this.$ = $$[$0];
|
223
|
-
break;
|
224
229
|
case 45:this.$ = $$[$0];
|
225
230
|
break;
|
226
231
|
case 46:this.$ = $$[$0];
|
@@ -233,11 +238,13 @@ case 49:this.$ = $$[$0];
|
|
233
238
|
break;
|
234
239
|
case 50:this.$ = $$[$0];
|
235
240
|
break;
|
236
|
-
case 51:this.$ =
|
241
|
+
case 51:this.$ = $$[$0];
|
242
|
+
break;
|
243
|
+
case 52:this.$ = (function () {}());
|
237
244
|
break;
|
238
245
|
}
|
239
246
|
},
|
240
|
-
table: [{1:[2,1],3:1,4:2,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{1:[3]},{1:[2,2],21:[1,24]},{1:[2,17],16:[2,17],21:[2,17]},{1:[2,19],10:[1,25],13:[1,26],15:[1,27],16:[2,19],21:[2,19]},{1:[2,20],15:[1,28],16:[2,20],21:[2,20],29:[1,30],36:29},{1:[2,21],15:[1,31],16:[2,21],21:[2,21]},{1:[2,22],13:[1,32],15:[1,33],16:[2,22],21:[2,22]},{1:[2,23],13:[1,34],16:[2,23],21:[2,23]},{1:[2,8],8:[1,35],10:[2,8],13:[2,8],15:[2,8],16:[2,8],21:[2,8]},{13:[1,36]},{1:[2,13],13:[2,13],16:[2,13],21:[2,13]},{1:[2,3],7:[1,37],8:[2,3],10:[2,3],13:[2,3],15:[2,3],16:[2,3],21:[2,3]},{6:38,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{6:39,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{1:[2,15],10:[2,15],13:[2,15],15:[2,15],16:[2,15],21:[2,15]},{1:[2,16],10:[2,16],13:[2,16],15:[2,16],16:[2,16],21:[2,16]},{1:[2,
|
247
|
+
table: [{1:[2,1],3:1,4:2,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{1:[3]},{1:[2,2],21:[1,24]},{1:[2,17],16:[2,17],21:[2,17]},{1:[2,19],10:[1,25],13:[1,26],15:[1,27],16:[2,19],21:[2,19]},{1:[2,20],15:[1,28],16:[2,20],21:[2,20],29:[1,30],36:29},{1:[2,21],15:[1,31],16:[2,21],21:[2,21]},{1:[2,22],13:[1,32],15:[1,33],16:[2,22],21:[2,22]},{1:[2,23],13:[1,34],16:[2,23],21:[2,23]},{1:[2,8],8:[1,35],10:[2,8],13:[2,8],15:[2,8],16:[2,8],21:[2,8]},{13:[1,36]},{1:[2,13],13:[2,13],16:[2,13],21:[2,13]},{1:[2,3],7:[1,37],8:[2,3],10:[2,3],13:[2,3],15:[2,3],16:[2,3],21:[2,3]},{6:38,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{6:39,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{1:[2,15],10:[2,15],13:[2,15],15:[2,15],16:[2,15],21:[2,15]},{1:[2,16],10:[2,16],13:[2,16],15:[2,16],16:[2,16],21:[2,16]},{1:[2,45],7:[2,45],8:[2,45],10:[2,45],11:[2,45],13:[2,45],15:[2,45],16:[2,45],21:[2,45],26:[2,45],27:[2,45],28:[2,45],29:[2,45]},{1:[2,46],7:[2,46],8:[2,46],10:[2,46],11:[2,46],13:[2,46],15:[2,46],16:[2,46],21:[2,46],26:[2,46],27:[2,46],28:[2,46],29:[2,46]},{1:[2,47],7:[2,47],8:[2,47],10:[2,47],11:[2,47],13:[2,47],15:[2,47],16:[2,47],21:[2,47],26:[2,47],27:[2,47],28:[2,47],29:[2,47]},{1:[2,48],7:[2,48],8:[2,48],10:[2,48],11:[2,48],13:[2,48],15:[2,48],16:[2,48],21:[2,48],26:[2,48],27:[2,48],28:[2,48],29:[2,48]},{1:[2,49],7:[2,49],8:[2,49],10:[2,49],11:[2,49],13:[2,49],15:[2,49],16:[2,49],21:[2,49],26:[2,49],27:[2,49],28:[2,49],29:[2,49]},{1:[2,50],7:[2,50],8:[2,50],10:[2,50],11:[2,50],13:[2,50],15:[2,50],16:[2,50],21:[2,50],26:[2,50],27:[2,50],28:[2,50],29:[2,50]},{1:[2,52],6:40,10:[2,52],11:[2,52],13:[2,52],15:[2,52],16:[2,52],21:[2,52],27:[2,52],29:[2,52],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:41,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{6:45,11:[1,42],12:43,25:44,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{14:46,18:15,19:[1,16],38:[1,23]},{4:47,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{4:48,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{1:[2,43],15:[2,43],16:[2,43],21:[2,43],29:[2,43]},{13:[1,49]},{4:50,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{14:51,18:15,19:[1,16],38:[1,23]},{4:52,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{14:53,18:15,19:[1,16],38:[1,23]},{6:54,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{30:[1,56],31:[1,57],32:[1,58],33:[1,59],34:[1,60],35:[1,55]},{6:61,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{1:[2,5],8:[2,5],10:[2,5],13:[2,5],15:[2,5],16:[2,5],21:[2,5]},{1:[2,6],8:[2,6],10:[2,6],13:[2,6],15:[2,6],16:[2,6],21:[2,6]},{1:[2,51],10:[2,51],11:[2,51],13:[2,51],15:[2,51],16:[2,51],21:[2,51],27:[2,51],29:[2,51]},{1:[2,18],16:[2,18],21:[2,18]},{1:[2,9],10:[2,9],13:[2,9],15:[2,9],16:[2,9],21:[2,9]},{11:[1,62],13:[1,63]},{11:[2,24],13:[2,24]},{26:[1,64],28:[1,65]},{1:[2,11],10:[2,11],13:[2,11],15:[2,11],16:[2,11],21:[2,11]},{16:[1,66],21:[1,24]},{16:[1,67],21:[1,24]},{37:[1,68]},{16:[1,69],21:[1,24]},{1:[2,39],13:[2,39],15:[2,39],16:[2,39],21:[2,39]},{16:[1,70],21:[1,24]},{1:[2,14],13:[2,14],16:[2,14],21:[2,14]},{1:[2,7],8:[2,7],10:[2,7],13:[2,7],15:[2,7],16:[2,7],21:[2,7]},{13:[1,71]},{13:[1,72]},{13:[1,73]},{13:[1,74]},{13:[1,75]},{1:[2,38],13:[2,38],15:[2,38],16:[2,38],21:[2,38]},{1:[2,4],8:[2,4],10:[2,4],13:[2,4],15:[2,4],16:[2,4],21:[2,4]},{1:[2,10],10:[2,10],13:[2,10],15:[2,10],16:[2,10],21:[2,10]},{6:45,25:76,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{6:77,18:78,19:[1,79],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{6:45,25:80,30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19]},{1:[2,12],10:[2,12],13:[2,12],15:[2,12],16:[2,12],21:[2,12]},{1:[2,42],15:[2,42],16:[2,42],21:[2,42],29:[2,42]},{15:[1,81]},{1:[2,37],15:[2,37],16:[2,37],21:[2,37]},{1:[2,40],13:[2,40],15:[2,40],16:[2,40],21:[2,40]},{18:82,38:[1,23]},{18:84,19:[1,83],38:[1,23]},{18:85,38:[1,23]},{18:86,38:[1,23]},{18:87,38:[1,23]},{11:[2,25],13:[2,25]},{11:[2,26],13:[2,26],27:[1,88]},{11:[2,27],13:[2,27],27:[1,89]},{11:[2,30],13:[2,30]},{11:[2,31],13:[2,31]},{4:90,5:9,6:12,7:[1,13],8:[1,14],9:4,14:11,17:8,18:15,19:[1,16],20:3,22:5,23:6,24:7,29:[1,10],30:[1,17],31:[1,18],32:[1,20],33:[1,21],34:[1,22],35:[1,19],38:[1,23]},{1:[2,41],15:[2,41],16:[2,41],21:[2,41],29:[2,41]},{1:[2,32],15:[2,32],16:[2,32],21:[2,32]},{1:[2,33],15:[2,33],16:[2,33],21:[2,33]},{1:[2,34],15:[2,34],16:[2,34],21:[2,34]},{1:[2,35],15:[2,35],16:[2,35],21:[2,35]},{1:[2,36],15:[2,36],16:[2,36],21:[2,36]},{11:[2,28],13:[2,28]},{11:[2,29],13:[2,29]},{16:[1,91],21:[1,24]},{1:[2,44],15:[2,44],16:[2,44],21:[2,44],29:[2,44]}],
|
241
248
|
defaultActions: {},
|
242
249
|
parseError: function parseError(str, hash) {
|
243
250
|
throw new Error(str);
|
@@ -354,7 +361,7 @@ exports.main = function commonjsMain(args) {
|
|
354
361
|
if (typeof module !== 'undefined' && require.main === module) {
|
355
362
|
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
|
356
363
|
}
|
357
|
-
}var AssociationCollection, COMMENT, Cache, Collection, Compile,
|
364
|
+
}var AssociationCollection, COMMENT, Cache, Collection, Compile, DynamicNode, Event, IDENTIFIER, KEYWORDS, LITERAL, Lexer, MULTI_DENT, Map, Model, Node, Property, PropertyAccessor, PropertyDefinition, STRING, Serenade, Transform, View, WHITESPACE, assignUnlessEqual, capitalize, compile, def, defineEvent, defineOptions, defineProperty, extend, format, getValue, hash, idCounter, isArray, isArrayIndex, merge, normalize, pairToObject, primitiveTypes, safeDelete, safePush, serializeObject, settings,
|
358
365
|
__hasProp = {}.hasOwnProperty,
|
359
366
|
__slice = [].slice,
|
360
367
|
__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; },
|
@@ -367,6 +374,8 @@ settings = {
|
|
367
374
|
|
368
375
|
def = Object.defineProperty;
|
369
376
|
|
377
|
+
primitiveTypes = ["undefined", "boolean", "number", "string"];
|
378
|
+
|
370
379
|
defineOptions = function(object, name) {
|
371
380
|
return def(object, name, {
|
372
381
|
get: function() {
|
@@ -460,6 +469,17 @@ capitalize = function(word) {
|
|
460
469
|
return word.slice(0, 1).toUpperCase() + word.slice(1);
|
461
470
|
};
|
462
471
|
|
472
|
+
hash = function(value) {
|
473
|
+
var key;
|
474
|
+
|
475
|
+
key = value instanceof Object ? (!("_s_hash" in value) ? def(value, "_s_hash", {
|
476
|
+
value: ++arguments.callee.current
|
477
|
+
}) : void 0, value._s_hash) : value;
|
478
|
+
return (typeof value) + ' ' + key;
|
479
|
+
};
|
480
|
+
|
481
|
+
hash.current = 0;
|
482
|
+
|
463
483
|
safePush = function(object, collection, item) {
|
464
484
|
if (!object[collection] || object[collection].indexOf(item) === -1) {
|
465
485
|
if (object.hasOwnProperty(collection)) {
|
@@ -489,6 +509,114 @@ safeDelete = function(object, collection, item) {
|
|
489
509
|
}
|
490
510
|
};
|
491
511
|
|
512
|
+
Map = (function() {
|
513
|
+
function Map(array) {
|
514
|
+
var element, index, _i, _len;
|
515
|
+
|
516
|
+
this.map = {};
|
517
|
+
for (index = _i = 0, _len = array.length; _i < _len; index = ++_i) {
|
518
|
+
element = array[index];
|
519
|
+
this.put(index, element);
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
Map.prototype.isMember = function(element) {
|
524
|
+
var _ref;
|
525
|
+
|
526
|
+
return ((_ref = this.map[hash(element)]) != null ? _ref[0].length : void 0) > 0;
|
527
|
+
};
|
528
|
+
|
529
|
+
Map.prototype.indexOf = function(element) {
|
530
|
+
var _ref, _ref1;
|
531
|
+
|
532
|
+
return (_ref = this.map[hash(element)]) != null ? (_ref1 = _ref[0]) != null ? _ref1[0] : void 0 : void 0;
|
533
|
+
};
|
534
|
+
|
535
|
+
Map.prototype.put = function(index, element) {
|
536
|
+
var existing;
|
537
|
+
|
538
|
+
existing = this.map[hash(element)];
|
539
|
+
return this.map[hash(element)] = existing ? [
|
540
|
+
existing[0].concat(index).sort(function(a, b) {
|
541
|
+
return a - b;
|
542
|
+
}), element
|
543
|
+
] : [[index], element];
|
544
|
+
};
|
545
|
+
|
546
|
+
Map.prototype.remove = function(element) {
|
547
|
+
var _base, _ref;
|
548
|
+
|
549
|
+
return (_ref = this.map[hash(element)]) != null ? typeof (_base = _ref[0]).shift === "function" ? _base.shift() : void 0 : void 0;
|
550
|
+
};
|
551
|
+
|
552
|
+
return Map;
|
553
|
+
|
554
|
+
})();
|
555
|
+
|
556
|
+
Transform = function(from, to) {
|
557
|
+
var actual, cleaned, cleanedMap, complete, completeMap, element, index, indexActual, indexWanted, operations, targetMap, wanted, _i, _j, _k, _len, _len1, _len2;
|
558
|
+
|
559
|
+
if (from == null) {
|
560
|
+
from = [];
|
561
|
+
}
|
562
|
+
if (to == null) {
|
563
|
+
to = [];
|
564
|
+
}
|
565
|
+
operations = [];
|
566
|
+
to = to.map(function(e) {
|
567
|
+
return e;
|
568
|
+
});
|
569
|
+
targetMap = new Map(to);
|
570
|
+
cleaned = [];
|
571
|
+
for (_i = 0, _len = from.length; _i < _len; _i++) {
|
572
|
+
element = from[_i];
|
573
|
+
if (targetMap.isMember(element)) {
|
574
|
+
cleaned.push(element);
|
575
|
+
} else {
|
576
|
+
operations.push({
|
577
|
+
type: "remove",
|
578
|
+
index: cleaned.length
|
579
|
+
});
|
580
|
+
}
|
581
|
+
targetMap.remove(element);
|
582
|
+
}
|
583
|
+
complete = [].concat(cleaned);
|
584
|
+
cleanedMap = new Map(cleaned);
|
585
|
+
for (index = _j = 0, _len1 = to.length; _j < _len1; index = ++_j) {
|
586
|
+
element = to[index];
|
587
|
+
if (!cleanedMap.isMember(element)) {
|
588
|
+
operations.push({
|
589
|
+
type: "insert",
|
590
|
+
index: index,
|
591
|
+
value: element
|
592
|
+
});
|
593
|
+
complete.splice(index, 0, element);
|
594
|
+
}
|
595
|
+
cleanedMap.remove(element);
|
596
|
+
}
|
597
|
+
completeMap = new Map(complete);
|
598
|
+
for (indexActual = _k = 0, _len2 = complete.length; _k < _len2; indexActual = ++_k) {
|
599
|
+
actual = complete[indexActual];
|
600
|
+
wanted = to[indexActual];
|
601
|
+
if (actual !== wanted) {
|
602
|
+
indexWanted = completeMap.indexOf(wanted);
|
603
|
+
completeMap.remove(actual);
|
604
|
+
completeMap.remove(wanted);
|
605
|
+
completeMap.put(indexWanted, actual);
|
606
|
+
complete[indexActual] = wanted;
|
607
|
+
complete[indexWanted] = actual;
|
608
|
+
operations.push({
|
609
|
+
type: "swap",
|
610
|
+
index: indexActual,
|
611
|
+
"with": indexWanted
|
612
|
+
});
|
613
|
+
} else {
|
614
|
+
completeMap.remove(actual);
|
615
|
+
}
|
616
|
+
}
|
617
|
+
return operations;
|
618
|
+
};
|
619
|
+
|
492
620
|
Event = (function() {
|
493
621
|
function Event(object, name, options) {
|
494
622
|
this.object = object;
|
@@ -507,17 +635,26 @@ Event = (function() {
|
|
507
635
|
});
|
508
636
|
|
509
637
|
Event.prototype.trigger = function() {
|
510
|
-
var args,
|
638
|
+
var args, _base,
|
511
639
|
_this = this;
|
512
640
|
|
513
641
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
514
642
|
if (this.listeners.length) {
|
515
643
|
this.queue.push(args);
|
516
644
|
if (this.async) {
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
645
|
+
if (this.options.animate) {
|
646
|
+
return (_base = this.queue).frame || (_base.frame = requestAnimationFrame((function() {
|
647
|
+
return _this.resolve();
|
648
|
+
}), this.options.timeout || 0));
|
649
|
+
} else {
|
650
|
+
if (this.queue.timeout && !this.options.buffer) {
|
651
|
+
return;
|
652
|
+
}
|
653
|
+
clearTimeout(this.queue.timeout);
|
654
|
+
return this.queue.timeout = setTimeout((function() {
|
655
|
+
return _this.resolve();
|
656
|
+
}), this.options.timeout || 0);
|
657
|
+
}
|
521
658
|
} else {
|
522
659
|
return this.resolve();
|
523
660
|
}
|
@@ -555,6 +692,9 @@ Event = (function() {
|
|
555
692
|
var args, perform, _i, _len, _ref,
|
556
693
|
_this = this;
|
557
694
|
|
695
|
+
if (this.queue.frame) {
|
696
|
+
cancelAnimationFrame(this.queue.frame);
|
697
|
+
}
|
558
698
|
clearTimeout(this.queue.timeout);
|
559
699
|
if (this.queue.length) {
|
560
700
|
perform = function(args) {
|
@@ -953,12 +1093,13 @@ PropertyDefinition = (function() {
|
|
953
1093
|
|
954
1094
|
def(PropertyDefinition.prototype, "eventOptions", {
|
955
1095
|
get: function() {
|
956
|
-
var name;
|
1096
|
+
var name, options;
|
957
1097
|
|
958
1098
|
name = this.name;
|
959
|
-
|
960
|
-
async: this.async != null ? this.async : settings.async,
|
1099
|
+
options = {
|
961
1100
|
timeout: this.timeout,
|
1101
|
+
buffer: this.buffer,
|
1102
|
+
animate: this.animate,
|
962
1103
|
bind: function() {
|
963
1104
|
this[name];
|
964
1105
|
return this[name + "_property"].registerGlobal();
|
@@ -969,6 +1110,10 @@ PropertyDefinition = (function() {
|
|
969
1110
|
return [(_ref = queue[0]) != null ? _ref[0] : void 0, (_ref1 = queue[queue.length - 1]) != null ? _ref1[1] : void 0];
|
970
1111
|
}
|
971
1112
|
};
|
1113
|
+
if (this.async != null) {
|
1114
|
+
options.async = this.async;
|
1115
|
+
}
|
1116
|
+
return options;
|
972
1117
|
}
|
973
1118
|
});
|
974
1119
|
|
@@ -1010,7 +1155,7 @@ PropertyAccessor = (function() {
|
|
1010
1155
|
this.object = object;
|
1011
1156
|
this.trigger = __bind(this.trigger, this);
|
1012
1157
|
this.name = this.definition.name;
|
1013
|
-
this.valueName = "
|
1158
|
+
this.valueName = "_" + this.name;
|
1014
1159
|
this.event = new Event(this.object, this.name + "_change", this.definition.eventOptions);
|
1015
1160
|
this._gcQueue = [];
|
1016
1161
|
}
|
@@ -1022,7 +1167,7 @@ PropertyAccessor = (function() {
|
|
1022
1167
|
if (this.definition.set) {
|
1023
1168
|
this.definition.set.call(this.object, value);
|
1024
1169
|
} else {
|
1025
|
-
def(this.object
|
1170
|
+
def(this.object, this.valueName, {
|
1026
1171
|
value: value,
|
1027
1172
|
configurable: true
|
1028
1173
|
});
|
@@ -1035,7 +1180,7 @@ PropertyAccessor = (function() {
|
|
1035
1180
|
var listener, value,
|
1036
1181
|
_this = this;
|
1037
1182
|
|
1038
|
-
if (this.definition.get && !(this.definition.cache && this.valueName in this.object
|
1183
|
+
if (this.definition.get && !(this.definition.cache && this.valueName in this.object)) {
|
1039
1184
|
listener = function(name) {
|
1040
1185
|
return _this.definition.addDependency(name);
|
1041
1186
|
};
|
@@ -1047,14 +1192,14 @@ PropertyAccessor = (function() {
|
|
1047
1192
|
this.object._s.property_access.unbind(listener);
|
1048
1193
|
}
|
1049
1194
|
if (this.definition.cache) {
|
1050
|
-
this.object
|
1195
|
+
this.object[this.valueName] = value;
|
1051
1196
|
if (!this._isCached) {
|
1052
1197
|
this._isCached = true;
|
1053
1198
|
this.bind(function() {});
|
1054
1199
|
}
|
1055
1200
|
}
|
1056
1201
|
} else {
|
1057
|
-
value = this.object
|
1202
|
+
value = this.object[this.valueName];
|
1058
1203
|
}
|
1059
1204
|
this.object._s.property_access.trigger(this.name);
|
1060
1205
|
return value;
|
@@ -1255,12 +1400,12 @@ PropertyAccessor = (function() {
|
|
1255
1400
|
|
1256
1401
|
PropertyAccessor.prototype.clearCache = function() {
|
1257
1402
|
if (this.definition.cache && this.definition.get) {
|
1258
|
-
return delete this.object
|
1403
|
+
return delete this.object[this.valueName];
|
1259
1404
|
}
|
1260
1405
|
};
|
1261
1406
|
|
1262
1407
|
PropertyAccessor.prototype.hasChanged = function() {
|
1263
|
-
var _ref;
|
1408
|
+
var _ref, _ref1;
|
1264
1409
|
|
1265
1410
|
if ((_ref = this.definition.changed) === true || _ref === false) {
|
1266
1411
|
return this.definition.changed;
|
@@ -1269,7 +1414,11 @@ PropertyAccessor = (function() {
|
|
1269
1414
|
if (this.definition.changed) {
|
1270
1415
|
return this.definition.changed.call(this.object, this._oldValue, this.get());
|
1271
1416
|
} else {
|
1272
|
-
|
1417
|
+
if (_ref1 = typeof this._oldValue, __indexOf.call(primitiveTypes, _ref1) >= 0) {
|
1418
|
+
return this._oldValue !== this.get();
|
1419
|
+
} else {
|
1420
|
+
return true;
|
1421
|
+
}
|
1273
1422
|
}
|
1274
1423
|
} else {
|
1275
1424
|
return true;
|
@@ -1454,12 +1603,12 @@ Model = (function() {
|
|
1454
1603
|
get: function() {
|
1455
1604
|
var valueName;
|
1456
1605
|
|
1457
|
-
valueName = "
|
1458
|
-
if (!this
|
1459
|
-
this
|
1460
|
-
this
|
1606
|
+
valueName = "_" + name;
|
1607
|
+
if (!this[valueName]) {
|
1608
|
+
this[valueName] = new Collection([]);
|
1609
|
+
this[valueName].change.bind(this[name + "_property"].trigger);
|
1461
1610
|
}
|
1462
|
-
return this
|
1611
|
+
return this[valueName];
|
1463
1612
|
},
|
1464
1613
|
set: function(value) {
|
1465
1614
|
return this[name].update(value);
|
@@ -1484,12 +1633,12 @@ Model = (function() {
|
|
1484
1633
|
set: function(model) {
|
1485
1634
|
var previous, valueName;
|
1486
1635
|
|
1487
|
-
valueName = "
|
1636
|
+
valueName = "_" + name;
|
1488
1637
|
if (model && model.constructor === Object && options.as) {
|
1489
1638
|
model = new (options.as())(model);
|
1490
1639
|
}
|
1491
|
-
previous = this
|
1492
|
-
this
|
1640
|
+
previous = this[valueName];
|
1641
|
+
this[valueName] = model;
|
1493
1642
|
if (options.inverseOf && !model[options.inverseOf].includes(this)) {
|
1494
1643
|
if (previous) {
|
1495
1644
|
previous[options.inverseOf]["delete"](this);
|
@@ -1526,12 +1675,12 @@ Model = (function() {
|
|
1526
1675
|
get: function() {
|
1527
1676
|
var valueName;
|
1528
1677
|
|
1529
|
-
valueName = "
|
1530
|
-
if (!this
|
1531
|
-
this
|
1532
|
-
this
|
1678
|
+
valueName = "_" + name;
|
1679
|
+
if (!this[valueName]) {
|
1680
|
+
this[valueName] = new AssociationCollection(this, options, []);
|
1681
|
+
this[valueName].change.bind(this[name + "_property"].trigger);
|
1533
1682
|
}
|
1534
|
-
return this
|
1683
|
+
return this[valueName];
|
1535
1684
|
},
|
1536
1685
|
set: function(value) {
|
1537
1686
|
return this[name].update(value);
|
@@ -2039,10 +2188,6 @@ DynamicNode = (function(_super) {
|
|
2039
2188
|
return this.rebuild();
|
2040
2189
|
};
|
2041
2190
|
|
2042
|
-
DynamicNode.prototype.appendNodeSet = function(nodes) {
|
2043
|
-
return this.insertNodeSet(this.nodeSets.length, nodes);
|
2044
|
-
};
|
2045
|
-
|
2046
2191
|
DynamicNode.prototype.deleteNodeSet = function(index) {
|
2047
2192
|
var node, _i, _len, _ref;
|
2048
2193
|
|
@@ -2060,12 +2205,38 @@ DynamicNode = (function(_super) {
|
|
2060
2205
|
last = ((_ref = this.nodeSets[index - 1]) != null ? (_ref1 = _ref.last) != null ? _ref1.lastElement : void 0 : void 0) || this.anchor;
|
2061
2206
|
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
|
2062
2207
|
node = nodes[_i];
|
2063
|
-
|
2208
|
+
if (this.anchor.parentNode) {
|
2209
|
+
node.insertAfter(last);
|
2210
|
+
}
|
2064
2211
|
last = node.lastElement;
|
2065
2212
|
}
|
2066
2213
|
return this.nodeSets.insertAt(index, new Collection(nodes));
|
2067
2214
|
};
|
2068
2215
|
|
2216
|
+
DynamicNode.prototype.swapNodeSet = function(fromIndex, toIndex) {
|
2217
|
+
var last, node, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
|
2218
|
+
|
2219
|
+
last = ((_ref = this.nodeSets[fromIndex - 1]) != null ? (_ref1 = _ref.last) != null ? _ref1.lastElement : void 0 : void 0) || this.anchor;
|
2220
|
+
_ref2 = this.nodeSets[toIndex];
|
2221
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
2222
|
+
node = _ref2[_i];
|
2223
|
+
if (this.anchor.parentNode) {
|
2224
|
+
node.insertAfter(last);
|
2225
|
+
}
|
2226
|
+
last = node.lastElement;
|
2227
|
+
}
|
2228
|
+
last = ((_ref3 = this.nodeSets[toIndex - 1]) != null ? (_ref4 = _ref3.last) != null ? _ref4.lastElement : void 0 : void 0) || this.anchor;
|
2229
|
+
_ref5 = this.nodeSets[fromIndex];
|
2230
|
+
for (_j = 0, _len1 = _ref5.length; _j < _len1; _j++) {
|
2231
|
+
node = _ref5[_j];
|
2232
|
+
if (this.anchor.parentNode) {
|
2233
|
+
node.insertAfter(last);
|
2234
|
+
}
|
2235
|
+
last = node.lastElement;
|
2236
|
+
}
|
2237
|
+
return _ref6 = [this.nodeSets[toIndex], this.nodeSets[fromIndex]], this.nodeSets[fromIndex] = _ref6[0], this.nodeSets[toIndex] = _ref6[1], _ref6;
|
2238
|
+
};
|
2239
|
+
|
2069
2240
|
DynamicNode.prototype.clear = function() {
|
2070
2241
|
var node, _i, _len, _ref;
|
2071
2242
|
|
@@ -2080,7 +2251,9 @@ DynamicNode = (function(_super) {
|
|
2080
2251
|
DynamicNode.prototype.remove = function() {
|
2081
2252
|
this.detach();
|
2082
2253
|
this.clear();
|
2083
|
-
|
2254
|
+
if (this.anchor.parentNode) {
|
2255
|
+
return this.anchor.parentNode.removeChild(this.anchor);
|
2256
|
+
}
|
2084
2257
|
};
|
2085
2258
|
|
2086
2259
|
DynamicNode.prototype.append = function(inside) {
|
@@ -2279,48 +2452,49 @@ Compile = {
|
|
2279
2452
|
return node;
|
2280
2453
|
},
|
2281
2454
|
view: function(ast, model, parent) {
|
2282
|
-
var
|
2455
|
+
var compileView, controller, skipCallback;
|
2283
2456
|
|
2284
|
-
controller = Serenade.
|
2457
|
+
controller = Serenade.controllers[ast.argument];
|
2285
2458
|
if (!controller) {
|
2286
2459
|
skipCallback = true;
|
2287
2460
|
controller = parent;
|
2288
2461
|
}
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2462
|
+
compileView = function(dynamic, before, after) {
|
2463
|
+
var view;
|
2464
|
+
|
2465
|
+
view = Serenade.views[after].render(model, controller, parent, skipCallback);
|
2466
|
+
dynamic.replace([view.nodes]);
|
2467
|
+
return dynamic;
|
2468
|
+
};
|
2469
|
+
if (ast.bound) {
|
2470
|
+
return this.bound(ast, model, controller, compileView);
|
2471
|
+
} else {
|
2472
|
+
return compileView(new DynamicNode(ast), void 0, ast.argument);
|
2473
|
+
}
|
2292
2474
|
},
|
2293
2475
|
helper: function(ast, model, controller) {
|
2294
|
-
var argument, context, dynamic, helperFunction,
|
2476
|
+
var argument, context, dynamic, helperFunction, renderBlock, update, _i, _len, _ref;
|
2295
2477
|
|
2296
2478
|
dynamic = new DynamicNode(ast);
|
2297
|
-
|
2298
|
-
var child, children, fragment, _i, _len;
|
2299
|
-
|
2479
|
+
renderBlock = function(model, controller) {
|
2300
2480
|
if (model == null) {
|
2301
2481
|
model = model;
|
2302
2482
|
}
|
2303
2483
|
if (controller == null) {
|
2304
2484
|
controller = controller;
|
2305
2485
|
}
|
2306
|
-
|
2307
|
-
children = compile(ast.children, model, controller);
|
2308
|
-
for (_i = 0, _len = children.length; _i < _len; _i++) {
|
2309
|
-
child = children[_i];
|
2310
|
-
child.append(fragment);
|
2311
|
-
}
|
2312
|
-
return fragment;
|
2486
|
+
return new View(null, ast.children).render(model, controller);
|
2313
2487
|
};
|
2314
2488
|
helperFunction = Serenade.Helpers[ast.command] || (function() {
|
2315
2489
|
throw SyntaxError("no helper " + ast.command + " defined");
|
2316
2490
|
})();
|
2317
2491
|
context = {
|
2318
|
-
render: render,
|
2319
2492
|
model: model,
|
2320
|
-
controller: controller
|
2493
|
+
controller: controller,
|
2494
|
+
render: renderBlock
|
2321
2495
|
};
|
2322
2496
|
update = function() {
|
2323
|
-
var args
|
2497
|
+
var args;
|
2324
2498
|
|
2325
2499
|
args = ast["arguments"].map(function(a) {
|
2326
2500
|
if (a.bound) {
|
@@ -2329,18 +2503,7 @@ Compile = {
|
|
2329
2503
|
return a.value;
|
2330
2504
|
}
|
2331
2505
|
});
|
2332
|
-
|
2333
|
-
var _i, _len, _ref, _results;
|
2334
|
-
|
2335
|
-
_ref = normalize(helperFunction.apply(context, args));
|
2336
|
-
_results = [];
|
2337
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2338
|
-
element = _ref[_i];
|
2339
|
-
_results.push(new Node(ast, element));
|
2340
|
-
}
|
2341
|
-
return _results;
|
2342
|
-
})();
|
2343
|
-
return dynamic.replace([nodes]);
|
2506
|
+
return dynamic.replace([normalize(ast, helperFunction.apply(context, args))]);
|
2344
2507
|
};
|
2345
2508
|
_ref = ast["arguments"];
|
2346
2509
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
@@ -2374,36 +2537,44 @@ Compile = {
|
|
2374
2537
|
return node;
|
2375
2538
|
},
|
2376
2539
|
collection: function(ast, model, controller) {
|
2377
|
-
var
|
2540
|
+
var compileItem, dynamic, renderedCollection, update, updateCollection;
|
2378
2541
|
|
2379
|
-
|
2542
|
+
dynamic = null;
|
2380
2543
|
compileItem = function(item) {
|
2381
2544
|
return compile(ast.children, item, controller);
|
2382
2545
|
};
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
update = function(dynamic, newCollection) {
|
2387
|
-
var item;
|
2388
|
-
|
2389
|
-
dynamic.unbindEvent(collection.change, updateCollection);
|
2390
|
-
dynamic.replace((function() {
|
2391
|
-
var _i, _len, _results;
|
2546
|
+
renderedCollection = [];
|
2547
|
+
updateCollection = function(_, after) {
|
2548
|
+
var operation, _i, _len, _ref;
|
2392
2549
|
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2550
|
+
_ref = Transform(renderedCollection, after);
|
2551
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2552
|
+
operation = _ref[_i];
|
2553
|
+
switch (operation.type) {
|
2554
|
+
case "insert":
|
2555
|
+
dynamic.insertNodeSet(operation.index, compileItem(operation.value));
|
2556
|
+
break;
|
2557
|
+
case "remove":
|
2558
|
+
dynamic.deleteNodeSet(operation.index);
|
2559
|
+
break;
|
2560
|
+
case "swap":
|
2561
|
+
dynamic.swapNodeSet(operation.index, operation["with"]);
|
2397
2562
|
}
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2563
|
+
}
|
2564
|
+
return renderedCollection = (after != null ? after.map(function(a) {
|
2565
|
+
return a;
|
2566
|
+
}) : void 0) || [];
|
2567
|
+
};
|
2568
|
+
update = function(dyn, before, after) {
|
2569
|
+
dynamic = dyn;
|
2570
|
+
dynamic.unbindEvent(before != null ? before.change : void 0, updateCollection);
|
2571
|
+
dynamic.bindEvent(after != null ? after.change : void 0, updateCollection);
|
2572
|
+
return updateCollection(before, after);
|
2402
2573
|
};
|
2403
|
-
return
|
2574
|
+
return this.bound(ast, model, controller, update);
|
2404
2575
|
},
|
2405
2576
|
"in": function(ast, model, controller) {
|
2406
|
-
return this.bound(ast, model, controller, function(dynamic, value) {
|
2577
|
+
return this.bound(ast, model, controller, function(dynamic, _, value) {
|
2407
2578
|
if (value) {
|
2408
2579
|
return dynamic.replace([compile(ast.children, value, controller)]);
|
2409
2580
|
} else {
|
@@ -2412,7 +2583,7 @@ Compile = {
|
|
2412
2583
|
});
|
2413
2584
|
},
|
2414
2585
|
"if": function(ast, model, controller) {
|
2415
|
-
return this.bound(ast, model, controller, function(dynamic, value) {
|
2586
|
+
return this.bound(ast, model, controller, function(dynamic, _, value) {
|
2416
2587
|
if (value) {
|
2417
2588
|
return dynamic.replace([compile(ast.children, model, controller)]);
|
2418
2589
|
} else if (ast["else"]) {
|
@@ -2423,7 +2594,7 @@ Compile = {
|
|
2423
2594
|
});
|
2424
2595
|
},
|
2425
2596
|
unless: function(ast, model, controller) {
|
2426
|
-
return this.bound(ast, model, controller, function(dynamic, value) {
|
2597
|
+
return this.bound(ast, model, controller, function(dynamic, _, value) {
|
2427
2598
|
var nodes;
|
2428
2599
|
|
2429
2600
|
if (value) {
|
@@ -2435,26 +2606,21 @@ Compile = {
|
|
2435
2606
|
});
|
2436
2607
|
},
|
2437
2608
|
bound: function(ast, model, controller, callback) {
|
2438
|
-
var dynamic,
|
2609
|
+
var dynamic, update;
|
2439
2610
|
|
2440
2611
|
dynamic = new DynamicNode(ast);
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
value = model[ast.argument];
|
2446
|
-
if (value !== lastValue) {
|
2447
|
-
callback(dynamic, value);
|
2612
|
+
update = function(before, after) {
|
2613
|
+
if (before !== after) {
|
2614
|
+
return callback(dynamic, before, after);
|
2448
2615
|
}
|
2449
|
-
return lastValue = value;
|
2450
2616
|
};
|
2451
|
-
update();
|
2617
|
+
update({}, model[ast.argument]);
|
2452
2618
|
dynamic.bindEvent(model["" + ast.argument + "_property"], update);
|
2453
2619
|
return dynamic;
|
2454
2620
|
}
|
2455
2621
|
};
|
2456
2622
|
|
2457
|
-
normalize = function(val) {
|
2623
|
+
normalize = function(ast, val) {
|
2458
2624
|
var reduction;
|
2459
2625
|
|
2460
2626
|
if (!val) {
|
@@ -2466,19 +2632,23 @@ normalize = function(val) {
|
|
2466
2632
|
if (typeof element === "string") {
|
2467
2633
|
div = Serenade.document.createElement("div");
|
2468
2634
|
div.innerHTML = element;
|
2469
|
-
_ref = div.
|
2635
|
+
_ref = div.childNodes;
|
2470
2636
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2471
2637
|
child = _ref[_i];
|
2472
|
-
aggregate.push(child);
|
2638
|
+
aggregate.push(new Node(ast, child));
|
2473
2639
|
}
|
2474
2640
|
} else if (element.nodeName === "#document-fragment") {
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2641
|
+
if (element.nodes) {
|
2642
|
+
aggregate = aggregate.concat(element.nodes);
|
2643
|
+
} else {
|
2644
|
+
_ref1 = element.childNodes;
|
2645
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
2646
|
+
child = _ref1[_j];
|
2647
|
+
aggregate.push(new Node(ast, child));
|
2648
|
+
}
|
2479
2649
|
}
|
2480
2650
|
} else {
|
2481
|
-
aggregate.push(element);
|
2651
|
+
aggregate.push(new Node(ast, element));
|
2482
2652
|
}
|
2483
2653
|
return aggregate;
|
2484
2654
|
};
|
@@ -2512,42 +2682,6 @@ parser.lexer = {
|
|
2512
2682
|
}
|
2513
2683
|
};
|
2514
2684
|
|
2515
|
-
CompiledView = (function() {
|
2516
|
-
function CompiledView(nodes) {
|
2517
|
-
this.nodes = nodes;
|
2518
|
-
}
|
2519
|
-
|
2520
|
-
CompiledView.prototype.remove = function() {
|
2521
|
-
var node, _i, _len, _ref, _results;
|
2522
|
-
|
2523
|
-
_ref = this.nodes;
|
2524
|
-
_results = [];
|
2525
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2526
|
-
node = _ref[_i];
|
2527
|
-
_results.push(node.remove());
|
2528
|
-
}
|
2529
|
-
return _results;
|
2530
|
-
};
|
2531
|
-
|
2532
|
-
def(CompiledView.prototype, "fragment", {
|
2533
|
-
enumerable: true,
|
2534
|
-
get: function() {
|
2535
|
-
var fragment, node, _i, _len, _ref;
|
2536
|
-
|
2537
|
-
fragment = Serenade.document.createDocumentFragment();
|
2538
|
-
_ref = this.nodes;
|
2539
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2540
|
-
node = _ref[_i];
|
2541
|
-
node.append(fragment);
|
2542
|
-
}
|
2543
|
-
return fragment;
|
2544
|
-
}
|
2545
|
-
});
|
2546
|
-
|
2547
|
-
return CompiledView;
|
2548
|
-
|
2549
|
-
})();
|
2550
|
-
|
2551
2685
|
View = (function() {
|
2552
2686
|
function View(name, view) {
|
2553
2687
|
this.name = name;
|
@@ -2572,20 +2706,10 @@ View = (function() {
|
|
2572
2706
|
}
|
2573
2707
|
};
|
2574
2708
|
|
2575
|
-
View.prototype.render = function() {
|
2576
|
-
var
|
2709
|
+
View.prototype.render = function(model, controller, parent, skipCallback) {
|
2710
|
+
var fragment, node, nodes, _i, _len;
|
2577
2711
|
|
2578
|
-
|
2579
|
-
return this.compile.apply(this, args).fragment;
|
2580
|
-
};
|
2581
|
-
|
2582
|
-
View.prototype.nodes = function(model, controller, parent, skipCallback) {
|
2583
|
-
var nodes;
|
2584
|
-
|
2585
|
-
if (this.name) {
|
2586
|
-
controller || (controller = Serenade.controllerFor(this.name, model));
|
2587
|
-
}
|
2588
|
-
controller || (controller = {});
|
2712
|
+
controller || (controller = Serenade.controllers[this.name] || {});
|
2589
2713
|
if (typeof controller === "function") {
|
2590
2714
|
controller = new controller(model, parent);
|
2591
2715
|
}
|
@@ -2597,14 +2721,24 @@ View = (function() {
|
|
2597
2721
|
})).concat([model]));
|
2598
2722
|
}
|
2599
2723
|
}
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2724
|
+
fragment = Serenade.document.createDocumentFragment();
|
2725
|
+
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
|
2726
|
+
node = nodes[_i];
|
2727
|
+
node.append(fragment);
|
2728
|
+
}
|
2729
|
+
fragment.nodes = nodes;
|
2730
|
+
fragment.remove = function() {
|
2731
|
+
var _j, _len1, _ref, _results;
|
2605
2732
|
|
2606
|
-
|
2607
|
-
|
2733
|
+
_ref = this.nodes;
|
2734
|
+
_results = [];
|
2735
|
+
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
|
2736
|
+
node = _ref[_j];
|
2737
|
+
_results.push(node.remove());
|
2738
|
+
}
|
2739
|
+
return _results;
|
2740
|
+
};
|
2741
|
+
return fragment;
|
2608
2742
|
};
|
2609
2743
|
|
2610
2744
|
return View;
|
@@ -2625,32 +2759,25 @@ Serenade = function(wrapped) {
|
|
2625
2759
|
};
|
2626
2760
|
|
2627
2761
|
extend(Serenade, {
|
2628
|
-
VERSION: '0.
|
2629
|
-
|
2630
|
-
|
2762
|
+
VERSION: '0.5.0',
|
2763
|
+
views: {},
|
2764
|
+
controllers: {},
|
2631
2765
|
document: typeof window !== "undefined" && window !== null ? window.document : void 0,
|
2632
2766
|
format: format,
|
2633
2767
|
defineProperty: defineProperty,
|
2634
2768
|
defineEvent: defineEvent,
|
2635
|
-
asyncEvents: false,
|
2636
2769
|
view: function(nameOrTemplate, template) {
|
2637
2770
|
if (template) {
|
2638
|
-
return this.
|
2771
|
+
return this.views[nameOrTemplate] = new View(nameOrTemplate, template);
|
2639
2772
|
} else {
|
2640
2773
|
return new View(void 0, nameOrTemplate);
|
2641
2774
|
}
|
2642
2775
|
},
|
2643
2776
|
render: function(name, model, controller, parent, skipCallback) {
|
2644
|
-
return this.
|
2645
|
-
},
|
2646
|
-
compile: function(name, model, controller, parent, skipCallback) {
|
2647
|
-
return this._views[name].compile(model, controller, parent, skipCallback);
|
2777
|
+
return this.views[name].render(model, controller, parent, skipCallback);
|
2648
2778
|
},
|
2649
2779
|
controller: function(name, klass) {
|
2650
|
-
return this.
|
2651
|
-
},
|
2652
|
-
controllerFor: function(name) {
|
2653
|
-
return this._controllers[name];
|
2780
|
+
return this.controllers[name] = klass;
|
2654
2781
|
},
|
2655
2782
|
clearIdentityMap: function() {
|
2656
2783
|
return Cache._identityMap = {};
|
@@ -2659,8 +2786,8 @@ extend(Serenade, {
|
|
2659
2786
|
return Serenade.clearIdentityMap();
|
2660
2787
|
},
|
2661
2788
|
unregisterAll: function() {
|
2662
|
-
Serenade.
|
2663
|
-
return Serenade.
|
2789
|
+
Serenade.views = {};
|
2790
|
+
return Serenade.controllers = {};
|
2664
2791
|
},
|
2665
2792
|
Model: Model,
|
2666
2793
|
Collection: Collection,
|
data/lib/serenade/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serenade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: execjs
|