aboutsummaryrefslogtreecommitdiffstats
path: root/docs/doc_widgets.js
diff options
context:
space:
mode:
authorMisko Hevery2010-12-23 00:44:27 +0100
committerMisko Hevery2011-01-10 11:50:11 -0800
commit4f22d6866c052fb5b770ce4f377cecacacd9e6d8 (patch)
tree6bdb1c5eb70cfd7e6bcf143c121c53025a0489a4 /docs/doc_widgets.js
parentaab3df7aeaf79908e8b6212288b283adb42b1ce6 (diff)
downloadangular.js-4f22d6866c052fb5b770ce4f377cecacacd9e6d8.tar.bz2
complete rewrite of documentation generation
- romeved mustache.js - unified templates - improved testability of the code
Diffstat (limited to 'docs/doc_widgets.js')
-rw-r--r--docs/doc_widgets.js71
1 files changed, 0 insertions, 71 deletions
diff --git a/docs/doc_widgets.js b/docs/doc_widgets.js
deleted file mode 100644
index b119e326..00000000
--- a/docs/doc_widgets.js
+++ /dev/null
@@ -1,71 +0,0 @@
-(function(){
-
- var angularJsUrl;
- var scripts = document.getElementsByTagName("script");
- var filename = /(.*\/)angular([^\/]*)/;
- for(var j = 0; j < scripts.length; j++) {
- var src = scripts[j].src;
- if (src && src.match(filename)) {
- angularJsUrl = src;
- }
- }
-
-
- var HTML_TEMPLATE =
- '<!doctype html>\n' +
- '<html xmlns:ng="http://angularjs.org">\n' +
- ' <script type="text/javascript" ng:autobind\n' +
- ' src="' + angularJsUrl + '"></script>\n' +
- ' <body>\n' +
- '_HTML_SOURCE_\n' +
- ' </body>\n' +
- '</html>';
-
- angular.widget('doc:example', function(element){
- this.descend(true); //compile the example code
- element.hide();
-
- var example = element.find('doc\\:source').eq(0),
- exampleSrc = example.text(),
- scenario = element.find('doc\\:scenario').eq(0);
-
- var code = indent(exampleSrc);
- var tabs = angular.element(
- '<ul class="doc-example">' +
- '<li class="doc-example-heading"><h3>Source</h3></li>' +
- '<li class="doc-example-source" ng:non-bindable>' +
- '<pre class="brush: js; html-script: true; highlight: [' +
- code.hilite + ']; toolbar: false;"></pre></li>' +
- '<li class="doc-example-heading"><h3>Live Preview</h3></li>' +
- '<li class="doc-example-live">' + exampleSrc +'</li>' +
- '<li class="doc-example-heading"><h3>Scenario Test</h3></li>' +
- '<li class="doc-example-scenario"><pre class="brush: js">' + scenario.text() + '</pre></li>' +
- '</ul>');
-
- tabs.find('li.doc-example-source > pre').text(HTML_TEMPLATE.replace('_HTML_SOURCE_', code.html));
-
- element.html('');
- element.append(tabs);
- element.show();
-
- var script = (exampleSrc.match(/<script[^\>]*>([\s\S]*)<\/script>/) || [])[1] || '';
- try {
- eval(script);
- } catch (e) {
- alert(e);
- }
- });
-
- function indent(text) {
- var lines = text.split(/\n/);
- var lineNo = [];
- while (lines[0].match(/^\s*$/)) lines.shift();
- while (lines[lines.length - 1].match(/^\s*$/)) lines.pop();
- for ( var i = 0; i < lines.length; i++) {
- lines[i] = ' ' + lines[i];
- lineNo.push(6 + i);
- }
- return {html: lines.join('\n'), hilite: lineNo.join(',') };
- };
-
-})(); \ No newline at end of file