Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-downloadsvg-directive

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-downloadsvg-directive - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

441

angular-downloadsvg-directive.js

@@ -16,113 +16,105 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

angular.module('hc.downloader', [])
.factory('svgDownload', ['$log', function($log) {
.factory('svgDownload', ['$log', function ($log) {
var svgSaver = new SvgSaver();
var svgSaver = new SvgSaver();
return function (el) {
if (angular.isString(el) && el.charAt(0) !== '<') {
el = document.querySelector(el);
}
return function(el) {
var svg = angular.element(el);
if (angular.isString(el) && el.charAt(0) != '<') {
el = document.querySelector(el);
}
if (svg.prop('tagName') !== 'svg') {
svg = svg.find('svg');
}
var svg = angular.element(el);
if (svg.length < 1) {
$log.warn('svgDownload Error: Element ' + el + ' not found');
return null;
}
if (svg.prop('tagName') !== 'svg') {
svg = svg.find('svg');
}
return {
getHtml: function () { return svgSaver.getHTML(svg[0]); },
getBlob: function () { return svgSaver.getBlob(svg[0]); },
asSvg: function (filename) { return svgSaver.asSvg(svg[0], filename); },
asPng: function (filename) { return svgSaver.asPng(svg[0], filename); }
};
};
}])
if (svg.length < 1) {
$log.warn('svgDownload Error: Element ' + el + ' not found');
return null;
}
/**
* @ngdoc directive
* @name hc.downloader.directive:svgDownload
* @restrict A
* @element button
*
* @description
* AngularJS directive to download an SVG element as an SVG file.
*
* @param {string} svg-download The source element to download. If blank uses the first svg in the body.
* @param {string=} filename Name of resaulting svg file. If blank uses title or 'untitled.svg'
* @param {string} [type='svg'] Type of file to download (svg or png)
*
* @example
return {
getHtml: function() { return svgSaver.getHTML(svg[0]); },
getBlob: function() { return svgSaver.getBlob(svg[0]); },
asSvg: function(filename) { return svgSaver.asSvg(svg[0],filename); },
asPng: function(filename) { return svgSaver.asPng(svg[0],filename); }
};
## A simple example
};
<example module="hc.downloader">
<file name="example.html">
<div ng-include="'octocat.html'"></div>
<button svg-download title="mysvg">Download as SVG</button>
<button svg-download title="mysvg" type="png">Download as PNG</button>
<small class="pull-right">Source: <a href="https://gist.github.com/johan/1007813">https://gist.github.com/johan/1007813</a></small>
</file>
<file name="octocat.html">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.2 -1 379 334">
<path id="puddle" d="m296.94 295.43c0 20.533-47.56 37.176-106.22 37.176-58.67 0-106.23-16.643-106.23-37.176s47.558-37.18 106.23-37.18c58.66 0 106.22 16.65 106.22 37.18z"/>
<g id="shadow-legs">
<path d="m161.85 331.22v-26.5c0-3.422-.619-6.284-1.653-8.701 6.853 5.322 7.316 18.695 7.316 18.695v17.004c6.166.481 12.534.773 19.053.861l-.172-16.92c-.944-23.13-20.769-25.961-20.769-25.961-7.245-1.645-7.137 1.991-6.409 4.34-7.108-12.122-26.158-10.556-26.158-10.556-6.611 2.357-.475 6.607-.475 6.607 10.387 3.775 11.33 15.105 11.33 15.105v23.622c5.72.98 11.71 1.79 17.94 2.4z"/>
<path d="m245.4 283.48s-19.053-1.566-26.16 10.559c.728-2.35.839-5.989-6.408-4.343 0 0-19.824 2.832-20.768 25.961l-.174 16.946c6.509-.025 12.876-.254 19.054-.671v-17.219s.465-13.373 7.316-18.695c-1.034 2.417-1.653 5.278-1.653 8.701v26.775c6.214-.544 12.211-1.279 17.937-2.188v-24.113s.944-11.33 11.33-15.105c0-.01 6.13-4.26-.48-6.62z"/>
</g>
<path id="cat" d="m378.18 141.32l.28-1.389c-31.162-6.231-63.141-6.294-82.487-5.49 3.178-11.451 4.134-24.627 4.134-39.32 0-21.073-7.917-37.931-20.77-50.759 2.246-7.25 5.246-23.351-2.996-43.963 0 0-14.541-4.617-47.431 17.396-12.884-3.22-26.596-4.81-40.328-4.81-15.109 0-30.376 1.924-44.615 5.83-33.94-23.154-48.923-18.411-48.923-18.411-9.78 24.457-3.733 42.566-1.896 47.063-11.495 12.406-18.513 28.243-18.513 47.659 0 14.658 1.669 27.808 5.745 39.237-19.511-.71-50.323-.437-80.373 5.572l.276 1.389c30.231-6.046 61.237-6.256 80.629-5.522.898 2.366 1.899 4.661 3.021 6.879-19.177.618-51.922 3.062-83.303 11.915l.387 1.36c31.629-8.918 64.658-11.301 83.649-11.882 11.458 21.358 34.048 35.152 74.236 39.484-5.704 3.833-11.523 10.349-13.881 21.374-7.773 3.718-32.379 12.793-47.142-12.599 0 0-8.264-15.109-24.082-16.292 0 0-15.344-.235-1.059 9.562 0 0 10.267 4.838 17.351 23.019 0 0 9.241 31.01 53.835 21.061v32.032s-.943 11.33-11.33 15.105c0 0-6.137 4.249.475 6.606 0 0 28.792 2.361 28.792-21.238v-34.929s-1.142-13.852 5.663-18.667v57.371s-.47 13.688-7.551 18.881c0 0-4.723 8.494 5.663 6.137 0 0 19.824-2.832 20.769-25.961l.449-58.06h4.765l.453 58.06c.943 23.129 20.768 25.961 20.768 25.961 10.383 2.357 5.663-6.137 5.663-6.137-7.08-5.193-7.551-18.881-7.551-18.881v-56.876c6.801 5.296 5.663 18.171 5.663 18.171v34.929c0 23.6 28.793 21.238 28.793 21.238 6.606-2.357.474-6.606.474-6.606-10.386-3.775-11.33-15.105-11.33-15.105v-45.786c0-17.854-7.518-27.309-14.87-32.3 42.859-4.25 63.426-18.089 72.903-39.591 18.773.516 52.557 2.803 84.873 11.919l.384-1.36c-32.131-9.063-65.692-11.408-84.655-11.96.898-2.172 1.682-4.431 2.378-6.755 19.25-.80 51.38-.79 82.66 5.46z"/>
<path id="face" d="m258.19 94.132c9.231 8.363 14.631 18.462 14.631 29.343 0 50.804-37.872 52.181-84.585 52.181-46.721 0-84.589-7.035-84.589-52.181 0-10.809 5.324-20.845 14.441-29.174 15.208-13.881 40.946-6.531 70.147-6.531 29.07-.004 54.72-7.429 69.95 6.357z"/>
<path id="eyes" d="m160.1 126.06 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z m94.43 0 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z"/>
<g id="face-features">
<path id="pupils" d="m154.46 126.38 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z m94.42 0 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z"/>
<circle id="nose" cx="188.5" cy="148.56" r="4.401"/>
<path id="mouth" d="m178.23 159.69c-.26-.738.128-1.545.861-1.805.737-.26 1.546.128 1.805.861 1.134 3.198 4.167 5.346 7.551 5.346s6.417-2.147 7.551-5.346c.26-.738 1.067-1.121 1.805-.861s1.121 1.067.862 1.805c-1.529 4.324-5.639 7.229-10.218 7.229s-8.68-2.89-10.21-7.22z"/>
</g>
<path id="octo" d="m80.641 179.82 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m8.5 4.72 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.193 6.14 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m4.72 7.08 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.188 6.61 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m7.09 5.66 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.91 3.78 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.87 0 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m10.01 -1.64 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z"/>
<path id="drop" d="m69.369 186.12l-3.066 10.683s-.8 3.861 2.84 4.546c3.8-.074 3.486-3.627 3.223-4.781z"/>
</svg>
</file>
<file name="octocat.css">
#puddle { fill: #9CDAF1; }
#shadow-legs { fill: #7DBBE6; }
#face { fill: #F4CBB2; }
#eyes { fill: #FFF; }
#face-features { fill: #AD5C51; }
#octo { fill: #C3E4D8; }
#drop { fill: #9CDAF1; }}
</file>
</example>
}])
*/
.directive('svgDownload', ['svgDownload', function (svgDownload) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', download);
/**
* @ngdoc directive
* @name hc.downloader.directive:svgDownload
* @restrict A
* @element button
*
* @description
* AngularJS directive to download an SVG element as an SVG file.
*
* @param {string} svg-download The source element to download. If blank uses the first svg in the body.
* @param {string=} filename Name of resaulting svg file. If blank uses title or 'untitled.svg'
* @param {string} [type='svg'] Type of file to download (svg or png)
*
* @example
function download () {
var ext = attrs.type || 'svg';
var filename = encodeURI(attrs.filename || attrs.title || 'untitled') + '.' + ext;
var svg = svgDownload(attrs.svgDownload || 'body');
if (svg) {
if (ext === 'svg') { svg.asSvg(filename); }
if (ext === 'png') { svg.asPng(filename); }
}
}
}
};
}]);
## A simple example
<example module="hc.downloader">
<file name="example.html">
<div ng-include="'octocat.html'"></div>
<button svg-download title="mysvg">Download as SVG</button>
<button svg-download title="mysvg" type="png">Download as PNG</button>
<small class="pull-right">Source: <a href="https://gist.github.com/johan/1007813">https://gist.github.com/johan/1007813</a></small>
</file>
<file name="octocat.html">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.2 -1 379 334">
<path id="puddle" d="m296.94 295.43c0 20.533-47.56 37.176-106.22 37.176-58.67 0-106.23-16.643-106.23-37.176s47.558-37.18 106.23-37.18c58.66 0 106.22 16.65 106.22 37.18z"/>
<g id="shadow-legs">
<path d="m161.85 331.22v-26.5c0-3.422-.619-6.284-1.653-8.701 6.853 5.322 7.316 18.695 7.316 18.695v17.004c6.166.481 12.534.773 19.053.861l-.172-16.92c-.944-23.13-20.769-25.961-20.769-25.961-7.245-1.645-7.137 1.991-6.409 4.34-7.108-12.122-26.158-10.556-26.158-10.556-6.611 2.357-.475 6.607-.475 6.607 10.387 3.775 11.33 15.105 11.33 15.105v23.622c5.72.98 11.71 1.79 17.94 2.4z"/>
<path d="m245.4 283.48s-19.053-1.566-26.16 10.559c.728-2.35.839-5.989-6.408-4.343 0 0-19.824 2.832-20.768 25.961l-.174 16.946c6.509-.025 12.876-.254 19.054-.671v-17.219s.465-13.373 7.316-18.695c-1.034 2.417-1.653 5.278-1.653 8.701v26.775c6.214-.544 12.211-1.279 17.937-2.188v-24.113s.944-11.33 11.33-15.105c0-.01 6.13-4.26-.48-6.62z"/>
</g>
<path id="cat" d="m378.18 141.32l.28-1.389c-31.162-6.231-63.141-6.294-82.487-5.49 3.178-11.451 4.134-24.627 4.134-39.32 0-21.073-7.917-37.931-20.77-50.759 2.246-7.25 5.246-23.351-2.996-43.963 0 0-14.541-4.617-47.431 17.396-12.884-3.22-26.596-4.81-40.328-4.81-15.109 0-30.376 1.924-44.615 5.83-33.94-23.154-48.923-18.411-48.923-18.411-9.78 24.457-3.733 42.566-1.896 47.063-11.495 12.406-18.513 28.243-18.513 47.659 0 14.658 1.669 27.808 5.745 39.237-19.511-.71-50.323-.437-80.373 5.572l.276 1.389c30.231-6.046 61.237-6.256 80.629-5.522.898 2.366 1.899 4.661 3.021 6.879-19.177.618-51.922 3.062-83.303 11.915l.387 1.36c31.629-8.918 64.658-11.301 83.649-11.882 11.458 21.358 34.048 35.152 74.236 39.484-5.704 3.833-11.523 10.349-13.881 21.374-7.773 3.718-32.379 12.793-47.142-12.599 0 0-8.264-15.109-24.082-16.292 0 0-15.344-.235-1.059 9.562 0 0 10.267 4.838 17.351 23.019 0 0 9.241 31.01 53.835 21.061v32.032s-.943 11.33-11.33 15.105c0 0-6.137 4.249.475 6.606 0 0 28.792 2.361 28.792-21.238v-34.929s-1.142-13.852 5.663-18.667v57.371s-.47 13.688-7.551 18.881c0 0-4.723 8.494 5.663 6.137 0 0 19.824-2.832 20.769-25.961l.449-58.06h4.765l.453 58.06c.943 23.129 20.768 25.961 20.768 25.961 10.383 2.357 5.663-6.137 5.663-6.137-7.08-5.193-7.551-18.881-7.551-18.881v-56.876c6.801 5.296 5.663 18.171 5.663 18.171v34.929c0 23.6 28.793 21.238 28.793 21.238 6.606-2.357.474-6.606.474-6.606-10.386-3.775-11.33-15.105-11.33-15.105v-45.786c0-17.854-7.518-27.309-14.87-32.3 42.859-4.25 63.426-18.089 72.903-39.591 18.773.516 52.557 2.803 84.873 11.919l.384-1.36c-32.131-9.063-65.692-11.408-84.655-11.96.898-2.172 1.682-4.431 2.378-6.755 19.25-.80 51.38-.79 82.66 5.46z"/>
<path id="face" d="m258.19 94.132c9.231 8.363 14.631 18.462 14.631 29.343 0 50.804-37.872 52.181-84.585 52.181-46.721 0-84.589-7.035-84.589-52.181 0-10.809 5.324-20.845 14.441-29.174 15.208-13.881 40.946-6.531 70.147-6.531 29.07-.004 54.72-7.429 69.95 6.357z"/>
<path id="eyes" d="m160.1 126.06 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z m94.43 0 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z"/>
<g id="face-features">
<path id="pupils" d="m154.46 126.38 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z m94.42 0 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z"/>
<circle id="nose" cx="188.5" cy="148.56" r="4.401"/>
<path id="mouth" d="m178.23 159.69c-.26-.738.128-1.545.861-1.805.737-.26 1.546.128 1.805.861 1.134 3.198 4.167 5.346 7.551 5.346s6.417-2.147 7.551-5.346c.26-.738 1.067-1.121 1.805-.861s1.121 1.067.862 1.805c-1.529 4.324-5.639 7.229-10.218 7.229s-8.68-2.89-10.21-7.22z"/>
</g>
<path id="octo" d="m80.641 179.82 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m8.5 4.72 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.193 6.14 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m4.72 7.08 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.188 6.61 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m7.09 5.66 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.91 3.78 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.87 0 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m10.01 -1.64 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z"/>
<path id="drop" d="m69.369 186.12l-3.066 10.683s-.8 3.861 2.84 4.546c3.8-.074 3.486-3.627 3.223-4.781z"/>
</svg>
</file>
<file name="octocat.css">
#puddle { fill: #9CDAF1; }
#shadow-legs { fill: #7DBBE6; }
#face { fill: #F4CBB2; }
#eyes { fill: #FFF; }
#face-features { fill: #AD5C51; }
#octo { fill: #C3E4D8; }
#drop { fill: #9CDAF1; }}
</file>
</example>
*/
.directive('svgDownload', ['svgDownload', function (svgDownload) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', download);
function download(){
var ext = attrs.type || 'svg';
var filename = encodeURI(attrs.filename || attrs.title || 'untitled') + '.' + ext;
var svg = svgDownload(attrs.svgDownload || 'body');
if (svg) {
if(ext === 'svg') { svg.asSvg(filename); }
if(ext === 'png') { svg.asPng(filename); }
}
}
}
};
}]);
},{"svgsaver":2}],2:[function(require,module,exports){
/* Some simple utilities */
'use strict';

@@ -138,2 +130,82 @@

var svgStyles = { // Whitelist of CSS styles and default values
'alignment-baseline': 'auto',
'baseline-shift': 'baseline',
'clip': 'auto',
'clip-path': 'none',
'clip-rule': 'nonzero',
'color': 'rgb(51, 51, 51)',
'color-interpolation': 'srgb',
'color-interpolation-filters': 'linearrgb',
'color-profile': 'auto',
'color-rendering': 'auto',
'cursor': 'auto',
'direction': 'ltr',
'display': 'inline',
'dominant-baseline': 'auto',
'enable-background': '',
'fill': 'rgb(0, 0, 0)',
'fill-opacity': '1',
'fill-rule': 'nonzero',
'filter': 'none',
'flood-color': 'rgb(0, 0, 0)',
'flood-opacity': '1',
'font': '',
'font-family': 'normal',
'font-size': 'medium',
'font-size-adjust': 'auto',
'font-stretch': 'normal',
'font-style': 'normal',
'font-variant': 'normal',
'font-weight': '400',
'glyph-orientation-horizontal': '0deg',
'glyph-orientation-vertical': 'auto',
'image-rendering': 'auto',
'kerning': 'auto',
'letter-spacing': '0',
'lighting-color': 'rgb(255, 255, 255)',
'marker': '',
'marker-end': 'none',
'marker-mid': 'none',
'marker-start': 'none',
'mask': 'none',
'opacity': '1',
'overflow': 'visible',
'paint-order': 'normal',
'pointer-events': 'auto',
'shape-rendering': 'auto',
'stop-color': 'rgb(0, 0, 0)',
'stop-opacity': '1',
'stroke': 'none',
'stroke-dasharray': 'none',
'stroke-dashoffset': '0',
'stroke-linecap': 'butt',
'stroke-linejoin': 'miter',
'stroke-miterlimit': '4',
'stroke-opacity': '1',
'stroke-width': '1',
'text-anchor': 'start',
'text-decoration': 'none',
'text-rendering': 'auto',
'unicode-bidi': 'normal',
'visibility': 'visible',
'word-spacing': '0px',
'writing-mode': 'lr-tb'
};
var svgAttrs = [// white list of attributes
'id', 'xml:base', 'xml:lang', 'xml:space', // Core
'height', 'result', 'width', 'x', 'y', // Primitive
'xlink:href', // Xlink attribute
'style', 'class', 'd', 'pathLength', // Path
'x', 'y', 'dx', 'dy', 'glyphRef', 'format', 'x1', 'y1', 'x2', 'y2', 'rotate', 'textLength', 'cx', 'cy', 'r', 'rx', 'ry', 'fx', 'fy', 'width', 'height', 'refX', 'refY', 'orient', 'markerUnits', 'markerWidth', 'markerHeight', 'maskUnits', 'transform', 'viewBox', 'version', // Container
'preserveAspectRatio', 'xmlns', 'points', // Polygons
'offset'];
// http://www.w3.org/TR/SVG/propidx.html
// via https://github.com/svg/svgo/blob/master/plugins/_collections.js
var inheritableAttrs = ['clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'transform', 'visibility', 'white-space', 'word-spacing', 'writing-mode'];
/* Some simple utilities */
var isFunction = function isFunction(a) {

@@ -190,56 +262,53 @@ return typeof a === 'function';

// Gets computed styles for an SVG element
// adapted from https://github.com/angular/angular.js/issues/2866#issuecomment-31012434
function getComputedStyles(node) {
if (isDefined(node.currentStyle)) {
//for old IE
return node.currentStyle;
} else if (isDefined(window.getComputedStyle)) {
//for modern browsers
return node.ownerDocument.defaultView.getComputedStyle(node, null);
} else {
return node.style;
}
}
var _isDefined = function _isDefined(a) {
return typeof a !== 'undefined';
};
var isObject = function isObject(a) {
return a !== null && typeof a === 'object';
};
// Vonvert computed styles to something we can iterate over
// adapted from http://stackoverflow.com/questions/754607/can-jquery-get-all-css-styles-associated-with-an-element/6416527#6416527
function convertComputedStyle(computed) {
if (isDefined(window.getComputedStyle)) {
var styles = {};
for (var i = 0, l = computed.length; i < l; i++) {
var prop = computed[i];
var val = computed.getPropertyValue(prop);
styles[prop] = val;
}
return styles;
}
return computed;
// from https://github.com/npm-dom/is-dom/blob/master/index.js
function isNode(val) {
if (!isObject(val)) return false;
if (_isDefined(window) && isObject(window.Node)) return val instanceof window.Node;
return 'number' == typeof val.nodeType && 'string' == typeof val.nodeName;
}
// Copies computed styles from source to target
function copyStyles(source, target, defaultStyles) {
// styles === false - copy none, true - copy all
if (defaultStyles === false) {
return;
var useComputedStyles = _isDefined(window) && _isDefined(window.getComputedStyle);
/**
* Returns a collection of CSS property-value pairs
* @param {Element} node A DOM element to copy styles from
* @param {Object} [target] An optional object to copy styles to
* @param {(Object|Boolean)} [default=true] A collection of CSS property-value pairs, false: copy none, true: copy all
* @return {object} collection of CSS property-value pairs
* @api public
*/
function computedStyles(node) {
var target = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var styleList = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
if (!isNode(node)) {
throw new Error('parameter 1 is not of type \'Element\'');
}
var srcStyles = getComputedStyles(source);
if (styleList === false) return target;
if (defaultStyles === true) {
// copy all styles
for (var key in convertComputedStyle(srcStyles)) {
target.style[key] = srcStyles[key];
}
return;
if (useComputedStyles) {
var computed = node.ownerDocument.defaultView.getComputedStyle(node, null);
var keysArray = styleList === true ? computed : Object.keys(styleList);
} else {
var computed = _isDefined(node.currentStyle) ? node.currentStyle : node.style;
var keysArray = styleList === true ? Object.keys(computed) : Object.keys(styleList);
}
var parStyles = getComputedStyles(target.parentNode);
for (var key in defaultStyles) {
var src = srcStyles[key];
if (src && src !== defaultStyles[key] && src !== parStyles[key]) {
target.style[key] = src;
for (var i = 0, l = keysArray.length; i < l; i++) {
var key = keysArray[i];
var value = useComputedStyles ? computed.getPropertyValue(key) : computed[key];
if (styleList === true || styleList[key] === true || value !== styleList[key]) {
target[key] = value;
}
}
return target;
}

@@ -258,3 +327,3 @@

if (attr.specified) {
if (attrs === false || isUndefined(styles[attr.name]) && attrs.indexOf(attr.name) < 0) {
if (attrs === '' || attrs === false || isUndefined(styles[attr.name]) && attrs.indexOf(attr.name) < 0) {
el.removeAttribute(attr.name);

@@ -271,4 +340,7 @@ }

computedStyles(src, clonedSvg.style, styles);
cleanAttrs(clonedSvg, attrs, styles);
Array.prototype.slice.call(clonedSvg.querySelectorAll('*')).forEach(function (target, index) {
copyStyles(srcChildren[index], target, styles);
computedStyles(srcChildren[index], target.style, styles);
cleanAttrs(target, attrs, styles);

@@ -280,76 +352,9 @@ });

var svgStyles = { // Whitelist of CSS styles and default values
'alignment-baseline': 'auto',
'baseline-shift': 'baseline',
'clip': 'auto',
'clip-path': 'none',
'clip-rule': 'nonzero',
'color': 'rgb(51, 51, 51)',
'color-interpolation': 'srgb',
'color-interpolation-filters': 'linearrgb',
'color-profile': 'auto',
'color-rendering': 'auto',
'cursor': 'auto',
'direction': 'ltr',
'display': 'inline',
'dominant-baseline': 'auto',
'enable-background': '',
'fill': 'rgb(0, 0, 0)',
'fill-opacity': '1',
'fill-rule': 'nonzero',
'filter': 'none',
'flood-color': 'rgb(0, 0, 0)',
'flood-opacity': '1',
'font': '',
'font-family': 'normal',
'font-size': 'medium',
'font-size-adjust': 'auto',
'font-stretch': 'normal',
'font-style': 'normal',
'font-variant': 'normal',
'font-weight': '400',
'glyph-orientation-horizontal': '0deg',
'glyph-orientation-vertical': 'auto',
'image-rendering': 'auto',
'kerning': 'auto',
'letter-spacing': '0',
'lighting-color': 'rgb(255, 255, 255)',
'marker': '',
'marker-end': 'none',
'marker-mid': 'none',
'marker-start': 'none',
'mask': 'none',
'opacity': '1',
'overflow': 'visible',
'paint-order': 'normal',
'pointer-events': 'auto',
'shape-rendering': 'auto',
'stop-color': 'rgb(0, 0, 0)',
'stop-opacity': '1',
'stroke': 'none',
'stroke-dasharray': 'none',
'stroke-dashoffset': '0',
'stroke-linecap': 'butt',
'stroke-linejoin': 'miter',
'stroke-miterlimit': '4',
'stroke-opacity': '1',
'stroke-width': '1',
'text-anchor': 'start',
'text-decoration': 'none',
'text-rendering': 'auto',
'unicode-bidi': 'normal',
'visibility': 'visible',
'word-spacing': '0px',
'writing-mode': 'lr-tb'
};
// inheritable styles may be overridden by parent, always copy for now
inheritableAttrs.forEach(function (k) {
if (k in svgStyles) {
svgStyles[k] = true;
}
});
var svgAttrs = [// white list of attributes
'id', 'xml:base', 'xml:lang', 'xml:space', // Core
'height', 'result', 'width', 'x', 'y', // Primitive
'xlink:href', // Xlink attribute
'style', 'class', 'd', 'pathLength', // Path
'x', 'y', 'dx', 'dy', 'glyphRef', 'format', 'x1', 'y1', 'x2', 'y2', 'rotate', 'textLength', 'cx', 'cy', 'r', 'rx', 'ry', 'fx', 'fy', 'width', 'height', 'refX', 'refY', 'orient', 'markerUnits', 'markerWidth', 'markerHeight', 'maskUnits', 'transform', 'viewBox', 'version', // Container
'preserveAspectRatio', 'xmlns', 'points', // Polygons
'offset'];
var SvgSaver = (function () {

@@ -356,0 +361,0 @@

@@ -1,1 +0,1 @@

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var SvgSaver=require("svgsaver");angular.module("hc.downloader",[]).factory("svgDownload",["$log",function($log){var svgSaver=new SvgSaver;return function(el){if(angular.isString(el)&&el.charAt(0)!="<"){el=document.querySelector(el)}var svg=angular.element(el);if(svg.prop("tagName")!=="svg"){svg=svg.find("svg")}if(svg.length<1){$log.warn("svgDownload Error: Element "+el+" not found");return null}return{getHtml:function(){return svgSaver.getHTML(svg[0])},getBlob:function(){return svgSaver.getBlob(svg[0])},asSvg:function(filename){return svgSaver.asSvg(svg[0],filename)},asPng:function(filename){return svgSaver.asPng(svg[0],filename)}}}}]).directive("svgDownload",["svgDownload",function(svgDownload){return{restrict:"A",link:function(scope,element,attrs){element.on("click",download);function download(){var ext=attrs.type||"svg";var filename=encodeURI(attrs.filename||attrs.title||"untitled")+"."+ext;var svg=svgDownload(attrs.svgDownload||"body");if(svg){if(ext==="svg"){svg.asSvg(filename)}if(ext==="png"){svg.asPng(filename)}}}}}}])},{svgsaver:2}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var isFunction=function isFunction(a){return typeof a==="function"};var isDefined=function isDefined(a){return typeof a!=="undefined"};var isUndefined=function isUndefined(a){return typeof a==="undefined"};var DownloadAttributeSupport=typeof document!=="undefined"&&"download"in document.createElement("a");function saveUri(uri,name){if(DownloadAttributeSupport){var dl=document.createElement("a");dl.setAttribute("href",uri);dl.setAttribute("download",name);dl.click();return true}else if(typeof window!=="undefined"){window.open(uri,"_blank","");return true}return false}function savePng(uri,name){var canvas=document.createElement("canvas");var context=canvas.getContext("2d");var image=new Image;image.onload=function(){canvas.width=image.width;canvas.height=image.height;context.drawImage(image,0,0);if(isDefined(window.saveAs)&&isDefined(canvas.toBlob)){canvas.toBlob(function(blob){saveAs(blob,name)})}else{saveUri(canvas.toDataURL("image/png"),name)}};image.src=uri;return true}function getComputedStyles(node){if(isDefined(node.currentStyle)){return node.currentStyle}else if(isDefined(window.getComputedStyle)){return node.ownerDocument.defaultView.getComputedStyle(node,null)}else{return node.style}}function convertComputedStyle(computed){if(isDefined(window.getComputedStyle)){var styles={};for(var i=0,l=computed.length;i<l;i++){var prop=computed[i];var val=computed.getPropertyValue(prop);styles[prop]=val}return styles}return computed}function copyStyles(source,target,defaultStyles){if(defaultStyles===false){return}var srcStyles=getComputedStyles(source);if(defaultStyles===true){for(var key in convertComputedStyle(srcStyles)){target.style[key]=srcStyles[key]}return}var parStyles=getComputedStyles(target.parentNode);for(var key in defaultStyles){var src=srcStyles[key];if(src&&src!==defaultStyles[key]&&src!==parStyles[key]){target.style[key]=src}}}function cleanAttrs(el,attrs,styles){if(attrs===true){return}Array.prototype.slice.call(el.attributes).forEach(function(attr){if(attr.specified){if(attrs===false||isUndefined(styles[attr.name])&&attrs.indexOf(attr.name)<0){el.removeAttribute(attr.name)}}})}function cloneSvg(src,attrs,styles){var clonedSvg=src.cloneNode(true);var srcChildren=src.querySelectorAll("*");Array.prototype.slice.call(clonedSvg.querySelectorAll("*")).forEach(function(target,index){copyStyles(srcChildren[index],target,styles);cleanAttrs(target,attrs,styles)});return clonedSvg}var svgStyles={"alignment-baseline":"auto","baseline-shift":"baseline",clip:"auto","clip-path":"none","clip-rule":"nonzero",color:"rgb(51, 51, 51)","color-interpolation":"srgb","color-interpolation-filters":"linearrgb","color-profile":"auto","color-rendering":"auto",cursor:"auto",direction:"ltr",display:"inline","dominant-baseline":"auto","enable-background":"",fill:"rgb(0, 0, 0)","fill-opacity":"1","fill-rule":"nonzero",filter:"none","flood-color":"rgb(0, 0, 0)","flood-opacity":"1",font:"","font-family":"normal","font-size":"medium","font-size-adjust":"auto","font-stretch":"normal","font-style":"normal","font-variant":"normal","font-weight":"400","glyph-orientation-horizontal":"0deg","glyph-orientation-vertical":"auto","image-rendering":"auto",kerning:"auto","letter-spacing":"0","lighting-color":"rgb(255, 255, 255)",marker:"","marker-end":"none","marker-mid":"none","marker-start":"none",mask:"none",opacity:"1",overflow:"visible","paint-order":"normal","pointer-events":"auto","shape-rendering":"auto","stop-color":"rgb(0, 0, 0)","stop-opacity":"1",stroke:"none","stroke-dasharray":"none","stroke-dashoffset":"0","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-opacity":"1","stroke-width":"1","text-anchor":"start","text-decoration":"none","text-rendering":"auto","unicode-bidi":"normal",visibility:"visible","word-spacing":"0px","writing-mode":"lr-tb"};var svgAttrs=["id","xml:base","xml:lang","xml:space","height","result","width","x","y","xlink:href","style","class","d","pathLength","x","y","dx","dy","glyphRef","format","x1","y1","x2","y2","rotate","textLength","cx","cy","r","rx","ry","fx","fy","width","height","refX","refY","orient","markerUnits","markerWidth","markerHeight","maskUnits","transform","viewBox","version","preserveAspectRatio","xmlns","points","offset"];var SvgSaver=function(){function SvgSaver(){var _ref=arguments.length<=0||arguments[0]===undefined?{}:arguments[0];var attrs=_ref.attrs;var styles=_ref.styles;_classCallCheck(this,SvgSaver);this.attrs=attrs===undefined?svgAttrs:attrs;this.styles=styles===undefined?svgStyles:styles}_createClass(SvgSaver,[{key:"getHTML",value:function getHTML(el){var svg=cloneSvg(el,this.attrs,this.styles);svg.setAttribute("xmlns","http://www.w3.org/2000/svg");svg.setAttribute("version",1.1);svg.setAttribute("width",svg.getAttribute("width")||"500");svg.setAttribute("height",svg.getAttribute("height")||"900");return svg.outerHTML||(new window.XMLSerializer).serializeToString(svg)}},{key:"getBlob",value:function getBlob(el){var html=this.getHTML(el);return new Blob([html],{type:"text/xml"})}},{key:"getUri",value:function getUri(el){var html=this.getHTML(el);if(isDefined(window.btoa)){return"data:image/svg+xml;base64,"+window.btoa(html)}return"data:image/svg+xml,"+encodeURIComponent(html)}},{key:"asSvg",value:function asSvg(el,filename){if(!filename||filename===""){filename=el.getAttribute("title");filename=(filename||"untitled")+".svg"}if(isDefined(window.saveAs)&&isFunction(Blob)){return saveAs(this.getBlob(el),filename)}else{return saveUri(this.getUri(el),filename)}}},{key:"asPng",value:function asPng(el,filename){if(!filename||filename===""){filename=el.getAttribute("title");filename=(filename||"untitled")+".png"}return savePng(this.getUri(el),filename)}}]);return SvgSaver}();exports["default"]=SvgSaver;module.exports=exports["default"]},{}]},{},[1]);
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var SvgSaver=require("svgsaver");angular.module("hc.downloader",[]).factory("svgDownload",["$log",function($log){var svgSaver=new SvgSaver;return function(el){if(angular.isString(el)&&el.charAt(0)!=="<"){el=document.querySelector(el)}var svg=angular.element(el);if(svg.prop("tagName")!=="svg"){svg=svg.find("svg")}if(svg.length<1){$log.warn("svgDownload Error: Element "+el+" not found");return null}return{getHtml:function(){return svgSaver.getHTML(svg[0])},getBlob:function(){return svgSaver.getBlob(svg[0])},asSvg:function(filename){return svgSaver.asSvg(svg[0],filename)},asPng:function(filename){return svgSaver.asPng(svg[0],filename)}}}}]).directive("svgDownload",["svgDownload",function(svgDownload){return{restrict:"A",link:function(scope,element,attrs){element.on("click",download);function download(){var ext=attrs.type||"svg";var filename=encodeURI(attrs.filename||attrs.title||"untitled")+"."+ext;var svg=svgDownload(attrs.svgDownload||"body");if(svg){if(ext==="svg"){svg.asSvg(filename)}if(ext==="png"){svg.asPng(filename)}}}}}}])},{svgsaver:2}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var svgStyles={"alignment-baseline":"auto","baseline-shift":"baseline",clip:"auto","clip-path":"none","clip-rule":"nonzero",color:"rgb(51, 51, 51)","color-interpolation":"srgb","color-interpolation-filters":"linearrgb","color-profile":"auto","color-rendering":"auto",cursor:"auto",direction:"ltr",display:"inline","dominant-baseline":"auto","enable-background":"",fill:"rgb(0, 0, 0)","fill-opacity":"1","fill-rule":"nonzero",filter:"none","flood-color":"rgb(0, 0, 0)","flood-opacity":"1",font:"","font-family":"normal","font-size":"medium","font-size-adjust":"auto","font-stretch":"normal","font-style":"normal","font-variant":"normal","font-weight":"400","glyph-orientation-horizontal":"0deg","glyph-orientation-vertical":"auto","image-rendering":"auto",kerning:"auto","letter-spacing":"0","lighting-color":"rgb(255, 255, 255)",marker:"","marker-end":"none","marker-mid":"none","marker-start":"none",mask:"none",opacity:"1",overflow:"visible","paint-order":"normal","pointer-events":"auto","shape-rendering":"auto","stop-color":"rgb(0, 0, 0)","stop-opacity":"1",stroke:"none","stroke-dasharray":"none","stroke-dashoffset":"0","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-opacity":"1","stroke-width":"1","text-anchor":"start","text-decoration":"none","text-rendering":"auto","unicode-bidi":"normal",visibility:"visible","word-spacing":"0px","writing-mode":"lr-tb"};var svgAttrs=["id","xml:base","xml:lang","xml:space","height","result","width","x","y","xlink:href","style","class","d","pathLength","x","y","dx","dy","glyphRef","format","x1","y1","x2","y2","rotate","textLength","cx","cy","r","rx","ry","fx","fy","width","height","refX","refY","orient","markerUnits","markerWidth","markerHeight","maskUnits","transform","viewBox","version","preserveAspectRatio","xmlns","points","offset"];var inheritableAttrs=["clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","fill","fill-opacity","fill-rule","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","kerning","letter-spacing","marker","marker-end","marker-mid","marker-start","pointer-events","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-rendering","transform","visibility","white-space","word-spacing","writing-mode"];var isFunction=function isFunction(a){return typeof a==="function"};var isDefined=function isDefined(a){return typeof a!=="undefined"};var isUndefined=function isUndefined(a){return typeof a==="undefined"};var DownloadAttributeSupport=typeof document!=="undefined"&&"download"in document.createElement("a");function saveUri(uri,name){if(DownloadAttributeSupport){var dl=document.createElement("a");dl.setAttribute("href",uri);dl.setAttribute("download",name);dl.click();return true}else if(typeof window!=="undefined"){window.open(uri,"_blank","");return true}return false}function savePng(uri,name){var canvas=document.createElement("canvas");var context=canvas.getContext("2d");var image=new Image;image.onload=function(){canvas.width=image.width;canvas.height=image.height;context.drawImage(image,0,0);if(isDefined(window.saveAs)&&isDefined(canvas.toBlob)){canvas.toBlob(function(blob){saveAs(blob,name)})}else{saveUri(canvas.toDataURL("image/png"),name)}};image.src=uri;return true}var _isDefined=function _isDefined(a){return typeof a!=="undefined"};var isObject=function isObject(a){return a!==null&&typeof a==="object"};function isNode(val){if(!isObject(val))return false;if(_isDefined(window)&&isObject(window.Node))return val instanceof window.Node;return"number"==typeof val.nodeType&&"string"==typeof val.nodeName}var useComputedStyles=_isDefined(window)&&_isDefined(window.getComputedStyle);function computedStyles(node){var target=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];var styleList=arguments.length<=2||arguments[2]===undefined?true:arguments[2];if(!isNode(node)){throw new Error("parameter 1 is not of type 'Element'")}if(styleList===false)return target;if(useComputedStyles){var computed=node.ownerDocument.defaultView.getComputedStyle(node,null);var keysArray=styleList===true?computed:Object.keys(styleList)}else{var computed=_isDefined(node.currentStyle)?node.currentStyle:node.style;var keysArray=styleList===true?Object.keys(computed):Object.keys(styleList)}for(var i=0,l=keysArray.length;i<l;i++){var key=keysArray[i];var value=useComputedStyles?computed.getPropertyValue(key):computed[key];if(styleList===true||styleList[key]===true||value!==styleList[key]){target[key]=value}}return target}function cleanAttrs(el,attrs,styles){if(attrs===true){return}Array.prototype.slice.call(el.attributes).forEach(function(attr){if(attr.specified){if(attrs===""||attrs===false||isUndefined(styles[attr.name])&&attrs.indexOf(attr.name)<0){el.removeAttribute(attr.name)}}})}function cloneSvg(src,attrs,styles){var clonedSvg=src.cloneNode(true);var srcChildren=src.querySelectorAll("*");computedStyles(src,clonedSvg.style,styles);cleanAttrs(clonedSvg,attrs,styles);Array.prototype.slice.call(clonedSvg.querySelectorAll("*")).forEach(function(target,index){computedStyles(srcChildren[index],target.style,styles);cleanAttrs(target,attrs,styles)});return clonedSvg}inheritableAttrs.forEach(function(k){if(k in svgStyles){svgStyles[k]=true}});var SvgSaver=function(){function SvgSaver(){var _ref=arguments.length<=0||arguments[0]===undefined?{}:arguments[0];var attrs=_ref.attrs;var styles=_ref.styles;_classCallCheck(this,SvgSaver);this.attrs=attrs===undefined?svgAttrs:attrs;this.styles=styles===undefined?svgStyles:styles}_createClass(SvgSaver,[{key:"getHTML",value:function getHTML(el){var svg=cloneSvg(el,this.attrs,this.styles);svg.setAttribute("xmlns","http://www.w3.org/2000/svg");svg.setAttribute("version",1.1);svg.setAttribute("width",svg.getAttribute("width")||"500");svg.setAttribute("height",svg.getAttribute("height")||"900");return svg.outerHTML||(new window.XMLSerializer).serializeToString(svg)}},{key:"getBlob",value:function getBlob(el){var html=this.getHTML(el);return new Blob([html],{type:"text/xml"})}},{key:"getUri",value:function getUri(el){var html=this.getHTML(el);if(isDefined(window.btoa)){return"data:image/svg+xml;base64,"+window.btoa(html)}return"data:image/svg+xml,"+encodeURIComponent(html)}},{key:"asSvg",value:function asSvg(el,filename){if(!filename||filename===""){filename=el.getAttribute("title");filename=(filename||"untitled")+".svg"}if(isDefined(window.saveAs)&&isFunction(Blob)){return saveAs(this.getBlob(el),filename)}else{return saveUri(this.getUri(el),filename)}}},{key:"asPng",value:function asPng(el,filename){if(!filename||filename===""){filename=el.getAttribute("title");filename=(filename||"untitled")+".png"}return savePng(this.getUri(el),filename)}}]);return SvgSaver}();exports["default"]=SvgSaver;module.exports=exports["default"]},{}]},{},[1]);

@@ -15,108 +15,102 @@ /*

angular.module('hc.downloader', [])
.factory('svgDownload', ['$log', function($log) {
.factory('svgDownload', ['$log', function ($log) {
var svgSaver = new SvgSaver();
var svgSaver = new SvgSaver();
return function (el) {
if (angular.isString(el) && el.charAt(0) !== '<') {
el = document.querySelector(el);
}
return function(el) {
var svg = angular.element(el);
if (angular.isString(el) && el.charAt(0) != '<') {
el = document.querySelector(el);
}
if (svg.prop('tagName') !== 'svg') {
svg = svg.find('svg');
}
var svg = angular.element(el);
if (svg.length < 1) {
$log.warn('svgDownload Error: Element ' + el + ' not found');
return null;
}
if (svg.prop('tagName') !== 'svg') {
svg = svg.find('svg');
}
return {
getHtml: function () { return svgSaver.getHTML(svg[0]); },
getBlob: function () { return svgSaver.getBlob(svg[0]); },
asSvg: function (filename) { return svgSaver.asSvg(svg[0], filename); },
asPng: function (filename) { return svgSaver.asPng(svg[0], filename); }
};
};
}])
if (svg.length < 1) {
$log.warn('svgDownload Error: Element ' + el + ' not found');
return null;
}
/**
* @ngdoc directive
* @name hc.downloader.directive:svgDownload
* @restrict A
* @element button
*
* @description
* AngularJS directive to download an SVG element as an SVG file.
*
* @param {string} svg-download The source element to download. If blank uses the first svg in the body.
* @param {string=} filename Name of resaulting svg file. If blank uses title or 'untitled.svg'
* @param {string} [type='svg'] Type of file to download (svg or png)
*
* @example
return {
getHtml: function() { return svgSaver.getHTML(svg[0]); },
getBlob: function() { return svgSaver.getBlob(svg[0]); },
asSvg: function(filename) { return svgSaver.asSvg(svg[0],filename); },
asPng: function(filename) { return svgSaver.asPng(svg[0],filename); }
};
## A simple example
};
<example module="hc.downloader">
<file name="example.html">
<div ng-include="'octocat.html'"></div>
<button svg-download title="mysvg">Download as SVG</button>
<button svg-download title="mysvg" type="png">Download as PNG</button>
<small class="pull-right">Source: <a href="https://gist.github.com/johan/1007813">https://gist.github.com/johan/1007813</a></small>
</file>
<file name="octocat.html">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.2 -1 379 334">
<path id="puddle" d="m296.94 295.43c0 20.533-47.56 37.176-106.22 37.176-58.67 0-106.23-16.643-106.23-37.176s47.558-37.18 106.23-37.18c58.66 0 106.22 16.65 106.22 37.18z"/>
<g id="shadow-legs">
<path d="m161.85 331.22v-26.5c0-3.422-.619-6.284-1.653-8.701 6.853 5.322 7.316 18.695 7.316 18.695v17.004c6.166.481 12.534.773 19.053.861l-.172-16.92c-.944-23.13-20.769-25.961-20.769-25.961-7.245-1.645-7.137 1.991-6.409 4.34-7.108-12.122-26.158-10.556-26.158-10.556-6.611 2.357-.475 6.607-.475 6.607 10.387 3.775 11.33 15.105 11.33 15.105v23.622c5.72.98 11.71 1.79 17.94 2.4z"/>
<path d="m245.4 283.48s-19.053-1.566-26.16 10.559c.728-2.35.839-5.989-6.408-4.343 0 0-19.824 2.832-20.768 25.961l-.174 16.946c6.509-.025 12.876-.254 19.054-.671v-17.219s.465-13.373 7.316-18.695c-1.034 2.417-1.653 5.278-1.653 8.701v26.775c6.214-.544 12.211-1.279 17.937-2.188v-24.113s.944-11.33 11.33-15.105c0-.01 6.13-4.26-.48-6.62z"/>
</g>
<path id="cat" d="m378.18 141.32l.28-1.389c-31.162-6.231-63.141-6.294-82.487-5.49 3.178-11.451 4.134-24.627 4.134-39.32 0-21.073-7.917-37.931-20.77-50.759 2.246-7.25 5.246-23.351-2.996-43.963 0 0-14.541-4.617-47.431 17.396-12.884-3.22-26.596-4.81-40.328-4.81-15.109 0-30.376 1.924-44.615 5.83-33.94-23.154-48.923-18.411-48.923-18.411-9.78 24.457-3.733 42.566-1.896 47.063-11.495 12.406-18.513 28.243-18.513 47.659 0 14.658 1.669 27.808 5.745 39.237-19.511-.71-50.323-.437-80.373 5.572l.276 1.389c30.231-6.046 61.237-6.256 80.629-5.522.898 2.366 1.899 4.661 3.021 6.879-19.177.618-51.922 3.062-83.303 11.915l.387 1.36c31.629-8.918 64.658-11.301 83.649-11.882 11.458 21.358 34.048 35.152 74.236 39.484-5.704 3.833-11.523 10.349-13.881 21.374-7.773 3.718-32.379 12.793-47.142-12.599 0 0-8.264-15.109-24.082-16.292 0 0-15.344-.235-1.059 9.562 0 0 10.267 4.838 17.351 23.019 0 0 9.241 31.01 53.835 21.061v32.032s-.943 11.33-11.33 15.105c0 0-6.137 4.249.475 6.606 0 0 28.792 2.361 28.792-21.238v-34.929s-1.142-13.852 5.663-18.667v57.371s-.47 13.688-7.551 18.881c0 0-4.723 8.494 5.663 6.137 0 0 19.824-2.832 20.769-25.961l.449-58.06h4.765l.453 58.06c.943 23.129 20.768 25.961 20.768 25.961 10.383 2.357 5.663-6.137 5.663-6.137-7.08-5.193-7.551-18.881-7.551-18.881v-56.876c6.801 5.296 5.663 18.171 5.663 18.171v34.929c0 23.6 28.793 21.238 28.793 21.238 6.606-2.357.474-6.606.474-6.606-10.386-3.775-11.33-15.105-11.33-15.105v-45.786c0-17.854-7.518-27.309-14.87-32.3 42.859-4.25 63.426-18.089 72.903-39.591 18.773.516 52.557 2.803 84.873 11.919l.384-1.36c-32.131-9.063-65.692-11.408-84.655-11.96.898-2.172 1.682-4.431 2.378-6.755 19.25-.80 51.38-.79 82.66 5.46z"/>
<path id="face" d="m258.19 94.132c9.231 8.363 14.631 18.462 14.631 29.343 0 50.804-37.872 52.181-84.585 52.181-46.721 0-84.589-7.035-84.589-52.181 0-10.809 5.324-20.845 14.441-29.174 15.208-13.881 40.946-6.531 70.147-6.531 29.07-.004 54.72-7.429 69.95 6.357z"/>
<path id="eyes" d="m160.1 126.06 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z m94.43 0 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z"/>
<g id="face-features">
<path id="pupils" d="m154.46 126.38 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z m94.42 0 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z"/>
<circle id="nose" cx="188.5" cy="148.56" r="4.401"/>
<path id="mouth" d="m178.23 159.69c-.26-.738.128-1.545.861-1.805.737-.26 1.546.128 1.805.861 1.134 3.198 4.167 5.346 7.551 5.346s6.417-2.147 7.551-5.346c.26-.738 1.067-1.121 1.805-.861s1.121 1.067.862 1.805c-1.529 4.324-5.639 7.229-10.218 7.229s-8.68-2.89-10.21-7.22z"/>
</g>
<path id="octo" d="m80.641 179.82 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m8.5 4.72 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.193 6.14 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m4.72 7.08 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.188 6.61 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m7.09 5.66 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.91 3.78 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.87 0 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m10.01 -1.64 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z"/>
<path id="drop" d="m69.369 186.12l-3.066 10.683s-.8 3.861 2.84 4.546c3.8-.074 3.486-3.627 3.223-4.781z"/>
</svg>
</file>
<file name="octocat.css">
#puddle { fill: #9CDAF1; }
#shadow-legs { fill: #7DBBE6; }
#face { fill: #F4CBB2; }
#eyes { fill: #FFF; }
#face-features { fill: #AD5C51; }
#octo { fill: #C3E4D8; }
#drop { fill: #9CDAF1; }}
</file>
</example>
}])
*/
.directive('svgDownload', ['svgDownload', function (svgDownload) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', download);
/**
* @ngdoc directive
* @name hc.downloader.directive:svgDownload
* @restrict A
* @element button
*
* @description
* AngularJS directive to download an SVG element as an SVG file.
*
* @param {string} svg-download The source element to download. If blank uses the first svg in the body.
* @param {string=} filename Name of resaulting svg file. If blank uses title or 'untitled.svg'
* @param {string} [type='svg'] Type of file to download (svg or png)
*
* @example
## A simple example
<example module="hc.downloader">
<file name="example.html">
<div ng-include="'octocat.html'"></div>
<button svg-download title="mysvg">Download as SVG</button>
<button svg-download title="mysvg" type="png">Download as PNG</button>
<small class="pull-right">Source: <a href="https://gist.github.com/johan/1007813">https://gist.github.com/johan/1007813</a></small>
</file>
<file name="octocat.html">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.2 -1 379 334">
<path id="puddle" d="m296.94 295.43c0 20.533-47.56 37.176-106.22 37.176-58.67 0-106.23-16.643-106.23-37.176s47.558-37.18 106.23-37.18c58.66 0 106.22 16.65 106.22 37.18z"/>
<g id="shadow-legs">
<path d="m161.85 331.22v-26.5c0-3.422-.619-6.284-1.653-8.701 6.853 5.322 7.316 18.695 7.316 18.695v17.004c6.166.481 12.534.773 19.053.861l-.172-16.92c-.944-23.13-20.769-25.961-20.769-25.961-7.245-1.645-7.137 1.991-6.409 4.34-7.108-12.122-26.158-10.556-26.158-10.556-6.611 2.357-.475 6.607-.475 6.607 10.387 3.775 11.33 15.105 11.33 15.105v23.622c5.72.98 11.71 1.79 17.94 2.4z"/>
<path d="m245.4 283.48s-19.053-1.566-26.16 10.559c.728-2.35.839-5.989-6.408-4.343 0 0-19.824 2.832-20.768 25.961l-.174 16.946c6.509-.025 12.876-.254 19.054-.671v-17.219s.465-13.373 7.316-18.695c-1.034 2.417-1.653 5.278-1.653 8.701v26.775c6.214-.544 12.211-1.279 17.937-2.188v-24.113s.944-11.33 11.33-15.105c0-.01 6.13-4.26-.48-6.62z"/>
</g>
<path id="cat" d="m378.18 141.32l.28-1.389c-31.162-6.231-63.141-6.294-82.487-5.49 3.178-11.451 4.134-24.627 4.134-39.32 0-21.073-7.917-37.931-20.77-50.759 2.246-7.25 5.246-23.351-2.996-43.963 0 0-14.541-4.617-47.431 17.396-12.884-3.22-26.596-4.81-40.328-4.81-15.109 0-30.376 1.924-44.615 5.83-33.94-23.154-48.923-18.411-48.923-18.411-9.78 24.457-3.733 42.566-1.896 47.063-11.495 12.406-18.513 28.243-18.513 47.659 0 14.658 1.669 27.808 5.745 39.237-19.511-.71-50.323-.437-80.373 5.572l.276 1.389c30.231-6.046 61.237-6.256 80.629-5.522.898 2.366 1.899 4.661 3.021 6.879-19.177.618-51.922 3.062-83.303 11.915l.387 1.36c31.629-8.918 64.658-11.301 83.649-11.882 11.458 21.358 34.048 35.152 74.236 39.484-5.704 3.833-11.523 10.349-13.881 21.374-7.773 3.718-32.379 12.793-47.142-12.599 0 0-8.264-15.109-24.082-16.292 0 0-15.344-.235-1.059 9.562 0 0 10.267 4.838 17.351 23.019 0 0 9.241 31.01 53.835 21.061v32.032s-.943 11.33-11.33 15.105c0 0-6.137 4.249.475 6.606 0 0 28.792 2.361 28.792-21.238v-34.929s-1.142-13.852 5.663-18.667v57.371s-.47 13.688-7.551 18.881c0 0-4.723 8.494 5.663 6.137 0 0 19.824-2.832 20.769-25.961l.449-58.06h4.765l.453 58.06c.943 23.129 20.768 25.961 20.768 25.961 10.383 2.357 5.663-6.137 5.663-6.137-7.08-5.193-7.551-18.881-7.551-18.881v-56.876c6.801 5.296 5.663 18.171 5.663 18.171v34.929c0 23.6 28.793 21.238 28.793 21.238 6.606-2.357.474-6.606.474-6.606-10.386-3.775-11.33-15.105-11.33-15.105v-45.786c0-17.854-7.518-27.309-14.87-32.3 42.859-4.25 63.426-18.089 72.903-39.591 18.773.516 52.557 2.803 84.873 11.919l.384-1.36c-32.131-9.063-65.692-11.408-84.655-11.96.898-2.172 1.682-4.431 2.378-6.755 19.25-.80 51.38-.79 82.66 5.46z"/>
<path id="face" d="m258.19 94.132c9.231 8.363 14.631 18.462 14.631 29.343 0 50.804-37.872 52.181-84.585 52.181-46.721 0-84.589-7.035-84.589-52.181 0-10.809 5.324-20.845 14.441-29.174 15.208-13.881 40.946-6.531 70.147-6.531 29.07-.004 54.72-7.429 69.95 6.357z"/>
<path id="eyes" d="m160.1 126.06 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z m94.43 0 c0 13.994-7.88 25.336-17.6 25.336-9.72 0-17.6-11.342-17.6-25.336 0-13.992 7.88-25.33 17.6-25.33 9.72.01 17.6 11.34 17.6 25.33z"/>
<g id="face-features">
<path id="pupils" d="m154.46 126.38 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z m94.42 0 c0 9.328-5.26 16.887-11.734 16.887s-11.733-7.559-11.733-16.887c0-9.331 5.255-16.894 11.733-16.894 6.47 0 11.73 7.56 11.73 16.89z"/>
<circle id="nose" cx="188.5" cy="148.56" r="4.401"/>
<path id="mouth" d="m178.23 159.69c-.26-.738.128-1.545.861-1.805.737-.26 1.546.128 1.805.861 1.134 3.198 4.167 5.346 7.551 5.346s6.417-2.147 7.551-5.346c.26-.738 1.067-1.121 1.805-.861s1.121 1.067.862 1.805c-1.529 4.324-5.639 7.229-10.218 7.229s-8.68-2.89-10.21-7.22z"/>
</g>
<path id="octo" d="m80.641 179.82 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m8.5 4.72 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.193 6.14 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m4.72 7.08 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m5.188 6.61 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m7.09 5.66 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.91 3.78 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m9.87 0 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z m10.01 -1.64 c0 1.174-1.376 2.122-3.07 2.122-1.693 0-3.07-.948-3.07-2.122 0-1.175 1.377-2.127 3.07-2.127 1.694 0 3.07.95 3.07 2.13z"/>
<path id="drop" d="m69.369 186.12l-3.066 10.683s-.8 3.861 2.84 4.546c3.8-.074 3.486-3.627 3.223-4.781z"/>
</svg>
</file>
<file name="octocat.css">
#puddle { fill: #9CDAF1; }
#shadow-legs { fill: #7DBBE6; }
#face { fill: #F4CBB2; }
#eyes { fill: #FFF; }
#face-features { fill: #AD5C51; }
#octo { fill: #C3E4D8; }
#drop { fill: #9CDAF1; }}
</file>
</example>
*/
.directive('svgDownload', ['svgDownload', function (svgDownload) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', download);
function download(){
var ext = attrs.type || 'svg';
var filename = encodeURI(attrs.filename || attrs.title || 'untitled') + '.' + ext;
var svg = svgDownload(attrs.svgDownload || 'body');
if (svg) {
if(ext === 'svg') { svg.asSvg(filename); }
if(ext === 'png') { svg.asPng(filename); }
}
}
}
};
}]);
function download () {
var ext = attrs.type || 'svg';
var filename = encodeURI(attrs.filename || attrs.title || 'untitled') + '.' + ext;
var svg = svgDownload(attrs.svgDownload || 'body');
if (svg) {
if (ext === 'svg') { svg.asSvg(filename); }
if (ext === 'png') { svg.asPng(filename); }
}
}
}
};
}]);
{
"name": "angular-downloadsvg-directive",
"version": "0.1.0",
"version": "0.1.2",
"description": "AngularJS directive to download SVGs",

@@ -17,3 +17,5 @@ "keywords": [

"build": "npm run browserify && npm run uglify && grunt ngdocs",
"lint": "jshint lib/angular-downloadsvg-directive.js"
"lint": "semistandard ./lib/",
"start": "grunt serve",
"check": "npm run lint && dependency-check package.json --entry lib/angular-downloadsvg-directive.js"
},

@@ -32,2 +34,3 @@ "repository": {

"browserify": "^11.2.0",
"dependency-check": "^2.5.1",
"grunt": "^0.4.4",

@@ -39,8 +42,9 @@ "grunt-bump": "0.0.13",

"grunt-ngdocs": "^0.2.5",
"jshint": "^2.8.0",
"load-grunt-tasks": "^0.4.0"
"load-grunt-tasks": "^0.4.0",
"semistandard": "^7.0.2",
"uglifyjs": "^2.4.10"
},
"dependencies": {
"svgsaver": "^0.2.2"
"svgsaver": "^0.3.3"
}
}

@@ -1,2 +0,2 @@

angular-downloadsvg-directive [![Bower version](https://badge.fury.io/bo/angular-downloadsvg-directive.png)](http://badge.fury.io/bo/angular-downloadsvg-directive)
angular-downloadsvg-directive
===

@@ -6,5 +6,8 @@

[![get this with bower](http://benschwarz.github.io/bower-badges/badge@2x.png)](http://bower.io/ "get this with bower")
[![Bower version](https://img.shields.io/bower/v/angular-downloadsvg-directive.svg)](http://bower.io/)
[![NPM](https://img.shields.io/npm/v/angular-downloadsvg-directive.svg)](https://www.npmjs.com/package/angular-downloadsvg-directive)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://en.wikipedia.org/wiki/MIT_License)
## Features
- Downloads SVG elements as an SVG or PNG file.

@@ -15,6 +18,21 @@ - Downloads the first `<svg>` element by default.

- Copies only SVG relevant and non-default styles. [See here](http://www.w3.org/TR/SVG/propidx.html).
- Computed styles are in-lined for maximum compatibility.
## Install
### npm
`npm install angular-downloadsvg-directive`
### Bower
`bower install angular-downloadsvg-directive`
### jspm
`jspm install npm:angular-downloadsvg-directive`
## Usage
1. `bower install Hypercubed/angular-downloadsvg-directive`
2. Include the `angular-downloadsvg-directive.js` in app. By default at `bower_components/angular-downloadsvg-directive/angular-downloadsvg-directive.js`.
1. Include the `angular-downloadsvg-directive.js` in app. For bower at `bower_components/angular-downloadsvg-directive/angular-downloadsvg-directive.js`.
4. Add `hc.downloader` as a module dependency to your app.

@@ -27,4 +45,4 @@

```html
<button svg-download="#chart" title="mysvg">Download as SVG</button>
<button svg-download="#chart" title="mysvg" type="png">Download as PNG</button>
<button svg-download="#chart" title="mysvg">Download as SVG</button>
<button svg-download="#chart" title="mysvg" type="png">Download as PNG</button>
```

@@ -31,0 +49,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc