(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' + ' \n' + '_HTML_SOURCE_\n' + ' \n' + ''; angular.widget('doc:example', function(element){ this.descend(true); //compile the example code //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 exampleSrc = example.text(), jsfiddle = example.attr('jsfiddle') || true, scenario = element.find('pre').eq(1); //doc-scenario var code = indent(exampleSrc); var tabHtml = ''; var tabs = angular.element(tabHtml); tabs.find('li').eq(1).find('pre').text(HTML_TEMPLATE.replace('_HTML_SOURCE_', code.html)); element.html(''); element.append(tabs); var script = (exampleSrc.match(/]*>([\s\S]*)<\/script>/) || [])[1] || ''; try { window.eval(script); } catch (e) { alert(e); } function jsFiddleButton(jsfiddle) { if (jsfiddle !== 'false') { if(jsfiddle == true) { //dynamically generate a fiddle var fiddleUrl = 'http://jsfiddle.net/api/post/library/pure/', fiddleSrc = exampleSrc, stripIndent = fiddleSrc.match(/^(\s*)/)[1].length; //escape closing textarea fiddleSrc = fiddleSrc.replace(/<\/textarea>/gi,'</textarea>') //strip extra indentation fiddleSrc = fiddleSrc.replace(new RegExp('^\\s{' + stripIndent + '}', 'gm'), ''); return '
' + '' + '' + '' + '' + '
'; } else { //use existing fiddle fiddleUrl = "http://jsfiddle.net" + jsfiddle; return '
' + '' + '
'; } } return ''; } }); function indent(text) { if (!text) return text; var lines = text.split(/\r?\n/); var lineNo = []; // 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 ( var 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 ( var i = 0; i < lines.length; i++) { lines[i] = ' ' + lines[i].substring(minIndent); lineNo.push(5 + i); } return {html: lines.join('\n'), hilite: lineNo.join(',') }; }; 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) { element.hide(); 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) { var elm = angular.element(elm), 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); element.show(); }); 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; } }); })(); a> 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274