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.
Files changed (2) hide show
  1. data/vendor/assets/javascripts/wingman.js +276 -213
  2. 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.domElement.className = this.domElement.className ? this.domElement.className.split(' ').concat(className).join(' ') : className;
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.domElement.className = this.domElement.className.replace(reg, '');
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.domElement.style[keyCssNotation] = value;
964
+ return this.el.style[keyCssNotation] = value;
965
965
  },
966
966
  setAttribute: function(key, value) {
967
- return this.domElement.setAttribute(key, value);
967
+ return this.el.setAttribute(key, value);
968
968
  },
969
969
  remove: function() {
970
- return this.domElement.parentNode.removeChild(this.domElement);
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.updateNavigationOptions(options);
1057
- return Wingman.Application.instance.updatePath();
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, NodeFactory, Parser, Template;
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 nodeData, _i, _len, _ref, _results;
1395
- _ref = this.tree.children;
1396
- _results = [];
1397
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1398
- nodeData = _ref[_i];
1399
- _results.push(NodeFactory.create(nodeData, el, context));
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 _results;
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
- NodeFactory = require('./template/node_factory');
1415
+ HandlerFactory = require('./template/handler_factory');
1411
1416
 
1412
1417
  Fleck = require('fleck');
1413
1418
 
1414
1419
  }).call(this);
1415
- }, "wingman/template/node_factory": function(exports, require, module) {(function() {
1416
- var ChildView, Conditional, Element, ForBlock;
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
- ForBlock = require('./node_factory/for_block');
1423
+ ForBlockHandler = require('./handler_factory/for_block_handler');
1434
1424
 
1435
- ChildView = require('./node_factory/child_view');
1425
+ ChildViewHandler = require('./handler_factory/child_view_handler');
1436
1426
 
1437
- Conditional = require('./node_factory/conditional');
1427
+ ConditionalHandler = require('./handler_factory/conditional_handler');
1438
1428
 
1439
- Element = require('./node_factory/element');
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/node_factory/child_view": function(exports, require, module) {(function() {
1443
- var ChildView;
1453
+ }, "wingman/template/handler_factory/child_view_handler": function(exports, require, module) {(function() {
1454
+ var ChildViewHandler;
1444
1455
 
1445
- module.exports = ChildView = (function() {
1456
+ module.exports = ChildViewHandler = (function() {
1446
1457
 
1447
- function ChildView(nodeData, scope, context) {
1448
- var element;
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.nodeData.name, this.options());
1453
- element = this.view.el;
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
- ChildView.prototype.options = function() {
1465
+ ChildViewHandler.prototype.viewOptions = function() {
1458
1466
  var options, properties;
1459
1467
  options = {
1460
1468
  render: true
1461
1469
  };
1462
- if (properties = this.properties()) options.properties = properties;
1470
+ if (properties = this.viewProperties()) options.properties = properties;
1463
1471
  return options;
1464
1472
  };
1465
1473
 
1466
- ChildView.prototype.properties = function() {
1474
+ ChildViewHandler.prototype.viewProperties = function() {
1467
1475
  var properties;
1468
- if (this.context.get(this.nodeData.name)) {
1476
+ if (this.context.get(this.options.name)) {
1469
1477
  properties = {};
1470
- properties[this.nodeData.name] = this.context.get(this.nodeData.name);
1478
+ properties[this.options.name] = this.context.get(this.options.name);
1471
1479
  return properties;
1472
1480
  }
1473
1481
  };
1474
1482
 
1475
- ChildView.prototype.remove = function() {
1483
+ ChildViewHandler.prototype.remove = function() {
1476
1484
  return this.view.remove();
1477
1485
  };
1478
1486
 
1479
- return ChildView;
1487
+ return ChildViewHandler;
1480
1488
 
1481
1489
  })();
1482
1490
 
1483
1491
  }).call(this);
1484
- }, "wingman/template/node_factory/conditional": function(exports, require, module) {(function() {
1485
- var Conditional, NodeFactory,
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
- NodeFactory = require('../node_factory');
1496
+ HandlerFactory = require('../handler_factory');
1489
1497
 
1490
- module.exports = Conditional = (function() {
1498
+ module.exports = ConditionalHandler = (function() {
1491
1499
 
1492
- function Conditional(nodeData, scope, context) {
1493
- this.nodeData = nodeData;
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.nodes = [];
1498
- this.context.observe(this.nodeData.source, this.update);
1499
- this.update(this.context.get(this.nodeData.source));
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
- Conditional.prototype.add = function(currentValue) {
1503
- var newNodeData, node, _i, _j, _len, _len2, _ref, _ref2, _results, _results2;
1504
- if (currentValue) {
1505
- _ref = this.nodeData.trueChildren;
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 = _ref.length; _i < _len; _i++) {
1508
- newNodeData = _ref[_i];
1509
- node = NodeFactory.create(newNodeData, this.scope, this.context);
1510
- _results.push(this.nodes.push(node));
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
- Conditional.prototype.remove = function() {
1526
- var node, _results;
1530
+ ConditionalHandler.prototype.remove = function() {
1531
+ var handler, _results;
1527
1532
  _results = [];
1528
- while (node = this.nodes.shift()) {
1529
- _results.push(node.remove());
1533
+ while (handler = this.handlers.shift()) {
1534
+ _results.push(handler.remove());
1530
1535
  }
1531
1536
  return _results;
1532
1537
  };
1533
1538
 
1534
- Conditional.prototype.update = function(currentValue) {
1539
+ ConditionalHandler.prototype.update = function(currentValue) {
1535
1540
  this.remove();
1536
1541
  return this.add(currentValue);
1537
1542
  };
1538
1543
 
1539
- return Conditional;
1544
+ return ConditionalHandler;
1540
1545
 
1541
1546
  })();
1542
1547
 
1543
1548
  }).call(this);
1544
- }, "wingman/template/node_factory/element": function(exports, require, module) {(function() {
1545
- var Element, Elementary, Module, NodeFactory, Wingman,
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 = Element = (function(_super) {
1558
+ module.exports = ElementHandler = (function(_super) {
1554
1559
 
1555
- __extends(Element, _super);
1560
+ __extends(ElementHandler, _super);
1556
1561
 
1557
- Element.include(Elementary);
1562
+ ElementHandler.include(Elementary);
1558
1563
 
1559
- function Element(elementData, scope, context) {
1560
- this.elementData = elementData;
1561
- this.scope = scope;
1564
+ function ElementHandler(options, context) {
1565
+ this.options = options;
1562
1566
  this.context = context;
1563
- this.domElement = Wingman.document.createElement(this.elementData.tag);
1564
- this.addToScope();
1565
- if (this.elementData.styles) this.setupStyles();
1566
- if (this.elementData.classes) this.setupClasses();
1567
- if (this.elementData.attributes) this.setupAttributes();
1568
- if (this.elementData.value) {
1569
- this.setupInnerHTML();
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
- Element.prototype.addToScope = function() {
1576
- return this.scope.appendChild(this.domElement);
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
- Element.prototype.setupClasses = function() {
1580
- var className, klass, _i, _len, _ref, _results;
1581
- _ref = this.elementData.classes;
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
- className = _ref[_i];
1585
- if (className.isDynamic) this.observeClass(className);
1586
- if (klass = className.get(this.context)) {
1587
- _results.push(this.addClass(klass));
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(void 0);
1597
+ _results.push(this.addClass(klass.value));
1590
1598
  }
1591
1599
  }
1592
1600
  return _results;
1593
1601
  };
1594
1602
 
1595
- Element.prototype.setupAttributes = function() {
1596
- var key, value, _ref, _results;
1597
- _ref = this.elementData.attributes;
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
- value = _ref[key];
1601
- this.setAttribute(key, value.get(this.context));
1602
- if (value.isDynamic) {
1603
- _results.push(this.observeAttribute(key, value));
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(void 0);
1613
+ _results.push(this.setAttribute(key, attribute.value));
1606
1614
  }
1607
1615
  }
1608
1616
  return _results;
1609
1617
  };
1610
1618
 
1611
- Element.prototype.observeAttribute = function(key, value) {
1619
+ ElementHandler.prototype.observeAttribute = function(key, attribute) {
1612
1620
  var _this = this;
1613
- return this.context.observe(value.get(), function(newValue) {
1621
+ return this.context.observe(attribute.value, function(newValue) {
1614
1622
  return _this.setAttribute(key, newValue);
1615
1623
  });
1616
1624
  };
1617
1625
 
1618
- Element.prototype.observeClass = function(className) {
1626
+ ElementHandler.prototype.observeClass = function(klass) {
1619
1627
  var _this = this;
1620
- return this.context.observe(className.get(), function(newClassName, oldClassName) {
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
- Element.prototype.setupStyles = function() {
1627
- var key, value, _ref, _results;
1628
- _ref = this.elementData.styles;
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
- value = _ref[key];
1632
- if (value.isDynamic) this.observeStyle(key, value);
1633
- _results.push(this.setStyle(key, value.get(this.context)));
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
- Element.prototype.observeStyle = function(key, value) {
1650
+ ElementHandler.prototype.observeStyle = function(key, style) {
1639
1651
  var _this = this;
1640
- return this.context.observe(value.get(), function(newValue) {
1652
+ return this.context.observe(style.value, function(newValue) {
1641
1653
  return _this.setStyle(key, newValue);
1642
1654
  });
1643
1655
  };
1644
1656
 
1645
- Element.prototype.setupInnerHTML = function() {
1657
+ ElementHandler.prototype.setupSource = function() {
1646
1658
  var _this = this;
1647
- return this.domElement.innerHTML = this.elementData.value.isDynamic ? (this.context.observe(this.elementData.value.get(), function(newValue) {
1648
- return _this.domElement.innerHTML = newValue;
1649
- }), this.context.get(this.elementData.value.get())) : this.elementData.value.get();
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
- Element.prototype.setupChildren = function() {
1653
- var child, _i, _len, _ref, _results;
1654
- _ref = this.elementData.children;
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
- _results.push(NodeFactory.create(child, this.domElement, this.context));
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 Element;
1683
+ return ElementHandler;
1664
1684
 
1665
1685
  })(Module);
1666
1686
 
1667
1687
  Wingman = require('../../../wingman');
1668
1688
 
1669
- NodeFactory = require('../node_factory');
1689
+ HandlerFactory = require('../handler_factory');
1670
1690
 
1671
1691
  }).call(this);
1672
- }, "wingman/template/node_factory/for_block": function(exports, require, module) {(function() {
1673
- var Fleck, ForBlock, NodeFactory, WingmanObject,
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
- NodeFactory = require('../node_factory');
1701
+ HandlerFactory = require('../handler_factory');
1682
1702
 
1683
- module.exports = ForBlock = (function() {
1703
+ module.exports = ForBlockHandler = (function() {
1684
1704
 
1685
- function ForBlock(nodeData, scope, context) {
1686
- this.nodeData = nodeData;
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.nodes = {};
1711
+ this.handlers = {};
1693
1712
  if (this.source()) this.addAll();
1694
- this.context.observe(this.nodeData.source, this.rebuild);
1695
- this.context.observe(this.nodeData.source, 'add', this.add);
1696
- this.context.observe(this.nodeData.source, 'remove', this.remove);
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
- ForBlock.prototype.add = function(value) {
1700
- var hash, key, newContext, newNodeData, node, _i, _len, _ref, _results,
1718
+ ForBlockHandler.prototype.add = function(value) {
1719
+ var child, hash, key, newContext, _i, _len, _ref, _results,
1701
1720
  _this = this;
1702
- this.nodes[value] = [];
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.nodeData.source.split('.').pop());
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.nodeData.children;
1734
+ _ref = this.options.children;
1716
1735
  _results = [];
1717
1736
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1718
- newNodeData = _ref[_i];
1719
- node = NodeFactory.create(newNodeData, this.scope, newContext);
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
- ForBlock.prototype.remove = function(value) {
1726
- var node;
1727
- while (this.nodes[value].length) {
1728
- node = this.nodes[value].pop();
1729
- node.remove();
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.nodes[value];
1761
+ return delete this.handlers[value];
1732
1762
  };
1733
1763
 
1734
- ForBlock.prototype.source = function() {
1735
- return this.context.get(this.nodeData.source);
1764
+ ForBlockHandler.prototype.source = function() {
1765
+ return this.context.get(this.options.source);
1736
1766
  };
1737
1767
 
1738
- ForBlock.prototype.addAll = function() {
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
- ForBlock.prototype.removeAll = function() {
1775
+ ForBlockHandler.prototype.removeAll = function() {
1746
1776
  var element, value, _ref, _results;
1747
- _ref = this.nodes;
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
- ForBlock.prototype.rebuild = function() {
1786
+ ForBlockHandler.prototype.rebuild = function() {
1757
1787
  this.removeAll();
1758
1788
  if (this.source()) return this.addAll();
1759
1789
  };
1760
1790
 
1761
- return ForBlock;
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, Value, selfClosingTags;
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
- this.currentScope.value = new Value(result.substr(0, result.length - 1));
1921
- this.scanner.head -= 1;
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]] = new Value(split[1]);
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(new Value(klass));
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] = new Value(value));
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 = this.domElement = (options != null ? options.el : void 0) || Wingman.document.createElement(this.tag || 'div');
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.6
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-11 00:00:00.000000000 Z
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: &70117532129560 !ruby/object:Gem::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: *70117532129560
27
+ version_requirements: *70288977942940
28
28
  description: This gem provides Wingman for your Rails 3 application.
29
29
  email:
30
30
  - rasmusrnielsen@gmail.com