|
37 | 37 | var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
38 | 38 | var path = document.createElementNS('http://www.w3.org/2000/svg', "path"); |
39 | 39 | var backgroundCircle = document.createElementNS('http://www.w3.org/2000/svg', "circle"); |
40 | | - var icongroup = document.createElementNS('http://www.w3.org/2000/svg', "g"); |
41 | | - var icon = document.createElementNS('http://www.w3.org/2000/svg', "text"); |
| 40 | + |
42 | 41 |
|
43 | 42 | svg.setAttribute('width', '31'); |
44 | 43 | svg.setAttribute('height', '42'); |
|
55 | 54 | path.setAttribute('stroke', 'white'); |
56 | 55 | path.setAttribute('style', 'fill:' + options.markerColor) |
57 | 56 |
|
58 | | - icon.textContent = options.icon; |
59 | | - icon.setAttribute('x', '7'); |
60 | | - icon.setAttribute('y', '23'); |
61 | | - icon.setAttribute('class', 'material-icons'); |
62 | | - icon.setAttribute('fill', options.iconColor); |
63 | | - icon.setAttribute('font-family', 'Material Icons'); |
64 | | - |
65 | | - svg.appendChild(path); |
66 | | - svg.appendChild(backgroundCircle); |
67 | | - icongroup.appendChild(icon); |
68 | | - svg.appendChild(icongroup); |
| 57 | + if (options.icon && options.icon.indexOf('fa-') === 0) { |
| 58 | + var icongroup = document.createElementNS('http://www.w3.org/2000/svg', "foreignObject"); |
| 59 | + var icon = document.createElement('i'); |
69 | 60 |
|
70 | | - return svg; |
71 | | - }, |
| 61 | + icongroup.setAttribute('height', '42'); |
| 62 | + icongroup.setAttribute('width', '31'); |
72 | 63 |
|
73 | | - _createInner: function() { |
74 | | - var iconClass, iconSpinClass = "", iconColorClass = "", iconColorStyle = "", options = this.options; |
| 64 | + icon.setAttribute('class', 'fas ' + options.icon); |
| 65 | + icon.style.color = options.iconColor; |
75 | 66 |
|
76 | | - if (options.spin && typeof options.spinClass === "string") { |
77 | | - iconSpinClass = options.spinClass; |
| 67 | + svg.appendChild(path); |
| 68 | + svg.appendChild(backgroundCircle); |
| 69 | + icongroup.appendChild(icon); |
| 70 | + svg.appendChild(icongroup); |
| 71 | + |
| 72 | + } else { |
| 73 | + var icongroup = document.createElementNS('http://www.w3.org/2000/svg', "g"); |
| 74 | + var icon = document.createElementNS('http://www.w3.org/2000/svg', "text"); |
| 75 | + icon.textContent = options.icon; |
| 76 | + icon.setAttribute('x', '7'); |
| 77 | + icon.setAttribute('y', '23'); |
| 78 | + icon.setAttribute('class', 'material-icons'); |
| 79 | + icon.setAttribute('fill', options.iconColor); |
| 80 | + icon.setAttribute('font-family', 'Material Icons'); |
| 81 | + |
| 82 | + svg.appendChild(path); |
| 83 | + svg.appendChild(backgroundCircle); |
| 84 | + icongroup.appendChild(icon); |
| 85 | + svg.appendChild(icongroup); |
78 | 86 | } |
79 | 87 |
|
80 | | - if (options.iconColor) { |
81 | | - if (options.iconColor === 'white' || options.iconColor === 'black') { |
82 | | - iconColorClass = "icon-" + options.iconColor; |
83 | | - } else { |
84 | | - iconColorStyle = "style='color: " + options.iconColor + "' "; |
85 | | - } |
86 | | - } |
87 | | - //return "<i " + iconColorStyle + "class='" + options.extraClasses + " " + options.prefix + " " + iconClass + " " + iconSpinClass + " " + iconColorClass + "'></i>" |
88 | | - return options.extraClasses + " " + iconClass + " " + iconSpinClass + " " + iconColorClass; |
| 88 | + return svg; |
89 | 89 | }, |
90 | 90 |
|
91 | 91 | _setIconStyles: function (img, name) { |
|
0 commit comments