short-jsdoc
Version:
short and simple jsdoc Object Oriented syntax format and implementation
2 lines • 29.3 kB
JavaScript
var Application=function(a){this.textFormat="markdown",this.templates=shortjsdoc,this.data=a,this.maker=new JsDocMaker,this.maker.data=a,this.maker.postProccess(),this.maker.postProccessBinding(),this.maker.postProccessInherited(),window.shortjsdocdata=a,0===jQuery("#mainContainer").size()&&jQuery("body").append('<div id="mainContainer"></div>'),this.$containerEl=jQuery("#mainContainer"),this.$body=jQuery(".main-view-container")};_(Application.prototype).extend({start:function(){this.router=new JsDocRouter(this),Backbone.history.start();var a=Backbone.history.getHash()||"index";Backbone.history.navigate(a,{trigger:!0})},showView:function(a){this.applicationView=this.applicationView||new ApplicationView(this),this.currentView=a,this.$containerEl.empty(),this.applicationView.renderIn(this.$containerEl),document.title=a.title||document.title},refreshWithNewModel:function(a){this.data=a,Backbone.history.navigate("#index",{trigger:!0}),this.showView(this.currentView)},showErrorView:function(a){var b=new AbstractView;b.application=this,b.template=_.template("<h1>"+a+"</h1>"),this.showView(b)}}),Application.startApplication=function(a){var b=new Application(a);b.start()};var JsDocRouter=Backbone.Router.extend({routes:{"class/:class":"showClass","class/:class?:options":"showClass","module/:module":"showModule","module/:module?:options":"showModule","method/:method":"showMethod","constructor/:method":"showMethod","function/:method":"showMethod","property/:property":"showProperty","event/:event":"showEvent","attribute/:attribute":"showAttribute",index:"showIndex","index/?:options":"showIndex",book:"showBook","book/?:options":"showBook",modules:"showModules",classes:"showClasses",parse:"showParse",tree:"showTree",hierarchyTree:"showHierarchyTree","file/:file":"showFile","file/:file?:options":"showFile",search:"doSearch","search/:options":"doSearch","dependencies/:options":"showDependencies",dependencies:"showDependencies"},initialize:function(a){this.application=a},showView:function(a,b){a.resourceNotFound?(b=b||Backbone.history.fragment,this.application.showErrorView("Resource "+b+" not found!")):this.application.showView(a)},showModule:function(a,b){b=b||"";var c=this.parseOptions(b),d=new ModuleView(this.application,a,c);this.showView(d)},parseOptions:function(a){var b={};return _(a.split("&")).each(function(a){var c=a.split("=");c.length>=2&&(b[c[0]]=c[1])}),b},showClass:function(a,b){b=b||"";var c=this.parseOptions(b),d=new ClassView(this.application,a,c);this.showView(d)},showMethod:function(a){var b=new MethodView(this.application,a);this.showView(b)},showProperty:function(a){var b=new PropertyView(this.application,a,"property");this.showView(b)},showEvent:function(a){var b=new PropertyView(this.application,a,"event");this.showView(b)},showAttribute:function(a){var b=new PropertyView(this.application,a,"attribute");this.showView(b)},showModules:function(){var a=new AbstractView(this.application);a.template="modules",this.showView(a)},showClasses:function(){var a=new AbstractView(this.application);a.template="classes",this.showView(a)},doSearch:function(a){var b=this.parseOptions(a||""),c=new SearchView(this.application,b);this.showView(c)},showDependencies:function(a){var b=this.parseOptions(a||""),c=new DependenciesView(this.application,b);this.showView(c)},showIndex:function(a){var b=this.parseOptions(a||""),c=new IndexView(this.application,b);this.application.showView(c)},showBook:function(a){var b=confirm("This can take some time for the browser, are you sure you want to continue ? ");if(b){var c=this.parseOptions(a||""),d=new BookView(this.application,c);this.application.showView(d)}else Backbone.history.navigate("index",{trigger:!0})},showTree:function(){var a=new TreeView(this.application);this.application.showView(a)},showHierarchyTree:function(){var a=new HierarchyTreeView(this.application);this.application.showView(a)},showParse:function(){var a=new ParseView(this.application);this.application.showView(a)},showFile:function(a,b){b=b||"";var c=this.parseOptions(b),d=new FileView(this.application,a,c);this.showView(d)}}),AbstractView=Backbone.View.extend({tagName:"div",initialize:function(a){this.application=a},renderIn:function(a){var b=_.isFunction(this.template)?this.template:this.application.templates[this.template],c=b.apply(this,[]);return this.$el.html(c),a.append(this.$el),this.afterRender(),this},render:function(){return this.renderIn(jQuery(this.el))},afterRender:function(){this.renderSource()},setTitle:function(a){this.title=a,setTimeout(function(){document.title=a},200)},renderSource_:function(a,b){if(a.commentRange){var c=new SourcesView(this.application,a);c.fileNameUrl=encodeURIComponent(this.jsdoc.fileName),c.renderIn(b)}},renderSource:function(){this.jsdoc&&(this.renderSource_(this.jsdoc,this.$('[data-type="sources"]')),this.$("pre code").addClass("prettyprint"),"undefined"!=typeof prettyPrint&&prettyPrint("pre code"))}});_(AbstractView.prototype).extend({printTag:function(a,b,c){return c=c||"span",b=b||"",a?"<"+c+(b?' class="'+b+'"':"")+">"+a+"</"+c+">":""},simpleName:function(a,b){return this.application.maker.simpleName(a,b)},makeLink:function(a,b,c){var d=a.annotation+"-name",e=b?'<a class="'+d+'" href="':"",f="";if(_.isString(a))f+="#"+a;else if("method"===a.annotation)f+="#method/"+a.absoluteName;else if("constructor"===a.annotation)f+="#constructor/"+a.absoluteName;else if("function"===a.annotation)f+="#function/"+a.absoluteName;else if("property"===a.annotation)f+="#property/"+a.absoluteName;else if("event"===a.annotation)f+="#event/"+a.absoluteName;else if("class"===a.annotation||"interface"===a.annotation)f+="#class/"+a.absoluteName;else{if("module"!==a.annotation)return"";f+="#module/"+a.name}var g=location.hash.indexOf("?")===-1?"":location.hash.split("?")[1];return g=this.paramStringToObject(g),_.isString(c)&&(c=this.paramStringToObject(c)),_.extend(g,c||{}),g=this.paramObjectToString(g),f+=g?"?"+g:"",e+=f+(b?'">'+a.name+"</a>":"")},paramStringToObject:function(a){var b=a.split("&"),c={};return _.each(b,function(a){var b=a.split("=");c[b[0]]=b[1]}),c},paramObjectToString:function(a){var b=[];return _.each(a,function(a,c){c&&b.push(c+"="+a)}),b.join("&")},printLiteralObjectType:function(a){var b=this,c=[];a.buffer.push(this.printType(a.type,!0));var d=1===_(a.type.properties).keys().length&&a.type.properties.prototype;d||("Object"===a.type.name&&(a.buffer.push("{"),_(a.type.properties).each(function(a,d){c.push(d+": "+b.printSingleTypeAsString(a,!0))})),a.buffer.push(c.join(", ")),"Object"===a.type.name&&a.buffer.push("}"))},printType:function(a,b){if(!a||!a.type)return"";var c=this,d=a.type.nativeTypeUrl||this.makeLink(a.type),e=a.type.name,f=a.type.nativeTypeUrl?" type external ":" type ",g=a.type.nativeTypeUrl?'<span class="glyphicon glyphicon-share"></span>':"";if(a.buffer.push('<a class="'+f+'" href="'+d+'">'+g+e+"</a>"),a.type.properties&&!b)this.printLiteralObjectType(a);else if(a.type.params&&"function"!==a.type.annotation){a.buffer.push("<");for(var h=0;h<(a.type.params||[]).length;h++){var i=a.type.params[h];c.printType({type:i,buffer:a.buffer}),h<a.type.params.length-1&&a.buffer.push(",")}a.buffer.push(">")}},printSingleTypeAsString:function(a,b){var c=[],d={type:a,typeTemplate:this.printType,buffer:c};this.printType(d);var e=c.join("");return e},printTypeAsString:function(a){var b=this;if(_(a).isArray()){var c=[];return _(a).each(function(a){c.push(b.printSingleTypeAsString(a))}),c.join('<span class="type-separator">or</span>')}return this.printSingleTypeAsString(a)},getTextHtml:function(a){if(!a||!a.text)return"";if(a.text_html_app)return a.text_html_app;var b=this,c=a.text,d=this.application.textFormat||"markdown",e=_(a.children).find(function(a){return"html"===a.annotation}),f=_(a.children).find(function(a){return"markdown"===a.annotation});return e&&(d="html"),f&&(d="markdown"),_(a.textMarks).each(function(a,e){"link"===a.name?c="markdown"===d?c.replace(e,"["+a.linkLabel+"]("+a.linkUrl+")"):c.replace(e,'< href="mark.linkUrl" class="text-mark-link">'+a.linkLabel+"</a>"):a.binding&&(c=c.replace(e,b.makeLink(a.binding,!0)))}),"markdown"===d&&(c=marked(c)),a.text_html_app=c,c},printMethod:function(a){var b="constructor"===a.annotation,c='<span class="method">',d=b?this.simpleName(a.ownerClass):a.name;return!b&&a.returns&&(c+=this.printTypeAsString(a.returns)+" "),c+='<a href="'+this.makeLink(a)+'">'+d+"</a>",c+"</span>"},getInherited:function(a,b){var c={};return"method"===b&&(c=_(a.methods).clone(),_(c).extend(a.inherited.methods||{})),c},getClassName:function(a,b){b=b||this.application.data;for(var c=a.split(".");c;){c=_.initial(c);var d=c.join(".");if(b.classes[d])return d}return a.substring(0,a.lastIndexOf("."))},getSimpleName:function(a){var b=this.getClassName(a);return a.substring(b.length+1,a.length)},getModuleClasses:function(a,b){b||(b=this.application.data);var c=[];return _(b.classes).each(function(b){0===b.absoluteName.indexOf(a)&&c.push(b)}),c},parseOptions:function(a,b,c){if(b=b||"&",c=c||"=",!a)return{};var d={};return _(a.split(b)).each(function(a){var b=a.split(c);b.length>=2&&(d[b[0]]=b[1],b[1]&&"0"!==b[1]&&"false"!==b[1]||(d[b[0]]=!1))}),d},getOptionsFromHash:function(a){a=a||window.location.hash;var b=a.split("?");return b=b.length<2?"":b[1],this.parseOptions(b)},setOptionsToHash:function(a,b){a=a||window.location.hash;var c=a.split("?");return c=c.length<2?"":c[1],c=this.parseOptions(c),_(c).extend(b),a.split("?")[0]+"?"+this.optionsToString(c)},optionsToString:function(a,b,c){b=b||"&",c=c||"=";var d=[];return _(a).each(function(a,b){d.push(b+c+a)}),d.join(b)},propertyIsPublicPredicate:function(a){return _.find(a.children,function(a){return"public"===a.annotation})},isClassPublic:function(a){var b=this.propertyIsPublicPredicate(a);return b=b||_.find(a.methods,this.propertyIsPublicPredicate),b=b||_.find(a.properties,this.propertyIsPublicPredicate),b=b||_.find(a.events,this.propertyIsPublicPredicate),b=b||_.find(a.attributes,this.propertyIsPublicPredicate)},isModulePublic:function(a){var b=this.getModuleClasses(a.name);return _.find(b,_.bind(this.isClassPublic,this))}});var IndexView=AbstractView.extend({className:"index",template:"index",initialize:function(a,b){var c=this;this.application=a,this.options=b||{},this.options.private=this.options.private?parseInt(this.options.private,10):0,this.modules=this.application.data.modules,this.options.private&&(this.modules=_.filter(this.modules,function(a){return c.isModulePublic(a)})),this.classes=this.application.data.classes,this.options.private&&(this.classes=_.filter(this.classes,function(a){return c.isClassPublic(a)}))}}),BookView=AbstractView.extend({className:"book",template:"book",initialize:function(a,b){var c=this;this.application=a,this.options=b||{},this.options.private=this.options.private?parseInt(this.options.private,10):0,this.modules=[],_.each(this.application.data.modules,function(a){c.modules.push(a)}),this.modules=this.modules.sort(function(a,b){return a.name<b.name?0:1}),this.options.private&&(this.modules=_.filter(this.modules,function(a){return c.isModulePublic(a)})),this.classes=this.application.data.classes,this.options.private&&(this.classes=_.filter(this.classes,function(a){return c.isClassPublic(a)})),this.title=this.application.data.projectMetadata.name},afterRender:function(){var a=this;this.$("[data-class]").each(function(){var b=jQuery(this),c=b.data("class"),d=new ClassView(a.application,c,a.options);_.extend(d.options,{dontShowSources:!0,dontShowSidebar:!0,dontShowOptions:!0}),d.resourceNotFound?b.append("Class "+c+" not found!"):d.renderIn(b)})}}),ClassView=AbstractView.extend({className:"class-view",template:"class",initialize:function(a,b,c){var d=this;return this.application=a,this.jsdoc=this.application.data.classes[b],this.jsdoc?(this.isInterface="interface"===this.jsdoc.annotation,this.jsdoc.textHtml=this.getTextHtml(this.jsdoc),this.options=c||{},this.options.inherited=this.options.inherited?parseInt(this.options.inherited,10):0,this.options.private=this.options.private?parseInt(this.options.private,10):0,this.options.text=this.options.text?parseInt(this.options.text,10):1,this.methods=this.jsdoc.methods||{},this.properties=this.jsdoc.properties||{},this.events=this.jsdoc.events||{},this.attributes=this.jsdoc.attributes||{},this.options.inherited&&(this.properties=_(_(this.properties).clone()).extend(this.jsdoc.inherited.properties),this.events=_(_(this.events).clone()).extend(this.jsdoc.inherited.events),this.attributes=_(_(this.attributes).clone()).extend(this.jsdoc.inherited.attributes),this.methods=_(_(this.methods).clone()).extend(this.jsdoc.inherited.methods)),this.options.private&&(this.properties=_.filter(this.properties,this.propertyIsPublicPredicate),this.methods=_.filter(this.methods,this.propertyIsPublicPredicate),this.events=_.filter(this.events,this.propertyIsPublicPredicate),this.attributes=_.filter(this.attributes,this.propertyIsPublicPredicate)),this.hierarchy=this.computeHierarchy(),this.knownSubclasses=this.computeKnownSubclasses(),this.inlineProperties=!0,void(this.inlineProperties&&(this.inlineMethodViews=[],_(this.methods).each(function(a){var b=new MethodView(d.application,a.absoluteName,!0);b.render(),d.inlineMethodViews.push(b)}),this.inlinePropertyViews=[],_(this.properties).each(function(a){var b=new PropertyView(d.application,a.absoluteName,"property",!0);b.render(),d.inlinePropertyViews.push(b)}),this.inlineEventViews=[],_(this.events).each(function(a){var b=new PropertyView(d.application,a.absoluteName,"event",!0);b.render(),d.inlineEventViews.push(b)}),this.inlineAttributeViews=[],_(this.attributes).each(function(a){var b=new PropertyView(d.application,a.absoluteName,"attribute",!0);b.render(),d.inlineAttributeViews.push(b)})))):void(this.resourceNotFound=!0)},afterRender:function(){var a=this;AbstractView.prototype.afterRender.apply(this,arguments),_.each(this.inlineMethodViews,function(b){a.$('[data-type="inline-methods"]').append(b.$el)}),_.each(this.inlinePropertyViews,function(b){a.$('[data-type="inline-properties"]').append(b.$el)}),_.each(this.inlineEventViews,function(b){a.$('[data-type="inline-events"]').append(b.$el)}),_.each(this.inlineAttributeViews,function(b){a.$('[data-type="inline-attributes"]').append(b.$el)})},makePartialText:function(a){if(a.text){var b=Math.min(a.text.length,100);return a.text.substring(0,b)+"..."}return""},computeHierarchy:function(){var a=[],b=this.jsdoc;do if(b&&b.extends&&(a.push(b),b.extends.absoluteName===b.absoluteName))break;while(b=b.extends);return a},computeKnownSubclasses:function(){var a=this,b=[];return _(this.application.data.classes).each(function(c){a.isInterface?_.each(c.implements,function(c){c.extends.absoluteName===a.jsdoc.absoluteName&&b.push(c)}):c.extends.absoluteName===a.jsdoc.absoluteName&&b.push(c)}),b}}),ModuleView=AbstractView.extend({className:"module",template:"module",initialize:function(a,b,c){var d=this;this.application=a,this.jsdoc=this.application.data.modules[b],this.classes=_(_(this.application.data.classes).values()).filter(function(a){return a.module.name===b&&"class"===a.annotation}),this.interfaces=_(_(this.application.data.classes).values()).filter(function(a){return a.module.name===b&&"interface"===a.annotation}),this.options=c||{},this.options.private=this.options.private?parseInt(this.options.private,10):0,this.options.private&&(this.classes=_.filter(this.classes,function(a){return d.isClassPublic(a)})),this.jsdoc.textHtml=this.getTextHtml(this.jsdoc)}}),MethodView=AbstractView.extend({className:"method-view",template:"method",initialize:function(a,b,c){if(this.application=a,this.asChildView=c,0!==Backbone.history.fragment.indexOf("function")){var d=this.getClassName(b),e=this.getSimpleName(b),f=this.application.data.classes[d];if(this.ownerModule=f.module.name,isNaN(parseInt(e,10))?(this.jsdoc=f.methods[e],this.isConstructor=!1):(this.jsdoc=f.constructors[parseInt(e,10)],this.isConstructor=!0),!this.jsdoc)return void(this.resourceNotFound=!0);this.jsdoc.textHtml=this.getTextHtml(this.jsdoc),this.ownerClass=this.application.data.classes[this.jsdoc.ownerClass]}else if(0===Backbone.history.fragment.indexOf("function")){var g=b.split(".")[0];this.ownerModule=this.application.data.modules[g];var h=_.find(this.ownerModule.functions,function(a){return a.absoluteName===b});if(this.jsdoc=h,this.jsdoc.textHtml=this.getTextHtml(this.jsdoc),!this.jsdoc)return void(this.resourceNotFound=!0);this.isFunction=!0}}}),PropertyView=AbstractView.extend({className:"property-view",template:"property",initialize:function(a,b,c,d){this.application=a,this.asChildView=d;var e={event:"Event",property:"Property",attribute:"Attribute"};this.propertyLabel=e[c];var f=this.getClassName(b),g=this.getSimpleName(b),h=this.application.data.classes[f];this.ownerModule=h.module.name;var i={event:"events",property:"properties",attribute:"attributes"};return this.jsdoc=h[i[c]][g],this.jsdoc?void(this.jsdoc.textHtml=this.getTextHtml(this.jsdoc)):void(this.resourceNotFound=!0)}}),SourcesView=AbstractView.extend({className:"sources",template:"sources",events:{'click [data-type="goto-source"]':"gotoSource"},initialize:function(a,b){this.application=a,this.jsdoc=b,this.allSource=this.application.maker.data.source;var c=400,d=Math.max(0,this.jsdoc.commentRange[0]-c),e=Math.min(this.allSource.length-1,this.jsdoc.commentRange[1]+c);this.sourceSubset=this.allSource.substring(d,e);var f=this.allSource.substring(this.jsdoc.commentRange[0],this.jsdoc.commentRange[1]),g=this.sourceSubset.substring(0,this.sourceSubset.indexOf(f)),h=g.split("\n").length;this.jsdocLineNumber=h-1,this.lineCount=f.split("\n").length},afterRender:function(){"undefined"!=typeof prettyPrint&&prettyPrint()},gotoSource:function(){var a="ol.linenums>li",b=jQuery(jQuery(a).get(this.jsdocLineNumber));b.size()&&(jQuery(window).scrollTop(b.position().top),b.addClass("selectedJsDocLine"));for(var c=0;c<this.lineCount;c++)b=jQuery(jQuery(a).get(this.jsdocLineNumber+c)),b.addClass("selectedJsDocLine")}}),ParseView=AbstractView.extend({className:"parse",events:{'click [data-action="inputcode_doit"]':"inputCodeDoit"},template:"parse",inputCodeDoit:function(){var a=this.$('[data-type="inputcode"]').val(),b=this.application.maker,c=this.$('[data-action="clean"]:checked').val();c&&(this.application.data=b.data={}),b.parseFile(a,"textarea"),b.postProccess(),b.postProccessBinding(),this.application.refreshWithNewModel(b.data)}}),ApplicationView=AbstractView.extend({className:"application-view",template:"application",initialize:function(a){this.application=a},renderIn:function(a){AbstractView.prototype.renderIn.apply(this,arguments),this.headerView=this.headerView||new HeaderView(this.application),this.headerView.renderIn(this.$('[data-type="header-container"]')),this.mainView=this.application.currentView,this.mainView.renderIn(this.$('[data-type="main-view-container"]')),document.title=this.title||window.location.href+""}}),HeaderView=AbstractView.extend({className:"header-view",template:"header",initialize:function(a){this.application=a},renderIn:function(){AbstractView.prototype.renderIn.apply(this,arguments),this.installTypeAhead()},installTypeAhead:function(){this.classes=this.application.data.classes,this.modules=this.application.data.modules,this.typeahead=$(".main-header .typeahead1").typeahead({hint:!0,highlight:!0,minLength:1},{name:"jsdoc",displayKey:"value",source:this.substringMatcher(),templates:{empty:'<div class="empty-message">Sorry, nothing found.</div>',suggestion:this.application.templates.typeaheadSuggestion}});var a=this;this.typeahead.on("typeahead:selected",function(){a.handleSearchSelection.apply(a,arguments)}),jQuery(window).width()<400&&jQuery(".tt-dropdown-menu").css({width:jQuery(window).width()+"px"})},handleSearchSelection:function(a,b,c){var d=this.makeLink(b.node);Backbone.history.navigate(d,{trigger:!0})},search:function(a){var b=this,c=[],d=new RegExp(a,"i");return _(b.classes).each(function(a){d.test(a.name)&&c.push({value:a.name,node:a}),_(a.methods).each(function(a){d.test(a.name)&&c.push({value:a.name,node:a})})}),_(b.modules).each(function(a){d.test(a.name)&&c.push({value:a.name,node:a})}),c},substringMatcher:function(){var a=this;return function(b,c){var d;d=a.search(b),c(d)}}}),FileView=AbstractView.extend({className:"file-view",template:"file",events:{'click [data-action="donwload"]':"download"},initialize:function(a,b,c){if(this.fileName=decodeURIComponent(b),this.application=a,this.jsdoc=this.application.data.files[b],!this.jsdoc)return void(this.resourceNotFound=!0);var d=this.application.data.source.indexOf("@filename",this.jsdoc.commentRange[1]);d=d===-1?this.application.data.source.length:d,this.fileContent=this.application.data.source.substring(this.jsdoc.commentRange[1],d)},afterRender:function(){"undefined"!=typeof prettyPrint&&prettyPrint()},download:function(){var a=this.fileName.split("/");a=a[a.length-1];var b=document.createElement("a"),c=new Blob([this.fileContent],{type:"text/javascript"});b.href=window.URL.createObjectURL(c),b.download=a,b.click()}}),SearchView=AbstractView.extend({className:"search-view",template:"search",events:{'click [data-action="search"]':"searchActionHandler"},initialize:function(a,b){this.application=a,this.jsdoc=this.application.data;var c=this;this.query=b,this.search(function(a){c.results=a,c.render()})},formToJson:function(a){var b=jQuery(a).serialize(),c=b.split("&"),d={};return _(c).each(function(a){var b=a.split("=");d[b[0]]=b[1]}),d},searchActionHandler:function(a){var b=this.$('[data-type="search-form"]').serialize();Backbone.history.navigate("search?"+b,{trigger:!0}),a.preventDefault()},search:function(a){if(this.query.keywords){var b=this,c={},d=b.query.keywords.toLowerCase(),e=function(a){},f=function(a,e){var f=a.absoluteName?a.absoluteName:a.name;if(f&&e){var f=f.toLowerCase();if(f&&f.indexOf(d)!==-1){var g,h,i;"param"===e.annotation?(i=e.parentNode.absoluteName+"."+e.name,g="parameter '"+e.name+"' of method '"+e.parentNode.absoluteName+"'",h=b.makeLink(e.parentNode)):(i=e.absoluteName,g=e.annotation+" '"+e.absoluteName+"'",h=b.makeLink(e)),c[i]={label:g,url:h}}}},g=function(){var b=[];_(c).each(function(a){b.push(a)}),a(b)};this.application.maker.recurseAST(e,f,g)}}}),AbstractTreeView=AbstractView.extend({expandAll:function(){var a=this;this.$(".tree [data-tree-node]").each(function(){a.treeView.expandNode($(this))})},collapseAll:function(){var a=this;this.$(".tree > ul > .tree-node > [data-tree-node]").each(function(){a.treeView.collapseNode($(this))})}});!function(){if(!window.TreeWidget){var a=function(a){this.rootNode=a};a.cssOptions={hoverChildren:!1,hoverColor:"red"},a.prototype.render=function(a){return this.parentEl=a,this._renderTree(this.rootNode,a)},a.prototype._renderTree=function(a,b){var c=this,d=this.renderNode({node:a,renderNode:this.renderNode,isRoot:!0});return b&&jQuery(b).empty().append(d),$(".tree li:has(ul)").addClass("parent_li").find(" > span").attr("title","Collapse this branch"),$(".tree li.parent_li > span").on("click",function(a){var b=$(this).parent("li.parent_li").find(" > ul > li");b.is(":visible")?c.collapseNode($(this)):c.expandNode($(this)),a.stopPropagation()}),d},a.prototype.collapseNode=function(a){var b=a.parent("li.parent_li").find(" > ul > li");b.hide("fast"),a.attr("title","Expand this branch").find(" > i").addClass("glyphicon-plus-sign").removeClass("glyphicon-minus-sign")},a.prototype.expandNode=function(a){var b=a.parent("li.parent_li").find(" > ul > li");b.show("fast"),a.attr("title","Collapse this branch").find(" > i").addClass("glyphicon-minus-sign").removeClass("glyphicon-plus-sign")},a.prototype.onNodeEvent=function(a,b){jQuery(this.parentEl).on(a,"li > span",function(){var a=parseInt($(this).data("tree-node-id"));b&&b(this,a)})},window.TreeWidget=a,a.treeNodeTemplate='<% var isRoot = isRoot || false; %><% if(isRoot) { %><div class="tree"><% } else { %><li class="tree-node tree-node-type-<%= node.type %>"><span data-tree-node data-tree-node-id="<%= node.tree_node_id %>"><i class="glyphicon glyphicon-minus-sign"></i><%= node.label%></span><% } %><% if(node.children) { %><ul><% _(node.children).each(function(child){ %><%= renderNode({node:child, isRoot: false, renderNode: renderNode}) %><% }) %></ul><% } %>'+"<%= isRoot ? '</div>' : '</li>' %>",a.prototype.renderNode=_(a.treeNodeTemplate).template()}}();var TreeView=AbstractTreeView.extend({className:"tree",template:"tree",events:{'click [data-action="show-tree"]':"showTree",'click [data-action="expand-all"]':"expandAll",'click [data-action="collapse-all"]':"collapseAll"},renderIn:function(){AbstractView.prototype.renderIn.apply(this,arguments),this.treeModel=this.buildTreeModel(this.application.data),this.treeView=new TreeWidget(this.treeModel),this.treeView.render(".the-tree"),this.treeView.onNodeEvent("click",function(a){alert(a.label+" was clicked")})},buildTreeModel:function(){var a={children:[]},b=this,c=this.application.data;return _(c.modules).each(function(d){a.children.push(b.buildTreeModelForModule(d,c))}),a},buildTreeModelForModule:function(a,b){var c={children:[],label:"Module "+this.makeLink(a,!0),type:"module"},d=this,e=_(b.classes).filter(function(b){return b.module.name===a.name});return _(e).each(function(a){c.children.push(d.buildTreeModelForClass(a,b))}),c},buildTreeModelForClass:function(a,b){var c={children:[],label:"Class "+this.makeLink(a,!0),type:"class"},d=this;return _(a.methods).each(function(a){c.children.push(d.buildTreeModelForMethod(a,b))}),_(a.properties).each(function(a){c.children.push(d.buildTreeModelForProperty(a,b,"Property"))}),_(a.events).each(function(a){c.children.push(d.buildTreeModelForProperty(a,b,"Event"))}),c},buildTreeModelForProperty:function(a,b,c){var d={children:[],label:c+" "+this.makeLink(a,!0),type:"method"};return d},buildTreeModelForMethod:function(a,b){var c={children:[],label:"Method "+this.makeLink(a,!0),type:"method"};return c}}),HierarchyTreeView=AbstractTreeView.extend({className:"hierarchy-tree",template:"hierarchytree",events:{'click [data-action="show-tree"]':"showTree",'click [data-action="expand-all"]':"expandAll",'click [data-action="collapse-all"]':"collapseAll"},renderIn:function(){AbstractView.prototype.renderIn.apply(this,arguments);var a=this.application.data.classes["javascript.Object"];a||(a={name:"Object"});this.classesExtendsFrom(a);this.treeModel=this.buildTreeModel(a),this.treeModel={label:"Something",children:[this.treeModel]},this.treeView=new TreeWidget(this.treeModel),this.treeView.render(".the-tree"),this.treeView.onNodeEvent("click",function(a){alert(a.label+" was clicked")})},classesExtendsFrom:function(a){var b=[];return _(this.application.data.classes).each(function(c){c.extends&&a&&(c.extends.absoluteName?c.extends.absoluteName===a.absoluteName&&c.absoluteName!==c.extends.absoluteName&&b.push(c):c.extends.name&&c.name!==c.extends.name&&c.extends.name===a.name&&b.push(c))}),b},buildTreeModel:function(a){if(!a)return[];var b={children:[],label:'<a href="'+this.makeLink(a)+'">'+(a.absoluteName||a.name)+"</a>"},c=this,d=c.classesExtendsFrom(a);return _(d).each(function(a){b.children.push(c.buildTreeModel(a))}),b}}),DependenciesView=AbstractView.extend({className:"dependencies",template:"dependencies",events:{'click [data-type="includeExtends"]':"includeExtends",'click [data-type="includeNativeClasses"]':"includeNativeClasses"},initialize:function(a,b){this.application=a,this.options=b||{},this.options.includeExtends=this.options.includeExtends&&"0"!==this.options.includeExtends,this.options.includeNativeClasses=this.options.includeNativeClasses&&"0"!==this.options.includeNativeClasses,this.ignoreClasses=this.options.includeNativeClasses?[]:["javascript.String","javascript.Object","javascript.Function","javascript.Any","javascript.Number","javascript.Boolean","javascript.Array"]},renderIn:function(){var a=this;AbstractView.prototype.renderIn.apply(this,arguments),toast("lib/vis/dist/vis.min.js","lib/vis/dist/vis.min.css",function(){a.doTheGraph()})},includeExtends:function(){var a=this.$('[data-type="includeExtends"]').is(":checked"),b=this.getOptionsFromHash();b.includeExtends=a?"1":"0";var c="dependencies?"+this.optionsToString(b);Backbone.history.navigate(c,{trigger:!0})},includeNativeClasses:function(){var a=this.$('[data-type="includeNativeClasses"]').is(":checked"),b=this.getOptionsFromHash();b.includeNativeClasses=a?"1":"0";var c="dependencies?"+this.optionsToString(b);Backbone.history.navigate(c,{trigger:!0})},doTheGraph:function(){this.$(".loading-message").show();var a={ignoreClasses:this.ignoreClasses,includeExtends:this.options.includeExtends},b=new this.application.maker.tools.DependencyTool(this.application.maker,a);b.calculateClassDependencies();var c=[],d=[],e=1,f={};_(this.application.data.classes).each(function(a){var b={id:e,label:a.name};c.push(b),f[a.absoluteName]=b,e++}),_(this.application.data.classes).each(function(a){_(a.dependencies.classes).each(function(b){f[a.absoluteName]&&f[b.absoluteName]&&d.push({from:f[a.absoluteName].id,to:f[b.absoluteName].id})})});var g=this.$('[data-type="dependency-graph"]').get(0),h={nodes:c,edges:d},i={nodes:{shape:"box"},edges:{style:"arrow"}};new vis.Network(g,h,i);this.$(".loading-message").hide()}});
//# sourceMappingURL=all.min.js.map