forked from Studio-42/elFinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overlay.js
50 lines (41 loc) · 959 Bytes
/
overlay.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
47
48
49
50
$.fn.elfinderoverlay = function(opts) {
"use strict";
var fm = this.parent().elfinder('instance'),
o, cnt, show, hide;
this.filter(':not(.elfinder-overlay)').each(function() {
opts = Object.assign({}, opts);
$(this).addClass('ui-front ui-widget-overlay elfinder-overlay')
.hide()
.on('mousedown', function(e) {
e.preventDefault();
e.stopPropagation();
})
.data({
cnt : 0,
show : typeof(opts.show) == 'function' ? opts.show : function() { },
hide : typeof(opts.hide) == 'function' ? opts.hide : function() { }
});
});
if (opts == 'show') {
o = this.eq(0);
cnt = o.data('cnt') + 1;
show = o.data('show');
fm.toFront(o);
o.data('cnt', cnt);
if (o.is(':hidden')) {
o.show();
show();
}
}
if (opts == 'hide') {
o = this.eq(0);
cnt = o.data('cnt') - 1;
hide = o.data('hide');
o.data('cnt', cnt);
if (cnt <= 0) {
o.hide();
hide();
}
}
return this;
};