/
script.js
79 lines (63 loc) · 1.69 KB
/
script.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*jslint white: true, browser: true, undef: true, nomen: true, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxerr: 14 */
/*global window: false, REDIPS: true */
/* enable strict mode */
"use strict";
var redipsInit,
shiftMode,
overflow,
shiftAnimation,
shiftAfter,
toggleConfirm,
counter = 0;
// redips initialization
redipsInit = function () {
// reference to the REDIPS.drag library
var rd = REDIPS.drag;
// initialization
rd.init();
// set mode option to "shift"
rd.dropMode = 'shift';
// enable animation on shifted elements
rd.animation.shift = true;
// set animation loop pause
rd.animation.pause = 20;
// add counter to cloned element name
rd.event.cloned = function () {
// increase counter
counter++;
// append to the DIV element name
rd.obj.innerHTML += counter;
};
};
// set shift mode
shiftMode = function (radio) {
REDIPS.drag.shift.mode= radio.value;
};
// set overflow
overflow = function (radio) {
REDIPS.drag.shift.overflow = radio.value;
};
// enable / disable animation
shiftAnimation = function (chk) {
REDIPS.drag.animation.shift = chk.checked;
};
// enable / disable shift after element is deleted
shiftAfter = function (chk) {
REDIPS.drag.shift.after = chk.value;
};
// toggles trash_ask parameter defined at the top
toggleConfirm = function (chk) {
if (chk.checked === true) {
REDIPS.drag.trash.question = 'Are you sure you want to delete DIV element?';
}
else {
REDIPS.drag.trash.question = null;
}
};
// add onload event listener
if (window.addEventListener) {
window.addEventListener('load', redipsInit, false);
}
else if (window.attachEvent) {
window.attachEvent('onload', redipsInit);
}