refactor(docs-app): move `bold` directive out of the app controller file

This commit is contained in:
Peter Bacon Darwin 2015-12-10 13:04:00 +00:00 committed by Naomi Black
parent 72e6a79126
commit b298b9c1af
3 changed files with 22 additions and 22 deletions

View File

@ -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');
<!-- Google Feedback -->
script(src="//www.gstatic.com/feedback/api.js" type="text/javascript")

View File

@ -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'), '<b>$&</b>');
});
html = html.replace(/\n/g, '<br>');
html = html.replace(/ /g, '&nbsp;');
element.html(html);
});
}
});
angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', function ($mdDialog, $timeout, $http, $sce) {
var vm = this;

View File

@ -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'), '<b>$&</b>');
});
html = html.replace(/\n/g, '<br>');
html = html.replace(/ /g, '&nbsp;');
element.html(html);
});
}
});