var docsApp = { controller: {}, directive: {}, serviceFactory: {} }; docsApp.directive.focused = function($timeout) { return function(scope, element, attrs) { element[0].focus(); element.bind('focus', function() { scope.$apply(attrs.focused + '=true'); }); element.bind('blur', function() { // have to use $timeout, so that we close the drop-down after the user clicks, // otherwise when the user clicks we process the closing before we process the click. $timeout(function() { scope.$eval(attrs.focused + '=false'); }); }); scope.$eval(attrs.focused + '=true') } }; docsApp.directive.code = function() { return { restrict:'E', terminal: true }; }; docsApp.directive.sourceEdit = function(getEmbeddedTemplate) { return { template: '\n', scope: true, controller: function($scope, $attrs, openJsFiddle) { var sources = { module: $attrs.sourceEdit, deps: read($attrs.sourceEditDeps), html: read($attrs.sourceEditHtml), css: read($attrs.sourceEditCss), js: read($attrs.sourceEditJs), unit: read($attrs.sourceEditUnit), scenario: read($attrs.sourceEditScenario) }; $scope.fiddle = function(e) { e.stopPropagation(); openJsFiddle(sources); } } } function read(text) { var files = []; angular.forEach(text ? text.split(' ') : [], function(refId) { files.push({name: refId.split('-')[0], content: getEmbeddedTemplate(refId)}); }); return files; } }; docsApp.directive.docTutorialNav = function(templateMerge) { var pages = [ '', 'step_00', 'step_01', 'step_02', 'step_03', 'step_04', 'step_05', 'step_06', 'step_07', 'step_08', 'step_09', 'step_10', 'step_11', 'the_end' ]; return { compile: function(element, attrs) { var seq = 1 * attrs.docTutorialNav, props = { seq: seq, prev: pages[seq], next: pages[2 + seq], diffLo: seq ? (seq - 1): '0~1', diffHi: seq }; element.addClass('btn-group'); element.addClass('tutorial-nav'); element.append(templateMerge( '
Reset the workspace to step ' + step + '.
' + '' + command + '
Refresh your browser or check the app out on angular\'s server.