wingman_rails 0.0.5 → 0.0.6
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 +58 -40
- metadata +3 -3
@@ -99,21 +99,22 @@
|
|
99
99
|
|
100
100
|
Application.include(Events);
|
101
101
|
|
102
|
+
Application.rootViewSiblings = function() {
|
103
|
+
var key, value, views;
|
104
|
+
views = {};
|
105
|
+
for (key in this) {
|
106
|
+
value = this[key];
|
107
|
+
if (key.match("(.+)View$") && key !== 'RootView') views[key] = value;
|
108
|
+
}
|
109
|
+
return views;
|
110
|
+
};
|
111
|
+
|
102
112
|
function Application(options) {
|
103
113
|
this.handlePopStateChange = __bind(this.handlePopStateChange, this);
|
104
|
-
this.buildController = __bind(this.buildController, this);
|
105
|
-
var key, value, _ref;
|
106
|
-
if (this.constructor.__super__.constructor.instance) {
|
114
|
+
this.buildController = __bind(this.buildController, this); if (this.constructor.__super__.constructor.instance) {
|
107
115
|
throw new Error('You cannot instantiate two Wingman apps at the same time.');
|
108
116
|
}
|
109
117
|
this.constructor.__super__.constructor.instance = this;
|
110
|
-
_ref = this.constructor;
|
111
|
-
for (key in _ref) {
|
112
|
-
value = _ref[key];
|
113
|
-
if (key.match("(.+)View$") && key !== 'RootView') {
|
114
|
-
this.constructor.RootView[key] = value;
|
115
|
-
}
|
116
|
-
}
|
117
118
|
this.bind('viewCreated', this.buildController);
|
118
119
|
this.el = (options != null ? options.el : void 0) || Wingman.document.body;
|
119
120
|
this.view = (options != null ? options.view : void 0) || this.buildView();
|
@@ -128,7 +129,8 @@
|
|
128
129
|
view = new this.constructor.RootView({
|
129
130
|
parent: this,
|
130
131
|
el: this.el,
|
131
|
-
app: this
|
132
|
+
app: this,
|
133
|
+
childClasses: this.constructor.rootViewSiblings()
|
132
134
|
});
|
133
135
|
view.bind('descendantCreated', function(view) {
|
134
136
|
return _this.trigger('viewCreated', view);
|
@@ -510,14 +512,17 @@
|
|
510
512
|
};
|
511
513
|
|
512
514
|
HasManyAssociation.prototype.build = function(arrayOrHash) {
|
513
|
-
var
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
515
|
+
var hash, _i, _len, _results;
|
516
|
+
if (Array.isArray(arrayOrHash)) {
|
517
|
+
_results = [];
|
518
|
+
for (_i = 0, _len = arrayOrHash.length; _i < _len; _i++) {
|
519
|
+
hash = arrayOrHash[_i];
|
520
|
+
_results.push(this.buildOne(hash));
|
521
|
+
}
|
522
|
+
return _results;
|
523
|
+
} else {
|
524
|
+
return this.buildOne(arrayOrHash);
|
519
525
|
}
|
520
|
-
return _results;
|
521
526
|
};
|
522
527
|
|
523
528
|
HasManyAssociation.prototype.forEach = function(callback) {
|
@@ -1444,7 +1449,7 @@
|
|
1444
1449
|
this.nodeData = nodeData;
|
1445
1450
|
this.scope = scope;
|
1446
1451
|
this.context = context;
|
1447
|
-
this.view = this.context.
|
1452
|
+
this.view = this.context.createChild(this.nodeData.name, this.options());
|
1448
1453
|
element = this.view.el;
|
1449
1454
|
this.scope.appendChild(element);
|
1450
1455
|
}
|
@@ -1572,13 +1577,17 @@
|
|
1572
1577
|
};
|
1573
1578
|
|
1574
1579
|
Element.prototype.setupClasses = function() {
|
1575
|
-
var className, _i, _len, _ref, _results;
|
1580
|
+
var className, klass, _i, _len, _ref, _results;
|
1576
1581
|
_ref = this.elementData.classes;
|
1577
1582
|
_results = [];
|
1578
1583
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1579
1584
|
className = _ref[_i];
|
1580
1585
|
if (className.isDynamic) this.observeClass(className);
|
1581
|
-
|
1586
|
+
if (klass = className.get(this.context)) {
|
1587
|
+
_results.push(this.addClass(klass));
|
1588
|
+
} else {
|
1589
|
+
_results.push(void 0);
|
1590
|
+
}
|
1582
1591
|
}
|
1583
1592
|
return _results;
|
1584
1593
|
};
|
@@ -1609,8 +1618,8 @@
|
|
1609
1618
|
Element.prototype.observeClass = function(className) {
|
1610
1619
|
var _this = this;
|
1611
1620
|
return this.context.observe(className.get(), function(newClassName, oldClassName) {
|
1612
|
-
_this.removeClass(oldClassName);
|
1613
|
-
return _this.addClass(newClassName);
|
1621
|
+
if (oldClassName) _this.removeClass(oldClassName);
|
1622
|
+
if (newClassName) return _this.addClass(newClassName);
|
1614
1623
|
});
|
1615
1624
|
};
|
1616
1625
|
|
@@ -1692,11 +1701,11 @@
|
|
1692
1701
|
_this = this;
|
1693
1702
|
this.nodes[value] = [];
|
1694
1703
|
newContext = new WingmanObject;
|
1695
|
-
if (this.context.
|
1696
|
-
newContext.
|
1704
|
+
if (this.context.createChild) {
|
1705
|
+
newContext.createChild = function() {
|
1697
1706
|
var args, _ref;
|
1698
1707
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1699
|
-
return (_ref = _this.context.
|
1708
|
+
return (_ref = _this.context.createChild).call.apply(_ref, [_this.context].concat(__slice.call(args)));
|
1700
1709
|
};
|
1701
1710
|
}
|
1702
1711
|
key = Fleck.singularize(this.nodeData.source.split('.').pop());
|
@@ -2051,6 +2060,11 @@
|
|
2051
2060
|
app: options.app
|
2052
2061
|
});
|
2053
2062
|
}
|
2063
|
+
if ((options != null ? options.childClasses : void 0) != null) {
|
2064
|
+
this.set({
|
2065
|
+
childClasses: options.childClasses
|
2066
|
+
});
|
2067
|
+
}
|
2054
2068
|
this.el = this.domElement = (options != null ? options.el : void 0) || Wingman.document.createElement(this.tag || 'div');
|
2055
2069
|
this.set({
|
2056
2070
|
children: []
|
@@ -2077,28 +2091,32 @@
|
|
2077
2091
|
return typeof this.ready === "function" ? this.ready() : void 0;
|
2078
2092
|
};
|
2079
2093
|
|
2080
|
-
_Class.prototype.
|
2081
|
-
|
2094
|
+
_Class.prototype.childClasses = function() {
|
2095
|
+
return this.constructor;
|
2096
|
+
};
|
2097
|
+
|
2098
|
+
_Class.prototype.createChild = function(name, options) {
|
2099
|
+
var child, className, klass,
|
2082
2100
|
_this = this;
|
2083
|
-
className = Fleck.camelize(Fleck.underscore(
|
2084
|
-
klass = this.
|
2085
|
-
|
2101
|
+
className = Fleck.camelize(Fleck.underscore(name), true) + 'View';
|
2102
|
+
klass = this.get('childClasses')[className];
|
2103
|
+
child = new klass({
|
2086
2104
|
parent: this,
|
2087
2105
|
app: this.get('app')
|
2088
2106
|
});
|
2089
2107
|
if (options != null ? options.properties : void 0) {
|
2090
|
-
|
2108
|
+
child.set(options.properties);
|
2091
2109
|
}
|
2092
|
-
this.get('children').push(
|
2093
|
-
|
2094
|
-
return _this.get('children').remove(
|
2110
|
+
this.get('children').push(child);
|
2111
|
+
child.bind('remove', function() {
|
2112
|
+
return _this.get('children').remove(child);
|
2095
2113
|
});
|
2096
|
-
|
2097
|
-
return _this.trigger('descendantCreated',
|
2114
|
+
child.bind('descendantCreated', function(child) {
|
2115
|
+
return _this.trigger('descendantCreated', child);
|
2098
2116
|
});
|
2099
|
-
this.trigger('descendantCreated',
|
2100
|
-
if (options != null ? options.render : void 0)
|
2101
|
-
return
|
2117
|
+
this.trigger('descendantCreated', child);
|
2118
|
+
if (options != null ? options.render : void 0) child.render();
|
2119
|
+
return child;
|
2102
2120
|
};
|
2103
2121
|
|
2104
2122
|
_Class.prototype.templateSource = function() {
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70117532129560 !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: *70117532129560
|
28
28
|
description: This gem provides Wingman for your Rails 3 application.
|
29
29
|
email:
|
30
30
|
- rasmusrnielsen@gmail.com
|