From b298b9c1af3fb78f57d97aede985427406027800 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Thu, 10 Dec 2015 13:04:00 +0000 Subject: [PATCH] refactor(docs-app): move `bold` directive out of the app controller file --- public/_includes/_scripts-include.jade | 3 ++- .../js/controllers/app-controller.js | 21 ------------------- public/resources/js/directives/bold.js | 20 ++++++++++++++++++ 3 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 public/resources/js/directives/bold.js diff --git a/public/_includes/_scripts-include.jade b/public/_includes/_scripts-include.jade index 8ee174929c..1e0a30a173 100644 --- a/public/_includes/_scripts-include.jade +++ b/public/_includes/_scripts-include.jade @@ -18,6 +18,7 @@ script(src="/resources/js/site.js") script(src="/resources/js/controllers/app-controller.js") script(src="/resources/js/directives/cheatsheet.js") script(src="/resources/js/directives/bio.js") +script(src="/resources/js/directives/bold.js") script(src="/resources/js/directives/code.js") script(src="/resources/js/directives/code-tabs.js") script(src="/resources/js/directives/code-pane.js") @@ -44,7 +45,7 @@ if current.path[0] == "docs" })(window,document,'script','//s.swiftypecdn.com/install/v1/st.js','_st'); _st('install','VsuU7kH5Hnnj9tfyNvfK'); - + script(src="//www.gstatic.com/feedback/api.js" type="text/javascript") diff --git a/public/resources/js/controllers/app-controller.js b/public/resources/js/controllers/app-controller.js index bdb19f9ba0..6d5770be5f 100644 --- a/public/resources/js/controllers/app-controller.js +++ b/public/resources/js/controllers/app-controller.js @@ -3,27 +3,6 @@ * */ -angularIO.directive('bold', function ($timeout) { - return { - scope: { bold: '=bold' }, - link: postLink - }; - function postLink (scope, element) { - var bold = typeof scope.bold === 'string' - ? [ scope.bold ] - : scope.bold; - $timeout(function () { - var html = element.html(); - angular.forEach(bold, function (bold) { - html = html.replace(new RegExp(bold.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), 'g'), '$&'); - }); - html = html.replace(/\n/g, '
'); - html = html.replace(/ /g, ' '); - element.html(html); - }); - } -}); - angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', function ($mdDialog, $timeout, $http, $sce) { var vm = this; diff --git a/public/resources/js/directives/bold.js b/public/resources/js/directives/bold.js new file mode 100644 index 0000000000..bf271c3a64 --- /dev/null +++ b/public/resources/js/directives/bold.js @@ -0,0 +1,20 @@ +angularIO.directive('bold', function ($timeout) { + return { + scope: { bold: '=bold' }, + link: postLink + }; + function postLink (scope, element) { + var bold = typeof scope.bold === 'string' + ? [ scope.bold ] + : scope.bold; + $timeout(function () { + var html = element.html(); + angular.forEach(bold, function (bold) { + html = html.replace(new RegExp(bold.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), 'g'), '$&'); + }); + html = html.replace(/\n/g, '
'); + html = html.replace(/ /g, ' '); + element.html(html); + }); + } +}); \ No newline at end of file