Skip to content

Commit

Permalink
chore: move code to github
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberalien committed Jan 15, 2023
0 parents commit 53d5f3e
Show file tree
Hide file tree
Showing 686 changed files with 643,264 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
149 changes: 149 additions & 0 deletions 0/0.1.2/plugin-fa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/**
* This file is part of the simple-svg package.
*
* (c) Vjacheslav Trushkin <[email protected]>
*
* For the full copyright and license information, please view the license.txt
* file that was distributed with this source code.
* @license MIT
*/

/**
* Plugin for FontAwesome icons
*/
(function(SimpleSVG) {
"use strict";

/**
* List of FontAwesome class names that do not represent icons
*
* @type {[string]}
*/
var faReserved = ['fa-lg', 'fa-2x', 'fa-3x', 'fa-4x', 'fa-5x', 'fa-fw', 'fa-ul', 'fa-li', 'fa-border', 'fa-pull-left', 'fa-pull-right', 'fa-spin', 'fa-pulse', 'fa-rotate-90', 'fa-rotate-180', 'fa-rotate-270', 'fa-flip-horizontal', 'fa-flip-vertical', 'fa-stack', 'fa-stack-1x', 'fa-stack-2x', 'fa-inverse'],
rotateAttribute = SimpleSVG.getConfig('_rotateAttribute'),
flipAttribute = SimpleSVG.getConfig('_flipAttribute'),
inlineAttribute = SimpleSVG.getConfig('_inlineModeAttribute');

/**
* Link to stylesheet
*
* @type {string}
*/
var stylesheetCDN = '//cdn.simplesvg.com/css/fa.css';

/**
* True if stylesheet has been added
*
* @type {boolean}
*/
var styleAdded = false;

/**
* Inserts short version of FontAwesome stylesheet into DOM
*/
function insertStylesheet() {
var element = document.createElement('link');

styleAdded = true;

element.setAttribute('rel', 'stylesheet');
element.setAttribute('type', 'text/css');
element.setAttribute('href', SimpleSVG.secureURL(stylesheetCDN));
document.head.appendChild(element);
}

/**
* Add finder to list of finders
*/
SimpleSVG.addFinder('fa', {
selector: '.fa',

/**
* Get icon name from element
*
* @param {Element} element
* @return {string}
*/
icon: function(element) {
var item;

for (var i = 0; i < element.classList.length; i++) {
item = element.classList[i];
if (item.slice(0, 3) === 'fa-' && faReserved.indexOf(item) === -1) {
return item;
}
}

return '';
},

/**
* Filter class names list, removing any FontAwesome specific classes
*
* @param {object} image
* @param {Array|DOMTokenList} list
* @return {Array}
*/
filterClasses: function(image, list) {
var results = [],
transform = {
rotate: 0,
hFlip: false,
vFlip: false
};

if (image.attributes === void 0) {
image.attributes = {};
}

for (var i = 0; i < list.length; i++) {
switch (list[i]) {
case 'fa-rotate-90':
transform.rotate = 1;
break;

case 'fa-rotate-180':
transform.rotate = 2;
break;

case 'fa-rotate-270':
transform.rotate = 3;
break;

case 'fa-flip-horizontal':
transform.hFlip = true;
break;

case 'fa-flip-vertical':
transform.vFlip = true;
break;

default:
results.push(list[i]);
}
}

if (image.attributes[inlineAttribute] === void 0) {
image.attributes[inlineAttribute] = true;
}

// Add transformation as attributes
if (transform.rotate) {
image.attributes[rotateAttribute] = transform.rotate;
}
if (transform.hFlip || transform.vFlip) {
image.attributes[flipAttribute] = (transform.hFlip && transform.vFlip) ? 'horizontal vertical' : (
transform.hFlip ? 'horizontal' : 'vertical'
);
}

// Insert short version of FontAwesome stylesheet into DOM
if (!styleAdded) {
insertStylesheet();
}

return results;
}
});

})(SimpleSVG);
1 change: 1 addition & 0 deletions 0/0.1.2/plugin-fa.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions 0/0.1.2/plugin-il.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* This file is part of the simple-svg package.
*
* (c) Vjacheslav Trushkin <[email protected]>
*
* For the full copyright and license information, please view the license.txt
* file that was distributed with this source code.
* @license MIT
*/

/**
* Plugin for icalicons icons
*/
(function(SimpleSVG) {
"use strict";

/**
* List of icalicons class names that do not represent icons
*
* @type {[string]}
*/
var inlineAttribute = SimpleSVG.getConfig('_inlineModeAttribute');

/**
* Add finder to list of finders
*/
SimpleSVG.addFinder('il', {
selector: '.il',

/**
* Get icon name from element
*
* @param {Element} element
* @return {string}
*/
icon: function(element) {
var item;

for (var i = 0; i < element.classList.length; i++) {
item = element.classList[i];
if (item.slice(0, 3) === 'il-') {
return item;
}
}

return '';
},

/**
* Filter class names list, removing any icalicons specific classes
*
* @param {object} image
* @param {Array|DOMTokenList} list
* @return {Array}
*/
filterClasses: function(image, list) {
var results;

results = list.filter(function(item) {
return item !== 'il' && item.slice(0, 3) !== 'il-';
});

if (image.attributes === void 0) {
image.attributes = {};
}

if (image.attributes[inlineAttribute] === void 0) {
image.attributes[inlineAttribute] = true;
}

image.attributes.width = '1em';
image.attributes.height = '1em';


return results;
}
});

})(SimpleSVG);
1 change: 1 addition & 0 deletions 0/0.1.2/plugin-il.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 53d5f3e

Please sign in to comment.