5 classes : false, // flat version of list of classes
6 currentClass : '--none--', // currently viewed class name
15 Roo.XComponent.hideProgress = true;
16 Roo.XComponent.build();
19 Roo.XComponent.on('buildcomplete', function() {
21 //Roo.XComponent.modules[0].el.fireEvent('render');
24 if (window.location.search.length > 0) {
25 this.prefix = window.location.search.substring(1);
28 window.onhashchange = function() { Roo.docs.init.onHashChange(); }
35 Roo.docs.doc_body_content.hide();
38 url : this.prefix + 'tree.json',
40 success : function(res, o)
42 var d = Roo.decode(res.responseText);
45 // our classes witch children first..
46 d.forEach(function(e) {
48 this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem', true );
53 d.forEach(function(e) {
55 this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem' ,true);
61 d.forEach(function(e) {
63 this.addTreeItem(Roo.docs.mobileNavGroup, e, 'NavSidebarItem', false);
68 d.forEach(function(e) {
70 this.addTreeItem(Roo.docs.mobileNavGroup, e, 'NavSidebarItem', false);
74 var roo = Roo.docs.navGroup.items[1].menu;
75 if (!Roo.docs.init.prefix.length) {
76 roo.show(roo.triggerEl, '?', false);
79 if (location.hash.length) {
94 hideChildren : function(c)
99 for (var i =0; i < c.cn.length; i++) {
100 this.hideChildren(c.cn[i]);
106 addTreeItem : function(parent, e, type , parent_e) {
108 this.classes[e.name] = e;
110 var node = parent.addxtypeChild(Roo.factory({
111 html: e.name.split('.').pop(),
116 preventDefault : true,
117 // cls : type == 'NavSidebarItem' ? 'open' : '',
119 click : (function(mi,ev,c)
122 ev.stopPropagation();
126 if (mi.menu.el.hasClass('show')) {
127 this.hideChildren(c); //mi.menu.hide();
128 // collapse children..
133 mi.menu.show(mi.menu.triggerEl,'?', false);
137 location.hash = '#' + c.name;
138 //Roo.docs.init.loadDoc(c);
140 }).createDelegate(this,[e], true)
143 fa : e.cn.length ? 'chevron-right' : '',
144 menu : !e.cn.length ? false : Roo.factory({
149 beforehide : (function(mi,c)
151 if (c.name.split('.').length < 2 && !Roo.docs.init.prefix.length) {
156 }).createDelegate(this,[e], true)
170 if (parent_e !== false) {
172 e.parent_menu = parent;
173 e.parent = parent_e == true ? null : parent_e;
176 parent.items.push(node);
177 if (e.cn.length && type == 'NavSidebarItem') {
178 this.topm = node.menu;
185 e.cn.forEach(function(ec) {
186 var cn = ec.name.split('.').pop();
188 if (cn == cn.toLowerCase()) {
189 this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
193 e.cn.forEach(function(ec) {
194 var cn = ec.name.split('.').pop();
195 if (cn != cn.toLowerCase()) {
196 this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
202 loadClass : function(name)
204 if(typeof(this.classes[name]) != 'undefined' && this.classes[name].is_class ) {
205 this.loadDoc(this.classes[name]);
212 loadSource : function( )
217 url : 'src/' +this.currentClass.replace(/\./g,'_') + '.js.html',
219 success : function(res, o)
221 Roo.docs.ViewSource.show({
222 source : res.responseText,
223 fname : this.currentClass.replace(/\./g,'/') + ".js"
233 loadDoc : function(cls)
235 if (this.currentClass == cls.name) {
238 //Roo.docs.mobileNavGroup.hide();
240 Roo.docs.doc_body_content.hide();
241 Roo.docs.navHeaderBar.collapse();
242 this.currentClass = cls.name;
244 Roo.docs.introBody.show();
250 var m = cls.parent_menu;
251 m.show(m.triggerEl,'?', false);
253 while ((mp = mp.parent)) {
255 m.show(m.triggerEl,'?', false);
257 cls.node.el.scrollIntoView(Roo.docs.sidebar.el,false);
258 Roo.docs.sidebar.el.select('.active').removeClass('active');
259 cls.node.el.addClass('active');
261 Roo.docs.introBody.hide();
262 Roo.docs.doc_body_content.show();
264 url : 'symbols/' + cls.name + '.json',
266 success : function(res, o)
268 var d = Roo.decode(res.responseText);
278 fillDoc : function(d)
281 "name" : "Roo.bootstrap.Progress",
283 "Roo.bootstrap.Component",
285 "Roo.util.Observable"
287 "desc" : "Bootstrap Progress class",
291 document.body.scrollTop = 0;
292 Roo.docs.doc_name.el.dom.innerHTML = Roo.docs.template.resolveLinks(d.name);
293 Roo.docs.doc_desc.el.dom.innerHTML = Roo.docs.template.summary(d);
294 Roo.docs.doc_extends.hide();
295 Roo.docs.doc_extends_sep.hide();
296 if (d.augments.length) {
297 Roo.docs.doc_extends.show();
298 Roo.docs.doc_extends_sep.show();
299 Roo.docs.doc_extends.el.dom.innerHTML = d.augments[0];
301 Roo.docs.doc_source.el.dom.innerHTML = d.name.replace(/\./g,"/") + ".js";
303 if (d.augments.length) {
304 Roo.docs.augments.show();
305 Roo.docs.augments.bodyEl().dom.innerHTML = Roo.docs.template.augments(d);
307 Roo.docs.augments.hide();
312 Roo.docs.configTableContainer.hide();
313 Roo.docs.methodsTableContainer.hide();
314 Roo.docs.eventsTableContainer.hide();
315 if (d.config.length) {
316 Roo.docs.configTableContainer.show();
317 Roo.docs.configTable.store.load( { params : { data : d.config.sort(Roo.docs.template.makeSortby("name")) }});
320 if (d.methods.length) {
321 Roo.docs.methodsTable.store.load( { params : { data : Roo.docs.template.methodsSort(d) }});
322 Roo.docs.methodsTableContainer.show();
324 if (d.events.length) {
325 Roo.docs.eventsTable.store.load( { params : { data : d.events.sort(Roo.docs.template.makeSortby("name")) }});
326 Roo.docs.eventsTableContainer.show();
331 onClick : function(e)
333 if (e.target.nodeName != 'A') {
336 if (!e.target.href.match(/#/)) {
340 var link = e.target.href.split('#')[1];
341 this.loadClass(link);
345 onHashChange : function()
347 if (this.hash == location.hash) {
353 loadHash : function()
355 if (location.hash.length < 2) {
358 this.loadClass(location.hash.substring(1));
359 this.hash = location.hash;
363 loadIntro : function()
370 success : function(res)
372 this.renderIntro(res.responseText);
381 // render the really simple markdown data
382 renderIntro : function(intro)
385 Roo.docs.doc_body_content.hide();
388 var lines = intro.split("\n");
389 var tree = { 'name' : 'root', cn : []};
390 var state = [ tree ];
391 for (var i=0;i< lines.length;i++) {
393 if (!line.length || line.match(/^\s+$/)) {
396 var sm = line.match(/^(\s+)(.*)/);
398 var sml = sm ? sm[1].length: 0;
400 sml = sml / 4; // 4 spaces indent?
401 var add = { name : sm ? sm[2] : line, cn : [] };
402 state[sml].cn.push(add);
408 for(var i = 0; i < tree.cn.length; i++) {
409 // make a container..
410 var treei = tree.cn[i];
425 for(var ii = 0; ii < treei.cn.length; ii++) {
426 var treeii = treei.cn[ii];
427 // another container..
429 header : treeii.name,
444 ctree.items[0].items.push(ctreei);
446 for(var iii = 0; iii < treeii.cn.length; iii++) {
447 var treeiii = treeii.cn[iii];
448 var ll = treeiii.name.match(/^(\S+)\s*(.*)$/);
449 //Roo.log(treeiii.name);
450 if (treeiii.name == 'Examples') {
451 for (var j =0;j< treeiii.cn.length; j++) {
452 var exs = treeiii.cn[j].name.match(/^\[([^\]]+)\](.*)$/);
453 footer += '<li><a target="_blank" href="../' + exs[1] + '">'+exs[2] + '</a></li>';
469 href : '#' + ( ll ? ll[1] : treeiii.name ) ,
470 html : ll ? ll[1] : treeiii.name,
477 html : ll && ll[2].length ? ' - ' + ll[2] : '',
485 ctreei.items.push(ctreeii);
489 //Roo.log("footer:"+ footer);
490 ctreei.footer = '<h5>Examples:</h5><ul>'+footer +'</ul>';
499 Roo.docs.introBody.addxtypeChild(ctree);
511 Roo.onReady(Roo.docs.init.onReady, Roo.docs.init);