-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentMatrix.js
More file actions
69 lines (62 loc) · 1.91 KB
/
contentMatrix.js
File metadata and controls
69 lines (62 loc) · 1.91 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*!
contentMatrix v1.0.0 (https://github.com/TechTarget/contentMatrix)
Author: Morgan Wigmanich <okize123@gmail.com> (http://github.com/okize)
Copyright (c) 2013 | Licensed under the MIT license
http://www.opensource.org/licenses/mit-license.php
*/
(function() {
(function(factory) {
if (typeof define === 'function' && define.amd) {
return define(['jquery'], factory);
} else {
return factory(jQuery);
}
})(function($) {
'use strict';
var Matrix, defaults, pluginName;
pluginName = 'contentMatrix';
defaults = {
effectType: 'glow',
effectSpeed: 500
};
Matrix = (function() {
function Matrix(element, options) {
this.options = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.el = $(element);
this.blocks = $(element).children('.contentBlock');
this.effectsMap = {
glow: 'glowEffect'
};
this.init();
}
Matrix.prototype.init = function() {
var self;
self = this;
return this.blocks.on({
mouseenter: function(e) {
return self[self.effectsMap[self.options.effectType]]('on', e.target);
},
mouseleave: function() {
return self[self.effectsMap[self.options.effectType]]('off');
}
});
};
Matrix.prototype.glowEffect = function(state, target) {
var me, opacity;
me = $(target).parents('.contentBlock');
opacity = (state === 'on' ? 0.75 : 1);
return this.blocks.not(me).stop().fadeTo(this.options.effectSpeed, opacity);
};
return Matrix;
})();
$.fn[pluginName] = function(options) {
return this.each(function() {
if (!$.data(this, 'plugin_#{pluginName}')) {
$.data(this, 'plugin_#{pluginName}', new Matrix(this, options));
}
});
};
});
}).call(this);