-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
85 lines (72 loc) · 2.64 KB
/
index.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
80
81
82
83
84
85
$(function() {
$("body").on("click", ".ajey", function() {
alert("click works");
});
$('.sortable').dragswap({
element : '.handle',
// element : 'li',
dropzone: '.item',
dropAnimation: true,
dropComplete: function(dragSrcEl, originalParent) {
console.log("original", $(dragSrcEl));
console.log("dragged", $(originalParent));
var draggedElement = $(originalParent);
var originalElement = $(dragSrcEl);
var originalState = $(dragSrcEl).attr("data-mode");
if(!(draggedElement.attr("data-mode") === "close" && originalElement.attr("data-mode") === "close")
&&
!(draggedElement.attr("data-mode") === "open" && originalElement.attr("data-mode") === "open")
) {
if(originalState === "open") {
expand(draggedElement);
collpase(originalElement);
} else {
expand(originalElement);
collpase(draggedElement);
}
}
}
});
$("body").on("click", ".min", function() {
var that = this;
var element = $(this).closest(".item");
var otherElement;
if(element.attr("data-mode") === "open") {
collpase(element, true);
} else if(element.attr("data-mode") === "close") {
expand(element, true);
}
element.closest(".column").find(".item").each(function(idx, item) {
if(element.attr("id") !== $(item).attr("id")) {
otherElement = $(item);
}
});
if(otherElement) {
console.log(otherElement);
if(otherElement.attr("data-mode") === "open") {
collpase(otherElement, true);
} else if(otherElement.attr("data-mode") === "close") {
expand(otherElement, true);
}
}
});
function collpase(element, animate) {
if(animate) {
element.find(".content").slideUp();
} else {
element.find(".content").hide();
}
element.find(".content").hide();
element.attr("data-mode", "close");
element.find(".min").css("background", "url('images/ic_plus_32px.png')");
}
function expand(element, animate) {
if(animate) {
element.find(".content").slideDown();
} else {
element.find(".content").show();
}
element.attr("data-mode", "open");
element.find(".min").css("background", "url('images/ic_minus_32px.png')");
}
});