tadv.js
2.9 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// TinyMCE Advanced jQuery sortables
(function($) {
tadvSortable = {
init : function() {
$("#toolbar_1").sortable({
connectWith: ["#toolbar_2, #toolbar_3, #toolbar_4, #tadvpalette"],
items : 'li',
stop : tadvSortable.update,
revert : true,
opacity : 0.7,
containment : '#contain'
});
$("#toolbar_2").sortable({
connectWith: ["#toolbar_1, #toolbar_3, #toolbar_4, #tadvpalette"],
items : 'li',
stop : tadvSortable.update,
revert : true,
opacity : 0.7,
containment : '#contain'
});
$("#toolbar_3").sortable({
connectWith: ["#toolbar_2, #toolbar_1, #toolbar_4, #tadvpalette"],
items : 'li',
stop : tadvSortable.update,
revert : true,
opacity : 0.7,
containment : '#contain'
});
$("#toolbar_4").sortable({
connectWith: ["#toolbar_2, #toolbar_3, #toolbar_1, #tadvpalette"],
items : 'li',
stop : tadvSortable.update,
revert : true,
opacity : 0.7,
containment : '#contain'
});
$("#tadvpalette").sortable({
connectWith: ["#toolbar_1, #toolbar_2, #toolbar_3, #toolbar_4"],
items : 'li',
stop : tadvSortable.update,
revert : true,
opacity : 0.7,
containment : '#contain'
});
this.update();
$(window).resize(function(){
tadvSortable.update();
});
},
I : function(a) {
return document.getElementById(a);
},
serialize : function() {
var tb1, tb2, tb3, tb4;
tb1 = $('#toolbar_1').sortable('serialize',{expression : '([^_]+)_(.+)'});
tb2 = $('#toolbar_2').sortable('serialize',{expression : '([^_]+)_(.+)'});
tb3 = $('#toolbar_3').sortable('serialize',{expression : '([^_]+)_(.+)'})
tb4 = $('#toolbar_4').sortable('serialize',{expression : '([^_]+)_(.+)'})
$('#toolbar_1order').val(tb1);
$('#toolbar_2order').val(tb2);
$('#toolbar_3order').val(tb3);
$('#toolbar_4order').val(tb4);
if ( (tb1.indexOf('wp_adv') != -1 && ! tb2) ||
(tb2.indexOf('wp_adv') != -1 && ! tb3) ||
(tb3.indexOf('wp_adv') != -1 && ! tb4) ||
tb4.indexOf('wp_adv') != -1 ) {
$('#sink_err').css('display', 'inline');
return false;
}
$('#tadvadmin').submit();
},
reset : function() {
var pd = this.I('tadvpalette');
if ( ! pd ) return;
if( pd.childNodes.length > 6 ) {
var last = pd.lastChild.previousSibling;
pd.style.height = last.offsetTop + last.offsetHeight + 30 + "px";
} else pd.style.height = "60px";
},
update : function() {
var t = tadvSortable, w;
t.reset();
$('#too_long').css('display', 'none');
$('#sink_err').css('display', 'none');
$('.container').each(function(no,o){
var kids = o.childNodes, tbwidth = o.clientWidth, W = 0;
for( i = 0; i < kids.length; i++ ) {
if ( w = kids[i].offsetWidth )
W += w;
}
if( (W+8) > tbwidth )
$('#too_long').css('display', 'inline');
});
}
}
}(jQuery));
jQuery(document).ready(function(){ tadvSortable.init(); });