|
85 | 85 | return {html: lines.join('\n'), hilite: lineNo.join(',') }; |
86 | 86 | }; |
87 | 87 |
|
| 88 | + var HTML_TPL = |
| 89 | + '<a ng:init="showInstructions = {show}" ng:show="!showInstructions" ng:click="showInstructions = true" href>Show Instructions</a>' + |
| 90 | + '<div ng:controller="TutorialInstructionsCtrl" ng:show="showInstructions">' + |
| 91 | + '<div class="tabs-nav">' + |
| 92 | + '<ul>' + |
| 93 | + '</ul>' + |
| 94 | + '</div>' + |
| 95 | + '<div class="tabs-content"><div class="tabs-content-inner">' + |
| 96 | + |
| 97 | + '</div></div>' + |
| 98 | + '</div>'; |
| 99 | + |
| 100 | + var HTML_NAV = '<li ng:class="currentCls(\'{id}\')"><a ng:click="select(\'{id}\')" href>{title}</a></li>'; |
| 101 | + var HTML_CONTENT = '<div ng:show="selected==\'{id}\'">{content}</div>'; |
| 102 | + |
| 103 | + var DEFAULT_NAV = |
| 104 | + '<li ng:class="currentCls(\'git-mac\')"><a ng:click="select(\'git-mac\')" href>Git on Mac/Linux</a></li>' + |
| 105 | + '<li ng:class="currentCls(\'git-win\')"><a ng:click="select(\'git-win\')" href>Git on Windows</a></li>' + |
| 106 | + '<li ng:class="currentCls(\'ss-mac\')"><a ng:click="select(\'ss-mac\')" href>Snapshots on Mac/Linux</a></li>' + |
| 107 | + '<li ng:class="currentCls(\'ss-win\')"><a ng:click="select(\'ss-win\')" href>Snapshots on Windows</a></li>'; |
| 108 | + |
| 109 | + var DEFAULT_CONTENT = |
| 110 | + '<div ng:show="selected==\'git-mac\'">' + |
| 111 | + '<ol>' + |
| 112 | + '<li><p>Reset the workspace to step {step}.</p>' + |
| 113 | + '<pre><code> git checkout -f step-{step}</code></pre></li>' + |
| 114 | + '<li><p>Refresh your browser or check the app out on <a href="http://angular.github.com/angular-phonecat/step-{step}/app">anglar\'s server</a>.</p></li>' + |
| 115 | + '</ol>' + |
| 116 | + '</div>' + |
| 117 | + |
| 118 | + '<div ng:show="selected==\'git-win\'">' + |
| 119 | + '<ol>' + |
| 120 | + '<li><p>Reset the workspace to step {step}.</p>' + |
| 121 | + '<pre><code> git checkout -f step-{step}</code></pre></li>' + |
| 122 | + '<li><p>Refresh your browser or check the app out on <a href="http://angular.github.com/angular-phonecat/step-{step}/app">anglar\'s server</a>.</p></li>' + |
| 123 | + '</ol>' + |
| 124 | + '</div>' + |
| 125 | + |
| 126 | + '<div ng:show="selected==\'ss-mac\'">' + |
| 127 | + '<ol>' + |
| 128 | + '<li><p>Reset the workspace to step {step}.</p>' + |
| 129 | + '<pre><code> ./goto_step.sh {step}</code></pre></li>' + |
| 130 | + '<li><p>Refresh your browser or check the app out on <a href="http://angular.github.com/angular-phonecat/step-{step}/app">anglar\'s server</a>.</p></li>' + |
| 131 | + '</ol>' + |
| 132 | + '</div>' + |
| 133 | + |
| 134 | + '<div ng:show="selected==\'ss-win\'">' + |
| 135 | + '<ol>' + |
| 136 | + '<li><p>Reset the workspace to step {step}.</p>' + |
| 137 | + '<pre><code> ./goto_step.bat {step}</code></pre></li>' + |
| 138 | + '<li><p>Refresh your browser or check the app out on <a href="http://angular.github.com/angular-phonecat/step-{step}/app">anglar\'s server</a>.</p></li>' + |
| 139 | + '</ol>' + |
| 140 | + '</div>'; |
| 141 | + |
| 142 | + angular.widget('doc:tutorial-instructions', function(element) { |
| 143 | + element.hide(); |
| 144 | + this.descend(true); |
| 145 | + |
| 146 | + var tabs = angular.element(HTML_TPL.replace('{show}', element.attr('show') || 'false')), |
| 147 | + nav = tabs.find('.tabs-nav ul'), |
| 148 | + content = tabs.find('.tabs-content-inner'), |
| 149 | + children = element.children(); |
| 150 | + |
| 151 | + if (children.length) { |
| 152 | + // load custom content |
| 153 | + angular.forEach(element.children(), function(elm) { |
| 154 | + var elm = angular.element(elm), |
| 155 | + id = elm.attr('id'); |
| 156 | + |
| 157 | + nav.append(HTML_NAV.replace('{title}', elm.attr('title')).replace(/\{id\}/g, id)); |
| 158 | + content.append(HTML_CONTENT.replace('{id}', id).replace('{content}', elm.html())); |
| 159 | + }); |
| 160 | + } else { |
| 161 | + // default |
| 162 | + nav.append(DEFAULT_NAV); |
| 163 | + content.append(DEFAULT_CONTENT.replace(/\{step\}/g, element.attr('step'))); |
| 164 | + } |
| 165 | + |
| 166 | + element.html(''); |
| 167 | + element.append(tabs); |
| 168 | + element.show(); |
| 169 | + }); |
88 | 170 | })(); |
0 commit comments