Permalink
Browse files

Upgrade Knockback

  • Loading branch information...
1 parent 2847a92 commit 6dd5344f2d1f8b95e91b31aa29a3dc56b5a36125 @kmalakoff committed Nov 26, 2013
@@ -39,7 +39,7 @@
<script src="vendor/xui-2.3.2.js"></script>
<script src="vendor/path-0.8.4.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-panes.js"></script>
<script type='text/javascript'>
@@ -31,7 +31,7 @@ <h1 data-bind="text: title"></h1>
</script>
<script src="vendor/jquery-1.9.1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-panes.js"></script>
<script src="..//knockback-transitions.js"></script>
@@ -31,7 +31,7 @@ <h1 data-bind="text: title"></h1>
</script>
<script src="vendor/jquery-1.9.1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-panes.js"></script>
<script src="..//knockback-transitions.js"></script>
@@ -31,7 +31,7 @@ <h1 data-bind="text: title"></h1>
</script>
<script src="vendor/jquery-1.9.1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-panes.js"></script>
<script src="..//knockback-transitions.js"></script>
@@ -31,7 +31,7 @@ <h1 data-bind="text: title"></h1>
</div>
<script src="vendor/zepto-1.0rc1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-panes.js"></script>
<script src="..//knockback-transitions.js"></script>
@@ -30,7 +30,7 @@ <h1 data-bind="text: title"></h1>
</script>
<script src="vendor/jquery-1.9.1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-simple.js"></script>
<script type='text/javascript'>
@@ -30,7 +30,7 @@ <h1 data-bind="text: title"></h1>
</div>
<script src="vendor/zepto-1.0rc1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-simple.js"></script>
<script type='text/javascript'>
View
@@ -30,7 +30,7 @@ <h1 data-bind="text: title"></h1>
</script>
<script src="vendor/jquery-1.9.1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-simple.js"></script>
<script type='text/javascript'>
View
@@ -30,7 +30,7 @@ <h1 data-bind="text: title"></h1>
</div>
<script src="vendor/zepto-1.0rc1.js"></script>
- <script src="vendor/knockback-core-stack-0.18.0.js"></script>
+ <script src="vendor/knockback-core-stack-0.18.1.js"></script>
<script src="../knockback-page-navigator-simple.js"></script>
<script type='text/javascript'>
@@ -1,5 +1,5 @@
/*
- knockback-core-stack.js 0.18.0
+ knockback-core-stack.js 0.18.1
(c) 2011-2013 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
@@ -7087,7 +7087,7 @@ ko.exportSymbol('nativeTemplateEngine', ko.nativeTemplateEngine);
}());
})();
/*
- knockback-core.js 0.18.0
+ knockback-core.js 0.18.1
(c) 2011-2013 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
@@ -7103,7 +7103,7 @@ ko.exportSymbol('nativeTemplateEngine', ko.nativeTemplateEngine);
}
})(function(require) {// Generated by CoffeeScript 1.6.3
/*
- knockback-core.js 0.18.0
+ knockback-core.js 0.18.1
(c) 2011-2013 Kevin Malakoff.
Knockback.js is freely distributable under the MIT license.
See the following for full license details:
@@ -7118,7 +7118,7 @@ var COMPARE_ASCENDING, COMPARE_DESCENDING, COMPARE_EQUAL, KB_TYPE_ARRAY, KB_TYPE
kb = (function() {
function kb() {}
- kb.VERSION = '0.18.0';
+ kb.VERSION = '0.18.1';
kb.TYPE_UNKNOWN = 0;
@@ -1,5 +1,5 @@
/*
- knockback-core-stack.js 0.18.0
+ knockback-core-stack.js 0.18.1
(c) 2011-2013 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
@@ -7087,7 +7087,7 @@ ko.exportSymbol('nativeTemplateEngine', ko.nativeTemplateEngine);
}());
})();
/*
- knockback-core.js 0.18.0
+ knockback-core.js 0.18.1
(c) 2011-2013 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
@@ -7103,7 +7103,7 @@ ko.exportSymbol('nativeTemplateEngine', ko.nativeTemplateEngine);
}
})(function(require) {// Generated by CoffeeScript 1.6.3
/*
- knockback-core.js 0.18.0
+ knockback-core.js 0.18.1
(c) 2011-2013 Kevin Malakoff.
Knockback.js is freely distributable under the MIT license.
See the following for full license details:
@@ -7118,7 +7118,7 @@ var COMPARE_ASCENDING, COMPARE_DESCENDING, COMPARE_EQUAL, KB_TYPE_ARRAY, KB_TYPE
kb = (function() {
function kb() {}
- kb.VERSION = '0.18.0';
+ kb.VERSION = '0.18.1';
kb.TYPE_UNKNOWN = 0;
@@ -7258,6 +7258,33 @@ kb = (function() {
return value;
};
+ kb.getValue = function(model, key, args) {
+ if (!model) {
+ return;
+ }
+ if (_.isFunction(model[key]) && kb.orm.useFunction(model, key)) {
+ return model[key]();
+ }
+ if (!args) {
+ return model.get(key);
+ }
+ return model.get.apply(model, _.map([key].concat(args), function(value) {
+ return _peekObservable(value);
+ }));
+ };
+
+ kb.setValue = function(model, key, value) {
+ var attributes;
+ if (!model) {
+ return;
+ }
+ if (_.isFunction(model[key]) && kb.orm.useFunction(model, key)) {
+ return model[key](value);
+ }
+ (attributes = {})[key] = value;
+ return model.set(attributes);
+ };
+
return kb;
})();
@@ -7357,6 +7384,23 @@ ORM = (function() {
}
};
+ ORM.prototype.useFunction = function(model, key) {
+ var adpater, _j, _len1, _ref1;
+ if (!this.adapters.length) {
+ return;
+ }
+ if (!this.initialized) {
+ this.initialize();
+ }
+ _ref1 = this.adapters;
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ adpater = _ref1[_j];
+ if (adpater.useFunction(model, key)) {
+ return true;
+ }
+ }
+ };
+
return ORM;
})();
@@ -7433,6 +7477,10 @@ ORMAdapter_BackboneRelational = (function() {
};
};
+ ORMAdapter_BackboneRelational.prototype.useFunction = function(model, key) {
+ return false;
+ };
+
return ORMAdapter_BackboneRelational;
})();
@@ -7482,6 +7530,10 @@ ORMAdapter_BackboneAssociations = (function() {
return null;
};
+ ORMAdapter_BackboneAssociations.prototype.useFunction = function(model, key) {
+ return false;
+ };
+
return ORMAdapter_BackboneAssociations;
})();
@@ -7549,6 +7601,10 @@ ORMAdapter_Supermodel = (function() {
}
};
+ ORMAdapter_Supermodel.prototype.useFunction = function(model, key) {
+ return !!this.relationType(model, key);
+ };
+
return ORMAdapter_Supermodel;
})();
@@ -8434,26 +8490,24 @@ kb.Observable = (function() {
_unwrapObservable(arg);
}
if (_this.read) {
- _this.update(_this.read.apply(_this, args));
+ _this.update(_this.read.apply(_this._vm, args));
} else if (!_.isUndefined(_model)) {
kb.ignore(function() {
- return _this.update(_this.getValue(_model));
+ return _this.update(kb.getValue(_model, _peekObservable(_this.key), _this.args));
});
}
return _unwrapObservable(_this._vo());
},
write: function(new_value) {
return kb.ignore(function() {
- var set_info, unwrapped_new_value, _model;
+ var unwrapped_new_value, _model;
unwrapped_new_value = _unwrapModels(new_value);
- set_info = {};
- set_info[_unwrapObservable(_this.key)] = unwrapped_new_value;
_model = _peekObservable(_this._model);
if (_this.write) {
- _this.write.apply(_this._vm, [unwrapped_new_value]);
- new_value = _this.getValue(_model);
+ _this.write.call(_this._vm, unwrapped_new_value);
+ new_value = kb.getValue(_model, _peekObservable(_this.key), _this.args);
} else if (_model) {
- _model.set.apply(_model, [set_info]);
+ kb.setValue(_model, _peekObservable(_this.key), unwrapped_new_value);
}
return _this.update(new_value);
});
@@ -8477,23 +8531,17 @@ kb.Observable = (function() {
},
write: function(new_model) {
return kb.ignore(function() {
- var new_value, previous_model, previous_value, _ref1;
+ var new_value;
if (_this.__kb_released || (_peekObservable(_this._model) === new_model)) {
return;
}
- if (previous_model = _peekObservable(_this._model)) {
- previous_value = _this.getValue(previous_model);
- }
+ new_value = kb.getValue(new_model, _peekObservable(_this.key), _this.args);
_this._model(new_model);
if (!new_model) {
return _this.update(null);
- }
- if (!_.isUndefined(new_value = _this.getValue(new_model))) {
+ } else if (!_.isUndefined(new_value)) {
return _this.update(new_value);
}
- if (((_ref1 = _this._vm[_this.key]) != null ? _ref1.setToDefault : void 0) && kb.utils.valueType(_this._vm[_this.key]) === KB_TYPE_SIMPLE) {
- return _this.update(previous_value || null);
- }
});
}
});
@@ -8535,7 +8583,7 @@ kb.Observable = (function() {
Observable.prototype.valueType = function() {
var new_value;
- new_value = this.getValue(_peekObservable(this._model));
+ new_value = kb.getValue(_peekObservable(this._model), _peekObservable(this.key));
this.value_type || this._updateValueObservable(new_value);
return this.value_type;
};
@@ -8546,7 +8594,7 @@ kb.Observable = (function() {
return;
}
if (!arguments.length) {
- new_value = this.getValue(_peekObservable(this._model));
+ new_value = kb.getValue(_peekObservable(this._model), _peekObservable(this.key));
}
(new_value !== void 0) || (new_value = null);
new_type = kb.utils.valueType(new_value);
@@ -8629,23 +8677,6 @@ kb.Observable = (function() {
return this._vo(value);
};
- Observable.prototype.getValue = function(model, args) {
- var key;
- if (!model) {
- return;
- }
- key = _peekObservable(this.key);
- if (!model.has || model.has(key)) {
- if (args) {
- return model.get.apply(model, args);
- } else {
- return model.get(key);
- }
- } else {
- return typeof model[key] === "function" ? model[key]() : void 0;
- }
- };
-
return Observable;
})();
@@ -8902,6 +8933,8 @@ kb.CollectionObservable = (function() {
var create_options, observable, _ref1;
if (_.isUndefined(options) && !(collection instanceof kb.Collection)) {
_ref1 = [new kb.Collection(), collection], collection = _ref1[0], options = _ref1[1];
+ } else if (_.isArray(collection)) {
+ collection = new kb.Collection(collection);
}
options || (options = {});
observable = kb.utils.wrappedObservable(_this, ko.observableArray([]));
View
@@ -27,7 +27,7 @@
"nib": ">=0.8.2"
},
"dependencies": {
- "knockback": "git+https://github.com/kmalakoff/knockback",
+ "knockback": "0.18.x",
"knockout": "3.0.x",
"backbone": "1.1.x",
"underscore": "1.5.x"
@@ -4,7 +4,7 @@ try
'underscore': "../../vendor/test/underscore-1.5.2"
'backbone': "../../vendor/test/backbone-1.1.0"
'knockout': "../../vendor/test/knockout-3.0.0"
- 'knockback': "../../vendor/test/knockback-core-0.18.0"
+ 'knockback': "../../vendor/test/knockback-core-0.18.1"
'knockback-page-navigator-panes': "../../knockback-page-navigator-panes"
shim:
underscore:
@@ -5,7 +5,7 @@
<title>Knockback.PageNavigatorPanes Test Suite</title>
<!-- LIBRARY DEPENDENCIES -->
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/knockback-core-stack-0.18.0.js"></script>
+ <script type="text/javascript" src="../../vendor/knockback-core-stack-0.18.1.js"></script>
<!-- LIBRARY -->
<script type="text/javascript" src="../../knockback-page-navigator-panes.js"></script>
@@ -4,7 +4,7 @@ try
'underscore': "../../vendor/test/underscore-1.5.2"
'backbone': "../../vendor/test/backbone-1.1.0"
'knockout': "../../vendor/test/knockout-3.0.0"
- 'knockback': "../../vendor/test/knockback-core-0.18.0"
+ 'knockback': "../../vendor/test/knockback-core-0.18.1"
'knockback-page-navigator-simple': "../../knockback-page-navigator-simple"
shim:
underscore:
@@ -5,7 +5,7 @@
<title>Knockback.PageNavigatorSimple Test Suite</title>
<!-- LIBRARY DEPENDENCIES -->
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/knockback-core-stack-0.18.0.js"></script>
+ <script type="text/javascript" src="../../vendor/knockback-core-stack-0.18.1.js"></script>
<!-- LIBRARY -->
<script type="text/javascript" src="../../knockback-page-navigator-simple.js"></script>
Oops, something went wrong.

0 comments on commit 6dd5344

Please sign in to comment.