-
Notifications
You must be signed in to change notification settings - Fork 2
/
ElementHider.js
44 lines (33 loc) · 1.01 KB
/
ElementHider.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
define(['jquery','DoughBaseComponent'], function ($, DoughBaseComponent) {
'use strict';
var ElementHiderProto,
defaultConfig = {
delay: 3000,
selectors: {
activeClass: 'is-active'
},
uiEvents: {
'click [data-dough-element-hider-close]': 'hide'
}
};
function ElementHider($el, config) {
ElementHider.baseConstructor.call(this, $el, config, defaultConfig);
}
DoughBaseComponent.extend(ElementHider);
ElementHider.componentName = 'ElementHider';
ElementHiderProto = ElementHider.prototype;
ElementHiderProto.init = function(initialised) {
this.$closeBtn = this.$el.find('[data-dough-element-hider-close]');
if(this.config.delay) {
setTimeout($.proxy(function() {
this.hide();
},this), this.config.delay);
}
this._initialisedSuccess(initialised);
return this;
};
ElementHiderProto.hide = function() {
this.$el.removeClass(this.config.selectors.activeClass);
};
return ElementHider;
});