Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated AMD tests

  • Loading branch information...
commit 8b4c1032a81796fba8842eba16f0fdcff9c3ac8c 1 parent 41743e7
@kmalakoff authored
Showing with 15,049 additions and 2,762 deletions.
  1. +1 −1  Bakefile.coffee
  2. +2 −0  knockback-inspector.js
  3. +1 −1  knockback-inspector.min.js
  4. +1 −1  package.json
  5. +2 −0  packages/npm/knockback-inspector.js
  6. +1 −1  packages/npm/knockback-inspector.min.js
  7. +2 −0  packages/nuget/Content/Scripts/knockback-inspector.js
  8. +1 −1  packages/nuget/Content/Scripts/knockback-inspector.min.js
  9. +3 −0  src/lib/kbi_core.coffee
  10. +3 −3 test/all_tests.html
  11. +23 −35 test/core/test-amd.coffee
  12. +5 −17 test/core/test-latest-amd.html
  13. +36 −36 test/core/test.coffee
  14. +5 −4 test/core/test.html
  15. +5 −4 test/core/test.min.html
  16. +2 −2 test/interactive/index.html
  17. +1 −1  test/lodash/bundle-config.coffee
  18. +4 −3 test/lodash/test.html
  19. +4 −4 test/packaging/test.html
  20. +0 −11 test/test_helpers.js
  21. +2 −2 tutorials/coffeescript/step1/index.html
  22. +2 −2 tutorials/coffeescript/step2/index.html
  23. +2 −2 tutorials/coffeescript/step3/index.html
  24. +2 −2 tutorials/coffeescript/step4/index.html
  25. +2 −2 tutorials/javascript/step1/index.html
  26. +2 −2 tutorials/javascript/step2/index.html
  27. +2 −2 tutorials/javascript/step3/index.html
  28. +2 −2 tutorials/javascript/step4/index.html
  29. +80 −65 vendor/{backbone-relational-0.8.0.js → backbone-relational-0.8.0plus.js}
  30. +9,597 −0 vendor/jquery-1.9.1.js
  31. +5,217 −0 vendor/optional/lodash-1.1.1.js
  32. +0 −196 vendor/test/qunit/qunit.css
  33. +0 −2,360 vendor/test/qunit/qunit.js
  34. +37 −0 vendor/test/qunit/qunit_test_runner.js
View
2  Bakefile.coffee
@@ -50,6 +50,6 @@ module.exports =
# amd tests
'cp -v underscore vendor/test/underscore.js'
'cp -v backbone vendor/test/backbone.js'
- 'cp knockout/build/output/knockout-latest.debug.js vendor/test/knockout-2.2.1.js'
+ 'cp knockout/build/output/knockout-latest.debug.js vendor/knockout-2.2.1.js'
'cp -v knockback/knockback-core.js vendor/test/knockback-core.js'
]
View
2  knockback-inspector.js
@@ -51,6 +51,8 @@ kbi = this.kbi = typeof exports !== 'undefined' ? exports : {};
this.kbi.VERSION = '0.1.6';
+this.kb = kb;
+
kbi.TemplateSource = (function() {
function TemplateSource(template_generator, binding_context) {
this.template_generator = template_generator;
View
2  knockback-inspector.min.js
@@ -1 +1 @@
-(function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback-inspector",["underscore","backbone","knockout","knockback"],factory)}else{return factory.call(this)}}(function(){var Backbone,e,kb,kbi,ko,_,_ref,_ref1,__hasProp={}.hasOwnProperty,__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};if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}_=_.hasOwnProperty("_")?_._:_;Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;kb=!this.kb&&typeof require!=="undefined"?require("knockback"):this.kb;kbi=this.kbi=typeof exports!=="undefined"?exports:{};this.kbi.VERSION="0.1.6";kbi.TemplateSource=function(){function TemplateSource(template_generator,binding_context){this.template_generator=template_generator;this.binding_context=binding_context!=null?binding_context:{}}TemplateSource.prototype.data=function(key,value){if(arguments.length===1){return this.binding_context[key]}return this.binding_context[key]=value};TemplateSource.prototype.text=function(){if(arguments.length>0){throw"kbi.TemplateSource: unexpected writing to template source"}return this.template_generator.viewText(this.binding_context)};return TemplateSource}();kbi.TemplateEngine=function(_super){__extends(TemplateEngine,_super);function TemplateEngine(){this.allowTemplateRewriting=false;this.generators={kbi_array_node:kbi.ArrayNodeViewGenerator,kbi_model_node:kbi.ModelNodeViewGenerator,kbi_collection_node:kbi.CollectionNodeViewGenerator}}TemplateEngine.prototype.generator=function(template_name,generator_class){if(arguments.length===1){return this.generators[template_name]}return this.generators[template_name]=generator_class};TemplateEngine.prototype.makeTemplateSource=function(template_name){if(this.generators.hasOwnProperty(template_name)){return new kbi.TemplateSource(new this.generators[template_name](template_name))}return TemplateEngine.__super__.makeTemplateSource.apply(this,arguments)};TemplateEngine.prototype.renderTemplateSource=function(template_source,binding_context,options){var key,value;for(key in binding_context){value=binding_context[key];template_source.data(key,value)}return TemplateEngine.__super__.renderTemplateSource.apply(this,arguments)};return TemplateEngine}(ko.nativeTemplateEngine);kbi.FetchedModel=function(_super){__extends(FetchedModel,_super);function FetchedModel(){_ref=FetchedModel.__super__.constructor.apply(this,arguments);return _ref}FetchedModel.prototype.parse=function(response){var attributes,collection,key,model,value;attributes={};for(key in response){value=response[key];if(_.isObject(value)){model=new kbi.FetchedModel;attributes[key]=model.set(model.parse(value))}else if(_.isArray(value)){collection=new kbi.FetchedCollection;attributes[key]=collection.reset(collection.parse(value))}else{attributes[key]=value}}return attributes};return FetchedModel}(Backbone.Model);kbi.FetchedCollection=function(_super){__extends(FetchedCollection,_super);function FetchedCollection(){_ref1=FetchedCollection.__super__.constructor.apply(this,arguments);return _ref1}FetchedCollection.prototype.model=kbi.FetchedModel;FetchedCollection.prototype.parse=function(response){var models;models=response.results?response.results:response;return _.map(response.results,function(result){var model;model=new kbi.FetchedModel;return model.set(model.parse(result))})};return FetchedCollection}(Backbone.Collection);kbi.NodeViewModel=function(){function NodeViewModel(name,opened,node){var model,node_value;this.name=name;this.node=node;this.opened=ko.observable(opened);node_value=ko.utils.unwrapObservable(this.node);if(node_value instanceof kb.ViewModel){this.node=node_value;model=kb.utils.wrappedModel(this.node);this.attribute_names=ko.observableArray(model?_.keys(model.attributes):[])}else if(kb.utils.hasCollectionSignature(node_value)){this.node=kb.collectionObservable(node_value)}else if(kb.utils.hasModelSignature(node_value)){this.node=kb.viewModel(node_value);this.attribute_names=ko.observableArray(_.keys(node_value.attributes))}return}return NodeViewModel}();kbi.nodeViewModel=kbi.nvm=function(name,opened,node){return new kbi.NodeViewModel(name,opened,node)};kbi.ArrayNodeViewGenerator=function(){function ArrayNodeViewGenerator(template_name){this.template_name=template_name}ArrayNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ArrayNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ArrayNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='array' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name + '[]'\"></span>\n</div>"};ArrayNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: '['+$index()+']'\"></label>\n <input type='text' data-bind=\"value: $data, valueUpdate: 'keyup'\">\n</fieldset>"};ArrayNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.nodeEnd=function(){return""};return ArrayNodeViewGenerator}();kbi.CollectionNodeViewGenerator=function(){function CollectionNodeViewGenerator(template_name){this.template_name=template_name}CollectionNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n "+this.modelNode()+"\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};CollectionNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};CollectionNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};CollectionNodeViewGenerator.prototype.modelNode=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};CollectionNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return CollectionNodeViewGenerator}();kbi.ModelNodeViewGenerator=function(){function ModelNodeViewGenerator(template_name){this.template_name=template_name}ModelNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: attribute_names -->\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ModelNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ModelNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};ModelNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: $data\"></label>\n <input type='text' data-bind=\"value: $parent.node[$data], valueUpdate: 'keyup'\">\n</fieldset>"};ModelNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("$data+'[]'",true,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return ModelNodeViewGenerator}();kbi.ViewHTML=function(){function ViewHTML(){}ViewHTML.arrayTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_array_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.modelTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_model_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.collectionTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_collection_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};return ViewHTML}();return kbi})}).call(this);
+(function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback-inspector",["underscore","backbone","knockout","knockback"],factory)}else{return factory.call(this)}}(function(){var Backbone,e,kb,kbi,ko,_,_ref,_ref1,__hasProp={}.hasOwnProperty,__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};if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}_=_.hasOwnProperty("_")?_._:_;Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;kb=!this.kb&&typeof require!=="undefined"?require("knockback"):this.kb;kbi=this.kbi=typeof exports!=="undefined"?exports:{};this.kbi.VERSION="0.1.6";this.kb=kb;kbi.TemplateSource=function(){function TemplateSource(template_generator,binding_context){this.template_generator=template_generator;this.binding_context=binding_context!=null?binding_context:{}}TemplateSource.prototype.data=function(key,value){if(arguments.length===1){return this.binding_context[key]}return this.binding_context[key]=value};TemplateSource.prototype.text=function(){if(arguments.length>0){throw"kbi.TemplateSource: unexpected writing to template source"}return this.template_generator.viewText(this.binding_context)};return TemplateSource}();kbi.TemplateEngine=function(_super){__extends(TemplateEngine,_super);function TemplateEngine(){this.allowTemplateRewriting=false;this.generators={kbi_array_node:kbi.ArrayNodeViewGenerator,kbi_model_node:kbi.ModelNodeViewGenerator,kbi_collection_node:kbi.CollectionNodeViewGenerator}}TemplateEngine.prototype.generator=function(template_name,generator_class){if(arguments.length===1){return this.generators[template_name]}return this.generators[template_name]=generator_class};TemplateEngine.prototype.makeTemplateSource=function(template_name){if(this.generators.hasOwnProperty(template_name)){return new kbi.TemplateSource(new this.generators[template_name](template_name))}return TemplateEngine.__super__.makeTemplateSource.apply(this,arguments)};TemplateEngine.prototype.renderTemplateSource=function(template_source,binding_context,options){var key,value;for(key in binding_context){value=binding_context[key];template_source.data(key,value)}return TemplateEngine.__super__.renderTemplateSource.apply(this,arguments)};return TemplateEngine}(ko.nativeTemplateEngine);kbi.FetchedModel=function(_super){__extends(FetchedModel,_super);function FetchedModel(){_ref=FetchedModel.__super__.constructor.apply(this,arguments);return _ref}FetchedModel.prototype.parse=function(response){var attributes,collection,key,model,value;attributes={};for(key in response){value=response[key];if(_.isObject(value)){model=new kbi.FetchedModel;attributes[key]=model.set(model.parse(value))}else if(_.isArray(value)){collection=new kbi.FetchedCollection;attributes[key]=collection.reset(collection.parse(value))}else{attributes[key]=value}}return attributes};return FetchedModel}(Backbone.Model);kbi.FetchedCollection=function(_super){__extends(FetchedCollection,_super);function FetchedCollection(){_ref1=FetchedCollection.__super__.constructor.apply(this,arguments);return _ref1}FetchedCollection.prototype.model=kbi.FetchedModel;FetchedCollection.prototype.parse=function(response){var models;models=response.results?response.results:response;return _.map(response.results,function(result){var model;model=new kbi.FetchedModel;return model.set(model.parse(result))})};return FetchedCollection}(Backbone.Collection);kbi.NodeViewModel=function(){function NodeViewModel(name,opened,node){var model,node_value;this.name=name;this.node=node;this.opened=ko.observable(opened);node_value=ko.utils.unwrapObservable(this.node);if(node_value instanceof kb.ViewModel){this.node=node_value;model=kb.utils.wrappedModel(this.node);this.attribute_names=ko.observableArray(model?_.keys(model.attributes):[])}else if(kb.utils.hasCollectionSignature(node_value)){this.node=kb.collectionObservable(node_value)}else if(kb.utils.hasModelSignature(node_value)){this.node=kb.viewModel(node_value);this.attribute_names=ko.observableArray(_.keys(node_value.attributes))}return}return NodeViewModel}();kbi.nodeViewModel=kbi.nvm=function(name,opened,node){return new kbi.NodeViewModel(name,opened,node)};kbi.ArrayNodeViewGenerator=function(){function ArrayNodeViewGenerator(template_name){this.template_name=template_name}ArrayNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ArrayNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ArrayNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='array' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name + '[]'\"></span>\n</div>"};ArrayNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: '['+$index()+']'\"></label>\n <input type='text' data-bind=\"value: $data, valueUpdate: 'keyup'\">\n</fieldset>"};ArrayNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.nodeEnd=function(){return""};return ArrayNodeViewGenerator}();kbi.CollectionNodeViewGenerator=function(){function CollectionNodeViewGenerator(template_name){this.template_name=template_name}CollectionNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n "+this.modelNode()+"\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};CollectionNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};CollectionNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};CollectionNodeViewGenerator.prototype.modelNode=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};CollectionNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return CollectionNodeViewGenerator}();kbi.ModelNodeViewGenerator=function(){function ModelNodeViewGenerator(template_name){this.template_name=template_name}ModelNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: attribute_names -->\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ModelNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ModelNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};ModelNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: $data\"></label>\n <input type='text' data-bind=\"value: $parent.node[$data], valueUpdate: 'keyup'\">\n</fieldset>"};ModelNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("$data+'[]'",true,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return ModelNodeViewGenerator}();kbi.ViewHTML=function(){function ViewHTML(){}ViewHTML.arrayTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_array_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.modelTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_model_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.collectionTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_collection_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};return ViewHTML}();return kbi})}).call(this);
View
2  package.json
@@ -25,7 +25,7 @@
"dependencies": {
"backbone": ">=1.0.0",
"knockout": "2.2.1",
- "backbone-relational": ">=0.8.0",
+ "backbone-relational": ">=0.8.0plus",
"backbone-modelref": ">=0.1.5",
"knockback": ">=0.17.0pre",
"lodash": ">=0.6.1"
View
2  packages/npm/knockback-inspector.js
@@ -51,6 +51,8 @@ kbi = this.kbi = typeof exports !== 'undefined' ? exports : {};
this.kbi.VERSION = '0.1.6';
+this.kb = kb;
+
kbi.TemplateSource = (function() {
function TemplateSource(template_generator, binding_context) {
this.template_generator = template_generator;
View
2  packages/npm/knockback-inspector.min.js
@@ -1 +1 @@
-(function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback-inspector",["underscore","backbone","knockout","knockback"],factory)}else{return factory.call(this)}}(function(){var Backbone,e,kb,kbi,ko,_,_ref,_ref1,__hasProp={}.hasOwnProperty,__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};if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}_=_.hasOwnProperty("_")?_._:_;Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;kb=!this.kb&&typeof require!=="undefined"?require("knockback"):this.kb;kbi=this.kbi=typeof exports!=="undefined"?exports:{};this.kbi.VERSION="0.1.6";kbi.TemplateSource=function(){function TemplateSource(template_generator,binding_context){this.template_generator=template_generator;this.binding_context=binding_context!=null?binding_context:{}}TemplateSource.prototype.data=function(key,value){if(arguments.length===1){return this.binding_context[key]}return this.binding_context[key]=value};TemplateSource.prototype.text=function(){if(arguments.length>0){throw"kbi.TemplateSource: unexpected writing to template source"}return this.template_generator.viewText(this.binding_context)};return TemplateSource}();kbi.TemplateEngine=function(_super){__extends(TemplateEngine,_super);function TemplateEngine(){this.allowTemplateRewriting=false;this.generators={kbi_array_node:kbi.ArrayNodeViewGenerator,kbi_model_node:kbi.ModelNodeViewGenerator,kbi_collection_node:kbi.CollectionNodeViewGenerator}}TemplateEngine.prototype.generator=function(template_name,generator_class){if(arguments.length===1){return this.generators[template_name]}return this.generators[template_name]=generator_class};TemplateEngine.prototype.makeTemplateSource=function(template_name){if(this.generators.hasOwnProperty(template_name)){return new kbi.TemplateSource(new this.generators[template_name](template_name))}return TemplateEngine.__super__.makeTemplateSource.apply(this,arguments)};TemplateEngine.prototype.renderTemplateSource=function(template_source,binding_context,options){var key,value;for(key in binding_context){value=binding_context[key];template_source.data(key,value)}return TemplateEngine.__super__.renderTemplateSource.apply(this,arguments)};return TemplateEngine}(ko.nativeTemplateEngine);kbi.FetchedModel=function(_super){__extends(FetchedModel,_super);function FetchedModel(){_ref=FetchedModel.__super__.constructor.apply(this,arguments);return _ref}FetchedModel.prototype.parse=function(response){var attributes,collection,key,model,value;attributes={};for(key in response){value=response[key];if(_.isObject(value)){model=new kbi.FetchedModel;attributes[key]=model.set(model.parse(value))}else if(_.isArray(value)){collection=new kbi.FetchedCollection;attributes[key]=collection.reset(collection.parse(value))}else{attributes[key]=value}}return attributes};return FetchedModel}(Backbone.Model);kbi.FetchedCollection=function(_super){__extends(FetchedCollection,_super);function FetchedCollection(){_ref1=FetchedCollection.__super__.constructor.apply(this,arguments);return _ref1}FetchedCollection.prototype.model=kbi.FetchedModel;FetchedCollection.prototype.parse=function(response){var models;models=response.results?response.results:response;return _.map(response.results,function(result){var model;model=new kbi.FetchedModel;return model.set(model.parse(result))})};return FetchedCollection}(Backbone.Collection);kbi.NodeViewModel=function(){function NodeViewModel(name,opened,node){var model,node_value;this.name=name;this.node=node;this.opened=ko.observable(opened);node_value=ko.utils.unwrapObservable(this.node);if(node_value instanceof kb.ViewModel){this.node=node_value;model=kb.utils.wrappedModel(this.node);this.attribute_names=ko.observableArray(model?_.keys(model.attributes):[])}else if(kb.utils.hasCollectionSignature(node_value)){this.node=kb.collectionObservable(node_value)}else if(kb.utils.hasModelSignature(node_value)){this.node=kb.viewModel(node_value);this.attribute_names=ko.observableArray(_.keys(node_value.attributes))}return}return NodeViewModel}();kbi.nodeViewModel=kbi.nvm=function(name,opened,node){return new kbi.NodeViewModel(name,opened,node)};kbi.ArrayNodeViewGenerator=function(){function ArrayNodeViewGenerator(template_name){this.template_name=template_name}ArrayNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ArrayNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ArrayNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='array' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name + '[]'\"></span>\n</div>"};ArrayNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: '['+$index()+']'\"></label>\n <input type='text' data-bind=\"value: $data, valueUpdate: 'keyup'\">\n</fieldset>"};ArrayNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.nodeEnd=function(){return""};return ArrayNodeViewGenerator}();kbi.CollectionNodeViewGenerator=function(){function CollectionNodeViewGenerator(template_name){this.template_name=template_name}CollectionNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n "+this.modelNode()+"\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};CollectionNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};CollectionNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};CollectionNodeViewGenerator.prototype.modelNode=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};CollectionNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return CollectionNodeViewGenerator}();kbi.ModelNodeViewGenerator=function(){function ModelNodeViewGenerator(template_name){this.template_name=template_name}ModelNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: attribute_names -->\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ModelNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ModelNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};ModelNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: $data\"></label>\n <input type='text' data-bind=\"value: $parent.node[$data], valueUpdate: 'keyup'\">\n</fieldset>"};ModelNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("$data+'[]'",true,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return ModelNodeViewGenerator}();kbi.ViewHTML=function(){function ViewHTML(){}ViewHTML.arrayTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_array_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.modelTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_model_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.collectionTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_collection_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};return ViewHTML}();return kbi})}).call(this);
+(function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback-inspector",["underscore","backbone","knockout","knockback"],factory)}else{return factory.call(this)}}(function(){var Backbone,e,kb,kbi,ko,_,_ref,_ref1,__hasProp={}.hasOwnProperty,__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};if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}_=_.hasOwnProperty("_")?_._:_;Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;kb=!this.kb&&typeof require!=="undefined"?require("knockback"):this.kb;kbi=this.kbi=typeof exports!=="undefined"?exports:{};this.kbi.VERSION="0.1.6";this.kb=kb;kbi.TemplateSource=function(){function TemplateSource(template_generator,binding_context){this.template_generator=template_generator;this.binding_context=binding_context!=null?binding_context:{}}TemplateSource.prototype.data=function(key,value){if(arguments.length===1){return this.binding_context[key]}return this.binding_context[key]=value};TemplateSource.prototype.text=function(){if(arguments.length>0){throw"kbi.TemplateSource: unexpected writing to template source"}return this.template_generator.viewText(this.binding_context)};return TemplateSource}();kbi.TemplateEngine=function(_super){__extends(TemplateEngine,_super);function TemplateEngine(){this.allowTemplateRewriting=false;this.generators={kbi_array_node:kbi.ArrayNodeViewGenerator,kbi_model_node:kbi.ModelNodeViewGenerator,kbi_collection_node:kbi.CollectionNodeViewGenerator}}TemplateEngine.prototype.generator=function(template_name,generator_class){if(arguments.length===1){return this.generators[template_name]}return this.generators[template_name]=generator_class};TemplateEngine.prototype.makeTemplateSource=function(template_name){if(this.generators.hasOwnProperty(template_name)){return new kbi.TemplateSource(new this.generators[template_name](template_name))}return TemplateEngine.__super__.makeTemplateSource.apply(this,arguments)};TemplateEngine.prototype.renderTemplateSource=function(template_source,binding_context,options){var key,value;for(key in binding_context){value=binding_context[key];template_source.data(key,value)}return TemplateEngine.__super__.renderTemplateSource.apply(this,arguments)};return TemplateEngine}(ko.nativeTemplateEngine);kbi.FetchedModel=function(_super){__extends(FetchedModel,_super);function FetchedModel(){_ref=FetchedModel.__super__.constructor.apply(this,arguments);return _ref}FetchedModel.prototype.parse=function(response){var attributes,collection,key,model,value;attributes={};for(key in response){value=response[key];if(_.isObject(value)){model=new kbi.FetchedModel;attributes[key]=model.set(model.parse(value))}else if(_.isArray(value)){collection=new kbi.FetchedCollection;attributes[key]=collection.reset(collection.parse(value))}else{attributes[key]=value}}return attributes};return FetchedModel}(Backbone.Model);kbi.FetchedCollection=function(_super){__extends(FetchedCollection,_super);function FetchedCollection(){_ref1=FetchedCollection.__super__.constructor.apply(this,arguments);return _ref1}FetchedCollection.prototype.model=kbi.FetchedModel;FetchedCollection.prototype.parse=function(response){var models;models=response.results?response.results:response;return _.map(response.results,function(result){var model;model=new kbi.FetchedModel;return model.set(model.parse(result))})};return FetchedCollection}(Backbone.Collection);kbi.NodeViewModel=function(){function NodeViewModel(name,opened,node){var model,node_value;this.name=name;this.node=node;this.opened=ko.observable(opened);node_value=ko.utils.unwrapObservable(this.node);if(node_value instanceof kb.ViewModel){this.node=node_value;model=kb.utils.wrappedModel(this.node);this.attribute_names=ko.observableArray(model?_.keys(model.attributes):[])}else if(kb.utils.hasCollectionSignature(node_value)){this.node=kb.collectionObservable(node_value)}else if(kb.utils.hasModelSignature(node_value)){this.node=kb.viewModel(node_value);this.attribute_names=ko.observableArray(_.keys(node_value.attributes))}return}return NodeViewModel}();kbi.nodeViewModel=kbi.nvm=function(name,opened,node){return new kbi.NodeViewModel(name,opened,node)};kbi.ArrayNodeViewGenerator=function(){function ArrayNodeViewGenerator(template_name){this.template_name=template_name}ArrayNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ArrayNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ArrayNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='array' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name + '[]'\"></span>\n</div>"};ArrayNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: '['+$index()+']'\"></label>\n <input type='text' data-bind=\"value: $data, valueUpdate: 'keyup'\">\n</fieldset>"};ArrayNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.nodeEnd=function(){return""};return ArrayNodeViewGenerator}();kbi.CollectionNodeViewGenerator=function(){function CollectionNodeViewGenerator(template_name){this.template_name=template_name}CollectionNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n "+this.modelNode()+"\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};CollectionNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};CollectionNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};CollectionNodeViewGenerator.prototype.modelNode=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};CollectionNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return CollectionNodeViewGenerator}();kbi.ModelNodeViewGenerator=function(){function ModelNodeViewGenerator(template_name){this.template_name=template_name}ModelNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: attribute_names -->\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ModelNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ModelNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};ModelNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: $data\"></label>\n <input type='text' data-bind=\"value: $parent.node[$data], valueUpdate: 'keyup'\">\n</fieldset>"};ModelNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("$data+'[]'",true,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return ModelNodeViewGenerator}();kbi.ViewHTML=function(){function ViewHTML(){}ViewHTML.arrayTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_array_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.modelTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_model_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.collectionTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_collection_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};return ViewHTML}();return kbi})}).call(this);
View
2  packages/nuget/Content/Scripts/knockback-inspector.js
@@ -51,6 +51,8 @@ kbi = this.kbi = typeof exports !== 'undefined' ? exports : {};
this.kbi.VERSION = '0.1.6';
+this.kb = kb;
+
kbi.TemplateSource = (function() {
function TemplateSource(template_generator, binding_context) {
this.template_generator = template_generator;
View
2  packages/nuget/Content/Scripts/knockback-inspector.min.js
@@ -1 +1 @@
-(function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback-inspector",["underscore","backbone","knockout","knockback"],factory)}else{return factory.call(this)}}(function(){var Backbone,e,kb,kbi,ko,_,_ref,_ref1,__hasProp={}.hasOwnProperty,__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};if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}_=_.hasOwnProperty("_")?_._:_;Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;kb=!this.kb&&typeof require!=="undefined"?require("knockback"):this.kb;kbi=this.kbi=typeof exports!=="undefined"?exports:{};this.kbi.VERSION="0.1.6";kbi.TemplateSource=function(){function TemplateSource(template_generator,binding_context){this.template_generator=template_generator;this.binding_context=binding_context!=null?binding_context:{}}TemplateSource.prototype.data=function(key,value){if(arguments.length===1){return this.binding_context[key]}return this.binding_context[key]=value};TemplateSource.prototype.text=function(){if(arguments.length>0){throw"kbi.TemplateSource: unexpected writing to template source"}return this.template_generator.viewText(this.binding_context)};return TemplateSource}();kbi.TemplateEngine=function(_super){__extends(TemplateEngine,_super);function TemplateEngine(){this.allowTemplateRewriting=false;this.generators={kbi_array_node:kbi.ArrayNodeViewGenerator,kbi_model_node:kbi.ModelNodeViewGenerator,kbi_collection_node:kbi.CollectionNodeViewGenerator}}TemplateEngine.prototype.generator=function(template_name,generator_class){if(arguments.length===1){return this.generators[template_name]}return this.generators[template_name]=generator_class};TemplateEngine.prototype.makeTemplateSource=function(template_name){if(this.generators.hasOwnProperty(template_name)){return new kbi.TemplateSource(new this.generators[template_name](template_name))}return TemplateEngine.__super__.makeTemplateSource.apply(this,arguments)};TemplateEngine.prototype.renderTemplateSource=function(template_source,binding_context,options){var key,value;for(key in binding_context){value=binding_context[key];template_source.data(key,value)}return TemplateEngine.__super__.renderTemplateSource.apply(this,arguments)};return TemplateEngine}(ko.nativeTemplateEngine);kbi.FetchedModel=function(_super){__extends(FetchedModel,_super);function FetchedModel(){_ref=FetchedModel.__super__.constructor.apply(this,arguments);return _ref}FetchedModel.prototype.parse=function(response){var attributes,collection,key,model,value;attributes={};for(key in response){value=response[key];if(_.isObject(value)){model=new kbi.FetchedModel;attributes[key]=model.set(model.parse(value))}else if(_.isArray(value)){collection=new kbi.FetchedCollection;attributes[key]=collection.reset(collection.parse(value))}else{attributes[key]=value}}return attributes};return FetchedModel}(Backbone.Model);kbi.FetchedCollection=function(_super){__extends(FetchedCollection,_super);function FetchedCollection(){_ref1=FetchedCollection.__super__.constructor.apply(this,arguments);return _ref1}FetchedCollection.prototype.model=kbi.FetchedModel;FetchedCollection.prototype.parse=function(response){var models;models=response.results?response.results:response;return _.map(response.results,function(result){var model;model=new kbi.FetchedModel;return model.set(model.parse(result))})};return FetchedCollection}(Backbone.Collection);kbi.NodeViewModel=function(){function NodeViewModel(name,opened,node){var model,node_value;this.name=name;this.node=node;this.opened=ko.observable(opened);node_value=ko.utils.unwrapObservable(this.node);if(node_value instanceof kb.ViewModel){this.node=node_value;model=kb.utils.wrappedModel(this.node);this.attribute_names=ko.observableArray(model?_.keys(model.attributes):[])}else if(kb.utils.hasCollectionSignature(node_value)){this.node=kb.collectionObservable(node_value)}else if(kb.utils.hasModelSignature(node_value)){this.node=kb.viewModel(node_value);this.attribute_names=ko.observableArray(_.keys(node_value.attributes))}return}return NodeViewModel}();kbi.nodeViewModel=kbi.nvm=function(name,opened,node){return new kbi.NodeViewModel(name,opened,node)};kbi.ArrayNodeViewGenerator=function(){function ArrayNodeViewGenerator(template_name){this.template_name=template_name}ArrayNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ArrayNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ArrayNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='array' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name + '[]'\"></span>\n</div>"};ArrayNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: '['+$index()+']'\"></label>\n <input type='text' data-bind=\"value: $data, valueUpdate: 'keyup'\">\n</fieldset>"};ArrayNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.nodeEnd=function(){return""};return ArrayNodeViewGenerator}();kbi.CollectionNodeViewGenerator=function(){function CollectionNodeViewGenerator(template_name){this.template_name=template_name}CollectionNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n "+this.modelNode()+"\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};CollectionNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};CollectionNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};CollectionNodeViewGenerator.prototype.modelNode=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};CollectionNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return CollectionNodeViewGenerator}();kbi.ModelNodeViewGenerator=function(){function ModelNodeViewGenerator(template_name){this.template_name=template_name}ModelNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: attribute_names -->\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ModelNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ModelNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};ModelNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: $data\"></label>\n <input type='text' data-bind=\"value: $parent.node[$data], valueUpdate: 'keyup'\">\n</fieldset>"};ModelNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("$data+'[]'",true,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return ModelNodeViewGenerator}();kbi.ViewHTML=function(){function ViewHTML(){}ViewHTML.arrayTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_array_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.modelTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_model_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.collectionTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_collection_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};return ViewHTML}();return kbi})}).call(this);
+(function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback-inspector",["underscore","backbone","knockout","knockback"],factory)}else{return factory.call(this)}}(function(){var Backbone,e,kb,kbi,ko,_,_ref,_ref1,__hasProp={}.hasOwnProperty,__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};if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}_=_.hasOwnProperty("_")?_._:_;Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;kb=!this.kb&&typeof require!=="undefined"?require("knockback"):this.kb;kbi=this.kbi=typeof exports!=="undefined"?exports:{};this.kbi.VERSION="0.1.6";this.kb=kb;kbi.TemplateSource=function(){function TemplateSource(template_generator,binding_context){this.template_generator=template_generator;this.binding_context=binding_context!=null?binding_context:{}}TemplateSource.prototype.data=function(key,value){if(arguments.length===1){return this.binding_context[key]}return this.binding_context[key]=value};TemplateSource.prototype.text=function(){if(arguments.length>0){throw"kbi.TemplateSource: unexpected writing to template source"}return this.template_generator.viewText(this.binding_context)};return TemplateSource}();kbi.TemplateEngine=function(_super){__extends(TemplateEngine,_super);function TemplateEngine(){this.allowTemplateRewriting=false;this.generators={kbi_array_node:kbi.ArrayNodeViewGenerator,kbi_model_node:kbi.ModelNodeViewGenerator,kbi_collection_node:kbi.CollectionNodeViewGenerator}}TemplateEngine.prototype.generator=function(template_name,generator_class){if(arguments.length===1){return this.generators[template_name]}return this.generators[template_name]=generator_class};TemplateEngine.prototype.makeTemplateSource=function(template_name){if(this.generators.hasOwnProperty(template_name)){return new kbi.TemplateSource(new this.generators[template_name](template_name))}return TemplateEngine.__super__.makeTemplateSource.apply(this,arguments)};TemplateEngine.prototype.renderTemplateSource=function(template_source,binding_context,options){var key,value;for(key in binding_context){value=binding_context[key];template_source.data(key,value)}return TemplateEngine.__super__.renderTemplateSource.apply(this,arguments)};return TemplateEngine}(ko.nativeTemplateEngine);kbi.FetchedModel=function(_super){__extends(FetchedModel,_super);function FetchedModel(){_ref=FetchedModel.__super__.constructor.apply(this,arguments);return _ref}FetchedModel.prototype.parse=function(response){var attributes,collection,key,model,value;attributes={};for(key in response){value=response[key];if(_.isObject(value)){model=new kbi.FetchedModel;attributes[key]=model.set(model.parse(value))}else if(_.isArray(value)){collection=new kbi.FetchedCollection;attributes[key]=collection.reset(collection.parse(value))}else{attributes[key]=value}}return attributes};return FetchedModel}(Backbone.Model);kbi.FetchedCollection=function(_super){__extends(FetchedCollection,_super);function FetchedCollection(){_ref1=FetchedCollection.__super__.constructor.apply(this,arguments);return _ref1}FetchedCollection.prototype.model=kbi.FetchedModel;FetchedCollection.prototype.parse=function(response){var models;models=response.results?response.results:response;return _.map(response.results,function(result){var model;model=new kbi.FetchedModel;return model.set(model.parse(result))})};return FetchedCollection}(Backbone.Collection);kbi.NodeViewModel=function(){function NodeViewModel(name,opened,node){var model,node_value;this.name=name;this.node=node;this.opened=ko.observable(opened);node_value=ko.utils.unwrapObservable(this.node);if(node_value instanceof kb.ViewModel){this.node=node_value;model=kb.utils.wrappedModel(this.node);this.attribute_names=ko.observableArray(model?_.keys(model.attributes):[])}else if(kb.utils.hasCollectionSignature(node_value)){this.node=kb.collectionObservable(node_value)}else if(kb.utils.hasModelSignature(node_value)){this.node=kb.viewModel(node_value);this.attribute_names=ko.observableArray(_.keys(node_value.attributes))}return}return NodeViewModel}();kbi.nodeViewModel=kbi.nvm=function(name,opened,node){return new kbi.NodeViewModel(name,opened,node)};kbi.ArrayNodeViewGenerator=function(){function ArrayNodeViewGenerator(template_name){this.template_name=template_name}ArrayNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($data) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ArrayNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ArrayNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='array' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name + '[]'\"></span>\n</div>"};ArrayNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: '['+$index()+']'\"></label>\n <input type='text' data-bind=\"value: $data, valueUpdate: 'keyup'\">\n</fieldset>"};ArrayNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("'['+$index()+']'",false,"$data")};ArrayNodeViewGenerator.prototype.nodeEnd=function(){return""};return ArrayNodeViewGenerator}();kbi.CollectionNodeViewGenerator=function(){function CollectionNodeViewGenerator(template_name){this.template_name=template_name}CollectionNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: node -->\n "+this.modelNode()+"\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};CollectionNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};CollectionNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};CollectionNodeViewGenerator.prototype.modelNode=function(){return""+kbi.ViewHTML.modelTree("'['+$index()+']'",false,"$data")};CollectionNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return CollectionNodeViewGenerator}();kbi.ModelNodeViewGenerator=function(){function ModelNodeViewGenerator(template_name){this.template_name=template_name}ModelNodeViewGenerator.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n <!-- ko if: opened -->\n <!-- ko foreach: attribute_names -->\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_SIMPLE) -->\n "+this.attributeEditor()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_ARRAY) -->\n "+this.arrayTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_MODEL) -->\n "+this.modelTree()+"\n <!-- /ko -->\n\n <!-- ko if: (kb.utils.valueType($parent.node[$data]) == kb.TYPE_COLLECTION) -->\n "+this.collectionTree()+"\n <!-- /ko -->\n\n <!-- /ko -->\n <!-- /ko -->\n"+this.nodeEnd()};ModelNodeViewGenerator.prototype.nodeStart=function(){return"<li class='kbi' data-bind=\"css: {opened: opened, closed: !opened()}\">"};ModelNodeViewGenerator.prototype.nodeManipulator=function(){return"<div class='collection' data-bind=\"click: function(){ opened(!opened()) }\">\n <span data-bind=\"text: (opened() ? '- ' : '+ ' )\"></span>\n <span data-bind=\"text: name\"></span>\n</div>"};ModelNodeViewGenerator.prototype.attributeEditor=function(){return"<fieldset class='kbi'>\n <label data-bind=\"text: $data\"></label>\n <input type='text' data-bind=\"value: $parent.node[$data], valueUpdate: 'keyup'\">\n</fieldset>"};ModelNodeViewGenerator.prototype.arrayTree=function(){return""+kbi.ViewHTML.arrayTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.modelTree=function(){return""+kbi.ViewHTML.modelTree("$data",false,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.collectionTree=function(){return""+kbi.ViewHTML.collectionTree("$data+'[]'",true,"$parent.node[$data]")};ModelNodeViewGenerator.prototype.nodeEnd=function(){return"</li>"};return ModelNodeViewGenerator}();kbi.ViewHTML=function(){function ViewHTML(){}ViewHTML.arrayTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_array_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.modelTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_model_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};ViewHTML.collectionTree=function(name,opened,node){return"<ul class='kbi' data-bind=\"template: {name: 'kbi_collection_node', data: kbi.nvm("+name+", "+opened+", "+node+')}"></ul>'};return ViewHTML}();return kbi})}).call(this);
View
3  src/lib/kbi_core.coffee
@@ -17,3 +17,6 @@ kb = if not @kb and (typeof(require) isnt 'undefined') then require('knockback')
# export or create kbi namespace
kbi = @kbi = if (typeof(exports) != 'undefined') then exports else {}
@kbi.VERSION = '0.1.6'
+
+# export Knockback so it is accessible by the views
+@kb = kb
View
6 test/all_tests.html
@@ -2,9 +2,9 @@
<html>
<head>
<title>Knockback-Inspector - All Tests</title>
- <link rel="stylesheet" href="vendor/qunit/qunit.css" type="text/css" media="screen" />
- <script type="text/javascript" src="vendor/qunit/jquery.js"></script>
- <script type="text/javascript" src="vendor/qunit/qunit.js"></script>
+ <link rel="stylesheet" href="../vendor/test/qunit/qunit-1.11.0.css" type="text/css" media="screen" />
+ <script type="text/javascript" src="../vendor/test/jquery-1.9.1.js"></script>
+ <script type="text/javascript" src="../vendor/test/qunit/qunit-1.11.0.js"></script>
<style type="text/css">
iframe, body {height: 100%; padding:0; margin: 0;}
iframe {float: left;}
View
58 test/core/test-amd.coffee
@@ -1,37 +1,25 @@
-$(->
- module("knockback-defaults-amd.js")
+try
+ require.config({
+ paths:
+ 'underscore': "../../vendor/test/underscore-1.4.4"
+ 'backbone': "../../vendor/test/backbone-1.0.0"
+ 'backbone-relational': "../../vendor/test/backbone-relational-0.6.0"
+ 'knockout': "../../vendor/test/knockout-2.2.1"
+ 'knockback': "../../vendor/test/knockback-core-0.17.0pre"
+ 'knockback-inspector': "../../knockback-inspector"
+ shim:
+ underscore:
+ exports: '_'
+ backbone:
+ exports: 'Backbone'
+ deps: ['underscore']
+ })
+
+ module_name = 'knockback-defaults'
+ module_name = 'knockback' if (require.toUrl(module_name).split('./..').length is 1)
# library and dependencies
- require(['underscore', 'backbone', 'knockout', 'knockback', 'knockback-inspector'], (_, Backbone, ko, kb, kbi) ->
- _ or= @_
- Backbone or= @Backbone
-
- test("TEST DEPENDENCY MISSING", ->
- ok(!!_); ok(!!Backbone); ok(!!ko); ok(!!kb); ok(!!kbi)
- )
-
- # make kbi global so can be accessed by templates
- window.kbi = kbi
-
- # set the template engine so Knockout can find 'kbi_model_node' and 'kbi_collection_node' templates
- ko.setTemplateEngine(new kbi.TemplateEngine())
-
- test("Backbone.Model", ->
- html = """
- <ul id='model' data-bind="template: {name: 'kbi_model_node', data: kbi.nvm('root', true, $data)}"></ul>
- """
-
- your_model = new Backbone.Model({name: 'Hello', place: 'World!'})
- ko.applyBindings(kb.viewModel(your_model), $(html)[0])
- )
-
- test("Backbone.Collection", ->
- html = """
- <ul id='collection' data-bind="template: {name: 'kbi_collection_node', data: kbi.nvm('root', true, $data)}"></ul>
- """
-
- your_collection = new Backbone.Collection([{name: 'Hello', place: 'World!'}, {name: 'Goodbye', place: 'Samsara!'}])
- ko.applyBindings(kb.collectionObservable(your_collection, {view_model: kb.ViewModel}), $(html)[0]);
- )
- )
-)
+ require ['underscore', 'backbone', 'knockout', 'knockback', 'knockback-inspector', 'qunit_test_runner'], (_, Backbone, ko, kb, kbi, runner) ->
+ window._ = window.Backbone = window.ko = window.kbi = null # force each test to require dependencies synchronously
+ # window.kb = null # force each test to require dependencies synchronously
+ require ['./build/test'], -> runner.start()
View
22 test/core/test-latest-amd.html
@@ -3,24 +3,13 @@
<head>
<title>Knockback-Inspector Test Suite (AMD)</title>
- <script src="../../vendor/test/require.js"></script>
- <script type="text/javascript">
- require.config({
- paths: {
- 'underscore': "../../vendor/test/underscore-1.4.4",
- 'backbone': "../../vendor/test/backbone-1.0.0",
- 'backbone-relational': "../../vendor/test/backbone-relational-0.6.0",
- 'knockout': "../../vendor/test/knockout-2.2.1",
- 'knockback': "../../vendor/test/knockback-core-0.17.0pre",
- 'knockback-inspector': "../../knockback-inspector"
- }
- });
- </script>
-
<!-- TESTS -->
- <link rel="stylesheet" href="../../vendor/test/qunit/qunit.css" type="text/css" media="screen" />
+ <script src="../../vendor/test/require.js"></script>
+ <link rel="stylesheet" href="../../vendor/test/qunit/qunit-1.11.0.css" type="text/css" media="screen" />
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/test/qunit/qunit.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit-1.11.0.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit_test_runner.js"></script>
+
<script type="text/javascript" src="build/test-amd.js"></script>
</head>
<body>
@@ -30,6 +19,5 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
- <script type="text/javascript">QUnit.done = function(failures, total) {if (!total) { $('#qunit-banner').removeClass('qunit-pass').addClass('qunit-fail'); throw 'Warning: no tests run'}}</script>
</body>
</html>
View
72 test/core/test.coffee
@@ -1,37 +1,37 @@
-$(->
- module("knockback-inspector")
-
- # import Underscore (or Lo-Dash with precedence), Backbone, Knockout, and Knockback
- Backbone = if not window.Backbone and (typeof(require) != 'undefined') then require('backbone') else window.Backbone
- ko = if not window.ko and (typeof(require) != 'undefined') then require('knockout') else window.ko
- kb = if not window.kb and (typeof(require) != 'undefined') then require('knockback') else window.kb
- kbi = if not window.kbi and (typeof(require) != 'undefined') then require('knockback-inspector') else window.kbi
-
- test("TEST DEPENDENCY MISSING", ->
- ok(!!Backbone); ok(!!ko); ok(!!kb); ok(!!kbi)
- )
-
- # make kbi global so can be accessed by templates
- window.kbi = kbi
-
- # set the template engine so Knockout can find 'kbi_model_node' and 'kbi_collection_node' templates
- ko.setTemplateEngine(new kbi.TemplateEngine())
-
- test("Backbone.Model", ->
- html = """
- <ul id='model' data-bind="template: {name: 'kbi_model_node', data: kbi.nvm('root', true, $data)}"></ul>
- """
-
- your_model = new Backbone.Model({name: 'Hello', place: 'World!'})
- ko.applyBindings(kb.viewModel(your_model), $(html)[0])
- )
-
- test("Backbone.Collection", ->
- html = """
- <ul id='collection' data-bind="template: {name: 'kbi_collection_node', data: kbi.nvm('root', true, $data)}"></ul>
- """
-
- your_collection = new Backbone.Collection([{name: 'Hello', place: 'World!'}, {name: 'Goodbye', place: 'Samsara!'}])
- ko.applyBindings(kb.collectionObservable(your_collection, {view_model: kb.ViewModel}), $(html)[0]);
- )
+module("knockback-inspector")
+
+# import Underscore (or Lo-Dash with precedence), Backbone, Knockout, and Knockback
+Backbone = if not window.Backbone and (typeof(require) != 'undefined') then require('backbone') else window.Backbone
+ko = if not window.ko and (typeof(require) != 'undefined') then require('knockout') else window.ko
+kb = if not window.kb and (typeof(require) != 'undefined') then require('knockback') else window.kb
+kbi = if not window.kbi and (typeof(require) != 'undefined') then require('knockback-inspector') else window.kbi
+
+test("TEST DEPENDENCY MISSING", ->
+ ok(!!Backbone); ok(!!ko); ok(!!kb); ok(!!kbi)
+)
+
+# make kbi global so can be accessed by templates
+window.kbi = kbi
+
+# set the template engine so Knockout can find 'kbi_model_node' and 'kbi_collection_node' templates
+ko.setTemplateEngine(new kbi.TemplateEngine())
+
+test("Backbone.Model", ->
+ html = """
+ <ul id='model' data-bind="template: {name: 'kbi_model_node', data: kbi.nvm('root', true, $data)}"></ul>
+ """
+
+ your_model = new Backbone.Model({name: 'Hello', place: 'World!'})
+ ko.applyBindings(kb.viewModel(your_model), $(html)[0])
+ ok(true)
+)
+
+test("Backbone.Collection", ->
+ html = """
+ <ul id='collection' data-bind="template: {name: 'kbi_collection_node', data: kbi.nvm('root', true, $data)}"></ul>
+ """
+
+ your_collection = new Backbone.Collection([{name: 'Hello', place: 'World!'}, {name: 'Goodbye', place: 'Samsara!'}])
+ ko.applyBindings(kb.collectionObservable(your_collection, {view_model: kb.ViewModel}), $(html)[0]);
+ ok(true)
)
View
9 test/core/test.html
@@ -4,15 +4,17 @@
<title>Knockback-Inspector Test Suite</title>
<!-- LIBRARY DEPENDENCIES -->
<script type="text/javascript" src="../../vendor/knockback-core-stack-0.17.0pre.js"></script>
- <script type="text/javascript" src="../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- LIBRARY -->
<script type="text/javascript" src="../../knockback-inspector.js"></script>
<!-- TESTS -->
- <link rel="stylesheet" href="../../vendor/test/qunit/qunit.css" type="text/css" media="screen" />
+ <link rel="stylesheet" href="../../vendor/test/qunit/qunit-1.11.0.css" type="text/css" media="screen" />
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/test/qunit/qunit.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit-1.11.0.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit_test_runner.js"></script>
+
<script type="text/javascript" src="build/test.js"></script>
</head>
@@ -23,6 +25,5 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
- <script type="text/javascript">QUnit.done = function(failures, total) {if (!total) { $('#qunit-banner').removeClass('qunit-pass').addClass('qunit-fail'); throw 'Warning: no tests run'}}</script>
</body>
</html>
View
9 test/core/test.min.html
@@ -4,15 +4,17 @@
<title>Knockback-Inspector Test Suite (Production)</title>
<!-- LIBRARY DEPENDENCIES -->
<script type="text/javascript" src='../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- LIBRARY -->
<script type="text/javascript" src="../../knockback-inspector.min.js"></script>
<!-- TESTS -->
- <link rel="stylesheet" href="../../vendor/test/qunit/qunit.css" type="text/css" media="screen" />
+ <link rel="stylesheet" href="../../vendor/test/qunit/qunit-1.11.0.css" type="text/css" media="screen" />
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/test/qunit/qunit.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit-1.11.0.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit_test_runner.js"></script>
+
<script type="text/javascript" src="build/test.js"></script>
</head>
<body>
@@ -22,6 +24,5 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
- <script type="text/javascript">QUnit.done = function(failures, total) {if (!total) { $('#qunit-banner').removeClass('qunit-pass').addClass('qunit-fail'); throw 'Warning: no tests run'}}</script>
</body>
</html>
View
4 test/interactive/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='../../knockback-inspector.js'></script>
View
2  test/lodash/bundle-config.coffee
@@ -1,6 +1,6 @@
module.exports =
'test/lodash/build/bundle-lodash.js':
- lodash: 'vendor/optional/lodash-1.1.0.js'
+ lodash: 'vendor/optional/lodash-1.1.1.js'
backbone: 'backbone'
'backbone-relational': 'backbone-relational'
knockout: 'knockout'
View
7 test/lodash/test.html
@@ -2,12 +2,14 @@
<html>
<head>
<title>Knockback-Inspector Test Suite Lo-Dash</title>
- <link rel="stylesheet" href="../../vendor/test/qunit/qunit.css" type="text/css" media="screen" />
+ <link rel="stylesheet" href="../../vendor/test/qunit/qunit-1.11.0.css" type="text/css" media="screen" />
<script type="text/javascript" src="build/bundle-lodash.js"></script>
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/test/qunit/qunit.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit-1.11.0.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit_test_runner.js"></script>
+
<script type="text/javascript" src="../core/build/test.js"></script>
</head>
<body>
@@ -17,6 +19,5 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
- <script type="text/javascript">QUnit.done = function(failures, total) {if (!total) { $('#qunit-banner').removeClass('qunit-pass').addClass('qunit-fail'); throw 'Warning: no tests run'}}</script>
</body>
</html>
View
8 test/packaging/test.html
@@ -2,12 +2,13 @@
<html>
<head>
<title>Knockback-Inspector Test Suite Packaging</title>
- <link rel="stylesheet" href="../../vendor/test/qunit/qunit.css" type="text/css" media="screen" />
-
<script type="text/javascript" src="build/bundle.js"></script>
+ <link rel="stylesheet" href="../../vendor/test/qunit/qunit-1.11.0.css" type="text/css" media="screen" />
<script type="text/javascript" src="../../vendor/test/jquery-1.9.1.js"></script>
- <script type="text/javascript" src="../../vendor/test/qunit/qunit.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit-1.11.0.js"></script>
+ <script type="text/javascript" src="../../vendor/test/qunit/qunit_test_runner.js"></script>
+
<script type="text/javascript" src="../core/build/test.js"></script>
</head>
<body>
@@ -17,6 +18,5 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
- <script type="text/javascript">QUnit.done = function(failures, total) {if (!total) { $('#qunit-banner').removeClass('qunit-pass').addClass('qunit-fail'); throw 'Warning: no tests run'}}</script>
</body>
</html>
View
11 test/test_helpers.js
@@ -1,11 +0,0 @@
-var testsDoneCallback = function(details) {
- // TODO: implement for requirejs
- if (typeof(require) != 'undefined') return;
-
- if (!details.total) {
- $('#qunit-banner').removeClass('qunit-pass').addClass('qunit-fail');
- throw new Error('Warning: no tests run');
- }
-};
-
-QUnit.done(testsDoneCallback);
View
4 tutorials/coffeescript/step1/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/coffeescript/step2/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/coffeescript/step3/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/coffeescript/step4/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/javascript/step1/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/javascript/step2/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/javascript/step3/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
4 tutorials/javascript/step4/index.html
@@ -5,9 +5,9 @@
<title class='inspector_title' data-bind="text: title"></title>
<!-- DEPENDENCIES -->
- <script type="text/javascript" src='../../../vendor/jquery-1.8.0.js'></script>
+ <script type="text/javascript" src='../../../vendor/jquery-1.9.1.js'></script>
<script type="text/javascript" src='../../../vendor/knockback-core-stack-0.17.0pre.js'></script>
- <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0.js"></script>
+ <script type="text/javascript" src="../../../vendor/backbone-relational-0.8.0plus.js"></script>
<!-- KNOCKBACK-INSPECTOR LIBRARY -->
<script src='javascripts/lib/kbi_core.js'></script>
View
145 vendor/backbone-relational-0.8.0.js → vendor/backbone-relational-0.8.0plus.js
@@ -1,6 +1,6 @@
/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */
/**
- * Backbone-relational.js 0.8.0
+ * Backbone-relational.js 0.8.0+
* (c) 2011-2013 Paul Uithol and contributors (https://github.com/PaulUithol/Backbone-relational/graphs/contributors)
*
* Backbone-relational may be freely distributed under the MIT license; see the accompanying LICENSE.txt.
@@ -150,6 +150,14 @@
},
/**
+ * Remove a scope.
+ * @param {Object} scope
+ */
+ removeModelScope: function( scope ) {
+ this._modelScopes = _.without( this._modelScopes, scope );
+ },
+
+ /**
* Add a set of subModelTypes to the store, that can be used to resolve the '_superModel'
* for a model later in 'setupSuperModel'.
*
@@ -804,7 +812,7 @@
if ( _.isString( this.collectionType ) ) {
this.collectionType = Backbone.Relational.store.getObjectByName( this.collectionType );
}
- if ( !this.collectionType.prototype instanceof Backbone.Collection ){
+ if ( this.collectionType !== Backbone.Collection && !( this.collectionType.prototype instanceof Backbone.Collection ) ) {
throw new Error( '`collectionType` must inherit from Backbone.Collection' );
}
@@ -878,7 +886,9 @@
}
else {
// If `merge` is true, update models here, instead of during update.
- model = this.relatedModel.findOrCreate( attributes, _.extend( { merge: true }, options, { create: this.options.createModels } ) );
+ model = this.relatedModel.findOrCreate( attributes,
+ _.extend( { merge: true }, options, { create: this.options.createModels } )
+ );
}
model && toAdd.push( model );
@@ -891,7 +901,9 @@
related = this._prepareCollection();
}
- related.update( toAdd, _.defaults( { merge: false, parse: false }, options ) );
+ // By now, both `merge` and `parse` will already have been executed for models if they were specified.
+ // Disable them to prevent additional calls.
+ related.set( toAdd, _.defaults( { merge: false, parse: false }, options ) );
}
return related;
@@ -1004,7 +1016,7 @@
var dit = this;
model.queue( function() {
if ( dit.related && !dit.related.get( model ) ) {
- dit.related.add( model, options );
+ dit.related.add( model, _.defaults( { merge: false, parse: false }, options ) );
}
});
},
@@ -1037,7 +1049,7 @@
// Nasty hack, for cases like 'model.get( <HasMany key> ).add( item )'.
// Defer 'processQueue', so that when 'Relation.createModels' is used we trigger 'HasMany'
// collection events only after the model is really fully set up.
- // Example: "p.get('jobs').add( { company: c, person: p } )".
+ // Example: event for "p.on( 'add:jobs' )" -> "p.get('jobs').add( { company: c.id, person: p.id } )".
if ( options && options.collection ) {
var dit = this,
collection = this.collection = options.collection;
@@ -1125,7 +1137,7 @@
else {
Backbone.Model.prototype.trigger.apply( this, arguments );
}
-
+
return this;
},
@@ -1136,11 +1148,11 @@
initializeRelations: function( options ) {
this.acquire(); // Setting up relations often also involve calls to 'set', and we only want to enter this function once
this._relations = {};
-
+
_.each( this.relations || [], function( rel ) {
Backbone.Relational.store.initializeRelation( this, rel, options );
}, this );
-
+
this._isInitialized = true;
this.release();
this.processQueue();
@@ -1213,7 +1225,7 @@
toFetch = keys && _.select( keys || [], function( id ) {
return ( id || id === 0 ) && ( refresh || !Backbone.Relational.store.find( rel.relatedModel, id ) );
}, this );
-
+
if ( toFetch && toFetch.length ) {
// Find (or create) a model for each one that is to be fetched
var created = [],
@@ -1234,7 +1246,7 @@
if ( rel.related instanceof Backbone.Collection && _.isFunction( rel.related.url ) ) {
setUrl = rel.related.url( models );
}
-
+
// An assumption is that when 'Backbone.Collection.url' is a function, it can handle building of set urls.
// To make sure it can, test if the url we got by supplying a list of models to fetch is different from
// the one supplied for the default fetch action (without args to 'url').
@@ -1303,7 +1315,7 @@
set: function( key, value, options ) {
Backbone.Relational.eventQueue.block();
-
+
// Duplicate backbone's behavior to allow separate key/value parameters, instead of a single 'attributes' object
var attributes;
if ( _.isObject( key ) || key == null ) {
@@ -1314,7 +1326,7 @@
attributes = {};
attributes[ key ] = value;
}
-
+
var result = Backbone.Model.prototype.set.apply( this, arguments );
// Ideal place to set up relations :)
@@ -1345,13 +1357,13 @@
unset: function( attribute, options ) {
Backbone.Relational.eventQueue.block();
-
+
var result = Backbone.Model.prototype.unset.apply( this, arguments );
this.updateRelations( options );
-
+
// Try to run the global queue holding external events
Backbone.Relational.eventQueue.unblock();
-
+
return result;
},
@@ -1360,10 +1372,10 @@
var result = Backbone.Model.prototype.clear.apply( this, arguments );
this.updateRelations( options );
-
+
// Try to run the global queue holding external events
Backbone.Relational.eventQueue.unblock();
-
+
return result;
},
@@ -1388,63 +1400,68 @@
if ( this.isLocked() ) {
return this.id;
}
-
+
this.acquire();
var json = Backbone.Model.prototype.toJSON.call( this, options );
-
+
if ( this.constructor._superModel && !( this.constructor._subModelTypeAttribute in json ) ) {
json[ this.constructor._subModelTypeAttribute ] = this.constructor._subModelTypeValue;
}
-
+
_.each( this._relations, function( rel ) {
- var value = json[ rel.key ];
+ var related = json[ rel.key ],
+ includeInJSON = rel.options.includeInJSON,
+ value = null;
- if ( rel.options.includeInJSON === true) {
- if ( value && _.isFunction( value.toJSON ) ) {
- json[ rel.keyDestination ] = value.toJSON( options );
- }
- else {
- json[ rel.keyDestination ] = null;
+ if ( includeInJSON === true ) {
+ if ( related && _.isFunction( related.toJSON ) ) {
+ value = related.toJSON( options );
}
}
- else if ( _.isString( rel.options.includeInJSON ) ) {
- if ( value instanceof Backbone.Collection ) {
- json[ rel.keyDestination ] = value.pluck( rel.options.includeInJSON );
+ else if ( _.isString( includeInJSON ) ) {
+ if ( related instanceof Backbone.Collection ) {
+ value = related.pluck( includeInJSON );
}
- else if ( value instanceof Backbone.Model ) {
- json[ rel.keyDestination ] = value.get( rel.options.includeInJSON );
+ else if ( related instanceof Backbone.Model ) {
+ value = related.get( includeInJSON );
}
- else {
- json[ rel.keyDestination ] = null;
+
+ // Add ids for 'unfound' models if includeInJSON is equal to (only) the relatedModel's `idAttribute`
+ if ( includeInJSON === rel.relatedModel.prototype.idAttribute ) {
+ if ( rel instanceof Backbone.HasMany ) {
+ value = value.concat( rel.keyIds );
+ }
+ else if ( rel instanceof Backbone.HasOne ) {
+ value = value || rel.keyId;
+ }
}
}
- else if ( _.isArray( rel.options.includeInJSON ) ) {
- if ( value instanceof Backbone.Collection ) {
- var valueSub = [];
- value.each( function( model ) {
+ else if ( _.isArray( includeInJSON ) ) {
+ if ( related instanceof Backbone.Collection ) {
+ value = [];
+ related.each( function( model ) {
var curJson = {};
- _.each( rel.options.includeInJSON, function( key ) {
+ _.each( includeInJSON, function( key ) {
curJson[ key ] = model.get( key );
});
- valueSub.push( curJson );
+ value.push( curJson );
});
- json[ rel.keyDestination ] = valueSub;
}
- else if ( value instanceof Backbone.Model ) {
- var valueSub = {};
- _.each( rel.options.includeInJSON, function( key ) {
- valueSub[ key ] = value.get( key );
+ else if ( related instanceof Backbone.Model ) {
+ value = {};
+ _.each( includeInJSON, function( key ) {
+ value[ key ] = related.get( key );
});
- json[ rel.keyDestination ] = valueSub;
- }
- else {
- json[ rel.keyDestination ] = null;
}
}
else {
delete json[ rel.key ];
}
+ if ( includeInJSON ) {
+ json[ rel.keyDestination ] = value;
+ }
+
if ( rel.keyDestination !== rel.key ) {
delete json[ rel.key ];
}
@@ -1548,17 +1565,15 @@
// inherited automatically (due to a redefinition of 'relations').
// Otherwise, make sure we don't get here again for this type by making '_superModel' false so we fail
// the isUndefined/isNull check next time.
- if ( this._superModel ) {
- //
- if ( this._superModel.prototype.relations ) {
- var supermodelRelationsExist = _.any( this.prototype.relations || [], function( rel ) {
- return rel.model && rel.model !== this;
+ if ( this._superModel && this._superModel.prototype.relations ) {
+ // Find relations that exist on the `_superModel`, but not yet on this model.
+ var inheritedRelations = _.select( this._superModel.prototype.relations || [], function( superRel ) {
+ return !_.any( this.prototype.relations || [], function( rel ) {
+ return superRel.relatedModel === rel.relatedModel && superRel.key === rel.key;
}, this );
+ }, this );
- if ( !supermodelRelationsExist ) {
- this.prototype.relations = this._superModel.prototype.relations.concat( this.prototype.relations );
- }
- }
+ this.prototype.relations = inheritedRelations.concat( this.prototype.relations );
}
else {
this._superModel = false;
@@ -1648,14 +1663,14 @@
/**
- * Override Backbone.Collection.add, so we'll create objects from attributes where required,
+ * Override Backbone.Collection.set, so we'll create objects from attributes where required,
* and update the existing models. Also, trigger 'relational:add'.
*/
- var add = Backbone.Collection.prototype.__add = Backbone.Collection.prototype.add;
- Backbone.Collection.prototype.add = function( models, options ) {
+ var set = Backbone.Collection.prototype.__set = Backbone.Collection.prototype.set;
+ Backbone.Collection.prototype.set = function( models, options ) {
// Short-circuit if this Collection doesn't hold RelationalModels
if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
- return add.apply( this, arguments );
+ return set.apply( this, arguments );
}
models = _.isArray( models ) ? models.slice() : [ models ];
@@ -1686,7 +1701,7 @@
}, this );
// Add 'models' in a single batch, so the original add will only be called once (and thus 'sort', etc).
- add.call( this, toAdd, options );
+ set.call( this, toAdd, options );
_.each( newModels, function( model ) {
// Fire a `relational:add` event for any model in `newModels` that has actually been added to the collection.
@@ -1799,4 +1814,4 @@
return child;
};
-})();
+})();
View
9,597 vendor/jquery-1.9.1.js
9,597 additions, 0 deletions not shown
View
5,217 vendor/optional/lodash-1.1.1.js
5,217 additions, 0 deletions not shown
View
196 vendor/test/qunit/qunit.css
@@ -1,196 +0,0 @@
-/** Font Family and Sizes */
-
-#qunit-tests, #qunit-header, .qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
- font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
-}
-
-#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
-#qunit-tests { font-size: smaller; }
-
-
-/** Resets */
-
-#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
- margin: 0;
- padding: 0;
-}
-
-
-/** Header */
-
-#qunit-header, .qunit-header {
- padding: 0.5em 0 0.5em 1em;
-
- color: #8699a4;
- background-color: #0d3349;
-
- font-size: 1.5em;
- line-height: 1em;
- font-weight: normal;
-
- border-radius: 15px 15px 0 0;
- -moz-border-radius: 15px 15px 0 0;
- -webkit-border-top-right-radius: 15px;
- -webkit-border-top-left-radius: 15px;
-}
-
-#qunit-header a {
- text-decoration: none;
- color: #c2ccd1;
-}
-
-#qunit-header a:hover,
-#qunit-header a:focus {
- color: #fff;
-}
-
-#qunit-banner {
- height: 5px;
-}
-
-#qunit-testrunner-toolbar {
- padding: 0em 0 0.5em 2em;
-}
-
-#qunit-userAgent {
- padding: 0.5em 0 0.5em 2.5em;
- background-color: #2b81af;
- color: #fff;
- text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
-}
-
-
-/** Tests: Pass/Fail */
-
-#qunit-tests {
- list-style-position: inside;
-}
-
-#qunit-tests li {
- padding: 0.4em 0.5em 0.4em 2.5em;
- border-bottom: 1px solid #fff;
- list-style-position: inside;
-}
-
-#qunit-tests li strong {
- cursor: pointer;
-}
-
-#qunit-tests ol {
- margin-top: 0.5em;
- padding: 0.5em;
-
- background-color: #fff;
-
- border-radius: 15px;
- -moz-border-radius: 15px;
- -webkit-border-radius: 15px;
-
- box-shadow: inset 0px 2px 13px #999;
- -moz-box-shadow: inset 0px 2px 13px #999;
- -webkit-box-shadow: inset 0px 2px 13px #999;
-}
-
-#qunit-tests table {
- border-collapse: collapse;
- margin-top: .2em;
-}
-
-#qunit-tests th {
- text-align: right;
- vertical-align: top;
- padding: 0 .5em 0 0;
-}
-
-#qunit-tests td {
- vertical-align: top;
-}
-
-#qunit-tests pre {
- margin: 0;
- white-space: pre-wrap;
- word-wrap: break-word;
-}
-
-#qunit-tests del {
- background-color: #e0f2be;
- color: #374e0c;
- text-decoration: none;
-}
-
-#qunit-tests ins {
- background-color: #ffcaca;
- color: #500;
- text-decoration: none;
-}
-
-/*** Test Counts */
-
-#qunit-tests b.counts { color: black; }
-#qunit-tests b.passed { color: #5E740B; }
-#qunit-tests b.failed { color: #710909; }
-
-#qunit-tests li li {
- margin: 0.5em;
- padding: 0.4em 0.5em 0.4em 0.5em;
- background-color: #fff;
- border-bottom: none;
- list-style-position: inside;
-}
-
-/*** Passing Styles */
-
-#qunit-tests li li.pass {
- color: #5E740B;
- background-color: #fff;
- border-left: 26px solid #C6E746;
-}
-
-#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
-#qunit-tests .pass .test-name { color: #366097; }
-
-#qunit-tests .pass .test-actual,
-#qunit-tests .pass .test-expected { color: #999999; }
-
-#qunit-banner.qunit-pass { background-color: #C6E746; }
-
-/*** Failing Styles */
-
-#qunit-tests li li.fail {
- color: #710909;
- background-color: #fff;
- border-left: 26px solid #EE5757;
-}
-
-#qunit-tests .fail { color: #000000; background-color: #EE5757; }
-#qunit-tests .fail .test-name,
-#qunit-tests .fail .module-name { color: #000000; }
-
-#qunit-tests .fail .test-actual { color: #EE5757; }
-#qunit-tests .fail .test-expected { color: green; }
-
-#qunit-banner.qunit-fail,
-#qunit-testrunner-toolbar { background-color: #EE5757; }
-
-
-/** Footer */
-
-#qunit-testresult {
- padding: 0.5em 0.5em 0.5em 2.5em;
-
- color: #2b81af;
- background-color: #D2E0E6;
-
- border-radius: 0 0 15px 15px;
- -moz-border-radius: 0 0 15px 15px;
- -webkit-border-bottom-right-radius: 15px;
- -webkit-border-bottom-left-radius: 15px;
-}
-
-/** Fixture */
-
-#qunit-fixture {
- position: absolute;
- top: -10000px;
- left: -10000px;
-}
View
2,360 vendor/test/qunit/qunit.js
@@ -1,2360 +0,0 @@
-/*
- * QUnit - A JavaScript Unit Testing Framework
- *
- * http://docs.jquery.com/QUnit
- *
- * Copyright (c) 2009 John Resig, Jörn Zaefferer
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
- */
-
-(function(window) {
-
-var QUnit = {
-
- // Initialize the configuration options
- init: function init() {
- config = {
- stats: { all: 0, bad: 0 },
- moduleStats: { all: 0, bad: 0 },
- started: +new Date,
- blocking: false,
- autorun: false,
- assertions: [],
- filters: [],
- queue: []
- };
-
- var tests = id("qunit-tests"),
- banner = id("qunit-banner"),
- result = id("qunit-testresult");
-
- if ( tests ) {
- tests.innerHTML = "";
- }
-
- if ( banner ) {
- banner.className = "";
- }
-
- if ( result ) {
- result.parentNode.removeChild( result );
- }
- },
-
- // call on start of module test to prepend name to all tests
- module: function module(name, testEnvironment) {
-
- synchronize(function() {
- if ( config.currentModule ) {
- QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all );
- }
-
- config.currentModule = name;
- config.moduleTestEnvironment = testEnvironment;
- config.moduleStats = { all: 0, bad: 0 };
-
- QUnit.moduleStart( name, testEnvironment );
- });
- },
-
- asyncTest: function asyncTest(testName, expected, callback) {
- if ( arguments.length === 2 ) {
- callback = expected;
- expected = 0;
- }
-
- QUnit.test(testName, expected, callback, true);
- },
-
- test: function test(testName, expected, callback, async) {
- var name = testName, testEnvironment = {};
-
- if ( arguments.length === 2 ) {
- callback = expected;
- expected = null;
- }
-
- if ( config.currentModule ) {
- name = config.currentModule + " module: " + name;
- }
-
- if ( !validTest(name) ) {
- return;
- }
-
- synchronize(function() {
- QUnit.testStart( testName );
-
- testEnvironment = extend({
- setup: function() {},
- teardown: function() {}
- }, config.moduleTestEnvironment);
-
- config.assertions = [];
- config.expected = null;
-
- if ( arguments.length >= 3 ) {
- config.expected = callback;
- callback = arguments[2];
- }
-
- try {
- if ( !config.pollution ) {
- saveGlobal();
- }
-
- testEnvironment.setup.call(testEnvironment);
- } catch(e) {
- QUnit.ok( false, "Setup failed on " + name + ": " + e.message );
- }
-
- if ( async ) {
- QUnit.stop();
- }
-
- try {
- callback.call(testEnvironment);
- } catch(e) {
- fail("Test " + name + " died, exception and test follows", e, callback);
- QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message );
- // else next test will carry the responsibility
- saveGlobal();
-
- // Restart the tests if they're blocking
- if ( config.blocking ) {
- start();
- }
- }
- });
-
- synchronize(function() {
- try {
- checkPollution();
- testEnvironment.teardown.call(testEnvironment);
- } catch(e) {
- QUnit.ok( false, "Teardown failed on " + name + ": " + e.message );
- }
-
- try {
- QUnit.reset();
- } catch(e) {
- fail("reset() failed, following Test " + name + ", exception and reset fn follows", e, reset);
- }
-
- if ( config.expected && config.expected != config.assertions.length ) {
- QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" );
- }
-
- var good = 0, bad = 0,
- tests = id("qunit-tests");
-
- config.stats.all += config.assertions.length;
- config.moduleStats.all += config.assertions.length;
-
- if ( tests ) {
- var ol = document.createElement("ol");
- ol.style.display = "none";
-
- for ( var i = 0; i < config.assertions.length; i++ ) {
- var assertion = config.assertions[i];
-
- var li = document.createElement("li");
- li.className = assertion.result ? "pass" : "fail";
- li.innerHTML = assertion.message || "(no message)";
- ol.appendChild( li );
-
- if ( assertion.result ) {
- good++;
- } else {
- bad++;
- config.stats.bad++;
- config.moduleStats.bad++;
- }
- }
-
- var b = document.createElement("strong");
- b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + config.assertions.length + ")</b>";
-
- addEvent(b, "click", function() {
- var next = b.nextSibling, display = next.style.display;
- next.style.display = display === "none" ? "block" : "none";
- });
-
- addEvent(b, "dblclick", function(e) {
- var target = (e || window.event).target;
- if ( target.nodeName.toLowerCase() === "strong" ) {
- var text = "", node = target.firstChild;
-
- while ( node.nodeType === 3 ) {
- text += node.nodeValue;
- node = node.nextSibling;
- }
-
- text = text.replace(/(^\s*|\s*$)/g, "");
-
- if ( window.location ) {
- window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text);
- }
- }
- });
-
- var li = document.createElement("li");
- li.className = bad ? "fail" : "pass";
- li.appendChild( b );
- li.appendChild( ol );
- tests.appendChild( li );
-
- if ( bad ) {
- var toolbar = id("qunit-testrunner-toolbar");
- if ( toolbar ) {
- toolbar.style.display = "block";
- id("qunit-filter-pass").disabled = null;
- id("qunit-filter-missing").disabled = null;
- }
- }
-
- } else {
- for ( var i = 0; i < config.assertions.length; i++ ) {
- if ( !config.assertions[i].result ) {
- bad++;
- config.stats.bad++;
- config.moduleStats.bad++;
- }
- }
- }
-
- QUnit.testDone( testName, bad, config.assertions.length );
-
- if ( !window.setTimeout && !config.queue.length ) {
- done();
- }
- });
-
- if ( window.setTimeout && !config.doneTimer ) {
- config.doneTimer = window.setTimeout(function(){
- if ( !config.queue.length ) {
- done();
- } else {
- synchronize( done );
- }
- }, 13);
- }
- },
-
- /**
- * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
- */
- expect: function expect(asserts) {
- config.expected = asserts;
- },
-
- /**
- * Asserts true.
- * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
- */
- ok: function ok(a, msg) {
- QUnit.log(a, msg);
-
- config.assertions.push({
- result: !!a,
- message: msg
- });
- },
-
- /**
- * Checks that the first two arguments are equal, with an optional message.
- * Prints out both actual and expected values.
- *
- * Prefered to ok( actual == expected, message )
- *
- * @example equals( format("Received {0} bytes.", 2), "Received 2 bytes." );
- *
- * @param Object actual
- * @param Object expected
- * @param String message (optional)
- */
- equals: function equals(actual, expected, message) {
- push(expected == actual, actual, expected, message);
- },
-
- same: function(a, b, message) {
- push(QUnit.equiv(a, b), a, b, message);
- },
-
- start: function start() {
- // A slight delay, to avoid any current callbacks
- if ( window.setTimeout ) {
- window.setTimeout(function() {
- if ( config.timeout ) {
- clearTimeout(config.timeout);
- }
-
- config.blocking = false;
- process();
- }, 13);
- } else {
- config.blocking = false;
- process();
- }
- },
-
- stop: function stop(timeout) {
- config.blocking = true;
-
- if ( timeout && window.setTimeout ) {
- config.timeout = window.setTimeout(function() {
- QUnit.ok( false, "Test timed out" );
- QUnit.start();
- }, timeout);
- }
- },
-
- /**
- * Resets the test setup. Useful for tests that modify the DOM.
- */
- reset: function reset() {
- if ( window.jQuery ) {
- jQuery("#main").html( config.fixture );
- jQuery.event.global = {};
- jQuery.ajaxSettings = extend({}, config.ajaxSettings);
- }
- },
-
- /**
- * Trigger an event on an element.
- *
- * @example triggerEvent( document.body, "click" );
- *
- * @param DOMElement elem
- * @param String type
- */
- triggerEvent: function triggerEvent( elem, type, event ) {
- if ( document.createEvent ) {
- event = document.createEvent("MouseEvents");
- event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
- 0, 0, 0, 0, 0, false, false, false, false, 0, null);
- elem.dispatchEvent( event );
-
- } else if ( elem.fireEvent ) {
- elem.fireEvent("on"+type);
- }
- },
-
- // Logging callbacks
- done: function done(failures, total) {},
- log: function log(result, message) {},
- testStart: function testStart(name) {},
- testDone: function testDone(name, failures, total) {},
- moduleStart: function moduleStart(name, testEnvironment) {},
- moduleDone: function moduleDone(name, failures, total) {}
-};
-
-// Maintain internal state
-var config = {
- // The queue of tests to run
- queue: [],
-
- // block until document ready
- blocking: true
-};
-
-// Load paramaters
-(function() {
- var location = window.location || { search: "", protocol: "file:" },
- GETParams = location.search.slice(1).split('&');
-
- for ( var i = 0; i < GETParams.length; i++ ) {
- GETParams[i] = decodeURIComponent( GETParams[i] );
- if ( GETParams[i] === "noglobals" ) {
- GETParams.splice( i, 1 );
- i--;
- config.noglobals = true;
- }
- }
-
- // restrict modules/tests by get parameters
- config.filters = GETParams;
-
- // Figure out if we're running the tests from a server or not
- QUnit.isLocal = !!(location.protocol === 'file:');
-})();
-
-// Expose the API as global variables, unless an 'exports'
-// object exists, in that case we assume we're in CommonJS
-if ( typeof exports === "undefined" || typeof require === "undefined" ) {
- extend(window, QUnit);
- window.QUnit = QUnit;
-} else {
- extend(exports, QUnit);
- exports.QUnit = QUnit;
-}
-
-if ( typeof document === "undefined" || document.readyState === "complete" ) {
- config.autorun = true;
-}
-
-addEvent(window, "load", function() {
- // Initialize the config, saving the execution queue
- var oldconfig = extend({}, config);
- QUnit.init();
- extend(config, oldconfig);
-
- config.blocking = false;
-
- var userAgent = id("qunit-userAgent");
- if ( userAgent ) {
- userAgent.innerHTML = navigator.userAgent;
- }
-
- var toolbar = id("qunit-testrunner-toolbar");
- if ( toolbar ) {
- toolbar.style.display = "none";
-
- var filter = document.createElement("input");
- filter.type = "checkbox";
- filter.id = "qunit-filter-pass";
- filter.disabled = true;
- addEvent( filter, "click", function() {
- var li = document.getElementsByTagName("li");
- for ( var i = 0; i < li.length; i++ ) {
- if ( li[i].className.indexOf("pass") > -1 ) {
- li[i].style.display = filter.checked ? "none" : "block";
- }
- }
- });
- toolbar.appendChild( filter );
-
- var label = document.createElement("label");
- label.setAttribute("for", "filter-pass");
- label.innerHTML = "Hide passed tests";
- toolbar.appendChild( label );
-
- var missing = document.createElement("input");
- missing.type = "checkbox";
- missing.id = "qunit-filter-missing";
- missing.disabled = true;
- addEvent( missing, "click", function() {
- var li = document.getElementsByTagName("li");
- for ( var i = 0; i < li.length; i++ ) {
- if ( li[i].className.indexOf("fail") > -1 && li[i].innerHTML.indexOf('missing test - untested code is broken code') > - 1 ) {
- li[i].parentNode.parentNode.style.display = missing.checked ? "none" : "block";
- }
- }
- });
- toolbar.appendChild( missing );
-
- label = document.createElement("label");
- label.setAttribute("for", "filter-missing");
- label.innerHTML = "Hide missing tests (untested code is broken code)";
- toolbar.appendChild( label );
- }
-
- var main = id('main');
- if ( main ) {
- config.fixture = main.innerHTML;
- }
-
- if ( window.jQuery ) {
- config.ajaxSettings = window.jQuery.ajaxSettings;
- }
-
- QUnit.start();
-});
-
-function done() {
- if ( config.doneTimer && window.clearTimeout ) {
- window.clearTimeout( config.doneTimer );
- config.doneTimer = null;
- }
-
- if ( config.queue.length ) {
- config.doneTimer = window.setTimeout(function(){
- if ( !config.queue.length ) {
- done();
- } else {
- synchronize( done );
- }
- }, 13);
-
- return;
- }
-
- config.autorun = true;
-
- // Log the last module results
- if ( config.currentModule ) {
- QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all );
- }
-
- var banner = id("qunit-banner"),
- tests = id("qunit-tests"),
- html = ['Tests completed in ',
- +new Date - config.started, ' milliseconds.<br/>',
- '<span class="bad">', config.stats.all - config.stats.bad, '</span> tests of <span class="all">', config.stats.all, '</span> passed, ', config.stats.bad,' failed.'].join('');
-
- if ( banner ) {
- banner.className += " " + (config.stats.bad ? "fail" : "pass");
- }
-
- if ( tests ) {
- var result = id("qunit-testresult");
-
- if ( !result ) {
- result = document.createElement("p");
- result.id = "qunit-testresult";
- result.className = "result";
- tests.parentNode.insertBefore( result, tests.nextSibling );
- }
-
- result.innerHTML = html;
- }
-
- QUnit.done( config.stats.bad, config.stats.all );
-}
-
-function validTest( name ) {
- var i = config.filters.length,
- run = false;
-
- if ( !i ) {
- return true;
- }
-
- while ( i-- ) {
- var filter = config.filters[i],
- not = filter.charAt(0) == '!';
-
- if ( not ) {
- filter = filter.slice(1);
- }
-
- if ( name.indexOf(filter) !== -1 ) {
- return !not;
- }
-
- if ( not ) {
- run = true;
- }
- }
-
- return run;
-}
-
-function push(result, actual, expected, message) {
- message = message || (result ? "okay" : "failed");
- QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) );
-}
-
-function synchronize( callback ) {
- config.queue.push( callback );
-
- if ( config.autorun && !config.blocking ) {
- process();
- }
-}
-
-function process() {
- while ( config.queue.length && !config.blocking ) {
- config.queue.shift()();
- }
-}
-
-function saveGlobal() {
- config.pollution = [];
-
- if ( config.noglobals ) {
- for ( var key in window ) {
- config.pollution.push( key );
- }
- }
-}
-
-function checkPollution( name ) {
- var old = config.pollution;
- saveGlobal();
-
- var newGlobals = diff( old, config.pollution );
- if ( newGlobals.length > 0 ) {
- ok( false, "Introduced global variable(s): " + newGlobals.join(", ") );
- config.expected++;
- }
-
- var deletedGlobals = diff( config.pollution, old );
- if ( deletedGlobals.length > 0 ) {
- ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") );
- config.expected++;
- }
-}
-
-// returns a new Array with the elements that are in a but not in b
-function diff( a, b ) {
- var result = a.slice();
- for ( var i = 0; i < result.length; i++ ) {
- for ( var j = 0; j < b.length; j++ ) {
- if ( result[i] === b[j] ) {
- result.splice(i, 1);
- i--;
- break;
- }
- }
- }
- return result;
-}
-
-function fail(message, exception, callback) {
- if ( typeof console !== "undefined" && console.error && console.warn ) {
- console.error(message);
- console.error(exception);
- console.warn(callback.toString());
-
- } else if ( window.opera && opera.postError ) {
- opera.postError(message, exception, callback.toString);
- }
-}
-
-function extend(a, b) {
- for ( var prop in b ) {
- a[prop] = b[prop];
- }
-
- return a;
-}
-
-function addEvent(elem, type, fn) {
- if ( elem.addEventListener ) {
- elem.addEventListener( type, fn, false );
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, fn );
- } else {
- fn();
- }
-}
-
-function id(name) {
- return !!(typeof document !== "undefined" && document && document.getElementById) &&
- document.getElementById( name );
-}
-
-// Test for equality any JavaScript type.
-// Discussions and reference: http://philrathe.com/articles/equiv
-// Test suites: http://philrathe.com/tests/equiv
-// Author: Philippe Rathé <prathe@gmail.com>
-QUnit.equiv = function () {
-
- var innerEquiv; // the real equiv function
- var callers = []; // stack to decide between skip/abort functions
-
-
- // Determine what is o.
- function hoozit(o) {
- if (o.constructor === String) {
- return "string";
-
- } else if (o.constructor === Boolean) {
- return "boolean";
-
- } else if (o.constructor === Number) {
-
- if (isNaN(o)) {
- return "nan";
- } else {
- return "number";
- }
-
- } else if (typeof o === "undefined") {
- return "undefined";
-
- // consider: typeof null === object
- } else if (o === null) {
- return "null";
-
- // consider: typeof [] === object
- } else if (o instanceof Array) {
- return "array";
-
- // consider: typeof new Date() === object
- } else if (o instanceof Date) {
- return "date";
-
- // consider: /./ instanceof Object;
- // /./ instanceof RegExp;
- // typeof /./ === "function"; // => false in IE and Opera,
- // true in FF and Safari
- } else if (o instanceof RegExp) {
- return "regexp";
-
- } else if (typeof o === "object") {
- return "object";
-
- } else if (o instanceof Function) {
- return "function";
- } else {
- return undefined;
- }
- }
-
- // Call the o related callback with the given arguments.
- function handleEvents(o, callbacks, args) {
- var prop = hoozit(o);
- if (prop) {
- if (hoozit(callbacks[prop]) === "function") {
- return callbacks[prop].apply(callbacks, args);
- } else {
- return callbacks[prop]; // or undefined
- }
- }
- }
-
- var callbacks = function () {
-
- // for string, boolean, number and null
- function useStrictEquality(b, a) {
- if (b instanceof a.constructor || a instanceof b.constructor) {
- // to catch short annotaion VS 'new' annotation of a declaration
- // e.g. var i = 1;
- // var j = new Number(1);
- return a == b;
- } else {
- return a === b;
- }
- }
-
- return {
- "string": useStrictEquality,
- "boolean": useStrictEquality,
- "number": useStrictEquality,
- "null": useStrictEquality,
- "undefined": useStrictEquality,
-
- "nan": function (b) {
- return isNaN(b);
- },
-
- "date": function (b, a) {
- return hoozit(b) === "date" && a.valueOf() === b.valueOf();
- },
-
- "regexp": function (b, a) {
- return hoozit(b) === "regexp" &&
- a.source === b.source && // the regex itself
- a.global === b.global && // and its modifers (gmi) ...
- a.ignoreCase === b.ignoreCase &&
- a.multiline === b.multiline;
- },
-
- // - skip when the property is a method of an instance (OOP)
- // - abort otherwise,
- // initial === would have catch identical references anyway
- "function": function () {
- var caller = callers[callers.length - 1];
- return caller !== Object &&
- typeof caller !== "undefined";
- },
-
- "array": function (b, a) {
- var i;
- var len;
-
- // b could be an object literal here
- if ( ! (hoozit(b) === "array")) {
- return false;
- }
-
- len = a.length;
- if (len !== b.length) { // safe and faster
- return false;
- }
- for (i = 0; i < len; i++) {
- if ( ! innerEquiv(a[i], b[i])) {
- return false;
- }
- }
- return true;
- },
-
- "object": function (b, a) {
- var i;
- var eq = true; // unless we can proove it
- var aProperties = [], bProperties = []; // collection of strings
-
- // comparing constructors is more strict than using instanceof
- if ( a.constructor !== b.constructor) {
- return false;
- }
-
- // stack constructor before traversing properties
- callers.push(a.constructor);
-
- for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
-
- aProperties.push(i); // collect a's properties
-
- if ( ! innerEquiv(a[i], b[i])) {
- eq = false;
- }
- }
-
- callers.pop(); // unstack, we are done
-
- for (i in b) {
- bProperties.push(i); // collect b's properties
- }
-
- // Ensures identical properties name
- return eq && innerEquiv(aProperties.sort(), bProperties.sort());
- }
- };
- }();
-
- innerEquiv = function () { // can take multiple arguments
- var args = Array.prototype.slice.apply(arguments);
- if (args.length < 2) {
- return true; // end transition
- }
-
- return (function (a, b) {
- if (a === b) {
- return true; // catch the most you can
- } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) {
- return false; // don't lose time with error prone cases
- } else {
- return handleEvents(a, callbacks, [b, a]);
- }
-
- // apply transition with (1..n) arguments
- })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
- };
-
- return innerEquiv;
-
-}();
-
-/**
- * jsDump
- * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
- * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- * Date: 5/15/2008
- * @projectDescription Advanced and extensible data dumping for Javascript.
- * @version 1.0.0
- * @author Ariel Flesler
- * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
- */
-QUnit.jsDump = (function() {
- function quote( str ) {
- return '"' + str.toString().replace(/"/g, '\\"') + '"';
- };
- function literal( o ) {
- return o + '';
- };
- function join( pre, arr, post ) {
- var s = jsDump.separator(),
- base = jsDump.indent(),
- inner = jsDump.indent(1);
- if ( arr.join )
- arr = arr.join( ',' + s + inner );
- if ( !arr )
- return pre + post;
- return [ pre, inner + arr, base + post ].join(s);
- };
- function array( arr ) {
- var i = arr.length, ret = Array(i);
- this.up();
- while ( i-- )
- ret[i] = this.parse( arr[i] );
- this.down();
- return join( '[', ret, ']' );
- };
-
- var reName = /^function (\w+)/;
-
- var jsDump = {
- parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
- var parser = this.parsers[ type || this.typeOf(obj) ];
- type = typeof parser;
-
- return type == 'function' ? parser.call( this, obj ) :
- type == 'string' ? parser :
- this.parsers.error;
- },
- typeOf:function( obj ) {
- var type = typeof obj,
- f = 'function';//we'll use it 3 times, save it
- return type != 'object' && type != f ? type :
- !obj ? 'null' :
- obj.exec ? 'regexp' :// some browsers (FF) consider regexps functions
- obj.getHours ? 'date' :
- obj.scrollBy ? 'window' :
- obj.nodeName == '#document' ? 'document' :
- obj.nodeName ? 'node' :
- obj.item ? 'nodelist' : // Safari reports nodelists as functions
- obj.callee ? 'arguments' :
- obj.call || obj.constructor != Array && //an array would also fall on this hack
- (obj+'').indexOf(f) != -1 ? f : //IE reports functions like alert, as objects
- 'length' in obj ? 'array' :
- type;
- },
- separator:function() {
- return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
- },
- indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
- if ( !this.multiline )
- return '';
- var chr = this.indentChar;
- if ( this.HTML )
- chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
- return Array( this._depth_ + (extra||0) ).join(chr);
- },
- up:function( a ) {
- this._depth_ += a || 1;
- },
- down:function( a ) {
- this._depth_ -= a || 1;
- },
- setParser:function( name, parser ) {
- this.parsers[name] = parser;
- },
- // The next 3 are exposed so you can use them
- quote:quote,
- literal:literal,
- join:join,
- //
- _depth_: 1,
- // This is the list of parsers, to modify them, use jsDump.setParser
- parsers:{
- window: '[Window]',
- document: '[Document]',
- error:'[ERROR]', //when no parser is found, shouldn't happen
- unknown: '[Unknown]',
- 'null':'null',
- undefined:'undefined',
- 'function':function( fn ) {
- var ret = 'function',
- name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
- if ( name )
- ret += ' ' + name;
- ret += '(';
-
- ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');
- return join( ret, this.parse(fn,'functionCode'), '}' );
- },
- array: array,
- nodelist: array,
- arguments: array,
- object:function( map ) {
- var ret = [ ];
- this.up();
- for ( var key in map )
- ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );
- this.down();
- return join( '{', ret, '}' );
- },
- node:function( node ) {
- var open = this.HTML ? '&lt;' : '<',
- close = this.HTML ? '&gt;' : '>';
-
- var tag = node.nodeName.toLowerCase(),
- ret = open + tag;
-
- for ( var a in this.DOMAttrs ) {
- var val = node[this.DOMAttrs[a]];
- if ( val )
- ret += ' ' + a + '=' + th