X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..3789b528d8dd8aad4558e38e22d775bcab1cbd36:/docs/js/Guides.js diff --git a/docs/js/Guides.js b/docs/js/Guides.js new file mode 100644 index 00000000..54980096 --- /dev/null +++ b/docs/js/Guides.js @@ -0,0 +1,39 @@ +/** + * Takes care of loading guides. + */ +Ext.define("Docs.Guides", { + singleton: true, + + /** + * Loads guide with given name. + * + * @param {String} name name of the guide + * @param {Boolean} noHistory true to not add browser history entry + */ + load: function(name, noHistory) { + noHistory || Docs.History.push("/guide/" + name); + + Ext.data.JsonP.request({ + url: Docs.App.getBaseUrl() + "/guides/" + name + "/README.js", + callbackName: name, + success: function(json) { + this.render(json.guide); + }, + scope: this + }); + }, + + render: function(html) { + Ext.get("api-guide").update(html); + this.syntaxHighlight(); + }, + + // Marks all code blocks with "prettyprint" class and then calls + // the prettify library function to highlight them. + syntaxHighlight: function() { + Ext.Array.forEach(Ext.query("pre > code"), function(el) { + Ext.get(el).addCls("prettyprint"); + }); + prettyPrint(); + } +});