voltron-svg 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28ecd71971ca9a92a417abc96253c819e109e672
4
- data.tar.gz: 27125bc3811515c90ae7808391ff227bb22c201e
3
+ metadata.gz: b2acd5225f79a370f67e5847d61deb97e05fe97c
4
+ data.tar.gz: 7ed8b5fb3f6baf871e5dc1a0b66c6ef95bfb5905
5
5
  SHA512:
6
- metadata.gz: 3b596c8d2e3e53195177320ade9b233c6a979ffc2f10e230e3a14d77dd5774b61bd5a5e8ffd93b3ebf851eae3e68819a2485944a371bb9b29276a8ccec2c242b
7
- data.tar.gz: 26ad47b62980c3212a02ac9179d3b45789f974fe528bb5680f7822a93c80863293d02f47da136953b4c6f1ef21abc8f7b5799150fb7b11762b971f42e8735f54
6
+ metadata.gz: 387ae6cefeb855175327f6cd82e84d4b4c672aa8311b598375de981732c525d751d5f9d15d412e582543b1af5cab34ae98f700379392e97093e6b1871ab99f18
7
+ data.tar.gz: 4bebf67ecbdbe0560336b364e7181b1b6a97ac132a6927bd982c92275331cd73f8558ba407c37fdba1e2d2d07e932e23945f39130c02e99b0d36b8079a25760a
@@ -1,134 +1,130 @@
1
1
  //= require voltron/svg-injector
2
2
 
3
3
  if(Voltron){
4
- Voltron.addModule('SVG', function(){
5
- return {
6
- initialize: function(){
7
- this.inject();
8
- },
9
-
10
- getTag: function(svg, image, options){
11
- options = $.extend(options, { src: svg, size: '16x16', svg: true, fallback: image });
12
- if(/^[0-9]+$/.test(options['size'].toString())) options['size'] = (options['size'] + 'x' + options['size']);
13
- var size = options['size'].split('x');
14
- if(!options['width']) options['width'] = size[0];
15
- if(!options['height']) options['height'] = size[1];
16
- return $('<img />', this.getDataAttribute(options, ['size', 'svg', 'fallback']));
17
- },
18
-
19
- getDataAttribute: function(options, attributes){
20
- for(var i=0; i<attributes.length; i++){
21
- var attr = attributes[i];
22
- if(options[attr]){
23
- options['data-' + attr] = options[attr];
24
- delete options[attr];
25
- }
26
- }
27
- return options;
28
- },
29
-
30
- inject: function(){
31
- var svgs = document.querySelectorAll('img[data-svg="true"]:not(.injected-svg)');
32
- var options = {
33
- each: function(svg){
34
- if(svg.getAttribute('data-size')){
35
- var dims = svg.getAttribute('data-size').split('x');
36
- svg.setAttribute('width', parseFloat(dims[0]));
37
- svg.setAttribute('height', parseFloat(dims[1]));
38
- }
39
- }
40
- };
41
- SVGInjector(svgs, options);
4
+ Voltron.addModule('SVG', function(){
5
+ return {
6
+ initialize: function(){
7
+ var svgs = document.querySelectorAll('img[data-svg="true"]:not(.injected-svg)');
8
+ var options = {
9
+ each: function(svg){
10
+ if(svg.getAttribute && svg.getAttribute('data-size')){
11
+ var dims = svg.getAttribute('data-size').split('x');
12
+ svg.setAttribute('width', parseFloat(dims[0]));
13
+ svg.setAttribute('height', parseFloat(dims[1]));
42
14
  }
15
+ }
43
16
  };
44
- }, true);
45
- }else{
46
- (function(funcName, baseObj) {
47
- "use strict";
48
- // The public function name defaults to window.docReady
49
- // but you can modify the last line of this function to pass in a different object or method name
50
- // if you want to put them in a different namespace and those will be used instead of
51
- // window.docReady(...)
52
- funcName = funcName || "docReady";
53
- baseObj = baseObj || window;
54
- var readyList = [];
55
- var readyFired = false;
56
- var readyEventHandlersInstalled = false;
57
-
58
- // call this when the document is ready
59
- // this function protects itself against being called more than once
60
- function ready() {
61
- if (!readyFired) {
62
- // this must be set to true before we start calling callbacks
63
- readyFired = true;
64
- for (var i = 0; i < readyList.length; i++) {
65
- // if a callback here happens to add new ready handlers,
66
- // the docReady() function will see that it already fired
67
- // and will schedule the callback to run right after
68
- // this event loop finishes so all handlers will still execute
69
- // in order and no new ones will be added to the readyList
70
- // while we are processing the list
71
- readyList[i].fn.call(window, readyList[i].ctx);
72
- }
73
- // allow any closures held by these functions to free
74
- readyList = [];
75
- }
17
+ SVGInjector(svgs, options);
18
+ },
19
+
20
+ getTag: function(svg, image, options){
21
+ options = $.extend(options, { src: svg, size: '16x16', svg: true, fallback: image });
22
+ if(/^[0-9]+$/.test(options['size'].toString())) options['size'] = (options['size'] + 'x' + options['size']);
23
+ var size = options['size'].split('x');
24
+ if(!options['width']) options['width'] = size[0];
25
+ if(!options['height']) options['height'] = size[1];
26
+ return $('<img />', this.getDataAttribute(options, ['size', 'svg', 'fallback']));
27
+ },
28
+
29
+ getDataAttribute: function(options, attributes){
30
+ for(var i=0; i<attributes.length; i++){
31
+ var attr = attributes[i];
32
+ if(options[attr]){
33
+ options['data-' + attr] = options[attr];
34
+ delete options[attr];
35
+ }
76
36
  }
77
-
78
- function readyStateChange() {
79
- if ( document.readyState === "complete" ) {
80
- ready();
81
- }
37
+ return options;
38
+ }
39
+ };
40
+ }, true);
41
+ }else{
42
+ (function(funcName, baseObj) {
43
+ "use strict";
44
+ // The public function name defaults to window.docReady
45
+ // but you can modify the last line of this function to pass in a different object or method name
46
+ // if you want to put them in a different namespace and those will be used instead of
47
+ // window.docReady(...)
48
+ funcName = funcName || "docReady";
49
+ baseObj = baseObj || window;
50
+ var readyList = [];
51
+ var readyFired = false;
52
+ var readyEventHandlersInstalled = false;
53
+
54
+ // call this when the document is ready
55
+ // this function protects itself against being called more than once
56
+ function ready() {
57
+ if (!readyFired) {
58
+ // this must be set to true before we start calling callbacks
59
+ readyFired = true;
60
+ for (var i = 0; i < readyList.length; i++) {
61
+ // if a callback here happens to add new ready handlers,
62
+ // the docReady() function will see that it already fired
63
+ // and will schedule the callback to run right after
64
+ // this event loop finishes so all handlers will still execute
65
+ // in order and no new ones will be added to the readyList
66
+ // while we are processing the list
67
+ readyList[i].fn.call(window, readyList[i].ctx);
82
68
  }
83
-
84
- // This is the one public interface
85
- // docReady(fn, context);
86
- // the context argument is optional - if present, it will be passed
87
- // as an argument to the callback
88
- baseObj[funcName] = function(callback, context) {
89
- // if ready has already fired, then just schedule the callback
90
- // to fire asynchronously, but right away
91
- if (readyFired) {
92
- setTimeout(function() {callback(context);}, 1);
93
- return;
94
- } else {
95
- // add the function and context to the list
96
- readyList.push({fn: callback, ctx: context});
97
- }
98
- // if document already ready to go, schedule the ready function to run
99
- // IE only safe when readyState is "complete", others safe when readyState is "interactive"
100
- if (document.readyState === "complete" || (!document.attachEvent && document.readyState === "interactive")) {
101
- setTimeout(ready, 1);
102
- } else if (!readyEventHandlersInstalled) {
103
- // otherwise if we don't have event handlers installed, install them
104
- if (document.addEventListener) {
105
- // first choice is DOMContentLoaded event
106
- document.addEventListener("DOMContentLoaded", ready, false);
107
- // backup is window load event
108
- window.addEventListener("load", ready, false);
109
- } else {
110
- // must be IE
111
- document.attachEvent("onreadystatechange", readyStateChange);
112
- window.attachEvent("onload", ready);
113
- }
114
- readyEventHandlersInstalled = true;
115
- }
69
+ // allow any closures held by these functions to free
70
+ readyList = [];
71
+ }
72
+ }
73
+
74
+ function readyStateChange() {
75
+ if ( document.readyState === "complete" ) {
76
+ ready();
77
+ }
78
+ }
79
+
80
+ // This is the one public interface
81
+ // docReady(fn, context);
82
+ // the context argument is optional - if present, it will be passed
83
+ // as an argument to the callback
84
+ baseObj[funcName] = function(callback, context) {
85
+ // if ready has already fired, then just schedule the callback
86
+ // to fire asynchronously, but right away
87
+ if (readyFired) {
88
+ setTimeout(function() {callback(context);}, 1);
89
+ return;
90
+ } else {
91
+ // add the function and context to the list
92
+ readyList.push({fn: callback, ctx: context});
93
+ }
94
+ // if document already ready to go, schedule the ready function to run
95
+ // IE only safe when readyState is "complete", others safe when readyState is "interactive"
96
+ if (document.readyState === "complete" || (!document.attachEvent && document.readyState === "interactive")) {
97
+ setTimeout(ready, 1);
98
+ } else if (!readyEventHandlersInstalled) {
99
+ // otherwise if we don't have event handlers installed, install them
100
+ if (document.addEventListener) {
101
+ // first choice is DOMContentLoaded event
102
+ document.addEventListener("DOMContentLoaded", ready, false);
103
+ // backup is window load event
104
+ window.addEventListener("load", ready, false);
105
+ } else {
106
+ // must be IE
107
+ document.attachEvent("onreadystatechange", readyStateChange);
108
+ window.attachEvent("onload", ready);
116
109
  }
117
- })("docReady", window);
110
+ readyEventHandlersInstalled = true;
111
+ }
112
+ }
113
+ })("docReady", window);
118
114
 
119
- window.injectSVG = function(){
120
- var svgs = document.querySelectorAll('img[data-svg="true"]');
121
- var options = {
122
- each: function(svg){
123
- if(svg.getAttribute('data-size')){
124
- var dims = svg.getAttribute('data-size').split('x');
125
- svg.setAttribute('width', parseFloat(dims[0]));
126
- svg.setAttribute('height', parseFloat(dims[1]));
127
- }
128
- }
129
- };
130
- SVGInjector(svgs, options);
115
+ window.injectSVG = function(){
116
+ var svgs = document.querySelectorAll('img[data-svg="true"]');
117
+ var options = {
118
+ each: function(svg){
119
+ if(svg.getAttribute('data-size')){
120
+ var dims = svg.getAttribute('data-size').split('x');
121
+ svg.setAttribute('width', parseFloat(dims[0]));
122
+ svg.setAttribute('height', parseFloat(dims[1]));
123
+ }
124
+ }
131
125
  };
126
+ SVGInjector(svgs, options);
127
+ };
132
128
 
133
- docReady(injectSVG);
129
+ docReady(injectSVG);
134
130
  }
@@ -1,5 +1,5 @@
1
1
  module Voltron
2
2
  module Svg
3
- VERSION = "0.1.4".freeze
3
+ VERSION = "0.1.5".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voltron-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hainer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: voltron