Skip to content

Commit

Permalink
Release v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fastfrwrd committed Jul 22, 2015
1 parent eafd0ef commit 26b27f3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-fontawesome",
"description": "Angular directive for FontAwesome",
"version": "0.3.2",
"version": "0.4.0",
"main": [
"dist/angular-fontawesome.js"
],
Expand Down
69 changes: 67 additions & 2 deletions dist/angular-fontawesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('picardy.fontawesome', [])
template: '<i class="fa"></i>',
replace: true,
link: function (scope, element, attrs) {

/*** STRING ATTRS ***/
// keep a state of the current attrs so that when they change,
// we can remove the old attrs before adding the new ones.
Expand All @@ -27,6 +27,7 @@ angular.module('picardy.fontawesome', [])
_observeStringAttr('name', 'fa');
_observeStringAttr('rotate');
_observeStringAttr('flip');
_observeStringAttr('stack');

/**
* size can be passed "large" or an integer
Expand All @@ -45,6 +46,23 @@ angular.module('picardy.fontawesome', [])
currentClasses.size = className;
});

/**
* stack can be passed "large" or an integer
*/
attrs.$observe('stack', function () {
var className;
element.removeClass(currentClasses.stack);

if (attrs.stack === 'large') {
className = 'fa-stack-lg';
} else if (!isNaN(parseInt(attrs.stack, 10))) {
className = 'fa-stack-' + attrs.stack + 'x';
}

element.addClass(className);
currentClasses.stack = className;
});

/*** BOOLEAN ATTRS ***/
// generic function to bind boolean attrs
function _observeBooleanAttr (attr, className) {
Expand All @@ -61,7 +79,7 @@ angular.module('picardy.fontawesome', [])
_observeBooleanAttr('spin');

/*** CONDITIONAL ATTRS ***/
// automatically populate fa-li if DOM structure indicates
// automatically populate fa-li if DOM structure indicates
element.toggleClass('fa-li', (
element.parent() &&
element.parent().parent() &&
Expand All @@ -72,4 +90,51 @@ angular.module('picardy.fontawesome', [])
);
}
};
})
.directive('faStack', function () {
return {
restrict: 'E',
transclude: true,
template: '<span ng-transclude class="fa-stack fa-lg"></span>',
replace: true,
link: function (scope, element, attrs) {

/*** STRING ATTRS ***/
// keep a state of the current attrs so that when they change,
// we can remove the old attrs before adding the new ones.
var currentClasses = {};

// generic function to bind string attrs
function _observeStringAttr (attr, baseClass) {
attrs.$observe(attr, function () {
baseClass = baseClass || 'fa-' + attr;
element.removeClass(currentClasses[attr]);
if (attrs[attr]) {
var className = [baseClass, attrs[attr]].join('-');
element.addClass(className);
currentClasses[attr] = className;
}
});
}

_observeStringAttr('size');

/**
* size can be passed "large" or an integer
*/
attrs.$observe('size', function () {
var className;
element.removeClass(currentClasses.size);

if (attrs.size === 'large') {
className = 'fa-lg';
} else if (!isNaN(parseInt(attrs.size, 10))) {
className = 'fa-' + attrs.size + 'x';
}

element.addClass(className);
currentClasses.size = className;
});
}
};
});
2 changes: 1 addition & 1 deletion dist/angular-fontawesome.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-fontawesome",
"version": "0.3.2",
"version": "0.4.0",
"author": "Paul Marbach <paul@picardylearning.com>",
"description": "Angular directive for FontAwesome",
"scripts": {
Expand Down

0 comments on commit 26b27f3

Please sign in to comment.