diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2016-01-28 16:30:12 +0100 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2016-01-28 16:30:12 +0100 |
commit | be83a8f382cf2fea98161bfd6d51719aacbf9aa9 (patch) | |
tree | 3fb02337f8d7d308ef7ca7818ecc3d3a6ee05d88 /afm-client/bower_components/foundation-apps/js/angular/vendor | |
parent | 1a4ed39bf86b2115eb0f1387d1e988462b492776 (diff) |
Update JSON API
Diffstat (limited to 'afm-client/bower_components/foundation-apps/js/angular/vendor')
-rw-r--r-- | afm-client/bower_components/foundation-apps/js/angular/vendor/markdown.js | 10 | ||||
-rwxr-xr-x | afm-client/bower_components/foundation-apps/js/angular/vendor/svgDirs.js | 101 |
2 files changed, 111 insertions, 0 deletions
diff --git a/afm-client/bower_components/foundation-apps/js/angular/vendor/markdown.js b/afm-client/bower_components/foundation-apps/js/angular/vendor/markdown.js new file mode 100644 index 0000000..d0dd9d6 --- /dev/null +++ b/afm-client/bower_components/foundation-apps/js/angular/vendor/markdown.js @@ -0,0 +1,10 @@ +angular.module('markdown', []) + .directive('markdown', function() { + return { + restrict: 'A', + link: function(scope, element, attrs, controller) { + element.html(marked(element.html())); + } + }; + +}); diff --git a/afm-client/bower_components/foundation-apps/js/angular/vendor/svgDirs.js b/afm-client/bower_components/foundation-apps/js/angular/vendor/svgDirs.js new file mode 100755 index 0000000..c07c883 --- /dev/null +++ b/afm-client/bower_components/foundation-apps/js/angular/vendor/svgDirs.js @@ -0,0 +1,101 @@ +'use strict'; + +(function(){ + var svgDirectives = {}; + + angular.forEach([ + 'clipPath', + 'colorProfile', + 'src', + 'cursor', + 'fill', + 'filter', + 'marker', + 'markerStart', + 'markerMid', + 'markerEnd', + 'mask', + 'stroke' + ], + function(attr) { + svgDirectives[attr] = [ + '$rootScope', + '$location', + '$interpolate', + '$sniffer', + 'urlResolve', + 'computeSVGAttrValue', + 'svgAttrExpressions', + function( + $rootScope, + $location, + $interpolate, + $sniffer, + urlResolve, + computeSVGAttrValue, + svgAttrExpressions) { + return { + restrict: 'A', + link: function(scope, element, attrs) { + var initialUrl; + + //Only apply to svg elements to avoid unnecessary observing + //Check that is in html5Mode and that history is supported + if ((!svgAttrExpressions.SVG_ELEMENT.test(element[0] && + element[0].toString())) || + !$location.$$html5 || + !$sniffer.history) return; + + //Assumes no expressions, since svg is unforgiving of xml violations + initialUrl = attrs[attr]; + attrs.$observe(attr, updateValue); + $rootScope.$on('$locationChangeSuccess', updateValue); + + function updateValue () { + var newVal = computeSVGAttrValue(initialUrl); + //Prevent recursive updating + if (newVal && attrs[attr] !== newVal) attrs.$set(attr, newVal); + } + } + }; + }]; + }); + + angular.module('ngSVGAttributes', []). + factory('urlResolve', [function() { + //Duplicate of urlResolve & urlParsingNode in angular core + var urlParsingNode = document.createElement('a'); + return function urlResolve(url) { + urlParsingNode.setAttribute('href', url); + return urlParsingNode; + }; + }]). + value('svgAttrExpressions', { + FUNC_URI: /^url\((.*)\)$/, + SVG_ELEMENT: /SVG[a-zA-Z]*Element/, + HASH_PART: /#.*/ + }). + factory('computeSVGAttrValue', [ + '$location', '$sniffer', 'svgAttrExpressions', 'urlResolve', + function($location, $sniffer, svgAttrExpressions, urlResolve) { + return function computeSVGAttrValue(url) { + var match, fullUrl; + if (match = svgAttrExpressions.FUNC_URI.exec(url)) { + //hash in html5Mode, forces to be relative to current url instead of base + if (match[1].indexOf('#') === 0) { + fullUrl = $location.absUrl(). + replace(svgAttrExpressions.HASH_PART, '') + + match[1]; + } + //Presumably links to external SVG document + else { + fullUrl = urlResolve(match[1]); + } + } + return fullUrl ? 'url(' + fullUrl + ')' : null; + }; + } + ] + ). + directive(svgDirectives); +}()); |