-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdecoy.js
More file actions
37 lines (30 loc) · 728 Bytes
/
decoy.js
File metadata and controls
37 lines (30 loc) · 728 Bytes
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
// Decoy 2.0.0
// More on https://github.com/corenzan/decoy
;(function($) {
$.fn.decoy = function() {
return this.map(function() {
var that, decoy;
that = $(this);
decoy = that.data('decoy');
if (!decoy) {
decoy = that.clone(true, true);
decoy.data('actual', that);
that.data('decoy', decoy);
that.before(decoy).detach();
}
return decoy[0];
});
};
$.fn.restore = function() {
return this.map(function() {
var that, actual;
that = $(this);
decoy = that.data('decoy');
if (decoy) {
decoy.before(that).detach();
that.removeData('decoy');
}
return that[0];
});
};
}(this.jQuery));