-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-gray.js
46 lines (35 loc) · 1.11 KB
/
angular-gray.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*!
* angular-gray 0.1.0
* Date: 2015-07-09
* Matthias Max, bitflower e.K., http://www.bitflower.net
* License: MIT
* jQuery code originally by Karl Horky, https://github.com/karlhorky
* https://github.com/karlhorky/gray
*/
(function() {
'use strict';
var app = angular.module('net.bitflower.grayscale', []);
app.directive('grayscale', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
// Set class
element.addClass('grayscale');
// Set configuration
if (attrs && attrs.grayscale) {
var config = scope.$eval(attrs.grayscale);
if (config.hover) {
element.addClass('grayscale-fade');
}
}
// Register image loaded event
element.on('load', function() {
// Apply jQuery plugin
element.gray();
}).on('error', function() {
//
});
}
};
}]);
})();