/* knockback-inspector.js 0.1.6 (c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/ License: MIT (http://www.opensource.org/licenses/mit-license.php) Dependencies: Knockout.js, Backbone.js, and Underscore.js. */(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-inspector",["underscore","backbone","knockout","knockback"],e):e.call(this)}(function(){var e,t,n,r,i,s={}.hasOwnProperty,o=function(e,t){function r(){this.constructor=e}for(var n in t)s.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};if(!this._&&typeof require!="undefined")try{i=require("lodash")}catch(u){i=require("underscore")}else i=this._;return i=i.hasOwnProperty("_")?i._:i,e=!this.Backbone&&typeof require!="undefined"?require("backbone"):this.Backbone,r=!this.ko&&typeof require!="undefined"?require("knockout"):this.ko,t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb,n=this.kbi=typeof exports!="undefined"?exports:{},this.kbi.VERSION="0.1.6",n.TemplateSource=function(){function e(e,t){this.template_generator=e,this.binding_context=t!=null?t:{}}return e.prototype.data=function(e,t){return arguments.length===1?this.binding_context[e]:this.binding_context[e]=t},e.prototype.text=function(){if(arguments.length>0)throw"kbi.TemplateSource: unexpected writing to template source";return this.template_generator.viewText(this.binding_context)},e}(),n.TemplateEngine=function(e){function t(){this.allowTemplateRewriting=!1,this.generators={kbi_array_node:n.ArrayNodeViewGenerator,kbi_model_node:n.ModelNodeViewGenerator,kbi_collection_node:n.CollectionNodeViewGenerator}}return o(t,e),t.prototype.generator=function(e,t){return arguments.length===1?this.generators[e]:this.generators[e]=t},t.prototype.makeTemplateSource=function(e){return this.generators.hasOwnProperty(e)?new n.TemplateSource(new this.generators[e](e)):t.__super__.makeTemplateSource.apply(this,arguments)},t.prototype.renderTemplateSource=function(e,n,r){var i,s;for(i in n)s=n[i],e.data(i,s);return t.__super__.renderTemplateSource.apply(this,arguments)},t}(r.nativeTemplateEngine),n.FetchedModel=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return o(t,e),t.prototype.parse=function(e){var t,r,s,o,u;t={};for(s in e)u=e[s],i.isObject(u)?(o=new n.FetchedModel,t[s]=o.set(o.parse(u))):i.isArray(u)?(r=new n.FetchedCollection,t[s]=r.reset(r.parse(u))):t[s]=u;return t},t}(e.Model),n.FetchedCollection=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return o(t,e),t.prototype.model=n.FetchedModel,t.prototype.parse=function(e){var t;return t=e.results?e.results:e,i.map(e.results,function(e){var t;return t=new n.FetchedModel,t.set(t.parse(e))})},t}(e.Collection),n.NodeViewModel=function(){function e(e,n,s){var o,u;this.name=e,this.node=s,this.opened=r.observable(n),u=r.utils.unwrapObservable(this.node),u instanceof t.ViewModel?(this.node=u,o=t.utils.wrappedModel(this.node),this.attribute_names=r.observableArray(o?i.keys(o.attributes):[])):typeof u.get=="function"&&typeof u.trigger=="function"&&(u.models?this.node=t.collectionObservable(u):(this.node=t.viewModel(u),this.attribute_names=r.observableArray(i.keys(u.attributes))));return}return e}(),n.nodeViewModel=n.nvm=function(e,t,r){return new n.NodeViewModel(e,t,r)},n.ArrayNodeViewGenerator=function(){function e(e){this.template_name=e}return e.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n \n \n \n "+this.attributeEditor()+"\n \n\n \n "+this.arrayTree()+"\n \n\n \n "+this.modelTree()+"\n \n\n \n "+this.collectionTree()+"\n \n\n \n \n"+this.nodeEnd()},e.prototype.nodeStart=function(){return"
  • "},e.prototype.nodeManipulator=function(){return"
    \n \n \n
    "},e.prototype.attributeEditor=function(){return"
    \n \n \n
    "},e.prototype.arrayTree=function(){return""+n.ViewHTML.arrayTree("'['+$index()+']'",!1,"$data")},e.prototype.modelTree=function(){return""+n.ViewHTML.modelTree("'['+$index()+']'",!1,"$data")},e.prototype.collectionTree=function(){return""+n.ViewHTML.collectionTree("'['+$index()+']'",!1,"$data")},e.prototype.nodeEnd=function(){return""},e}(),n.CollectionNodeViewGenerator=function(){function e(e){this.template_name=e}return e.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n \n \n "+this.modelNode()+"\n \n \n"+this.nodeEnd()},e.prototype.nodeStart=function(){return"
  • "},e.prototype.nodeManipulator=function(){return"
    \n \n \n
    "},e.prototype.modelNode=function(){return""+n.ViewHTML.modelTree("'['+$index()+']'",!1,"$data")},e.prototype.nodeEnd=function(){return"
  • "},e}(),n.ModelNodeViewGenerator=function(){function e(e){this.template_name=e}return e.prototype.viewText=function(){return""+this.nodeStart()+"\n"+this.nodeManipulator()+"\n \n \n \n "+this.attributeEditor()+"\n \n\n \n "+this.arrayTree()+"\n \n\n \n "+this.modelTree()+"\n \n\n \n "+this.collectionTree()+"\n \n\n \n \n"+this.nodeEnd()},e.prototype.nodeStart=function(){return"
  • "},e.prototype.nodeManipulator=function(){return"
    \n \n \n
    "},e.prototype.attributeEditor=function(){return"
    \n \n \n
    "},e.prototype.arrayTree=function(){return""+n.ViewHTML.arrayTree("$data",!1,"$parent.node[$data]")},e.prototype.modelTree=function(){return""+n.ViewHTML.modelTree("$data",!1,"$parent.node[$data]")},e.prototype.collectionTree=function(){return""+n.ViewHTML.collectionTree("$data+'[]'",!0,"$parent.node[$data]")},e.prototype.nodeEnd=function(){return"
  • "},e}(),n.ViewHTML=function(){function e(){}return e.arrayTree=function(e,t,n){return"'},e.modelTree=function(e,t,n){return"'},e.collectionTree=function(e,t,n){return"'},e}(),n})}).call(this);