wingman_rails 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -984,14 +984,14 @@
984
984
  bind: function(eventName, callback) {
985
985
  var _base;
986
986
  if (!callback) throw new Error('Callback must be set!');
987
- this._callbacks || (this._callbacks = {});
987
+ if (!this.hasOwnProperty('_callbacks')) this._callbacks = {};
988
988
  (_base = this._callbacks)[eventName] || (_base[eventName] = []);
989
989
  this._callbacks[eventName].push(callback);
990
990
  return this._callbacks;
991
991
  },
992
992
  unbind: function(eventName, callback) {
993
993
  var index, list;
994
- list = this._callbacks && this._callbacks[eventName];
994
+ list = this.hasOwnProperty('_callbacks') && this._callbacks[eventName];
995
995
  if (!list) return false;
996
996
  index = list.indexOf(callback);
997
997
  return list.splice(index, 1);
@@ -1000,7 +1000,7 @@
1000
1000
  var args, callback, eventName, list, _i, _len, _ref, _results;
1001
1001
  args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
1002
1002
  eventName = args.shift();
1003
- list = this._callbacks && this._callbacks[eventName];
1003
+ list = this.hasOwnProperty('_callbacks') && this._callbacks[eventName];
1004
1004
  if (!list) return;
1005
1005
  _ref = list.slice();
1006
1006
  _results = [];
@@ -1451,14 +1451,16 @@
1451
1451
 
1452
1452
  }).call(this);
1453
1453
  }, "wingman/template/handler_factory/child_view_handler": function(exports, require, module) {(function() {
1454
- var ChildViewHandler;
1454
+ var ChildViewHandler, Wingman;
1455
+
1456
+ Wingman = require('../../../wingman');
1455
1457
 
1456
1458
  module.exports = ChildViewHandler = (function() {
1457
1459
 
1458
1460
  function ChildViewHandler(options, context) {
1459
1461
  this.options = options;
1460
1462
  this.context = context;
1461
- this.view = this.context.createChild(this.options.name, this.viewOptions());
1463
+ this.view = this.context.createChild(this.viewName(), this.viewOptions());
1462
1464
  this.options.scope.appendChild(this.view.el);
1463
1465
  }
1464
1466
 
@@ -1472,18 +1474,33 @@
1472
1474
  };
1473
1475
 
1474
1476
  ChildViewHandler.prototype.viewProperties = function() {
1475
- var properties;
1476
- if (this.context.get(this.options.name)) {
1477
- properties = {};
1477
+ var key, properties, _i, _len, _ref;
1478
+ properties = {};
1479
+ if (this.options.name && this.context.get(this.options.name)) {
1478
1480
  properties[this.options.name] = this.context.get(this.options.name);
1479
- return properties;
1480
1481
  }
1482
+ if (this.options.properties) {
1483
+ _ref = this.options.properties;
1484
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1485
+ key = _ref[_i];
1486
+ properties[key] = this.context.get(key);
1487
+ }
1488
+ }
1489
+ return properties;
1481
1490
  };
1482
1491
 
1483
1492
  ChildViewHandler.prototype.remove = function() {
1484
1493
  return this.view.remove();
1485
1494
  };
1486
1495
 
1496
+ ChildViewHandler.prototype.viewName = function() {
1497
+ if (this.options.name) {
1498
+ return this.options.name;
1499
+ } else {
1500
+ return this.context.get(this.options.path);
1501
+ }
1502
+ };
1503
+
1487
1504
  return ChildViewHandler;
1488
1505
 
1489
1506
  })();
@@ -1657,7 +1674,7 @@
1657
1674
  ElementHandler.prototype.setupSource = function() {
1658
1675
  var _this = this;
1659
1676
  this.el.innerHTML = this.context.get(this.options.source);
1660
- return this.context.observe(this.options.source, function(newValue) {
1677
+ return this.context.observe(this.options.source, function(newValue, oldValue) {
1661
1678
  return _this.el.innerHTML = newValue;
1662
1679
  });
1663
1680
  };
@@ -1691,8 +1708,7 @@
1691
1708
  }).call(this);
1692
1709
  }, "wingman/template/handler_factory/for_block_handler": function(exports, require, module) {(function() {
1693
1710
  var Fleck, ForBlockHandler, HandlerFactory, WingmanObject,
1694
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
1695
- __slice = Array.prototype.slice;
1711
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
1696
1712
 
1697
1713
  WingmanObject = require('../../shared/object');
1698
1714
 
@@ -1716,17 +1732,9 @@
1716
1732
  }
1717
1733
 
1718
1734
  ForBlockHandler.prototype.add = function(value) {
1719
- var child, hash, key, newContext, _i, _len, _ref, _results,
1720
- _this = this;
1735
+ var child, hash, key, newContext, _i, _len, _ref, _results;
1721
1736
  this.handlers[value] = [];
1722
- newContext = new WingmanObject;
1723
- if (this.context.createChild) {
1724
- newContext.createChild = function() {
1725
- var args, _ref;
1726
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
1727
- return (_ref = _this.context.createChild).call.apply(_ref, [_this.context].concat(__slice.call(args)));
1728
- };
1729
- }
1737
+ newContext = Object.create(this.context);
1730
1738
  key = Fleck.singularize(this.options.source.split('.').pop());
1731
1739
  hash = {};
1732
1740
  hash[key] = value;
@@ -1926,14 +1934,28 @@
1926
1934
  };
1927
1935
 
1928
1936
  _Class.prototype.scanForViewToken = function() {
1929
- var newNode, result;
1930
- result = this.scanner.scan(/\{view (.*?)\}/);
1937
+ var identifier, newNode, option, optionRegex, options, result;
1938
+ result = this.scanner.scan(/\{view ([a-zA-Z\.']+)(,{1} {1}(.*?))?\}/);
1931
1939
  if (result) {
1940
+ identifier = this.scanner.getCapture(0);
1941
+ options = this.scanner.getCapture(2);
1932
1942
  newNode = {
1933
- name: this.scanner.getCapture(0),
1934
1943
  parent: this.currentScope,
1935
1944
  type: 'childView'
1936
1945
  };
1946
+ if (options) {
1947
+ optionRegex = /(\w+): \[(.*?)\]/g;
1948
+ while (option = optionRegex.exec(options)) {
1949
+ if (option[1] === 'properties') {
1950
+ newNode.properties = option[2].replace(/\'| /g, '').split(',');
1951
+ }
1952
+ }
1953
+ }
1954
+ if (identifier[0] === "'") {
1955
+ newNode.name = identifier.replace(/\'/g, '');
1956
+ } else {
1957
+ newNode.path = identifier;
1958
+ }
1937
1959
  this.currentScope.children.push(newNode);
1938
1960
  }
1939
1961
  return result;
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.8
4
+ version: 0.0.9
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-17 00:00:00.000000000 Z
12
+ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70103484772120 !ruby/object:Gem::Requirement
16
+ requirement: &70123886167620 !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: *70103484772120
27
+ version_requirements: *70123886167620
28
28
  description: This gem provides Wingman for your Rails 3 application.
29
29
  email:
30
30
  - rasmusrnielsen@gmail.com