wingman_rails 0.0.6 → 0.0.7
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/vendor/assets/javascripts/wingman.js +276 -213
- metadata +4 -4
@@ -208,7 +208,6 @@
|
|
208
208
|
_Class.include(Navigator);
|
209
209
|
|
210
210
|
function _Class(view) {
|
211
|
-
_Class.__super__.constructor.call(this);
|
212
211
|
this.set({
|
213
212
|
view: view
|
214
213
|
});
|
@@ -216,6 +215,7 @@
|
|
216
215
|
app: view.app
|
217
216
|
});
|
218
217
|
this.setupBindings();
|
218
|
+
_Class.__super__.constructor.call(this);
|
219
219
|
if (typeof this.ready === "function") this.ready();
|
220
220
|
}
|
221
221
|
|
@@ -947,7 +947,7 @@
|
|
947
947
|
(_base = this.classCache())[className] || (_base[className] = 0);
|
948
948
|
this.classCache()[className]++;
|
949
949
|
if (this.classCache()[className] === 1) {
|
950
|
-
return this.
|
950
|
+
return this.el.className = this.el.className ? this.el.className.split(' ').concat(className).join(' ') : className;
|
951
951
|
}
|
952
952
|
},
|
953
953
|
removeClass: function(className) {
|
@@ -955,19 +955,19 @@
|
|
955
955
|
if (this.classCache()[className]) this.classCache()[className]--;
|
956
956
|
if (this.classCache()[className] === 0) {
|
957
957
|
reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
958
|
-
return this.
|
958
|
+
return this.el.className = this.el.className.replace(reg, '');
|
959
959
|
}
|
960
960
|
},
|
961
961
|
setStyle: function(key, value) {
|
962
962
|
var keyCssNotation;
|
963
963
|
keyCssNotation = this.convertCssPropertyFromDomToCssNotation(key);
|
964
|
-
return this.
|
964
|
+
return this.el.style[keyCssNotation] = value;
|
965
965
|
},
|
966
966
|
setAttribute: function(key, value) {
|
967
|
-
return this.
|
967
|
+
return this.el.setAttribute(key, value);
|
968
968
|
},
|
969
969
|
remove: function() {
|
970
|
-
return this.
|
970
|
+
return this.el.parentNode.removeChild(this.el);
|
971
971
|
},
|
972
972
|
convertCssPropertyFromDomToCssNotation: function(propertyName) {
|
973
973
|
return propertyName.replace(/(-[a-z]{1})/g, function(s) {
|
@@ -1053,8 +1053,10 @@
|
|
1053
1053
|
navigate: function(location, options) {
|
1054
1054
|
if (options == null) options = {};
|
1055
1055
|
Wingman.window.history.pushState(options, '', "/" + location);
|
1056
|
-
Wingman.Application.instance
|
1057
|
-
|
1056
|
+
if (Wingman.Application.instance) {
|
1057
|
+
Wingman.Application.instance.updateNavigationOptions(options);
|
1058
|
+
return Wingman.Application.instance.updatePath();
|
1059
|
+
}
|
1058
1060
|
},
|
1059
1061
|
back: function(times) {
|
1060
1062
|
if (times == null) times = 1;
|
@@ -1374,7 +1376,7 @@
|
|
1374
1376
|
|
1375
1377
|
}).call(this);
|
1376
1378
|
}, "wingman/template": function(exports, require, module) {(function() {
|
1377
|
-
var Fleck,
|
1379
|
+
var Fleck, HandlerFactory, Parser, Template;
|
1378
1380
|
|
1379
1381
|
module.exports = Template = (function() {
|
1380
1382
|
|
@@ -1391,14 +1393,17 @@
|
|
1391
1393
|
}
|
1392
1394
|
|
1393
1395
|
Template.prototype.evaluate = function(el, context) {
|
1394
|
-
var
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1396
|
+
var key, options, value, _ref;
|
1397
|
+
options = {
|
1398
|
+
el: el,
|
1399
|
+
type: 'element'
|
1400
|
+
};
|
1401
|
+
_ref = this.tree;
|
1402
|
+
for (key in _ref) {
|
1403
|
+
value = _ref[key];
|
1404
|
+
options[key] = value;
|
1400
1405
|
}
|
1401
|
-
return
|
1406
|
+
return HandlerFactory.create(options, context);
|
1402
1407
|
};
|
1403
1408
|
|
1404
1409
|
return Template;
|
@@ -1407,142 +1412,142 @@
|
|
1407
1412
|
|
1408
1413
|
Parser = require('./template/parser');
|
1409
1414
|
|
1410
|
-
|
1415
|
+
HandlerFactory = require('./template/handler_factory');
|
1411
1416
|
|
1412
1417
|
Fleck = require('fleck');
|
1413
1418
|
|
1414
1419
|
}).call(this);
|
1415
|
-
}, "wingman/template/
|
1416
|
-
var
|
1417
|
-
|
1418
|
-
exports.create = function(nodeData, scope, context) {
|
1419
|
-
this.nodeData = nodeData;
|
1420
|
-
this.scope = scope;
|
1421
|
-
this.context = context;
|
1422
|
-
if (this.nodeData.type === 'for') {
|
1423
|
-
return new ForBlock(this.nodeData, this.scope, this.context);
|
1424
|
-
} else if (this.nodeData.type === 'childView') {
|
1425
|
-
return new ChildView(this.nodeData, this.scope, this.context);
|
1426
|
-
} else if (this.nodeData.type === 'conditional') {
|
1427
|
-
return new Conditional(this.nodeData, this.scope, this.context);
|
1428
|
-
} else {
|
1429
|
-
return new Element(this.nodeData, this.scope, this.context);
|
1430
|
-
}
|
1431
|
-
};
|
1420
|
+
}, "wingman/template/handler_factory": function(exports, require, module) {(function() {
|
1421
|
+
var ChildViewHandler, ConditionalHandler, ElementHandler, ForBlockHandler, MAP, TextHandler;
|
1432
1422
|
|
1433
|
-
|
1423
|
+
ForBlockHandler = require('./handler_factory/for_block_handler');
|
1434
1424
|
|
1435
|
-
|
1425
|
+
ChildViewHandler = require('./handler_factory/child_view_handler');
|
1436
1426
|
|
1437
|
-
|
1427
|
+
ConditionalHandler = require('./handler_factory/conditional_handler');
|
1438
1428
|
|
1439
|
-
|
1429
|
+
ElementHandler = require('./handler_factory/element_handler');
|
1430
|
+
|
1431
|
+
TextHandler = require('./handler_factory/text_handler');
|
1432
|
+
|
1433
|
+
MAP = {
|
1434
|
+
"for": ForBlockHandler,
|
1435
|
+
childView: ChildViewHandler,
|
1436
|
+
conditional: ConditionalHandler,
|
1437
|
+
element: ElementHandler,
|
1438
|
+
text: TextHandler
|
1439
|
+
};
|
1440
|
+
|
1441
|
+
exports.create = function(options, context) {
|
1442
|
+
var klass;
|
1443
|
+
klass = MAP[options.type];
|
1444
|
+
if (klass) {
|
1445
|
+
delete options.type;
|
1446
|
+
return new klass(options, context);
|
1447
|
+
} else {
|
1448
|
+
throw new Error("Cannot create unknown node type (" + options.type + ")!");
|
1449
|
+
}
|
1450
|
+
};
|
1440
1451
|
|
1441
1452
|
}).call(this);
|
1442
|
-
}, "wingman/template/
|
1443
|
-
var
|
1453
|
+
}, "wingman/template/handler_factory/child_view_handler": function(exports, require, module) {(function() {
|
1454
|
+
var ChildViewHandler;
|
1444
1455
|
|
1445
|
-
module.exports =
|
1456
|
+
module.exports = ChildViewHandler = (function() {
|
1446
1457
|
|
1447
|
-
function
|
1448
|
-
|
1449
|
-
this.nodeData = nodeData;
|
1450
|
-
this.scope = scope;
|
1458
|
+
function ChildViewHandler(options, context) {
|
1459
|
+
this.options = options;
|
1451
1460
|
this.context = context;
|
1452
|
-
this.view = this.context.createChild(this.
|
1453
|
-
|
1454
|
-
this.scope.appendChild(element);
|
1461
|
+
this.view = this.context.createChild(this.options.name, this.viewOptions());
|
1462
|
+
this.options.scope.appendChild(this.view.el);
|
1455
1463
|
}
|
1456
1464
|
|
1457
|
-
|
1465
|
+
ChildViewHandler.prototype.viewOptions = function() {
|
1458
1466
|
var options, properties;
|
1459
1467
|
options = {
|
1460
1468
|
render: true
|
1461
1469
|
};
|
1462
|
-
if (properties = this.
|
1470
|
+
if (properties = this.viewProperties()) options.properties = properties;
|
1463
1471
|
return options;
|
1464
1472
|
};
|
1465
1473
|
|
1466
|
-
|
1474
|
+
ChildViewHandler.prototype.viewProperties = function() {
|
1467
1475
|
var properties;
|
1468
|
-
if (this.context.get(this.
|
1476
|
+
if (this.context.get(this.options.name)) {
|
1469
1477
|
properties = {};
|
1470
|
-
properties[this.
|
1478
|
+
properties[this.options.name] = this.context.get(this.options.name);
|
1471
1479
|
return properties;
|
1472
1480
|
}
|
1473
1481
|
};
|
1474
1482
|
|
1475
|
-
|
1483
|
+
ChildViewHandler.prototype.remove = function() {
|
1476
1484
|
return this.view.remove();
|
1477
1485
|
};
|
1478
1486
|
|
1479
|
-
return
|
1487
|
+
return ChildViewHandler;
|
1480
1488
|
|
1481
1489
|
})();
|
1482
1490
|
|
1483
1491
|
}).call(this);
|
1484
|
-
}, "wingman/template/
|
1485
|
-
var
|
1492
|
+
}, "wingman/template/handler_factory/conditional_handler": function(exports, require, module) {(function() {
|
1493
|
+
var ConditionalHandler, HandlerFactory,
|
1486
1494
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
1487
1495
|
|
1488
|
-
|
1496
|
+
HandlerFactory = require('../handler_factory');
|
1489
1497
|
|
1490
|
-
module.exports =
|
1498
|
+
module.exports = ConditionalHandler = (function() {
|
1491
1499
|
|
1492
|
-
function
|
1493
|
-
this.
|
1494
|
-
this.scope = scope;
|
1500
|
+
function ConditionalHandler(options, context) {
|
1501
|
+
this.options = options;
|
1495
1502
|
this.context = context;
|
1496
1503
|
this.update = __bind(this.update, this);
|
1497
|
-
this.
|
1498
|
-
this.context.observe(this.
|
1499
|
-
this.update(this.context.get(this.
|
1504
|
+
this.handlers = [];
|
1505
|
+
this.context.observe(this.options.source, this.update);
|
1506
|
+
this.update(this.context.get(this.options.source));
|
1500
1507
|
}
|
1501
1508
|
|
1502
|
-
|
1503
|
-
var
|
1504
|
-
|
1505
|
-
|
1509
|
+
ConditionalHandler.prototype.add = function(currentValue) {
|
1510
|
+
var child, children, handler, key, options, value, _i, _len, _results;
|
1511
|
+
children = (currentValue && this.options.trueChildren) || this.options.falseChildren;
|
1512
|
+
if (children) {
|
1506
1513
|
_results = [];
|
1507
|
-
for (_i = 0, _len =
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1514
|
+
for (_i = 0, _len = children.length; _i < _len; _i++) {
|
1515
|
+
child = children[_i];
|
1516
|
+
options = {
|
1517
|
+
scope: this.options.scope
|
1518
|
+
};
|
1519
|
+
for (key in child) {
|
1520
|
+
value = child[key];
|
1521
|
+
options[key] = value;
|
1522
|
+
}
|
1523
|
+
handler = HandlerFactory.create(options, this.context);
|
1524
|
+
_results.push(this.handlers.push(handler));
|
1511
1525
|
}
|
1512
1526
|
return _results;
|
1513
|
-
} else if (this.nodeData.falseChildren) {
|
1514
|
-
_ref2 = this.nodeData.falseChildren;
|
1515
|
-
_results2 = [];
|
1516
|
-
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
1517
|
-
newNodeData = _ref2[_j];
|
1518
|
-
node = NodeFactory.create(newNodeData, this.scope, this.context);
|
1519
|
-
_results2.push(this.nodes.push(node));
|
1520
|
-
}
|
1521
|
-
return _results2;
|
1522
1527
|
}
|
1523
1528
|
};
|
1524
1529
|
|
1525
|
-
|
1526
|
-
var
|
1530
|
+
ConditionalHandler.prototype.remove = function() {
|
1531
|
+
var handler, _results;
|
1527
1532
|
_results = [];
|
1528
|
-
while (
|
1529
|
-
_results.push(
|
1533
|
+
while (handler = this.handlers.shift()) {
|
1534
|
+
_results.push(handler.remove());
|
1530
1535
|
}
|
1531
1536
|
return _results;
|
1532
1537
|
};
|
1533
1538
|
|
1534
|
-
|
1539
|
+
ConditionalHandler.prototype.update = function(currentValue) {
|
1535
1540
|
this.remove();
|
1536
1541
|
return this.add(currentValue);
|
1537
1542
|
};
|
1538
1543
|
|
1539
|
-
return
|
1544
|
+
return ConditionalHandler;
|
1540
1545
|
|
1541
1546
|
})();
|
1542
1547
|
|
1543
1548
|
}).call(this);
|
1544
|
-
}, "wingman/template/
|
1545
|
-
var
|
1549
|
+
}, "wingman/template/handler_factory/element_handler": function(exports, require, module) {(function() {
|
1550
|
+
var ElementHandler, Elementary, HandlerFactory, Module, Wingman,
|
1546
1551
|
__hasProp = Object.prototype.hasOwnProperty,
|
1547
1552
|
__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; };
|
1548
1553
|
|
@@ -1550,127 +1555,142 @@
|
|
1550
1555
|
|
1551
1556
|
Elementary = require('../../shared/elementary');
|
1552
1557
|
|
1553
|
-
module.exports =
|
1558
|
+
module.exports = ElementHandler = (function(_super) {
|
1554
1559
|
|
1555
|
-
__extends(
|
1560
|
+
__extends(ElementHandler, _super);
|
1556
1561
|
|
1557
|
-
|
1562
|
+
ElementHandler.include(Elementary);
|
1558
1563
|
|
1559
|
-
function
|
1560
|
-
this.
|
1561
|
-
this.scope = scope;
|
1564
|
+
function ElementHandler(options, context) {
|
1565
|
+
this.options = options;
|
1562
1566
|
this.context = context;
|
1563
|
-
this.
|
1564
|
-
this.
|
1565
|
-
if (this.
|
1566
|
-
if (this.
|
1567
|
-
if (this.
|
1568
|
-
|
1569
|
-
|
1570
|
-
} else if (this.elementData.children) {
|
1567
|
+
this.setupDomElement();
|
1568
|
+
if (this.options.styles) this.setupStyles();
|
1569
|
+
if (this.options.classes) this.setupClasses();
|
1570
|
+
if (this.options.attributes) this.setupAttributes();
|
1571
|
+
if (this.options.source) {
|
1572
|
+
this.setupSource();
|
1573
|
+
} else if (this.options.children) {
|
1571
1574
|
this.setupChildren();
|
1572
1575
|
}
|
1573
1576
|
}
|
1574
1577
|
|
1575
|
-
|
1576
|
-
|
1578
|
+
ElementHandler.prototype.setupDomElement = function() {
|
1579
|
+
var element;
|
1580
|
+
return this.el = this.options.el ? this.options.el : (element = Wingman.document.createElement(this.options.tag), this.options.scope.appendChild(element), element);
|
1577
1581
|
};
|
1578
1582
|
|
1579
|
-
|
1580
|
-
var
|
1581
|
-
_ref = this.
|
1583
|
+
ElementHandler.prototype.setupClasses = function() {
|
1584
|
+
var klass, klassValue, _i, _len, _ref, _results;
|
1585
|
+
_ref = this.options.classes;
|
1582
1586
|
_results = [];
|
1583
1587
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1584
|
-
|
1585
|
-
if (
|
1586
|
-
|
1587
|
-
|
1588
|
+
klass = _ref[_i];
|
1589
|
+
if (klass.isDynamic) {
|
1590
|
+
this.observeClass(klass);
|
1591
|
+
if (klassValue = this.context.get(klass.value)) {
|
1592
|
+
_results.push(this.addClass(klassValue));
|
1593
|
+
} else {
|
1594
|
+
_results.push(void 0);
|
1595
|
+
}
|
1588
1596
|
} else {
|
1589
|
-
_results.push(
|
1597
|
+
_results.push(this.addClass(klass.value));
|
1590
1598
|
}
|
1591
1599
|
}
|
1592
1600
|
return _results;
|
1593
1601
|
};
|
1594
1602
|
|
1595
|
-
|
1596
|
-
var
|
1597
|
-
_ref = this.
|
1603
|
+
ElementHandler.prototype.setupAttributes = function() {
|
1604
|
+
var attribute, key, _ref, _results;
|
1605
|
+
_ref = this.options.attributes;
|
1598
1606
|
_results = [];
|
1599
1607
|
for (key in _ref) {
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
_results.push(this.
|
1608
|
+
attribute = _ref[key];
|
1609
|
+
if (attribute.isDynamic) {
|
1610
|
+
this.observeAttribute(key, attribute);
|
1611
|
+
_results.push(this.setAttribute(key, this.context.get(attribute.value)));
|
1604
1612
|
} else {
|
1605
|
-
_results.push(
|
1613
|
+
_results.push(this.setAttribute(key, attribute.value));
|
1606
1614
|
}
|
1607
1615
|
}
|
1608
1616
|
return _results;
|
1609
1617
|
};
|
1610
1618
|
|
1611
|
-
|
1619
|
+
ElementHandler.prototype.observeAttribute = function(key, attribute) {
|
1612
1620
|
var _this = this;
|
1613
|
-
return this.context.observe(value
|
1621
|
+
return this.context.observe(attribute.value, function(newValue) {
|
1614
1622
|
return _this.setAttribute(key, newValue);
|
1615
1623
|
});
|
1616
1624
|
};
|
1617
1625
|
|
1618
|
-
|
1626
|
+
ElementHandler.prototype.observeClass = function(klass) {
|
1619
1627
|
var _this = this;
|
1620
|
-
return this.context.observe(
|
1628
|
+
return this.context.observe(klass.value, function(newClassName, oldClassName) {
|
1621
1629
|
if (oldClassName) _this.removeClass(oldClassName);
|
1622
1630
|
if (newClassName) return _this.addClass(newClassName);
|
1623
1631
|
});
|
1624
1632
|
};
|
1625
1633
|
|
1626
|
-
|
1627
|
-
var key,
|
1628
|
-
_ref = this.
|
1634
|
+
ElementHandler.prototype.setupStyles = function() {
|
1635
|
+
var key, style, _ref, _results;
|
1636
|
+
_ref = this.options.styles;
|
1629
1637
|
_results = [];
|
1630
1638
|
for (key in _ref) {
|
1631
|
-
|
1632
|
-
if (
|
1633
|
-
|
1639
|
+
style = _ref[key];
|
1640
|
+
if (style.isDynamic) {
|
1641
|
+
this.observeStyle(key, style);
|
1642
|
+
_results.push(this.setStyle(key, this.context.get(style.value)));
|
1643
|
+
} else {
|
1644
|
+
_results.push(this.setStyle(key, style.value));
|
1645
|
+
}
|
1634
1646
|
}
|
1635
1647
|
return _results;
|
1636
1648
|
};
|
1637
1649
|
|
1638
|
-
|
1650
|
+
ElementHandler.prototype.observeStyle = function(key, style) {
|
1639
1651
|
var _this = this;
|
1640
|
-
return this.context.observe(value
|
1652
|
+
return this.context.observe(style.value, function(newValue) {
|
1641
1653
|
return _this.setStyle(key, newValue);
|
1642
1654
|
});
|
1643
1655
|
};
|
1644
1656
|
|
1645
|
-
|
1657
|
+
ElementHandler.prototype.setupSource = function() {
|
1646
1658
|
var _this = this;
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1659
|
+
this.el.innerHTML = this.context.get(this.options.source);
|
1660
|
+
return this.context.observe(this.options.source, function(newValue) {
|
1661
|
+
return _this.el.innerHTML = newValue;
|
1662
|
+
});
|
1650
1663
|
};
|
1651
1664
|
|
1652
|
-
|
1653
|
-
var child, _i, _len, _ref, _results;
|
1654
|
-
_ref = this.
|
1665
|
+
ElementHandler.prototype.setupChildren = function() {
|
1666
|
+
var child, key, options, value, _i, _len, _ref, _results;
|
1667
|
+
_ref = this.options.children;
|
1655
1668
|
_results = [];
|
1656
1669
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1657
1670
|
child = _ref[_i];
|
1658
|
-
|
1671
|
+
options = {
|
1672
|
+
scope: this.el
|
1673
|
+
};
|
1674
|
+
for (key in child) {
|
1675
|
+
value = child[key];
|
1676
|
+
options[key] = value;
|
1677
|
+
}
|
1678
|
+
_results.push(HandlerFactory.create(options, this.context));
|
1659
1679
|
}
|
1660
1680
|
return _results;
|
1661
1681
|
};
|
1662
1682
|
|
1663
|
-
return
|
1683
|
+
return ElementHandler;
|
1664
1684
|
|
1665
1685
|
})(Module);
|
1666
1686
|
|
1667
1687
|
Wingman = require('../../../wingman');
|
1668
1688
|
|
1669
|
-
|
1689
|
+
HandlerFactory = require('../handler_factory');
|
1670
1690
|
|
1671
1691
|
}).call(this);
|
1672
|
-
}, "wingman/template/
|
1673
|
-
var Fleck,
|
1692
|
+
}, "wingman/template/handler_factory/for_block_handler": function(exports, require, module) {(function() {
|
1693
|
+
var Fleck, ForBlockHandler, HandlerFactory, WingmanObject,
|
1674
1694
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
1675
1695
|
__slice = Array.prototype.slice;
|
1676
1696
|
|
@@ -1678,28 +1698,27 @@
|
|
1678
1698
|
|
1679
1699
|
Fleck = require('fleck');
|
1680
1700
|
|
1681
|
-
|
1701
|
+
HandlerFactory = require('../handler_factory');
|
1682
1702
|
|
1683
|
-
module.exports =
|
1703
|
+
module.exports = ForBlockHandler = (function() {
|
1684
1704
|
|
1685
|
-
function
|
1686
|
-
this.
|
1687
|
-
this.scope = scope;
|
1705
|
+
function ForBlockHandler(options, context) {
|
1706
|
+
this.options = options;
|
1688
1707
|
this.context = context;
|
1689
1708
|
this.rebuild = __bind(this.rebuild, this);
|
1690
1709
|
this.remove = __bind(this.remove, this);
|
1691
1710
|
this.add = __bind(this.add, this);
|
1692
|
-
this.
|
1711
|
+
this.handlers = {};
|
1693
1712
|
if (this.source()) this.addAll();
|
1694
|
-
this.context.observe(this.
|
1695
|
-
this.context.observe(this.
|
1696
|
-
this.context.observe(this.
|
1713
|
+
this.context.observe(this.options.source, this.rebuild);
|
1714
|
+
this.context.observe(this.options.source, 'add', this.add);
|
1715
|
+
this.context.observe(this.options.source, 'remove', this.remove);
|
1697
1716
|
}
|
1698
1717
|
|
1699
|
-
|
1700
|
-
var hash, key, newContext,
|
1718
|
+
ForBlockHandler.prototype.add = function(value) {
|
1719
|
+
var child, hash, key, newContext, _i, _len, _ref, _results,
|
1701
1720
|
_this = this;
|
1702
|
-
this.
|
1721
|
+
this.handlers[value] = [];
|
1703
1722
|
newContext = new WingmanObject;
|
1704
1723
|
if (this.context.createChild) {
|
1705
1724
|
newContext.createChild = function() {
|
@@ -1708,43 +1727,54 @@
|
|
1708
1727
|
return (_ref = _this.context.createChild).call.apply(_ref, [_this.context].concat(__slice.call(args)));
|
1709
1728
|
};
|
1710
1729
|
}
|
1711
|
-
key = Fleck.singularize(this.
|
1730
|
+
key = Fleck.singularize(this.options.source.split('.').pop());
|
1712
1731
|
hash = {};
|
1713
1732
|
hash[key] = value;
|
1714
1733
|
newContext.set(hash);
|
1715
|
-
_ref = this.
|
1734
|
+
_ref = this.options.children;
|
1716
1735
|
_results = [];
|
1717
1736
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1718
|
-
|
1719
|
-
|
1720
|
-
_results.push(this.nodes[value].push(node));
|
1737
|
+
child = _ref[_i];
|
1738
|
+
_results.push(this.handlers[value].push(this.createHandler(child, newContext)));
|
1721
1739
|
}
|
1722
1740
|
return _results;
|
1723
1741
|
};
|
1724
1742
|
|
1725
|
-
|
1726
|
-
var
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1743
|
+
ForBlockHandler.prototype.createHandler = function(child, context) {
|
1744
|
+
var key, options, value;
|
1745
|
+
options = {
|
1746
|
+
scope: this.options.scope
|
1747
|
+
};
|
1748
|
+
for (key in child) {
|
1749
|
+
value = child[key];
|
1750
|
+
options[key] = value;
|
1751
|
+
}
|
1752
|
+
return HandlerFactory.create(options, context);
|
1753
|
+
};
|
1754
|
+
|
1755
|
+
ForBlockHandler.prototype.remove = function(value) {
|
1756
|
+
var handler;
|
1757
|
+
while (this.handlers[value].length) {
|
1758
|
+
handler = this.handlers[value].pop();
|
1759
|
+
handler.remove();
|
1730
1760
|
}
|
1731
|
-
return delete this.
|
1761
|
+
return delete this.handlers[value];
|
1732
1762
|
};
|
1733
1763
|
|
1734
|
-
|
1735
|
-
return this.context.get(this.
|
1764
|
+
ForBlockHandler.prototype.source = function() {
|
1765
|
+
return this.context.get(this.options.source);
|
1736
1766
|
};
|
1737
1767
|
|
1738
|
-
|
1768
|
+
ForBlockHandler.prototype.addAll = function() {
|
1739
1769
|
var _this = this;
|
1740
1770
|
return this.source().forEach(function(value) {
|
1741
1771
|
return _this.add(value);
|
1742
1772
|
});
|
1743
1773
|
};
|
1744
1774
|
|
1745
|
-
|
1775
|
+
ForBlockHandler.prototype.removeAll = function() {
|
1746
1776
|
var element, value, _ref, _results;
|
1747
|
-
_ref = this.
|
1777
|
+
_ref = this.handlers;
|
1748
1778
|
_results = [];
|
1749
1779
|
for (value in _ref) {
|
1750
1780
|
element = _ref[value];
|
@@ -1753,25 +1783,58 @@
|
|
1753
1783
|
return _results;
|
1754
1784
|
};
|
1755
1785
|
|
1756
|
-
|
1786
|
+
ForBlockHandler.prototype.rebuild = function() {
|
1757
1787
|
this.removeAll();
|
1758
1788
|
if (this.source()) return this.addAll();
|
1759
1789
|
};
|
1760
1790
|
|
1761
|
-
return
|
1791
|
+
return ForBlockHandler;
|
1792
|
+
|
1793
|
+
})();
|
1794
|
+
|
1795
|
+
}).call(this);
|
1796
|
+
}, "wingman/template/handler_factory/text_handler": function(exports, require, module) {(function() {
|
1797
|
+
var TextHandler, Wingman;
|
1798
|
+
|
1799
|
+
Wingman = require('../../../wingman');
|
1800
|
+
|
1801
|
+
module.exports = TextHandler = (function() {
|
1802
|
+
|
1803
|
+
function TextHandler(options, context) {
|
1804
|
+
this.options = options;
|
1805
|
+
this.context = context;
|
1806
|
+
this.textNode = Wingman.document.createTextNode(this.options.value);
|
1807
|
+
this.options.scope.appendChild(this.textNode);
|
1808
|
+
}
|
1809
|
+
|
1810
|
+
TextHandler.prototype.remove = function() {
|
1811
|
+
return this.textNode.parentNode.removeChild(this.textNode);
|
1812
|
+
};
|
1813
|
+
|
1814
|
+
return TextHandler;
|
1762
1815
|
|
1763
1816
|
})();
|
1764
1817
|
|
1765
1818
|
}).call(this);
|
1766
1819
|
}, "wingman/template/parser": function(exports, require, module) {(function() {
|
1767
|
-
var StringScanner,
|
1820
|
+
var StringScanner, buildText, selfClosingTags;
|
1768
1821
|
|
1769
1822
|
StringScanner = require("strscan").StringScanner;
|
1770
1823
|
|
1771
|
-
Value = require("./parser/value");
|
1772
|
-
|
1773
1824
|
selfClosingTags = ['input', 'img', 'br', 'hr'];
|
1774
1825
|
|
1826
|
+
buildText = function(value) {
|
1827
|
+
var isDynamic, newNode;
|
1828
|
+
if (isDynamic = value.match(/^\{(.*?)\}$/)) {
|
1829
|
+
value = value.substring(1, value.length - 1);
|
1830
|
+
}
|
1831
|
+
return newNode = {
|
1832
|
+
type: 'text',
|
1833
|
+
value: value,
|
1834
|
+
isDynamic: isDynamic
|
1835
|
+
};
|
1836
|
+
};
|
1837
|
+
|
1775
1838
|
module.exports = (function() {
|
1776
1839
|
|
1777
1840
|
_Class.parse = function(source) {
|
@@ -1814,7 +1877,7 @@
|
|
1814
1877
|
};
|
1815
1878
|
|
1816
1879
|
_Class.prototype.scan = function() {
|
1817
|
-
return this.scanForEndTag() || this.scanForStartTag() || this.scanForIfToken() || this.scanForElseToken() || this.scanForViewToken() || this.scanForForToken() || this.scanForEndToken() || this.scanForText();
|
1880
|
+
return this.scanForEndTag() || this.scanForStartTag() || this.scanForIfToken() || this.scanForElseToken() || this.scanForViewToken() || this.scanForForToken() || this.scanForEndToken() || this.scanForSource() || this.scanForText();
|
1818
1881
|
};
|
1819
1882
|
|
1820
1883
|
_Class.prototype.scanForEndTag = function() {
|
@@ -1914,11 +1977,36 @@
|
|
1914
1977
|
return result;
|
1915
1978
|
};
|
1916
1979
|
|
1980
|
+
_Class.prototype.scanForSource = function() {
|
1981
|
+
var result, value;
|
1982
|
+
result = this.scanner.scan(/\{[a-zA-Z\.]+\}\<\//);
|
1983
|
+
if (result) {
|
1984
|
+
value = result.substr(1, result.length - 4);
|
1985
|
+
this.currentScope.source = value;
|
1986
|
+
this.scanner.head -= 2;
|
1987
|
+
} else {
|
1988
|
+
result = this.scanner.scan(/\{[a-zA-Z\.]+\}$/);
|
1989
|
+
if (result) {
|
1990
|
+
value = result.substr(1, result.length - 2);
|
1991
|
+
this.currentScope.source = value;
|
1992
|
+
}
|
1993
|
+
}
|
1994
|
+
return result;
|
1995
|
+
};
|
1996
|
+
|
1917
1997
|
_Class.prototype.scanForText = function() {
|
1918
|
-
var result;
|
1998
|
+
var newNode, result, value;
|
1919
1999
|
result = this.scanner.scanUntil(/</);
|
1920
|
-
|
1921
|
-
|
2000
|
+
if (result) {
|
2001
|
+
value = result.substr(0, result.length - 1);
|
2002
|
+
newNode = buildText(value);
|
2003
|
+
this.currentScope.children.push(newNode);
|
2004
|
+
this.scanner.head -= 1;
|
2005
|
+
} else {
|
2006
|
+
value = this.scanner.scanUntil(/$/);
|
2007
|
+
newNode = buildText(value);
|
2008
|
+
this.currentScope.children.push(newNode);
|
2009
|
+
}
|
1922
2010
|
return result;
|
1923
2011
|
};
|
1924
2012
|
|
@@ -1939,7 +2027,7 @@
|
|
1939
2027
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1940
2028
|
styleAsString = _ref[_i];
|
1941
2029
|
split = styleAsString.split(':');
|
1942
|
-
styles[split[0]] =
|
2030
|
+
styles[split[0]] = buildText(split[1]);
|
1943
2031
|
}
|
1944
2032
|
return styles;
|
1945
2033
|
};
|
@@ -1950,7 +2038,7 @@
|
|
1950
2038
|
_ref = classesAsString.split(' ');
|
1951
2039
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1952
2040
|
klass = _ref[_i];
|
1953
|
-
classes.push(
|
2041
|
+
classes.push(buildText(klass));
|
1954
2042
|
}
|
1955
2043
|
return classes;
|
1956
2044
|
};
|
@@ -1970,7 +2058,7 @@
|
|
1970
2058
|
_results = [];
|
1971
2059
|
for (key in attributes) {
|
1972
2060
|
value = attributes[key];
|
1973
|
-
_results.push(node.attributes[key] =
|
2061
|
+
_results.push(node.attributes[key] = buildText(value));
|
1974
2062
|
}
|
1975
2063
|
return _results;
|
1976
2064
|
}
|
@@ -1980,31 +2068,6 @@
|
|
1980
2068
|
|
1981
2069
|
})();
|
1982
2070
|
|
1983
|
-
}).call(this);
|
1984
|
-
}, "wingman/template/parser/value": function(exports, require, module) {(function() {
|
1985
|
-
|
1986
|
-
module.exports = (function() {
|
1987
|
-
|
1988
|
-
function _Class(body) {
|
1989
|
-
var match;
|
1990
|
-
this.body = body;
|
1991
|
-
match = this.body.match(/^\{(.*?)\}$/);
|
1992
|
-
this.isDynamic = !!match;
|
1993
|
-
if (this.isDynamic) this.body = match[1];
|
1994
|
-
}
|
1995
|
-
|
1996
|
-
_Class.prototype.get = function(context) {
|
1997
|
-
if (this.isDynamic && context) {
|
1998
|
-
return context.get(this.body);
|
1999
|
-
} else {
|
2000
|
-
return this.body;
|
2001
|
-
}
|
2002
|
-
};
|
2003
|
-
|
2004
|
-
return _Class;
|
2005
|
-
|
2006
|
-
})();
|
2007
|
-
|
2008
2071
|
}).call(this);
|
2009
2072
|
}, "wingman/view": function(exports, require, module) {(function() {
|
2010
2073
|
var Elementary, Fleck, STYLE_NAMES, Wingman, WingmanObject,
|
@@ -2049,7 +2112,6 @@
|
|
2049
2112
|
};
|
2050
2113
|
|
2051
2114
|
function _Class(options) {
|
2052
|
-
_Class.__super__.constructor.call(this);
|
2053
2115
|
if ((options != null ? options.parent : void 0) != null) {
|
2054
2116
|
this.set({
|
2055
2117
|
parent: options.parent
|
@@ -2065,10 +2127,11 @@
|
|
2065
2127
|
childClasses: options.childClasses
|
2066
2128
|
});
|
2067
2129
|
}
|
2068
|
-
this.el =
|
2130
|
+
this.el = (options != null ? options.el : void 0) || Wingman.document.createElement(this.tag || 'div');
|
2069
2131
|
this.set({
|
2070
2132
|
children: []
|
2071
2133
|
});
|
2134
|
+
_Class.__super__.constructor.call(this);
|
2072
2135
|
if (options != null ? options.render : void 0) this.render();
|
2073
2136
|
}
|
2074
2137
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wingman_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70288977942940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version: '5.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70288977942940
|
28
28
|
description: This gem provides Wingman for your Rails 3 application.
|
29
29
|
email:
|
30
30
|
- rasmusrnielsen@gmail.com
|