(function() { var angularJsUrl; var scripts = document.getElementsByTagName("script"); var angularJsRegex = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/; for(var j = 0; j < scripts.length; j++) { var src = scripts[j].src; if (src && src.match(angularJsRegex)) { angularJsUrl = src.replace('docs.angularjs.org', 'code.angularjs.org'); continue; } } var HTML_TEMPLATE = '\n' + '\n' + ' \n' + '_SCRIPT_SOURCE_' + ' \n' + '_HTML_SOURCE_\n' + ' \n' + ''; angular.widget('doc:example', ['$injector', '$element', function($injector, element){ this.descend(true); //compile the example code var module = element.attr('module') || ''; //jQuery find() methods in this widget contain primitive selectors on purpose so that we can use //jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName! var example = element.find('pre').eq(0), //doc-source scriptSrc = '', htmlSrc = example.text().replace(/]*>([\s\S]+)<\/script>/im, function(_, script) { scriptSrc = script; return ''; }), showSource = example.attr('source') !== 'false', jsfiddle = example.attr('jsfiddle') || true, scenario = element.find('pre').eq(1); //doc-scenario var tabHtml = ''; var tabs = angular.element(tabHtml); tabs.find('li').eq(1).find('pre').text( HTML_TEMPLATE. replace('_SCRIPT_SOURCE_', scriptSrc ? ' \n' : ''). replace('_HTML_SOURCE_', indent(htmlSrc, ' ')). replace('_MODULE_', module ? '="' + module + '"' : '')); element.html(''); element.append(tabs); try { if (window.execScript) { // IE window.execScript(scriptSrc || '"stupid IE!"'); // IE complains when evaling empty string } else { window.eval(scriptSrc); } } catch (e) { alert(e); } if (module) { $injector.invoke(null, angular.module[module]); } function jsFiddleButton(jsfiddle) { var fixJsFiddleIssue132 = true; if (jsfiddle !== 'false') { if(jsfiddle === true) { //dynamically generate a fiddle var fiddleUrl = 'http://jsfiddle.net/api/post/library/pure/'; function jsFiddleEscape(text, prefix) { return indent(text.replace(/<\/textarea>/gi,'</textarea>'), prefix); } return '
' + (fixJsFiddleIssue132 ? '' : '') + '' + '' + '' + '' + '' + '
'; } else { //use existing fiddle fiddleUrl = "http://jsfiddle.net" + jsfiddle; return '
' + '' + '
'; } } return ''; } }]); function indent(text, prefix) { prefix = prefix || ''; if (!text) return text; var lines = text.split(/\r?\n/); var i; // remove any leading blank lines while (lines[0].match(/^\s*$/)) lines.shift(); // remove any trailing blank lines while (lines[lines.length - 1].match(/^\s*$/)) lines.pop(); var minIndent = 999; for (i = 0; i < lines.length; i++) { var line = lines[0]; var indent = line.match(/^\s*/)[0]; if (indent !== line && indent.length < minIndent) { minIndent = indent.length; } } for (i = 0; i < lines.length; i++) { lines[i] = prefix + lines[i].substring(minIndent); } return lines.join('\n'); } var HTML_TPL = '

Workspace Reset Instructions  ➤

' + '
' + '
' + '
    ' + '
' + '
' + '
' + '
' + '
'; var HTML_NAV = '
  • {title}
  • '; var HTML_CONTENT = '
    {content}
    '; var DEFAULT_NAV = '
  • Git on Mac/Linux
  • ' + '
  • Git on Windows
  • ' + '
  • Snapshots on Mac/Linux
  • ' + '
  • Snapshots on Windows
  • '; var DEFAULT_CONTENT = '
    ' + '
      ' + '
    1. Reset the workspace to step {step}.

      ' + '
       git checkout -f step-{step}
    2. ' + '
    3. Refresh your browser or check the app out on angular\'s server.

    4. ' + '
    ' + '
    ' + '
    ' + '
      ' + '
    1. Reset the workspace to step {step}.

      ' + '
       git checkout -f step-{step}
    2. ' + '
    3. Refresh your browser or check the app out on angular\'s server.

    4. ' + '
    ' + '
    ' + '
    ' + '
      ' + '
    1. Reset the workspace to step {step}.

      ' + '
       ./goto_step.sh {step}
    2. ' + '
    3. Refresh your browser or check the app out on angular\'s server.

    4. ' + '
    ' + '
    ' + '
    ' + '
      ' + '
    1. Reset the workspace to step {step}.

      ' + '
       ./goto_step.bat {step}
    2. ' + '
    3. Refresh your browser or check the app out on angular\'s server.

    4. ' + '
    ' + '
    '; angular.widget('doc:tutorial-instructions', function(element) { this.descend(true); var tabs = angular.element(HTML_TPL.replace('{show}', element.attr('show') || 'false')), nav = tabs.find('ul'), // use simple selectors because jqLite find() supports getElementsByTagName only content = tabs.find('div').find('div'), children = element.children(); if (children.length) { // load custom content angular.forEach(element.children(), function(elm) { elm = angular.element(elm); var id = elm.attr('id'); nav.append(HTML_NAV.replace('{title}', elm.attr('title')).replace(/\{id\}/g, id)); content.append(HTML_CONTENT.replace('{id}', id).replace('{content}', elm.html())); }); } else { // default nav.append(DEFAULT_NAV); content.append(DEFAULT_CONTENT.replace(/\{step\}/g, element.attr('step'))); } element.html(''); element.append(tabs); }); angular.directive('doc:tutorial-nav', function(step) { return function(element) { var prevStep, codeDiff, nextStep, content; step = parseInt(step, 10); if (step === 0) { prevStep = ''; nextStep = 'step_01'; codeDiff = 'step-0~7...step-0'; } else if (step === 11){ prevStep = 'step_10'; nextStep = 'the_end'; codeDiff = 'step-10...step-11'; } else { prevStep = 'step_' + pad(step - 1); nextStep = 'step_' + pad(step + 1); codeDiff = 'step-' + step + '...step-' + step; } content = angular.element( '
  • Previous
  • ' + '
  • Live Demo
  • ' + '
  • Code Diff
  • ' + '
  • Next
  • ' ); element.attr('id', 'tutorial-nav'); element.append(content); }; function pad(step) { return (step < 10) ? ('0' + step) : step; } }); })();