diff options
| author | Matias Niemelä | 2013-05-09 15:58:34 -0400 |
|---|---|---|
| committer | Misko Hevery | 2013-05-13 16:55:14 -0700 |
| commit | c8197b44eb0b4d49acda142f4179876732e1c751 (patch) | |
| tree | 8cb855da7edb2b49649c1436e1263bd40d8b2ff7 /src/bootstrap | |
| parent | b6e5972eb371412d99fc50def000f3afab5bec79 (diff) | |
| download | angular.js-c8197b44eb0b4d49acda142f4179876732e1c751.tar.bz2 | |
feat(ngdocs): external links to github, plunkr and jsfiddle available for code examples
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bootstrap.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/bootstrap/bootstrap.js b/src/bootstrap/bootstrap.js index c9719b0c..91d6590e 100644 --- a/src/bootstrap/bootstrap.js +++ b/src/bootstrap/bootstrap.js @@ -48,6 +48,48 @@ directive.dropdownToggle = }; }]; +directive.syntax = function() { + return { + restrict: 'A', + link: function(scope, element, attrs) { + function makeLink(type, text, link, icon) { + return '<a href="' + link + '" class="btn syntax-' + type + '" target="_blank" rel="nofollow">' + + '<span class="' + icon + '"></span> ' + text + + '</a>'; + }; + var html = '<nav class="syntax-links">'; + var types = { + 'github' : { + text : 'View on Github', + key : 'syntaxGithub', + icon : 'icon-github' + }, + 'plunkr' : { + text : 'View on Plunkr', + key : 'syntaxPlunkr', + icon : 'icon-arrow-down' + }, + 'jsfiddle' : { + text : 'View on JSFiddle', + key : 'syntaxFiddle', + icon : 'icon-cloud' + } + }; + for(var type in types) { + var data = types[type]; + var link = attrs[data.key]; + if(link) { + html += makeLink(type, data.text, link, data.icon); + } + }; + html += '</nav>'; + var nav = angular.element(html); + var node = element[0]; + var par = node.parentNode; + par.insertBefore(nav[0], node); + } + } +} directive.tabbable = function() { return { |
