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)
124 if (c.cn.length && !Roo.docs.init.prefix.length) {
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 (Roo.docs.init.prefix.length) {
155 if (c.name.split('.').length < 2) {
160 }).createDelegate(this,[e], true)
174 if (parent_e !== false) {
176 e.parent_menu = parent;
177 e.parent = parent_e == true ? null : parent_e;
180 parent.items.push(node);
181 if (e.cn.length && type == 'NavSidebarItem') {
182 this.topm = node.menu;
189 e.cn.forEach(function(ec) {
190 var cn = ec.name.split('.').pop();
192 if (cn == cn.toLowerCase()) {
193 this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
197 e.cn.forEach(function(ec) {
198 var cn = ec.name.split('.').pop();
199 if (cn != cn.toLowerCase()) {
200 this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
206 loadClass : function(name)
208 if(typeof(this.classes[name]) != 'undefined' && this.classes[name].is_class ) {
209 this.loadDoc(this.classes[name]);
216 loadSource : function( )
221 url : 'src/' +this.currentClass.replace(/\./g,'_') + '.js.html',
223 success : function(res, o)
225 Roo.docs.ViewSource.show({
226 source : res.responseText,
227 fname : this.currentClass.replace(/\./g,'/') + ".js"
237 loadDoc : function(cls)
239 if (this.currentClass == cls.name) {
242 //Roo.docs.mobileNavGroup.hide();
244 Roo.docs.doc_body_content.hide();
245 Roo.docs.navHeaderBar.collapse();
246 this.currentClass = cls.name;
248 Roo.docs.introBody.show();
254 var m = cls.parent_menu;
255 m.show(m.triggerEl,'?', false);
257 while ((mp = mp.parent)) {
259 m.show(m.triggerEl,'?', false);
261 cls.node.el.scrollIntoView(Roo.docs.sidebar.el,false);
262 Roo.docs.sidebar.el.select('.active').removeClass('active');
263 cls.node.el.addClass('active');
265 Roo.docs.introBody.hide();
266 Roo.docs.doc_body_content.show();
268 url : this.prefix + 'symbols/' + cls.name + '.json',
270 success : function(res, o)
273 var d = Roo.decode(res.responseText);
275 if (typeof(d.augments) == 'undefined') {
277 d.config = []; // props for ctor?
279 this.fillAugments(d, d.extends, Roo.docs.init.fillDoc);
292 fillAugments : function(d, ext, cb )
295 if (Roo.docs.init.n > 20) {
302 var next = ext.shift();
303 d.augments.push(next);
304 var ax = new Roo.data.Connection({});
306 url : this.prefix + 'symbols/' + next + '.json',
308 success : function(res, o)
311 var r = Roo.decode(res.responseText);
314 // copy methods that are not constructors..
316 r.methods.forEach(function(m) {
318 if (r.methods.find(function(e) {
319 return e.name == m.name;
323 if (m.isConstructor || m.static) {
329 r.props.forEach(function(m) {
333 if (r.props.find(function(e) {
334 return e.name == m.name;
342 r.events.forEach(function(m) {
343 if (r.events.find(function(e) {
344 return e.name == m.name;
351 this.fillAugments(d,ext, cb)
361 fillDoc : function(d)
364 "name" : "Roo.bootstrap.Progress",
366 "Roo.bootstrap.Component",
368 "Roo.util.Observable"
370 "desc" : "Bootstrap Progress class",
374 document.body.scrollTop = 0;
375 Roo.docs.doc_name.el.dom.innerHTML = Roo.docs.template.resolveLinks(d.name);
376 Roo.docs.doc_desc.el.dom.innerHTML = Roo.docs.template.summary(d);
377 Roo.docs.doc_extends.hide();
378 Roo.docs.doc_extends_sep.hide();
379 if (d.augments.length) {
380 Roo.docs.doc_extends.show();
381 Roo.docs.doc_extends_sep.show();
382 Roo.docs.doc_extends.el.dom.innerHTML = d.augments[0];
384 Roo.docs.doc_source.el.dom.innerHTML = d.name.replace(/\./g,"/") + ".js";
386 if (d.augments.length) {
387 Roo.docs.augments.show();
388 Roo.docs.augments.bodyEl().dom.innerHTML = Roo.docs.template.augments(d);
390 Roo.docs.augments.hide();
395 Roo.docs.configTableContainer.hide();
396 Roo.docs.methodsTableContainer.hide();
397 Roo.docs.eventsTableContainer.hide();
398 if (d.config.length) {
399 Roo.docs.configTableContainer.show();
400 Roo.docs.configTable.store.load( { params : { data : d.config.sort(Roo.docs.template.makeSortby("name")) }});
403 if (d.methods.length) {
404 Roo.docs.methodsTable.store.load( { params : { data : Roo.docs.template.methodsSort(d) }});
405 Roo.docs.methodsTableContainer.show();
407 if (d.events.length) {
408 Roo.docs.eventsTable.store.load( { params : { data : d.events.sort(Roo.docs.template.makeSortby("name")) }});
409 Roo.docs.eventsTableContainer.show();
414 onClick : function(e)
416 if (e.target.nodeName != 'A') {
419 if (!e.target.href.match(/#/)) {
423 var link = e.target.href.split('#')[1];
424 this.loadClass(link);
428 onHashChange : function()
430 if (this.hash == location.hash) {
436 loadHash : function()
438 if (location.hash.length < 2) {
441 this.loadClass(location.hash.substring(1));
442 this.hash = location.hash;
446 loadIntro : function()
453 success : function(res)
455 this.renderIntro(res.responseText);
464 // render the really simple markdown data
465 renderIntro : function(intro)
468 Roo.docs.doc_body_content.hide();
471 var lines = intro.split("\n");
472 var tree = { 'name' : 'root', cn : []};
473 var state = [ tree ];
474 for (var i=0;i< lines.length;i++) {
476 if (!line.length || line.match(/^\s+$/)) {
479 var sm = line.match(/^(\s+)(.*)/);
481 var sml = sm ? sm[1].length: 0;
483 sml = sml / 4; // 4 spaces indent?
484 var add = { name : sm ? sm[2] : line, cn : [] };
485 state[sml].cn.push(add);
491 for(var i = 0; i < tree.cn.length; i++) {
492 // make a container..
493 var treei = tree.cn[i];
508 for(var ii = 0; ii < treei.cn.length; ii++) {
509 var treeii = treei.cn[ii];
510 // another container..
512 header : treeii.name,
527 ctree.items[0].items.push(ctreei);
529 for(var iii = 0; iii < treeii.cn.length; iii++) {
530 var treeiii = treeii.cn[iii];
531 var ll = treeiii.name.match(/^(\S+)\s*(.*)$/);
532 //Roo.log(treeiii.name);
533 if (treeiii.name == 'Examples') {
534 for (var j =0;j< treeiii.cn.length; j++) {
535 var exs = treeiii.cn[j].name.match(/^\[([^\]]+)\](.*)$/);
536 footer += '<li><a target="_blank" href="../' + exs[1] + '">'+exs[2] + '</a></li>';
552 href : '#' + ( ll ? ll[1] : treeiii.name ) ,
553 html : ll ? ll[1] : treeiii.name,
560 html : ll && ll[2].length ? ' - ' + ll[2] : '',
568 ctreei.items.push(ctreeii);
572 //Roo.log("footer:"+ footer);
573 ctreei.footer = '<h5>Examples:</h5><ul>'+footer +'</ul>';
582 Roo.docs.introBody.addxtypeChild(ctree);
594 Roo.onReady(Roo.docs.init.onReady, Roo.docs.init);