5 classes : false, // flat version of list of classes
6 currentClass : '', // currently viewed class name
13 //if (typeof(pagedata) == 'undefined') {
14 // Site.onReady.defer(100, Roo.docs.init);
19 Roo.XComponent.hideProgress = true;
20 Roo.XComponent.build();
25 Roo.XComponent.on('buildcomplete', function() {
27 //Roo.XComponent.modules[0].el.fireEvent('render');
32 window.onhashchange = function() { Roo.docs.init.onHashChange(); }
37 //Roo.get(document.body).on('click', this.onClick, this);
44 Roo.docs.doc_body_content.hide();
49 success : function(res, o)
51 var d = Roo.decode(res.responseText);
54 // our classes witch children first..
55 d.forEach(function(e) {
57 this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem');
62 d.forEach(function(e) {
64 this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem');
67 var roo = Roo.docs.navGroup.items[1].menu;
68 roo.show(roo.triggerEl, '?', false);
69 if (location.hash.length) {
84 hideChildren : function(c)
89 for (var i =0; i < c.cn.length; i++) {
90 this.hideChildren(c.cn[i]);
96 addTreeItem : function(parent, e, type , parent_e) {
98 this.classes[e.name] = e;
100 var node = parent.addxtypeChild(Roo.factory({
101 html: e.name.split('.').pop(),
106 preventDefault : true,
107 // cls : type == 'NavSidebarItem' ? 'open' : '',
109 click : (function(mi,ev,c)
112 ev.stopPropagation();
116 if (mi.menu.el.hasClass('show')) {
117 this.hideChildren(c); //mi.menu.hide();
118 // collapse children..
123 mi.menu.show(mi.menu.triggerEl,'?', false);
127 location.hash = '#' + c.name;
128 //Roo.docs.init.loadDoc(c);
130 }).createDelegate(this,[e], true)
133 fa : e.cn.length ? 'chevron-right' : '',
134 menu : !e.cn.length ? false : Roo.factory({
139 beforehide : (function(mi,c)
141 if (c.name.split('.').length < 2) {
146 }).createDelegate(this,[e], true)
153 e.parent_menu = parent;
155 parent.items.push(node);
156 if (e.cn.length && type == 'NavSidebarItem') {
157 this.topm = node.menu;
164 e.cn.forEach(function(ec) {
165 var cn = ec.name.split('.').pop();
167 if (cn == cn.toLowerCase()) {
168 this.addTreeItem(node.menu, ec,'MenuItem', e);
172 e.cn.forEach(function(ec) {
173 var cn = ec.name.split('.').pop();
174 if (cn != cn.toLowerCase()) {
175 this.addTreeItem(node.menu, ec,'MenuItem', e);
181 loadClass : function(name)
183 if(typeof(this.classes[name]) != 'undefined' && this.classes[name].is_class ) {
184 this.loadDoc(this.classes[name]);
191 loadSource : function( )
196 url : 'src/' +this.currentClass.replace(/\./g,'_') + '.js.html',
198 success : function(res, o)
200 Roo.docs.ViewSource.show({
201 source : res.responseText,
202 fname : this.currentClass.replace(/\./g,'/') + ".js"
212 loadDoc : function(cls)
214 Roo.docs.doc_body_content.hide();
215 this.currentClass = cls.name;
217 Roo.docs.introBody.show();
223 var m = cls.parent_menu;
224 m.show(m.triggerEl,'?', false);
226 while ((mp = mp.parent)) {
228 m.show(m.triggerEl,'?', false);
230 cls.node.el.scrollIntoView(Roo.docs.sidebar.el,false);
231 Roo.docs.sidebar.el.select('.active').removeClass('active');
232 cls.node.el.addClass('active');
234 Roo.docs.introBody.hide();
235 Roo.docs.doc_body_content.show();
237 url : 'symbols/' + cls.name + '.json',
239 success : function(res, o)
241 var d = Roo.decode(res.responseText);
251 fillDoc : function(d)
254 "name" : "Roo.bootstrap.Progress",
256 "Roo.bootstrap.Component",
258 "Roo.util.Observable"
260 "desc" : "Bootstrap Progress class",
264 document.body.scrollTop = 0;
266 if (typeof(Roo.docs['doc_' + k]) != 'undefined') {
267 Roo.docs['doc_' + k].el.dom.innerHTML = Roo.docs.template.resolveLinks(d[k]);;
270 Roo.docs.doc_extends.hide();
271 Roo.docs.doc_extends_sep.hide();
272 if (d.augments.length) {
273 Roo.docs.doc_extends.show();
274 Roo.docs.doc_extends_sep.show();
275 Roo.docs.doc_extends.el.dom.innerHTML = d.augments[0];
277 Roo.docs.doc_source.el.dom.innerHTML = d.name.replace(/\./g,"/") + ".js";
279 if (d.augments.length) {
280 Roo.docs.augments.show();
281 Roo.docs.augments.bodyEl().dom.innerHTML = Roo.docs.template.augments(d);
283 Roo.docs.augments.hide();
288 Roo.docs.configTableContainer.hide();
289 Roo.docs.methodsTableContainer.hide();
290 Roo.docs.eventsTableContainer.hide();
291 if (d.config.length) {
292 Roo.docs.configTableContainer.show();
293 Roo.docs.configTable.store.load( { params : { data : d.config.sort(Roo.docs.template.makeSortby("name")) }});
296 if (d.methods.length) {
297 Roo.docs.methodsTable.store.load( { params : { data : Roo.docs.template.methodsSort(d) }});
298 Roo.docs.methodsTableContainer.show();
300 if (d.events.length) {
301 Roo.docs.eventsTable.store.load( { params : { data : d.events.sort(Roo.docs.template.makeSortby("name")) }});
302 Roo.docs.eventsTableContainer.show();
307 onClick : function(e)
309 if (e.target.nodeName != 'A') {
312 if (!e.target.href.match(/#/)) {
316 var link = e.target.href.split('#')[1];
317 this.loadClass(link);
321 onHashChange : function()
323 if (this.hash == location.hash) {
329 loadHash : function()
331 if (location.hash.length < 2) {
334 this.loadClass(location.hash.substring(1));
335 this.hash = location.hash;
339 loadIntro : function()
346 success : function(res)
348 this.renderIntro(res.responseText);
357 // render the really simple markdown data
358 renderIntro : function(intro)
361 Roo.docs.doc_body_content.hide();
364 var lines = intro.split("\n");
365 var tree = { 'name' : 'root', cn : []};
366 var state = [ tree ];
367 for (var i=0;i< lines.length;i++) {
369 if (!line.length || line.match(/^\s+$/)) {
372 var sm = line.match(/^(\s+)(.*)/);
374 var sml = sm ? sm[1].length: 0;
376 sml = sml / 4; // 4 spaces indent?
377 var add = { name : sm ? sm[2] : line, cn : [] };
378 state[sml].cn.push(add);
384 for(var i = 0; i < tree.cn.length; i++) {
385 // make a container..
386 var treei = tree.cn[i];
401 for(var ii = 0; ii < treei.cn.length; ii++) {
402 var treeii = treei.cn[ii];
403 // another container..
405 header : treeii.name,
420 ctree.items[0].items.push(ctreei);
422 for(var iii = 0; iii < treeii.cn.length; iii++) {
423 var treeiii = treeii.cn[iii];
424 var ll = treeiii.name.match(/^(\S+)\s*(.*)$/);
425 //Roo.log(treeiii.name);
426 if (treeiii.name == 'Examples') {
427 for (var j =0;j< treeiii.cn.length; j++) {
428 var exs = treeiii.cn[j].name.match(/^\[([^\]]+)\](.*)$/);
429 footer += '<li><a target="_blank" href="../' + exs[1] + '">'+exs[2] + '</a></li>';
445 href : '#' + ( ll ? ll[1] : treeiii.name ) ,
446 html : ll ? ll[1] : treeiii.name,
453 html : ll && ll[2].length ? ' - ' + ll[2] : '',
461 ctreei.items.push(ctreeii);
465 //Roo.log("footer:"+ footer);
466 ctreei.footer = '<h5>Examples:</h5><ul>'+footer +'</ul>';
475 Roo.docs.introBody.addxtypeChild(ctree);
487 Roo.onReady(Roo.docs.init.onReady, Roo.docs.init);