1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
(function ($) {
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
Drupal.behaviors.dashboard = {
|
12 |
|
|
attach: function (context, settings) {
|
13 |
|
|
$('#dashboard', context).once(function () {
|
14 |
|
|
$(this).prepend('<div class="customize clearfix"><ul class="action-links"><li><a href="#">' + Drupal.t('Customize dashboard') + '</a></li></ul><div class="canvas"></div></div>');
|
15 |
|
|
$('.customize .action-links a', this).click(Drupal.behaviors.dashboard.enterCustomizeMode);
|
16 |
|
|
});
|
17 |
|
|
Drupal.behaviors.dashboard.addPlaceholders();
|
18 |
|
|
if (Drupal.settings.dashboard.launchCustomize) {
|
19 |
|
|
Drupal.behaviors.dashboard.enterCustomizeMode();
|
20 |
|
|
}
|
21 |
|
|
},
|
22 |
|
|
|
23 |
|
|
addPlaceholders: function() {
|
24 |
|
|
$('#dashboard .dashboard-region .region').each(function () {
|
25 |
|
|
var empty_text = "";
|
26 |
|
|
|
27 |
|
|
if ($('.block', this).length == 0) {
|
28 |
|
|
|
29 |
|
|
if ($('#dashboard').hasClass('customize-mode')) {
|
30 |
|
|
empty_text = Drupal.settings.dashboard.emptyRegionTextActive;
|
31 |
|
|
} else {
|
32 |
|
|
empty_text = Drupal.settings.dashboard.emptyRegionTextInactive;
|
33 |
|
|
}
|
34 |
|
|
|
35 |
b4adf10d
|
Assos Assos
|
if ($('.dashboard-placeholder', this).length == 0) {
|
36 |
|
|
$(this).append('<div class="dashboard-placeholder"></div>');
|
37 |
85ad3d82
|
Assos Assos
|
}
|
38 |
b4adf10d
|
Assos Assos
|
$('.dashboard-placeholder', this).html(empty_text);
|
39 |
85ad3d82
|
Assos Assos
|
}
|
40 |
|
|
else {
|
41 |
b4adf10d
|
Assos Assos
|
$('.dashboard-placeholder', this).remove();
|
42 |
85ad3d82
|
Assos Assos
|
}
|
43 |
|
|
});
|
44 |
|
|
},
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
enterCustomizeMode: function () {
|
50 |
|
|
$('#dashboard').addClass('customize-mode customize-inactive');
|
51 |
|
|
Drupal.behaviors.dashboard.addPlaceholders();
|
52 |
|
|
|
53 |
|
|
$('#dashboard .customize .action-links').hide();
|
54 |
|
|
|
55 |
|
|
$('div.customize .canvas').load(Drupal.settings.dashboard.drawer, Drupal.behaviors.dashboard.setupDrawer);
|
56 |
|
|
},
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
exitCustomizeMode: function () {
|
62 |
|
|
$('#dashboard').removeClass('customize-mode customize-inactive');
|
63 |
|
|
Drupal.behaviors.dashboard.addPlaceholders();
|
64 |
|
|
location.href = Drupal.settings.dashboard.dashboard;
|
65 |
|
|
},
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
setupDrawer: function () {
|
71 |
|
|
$('div.customize .canvas-content input').click(Drupal.behaviors.dashboard.exitCustomizeMode);
|
72 |
|
|
$('div.customize .canvas-content').append('<a class="button" href="' + Drupal.settings.dashboard.dashboard + '">' + Drupal.t('Done') + '</a>');
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
var regions = $('#dashboard div.region');
|
76 |
|
|
regions.sortable({
|
77 |
|
|
connectWith: regions,
|
78 |
|
|
cursor: 'move',
|
79 |
|
|
cursorAt: {top:0},
|
80 |
|
|
dropOnEmpty: true,
|
81 |
|
|
items: '> div.block, > div.disabled-block',
|
82 |
|
|
placeholder: 'block-placeholder clearfix',
|
83 |
|
|
tolerance: 'pointer',
|
84 |
|
|
start: Drupal.behaviors.dashboard.start,
|
85 |
|
|
over: Drupal.behaviors.dashboard.over,
|
86 |
|
|
sort: Drupal.behaviors.dashboard.sort,
|
87 |
|
|
update: Drupal.behaviors.dashboard.update
|
88 |
|
|
});
|
89 |
|
|
},
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
start: function (event, ui) {
|
102 |
|
|
$('#dashboard').removeClass('customize-inactive');
|
103 |
|
|
var item = $(ui.item);
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
if (!item.hasClass('disabled-block')) {
|
107 |
|
|
item.css({height: 'auto'});
|
108 |
|
|
}
|
109 |
|
|
},
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
over: function (event, ui) {
|
122 |
|
|
var item = $(ui.item);
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
if ($(this).closest('#disabled-blocks').length) {
|
126 |
|
|
item.css('width', '');
|
127 |
|
|
}
|
128 |
|
|
else {
|
129 |
|
|
item.css('width', $(this).width());
|
130 |
|
|
}
|
131 |
|
|
},
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
sort: function (event, ui) {
|
144 |
|
|
var item = $(ui.item);
|
145 |
|
|
|
146 |
|
|
if (event.pageX > ui.offset.left + item.width()) {
|
147 |
|
|
item.css('left', event.pageX);
|
148 |
|
|
}
|
149 |
|
|
},
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
update: function (event, ui) {
|
162 |
|
|
$('#dashboard').addClass('customize-inactive');
|
163 |
|
|
var item = $(ui.item);
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
if (item.hasClass('disabled-block')) {
|
167 |
|
|
var module, delta, itemClass;
|
168 |
|
|
itemClass = item.attr('class');
|
169 |
|
|
|
170 |
|
|
module = itemClass.match(/\bmodule-(\S+)\b/)[1];
|
171 |
|
|
delta = itemClass.match(/\bdelta-(\S+)\b/)[1];
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
$.get(Drupal.settings.dashboard.blockContent + '/' + module + '/' + delta, {},
|
175 |
|
|
function (block) {
|
176 |
|
|
if (block) {
|
177 |
|
|
item.html(block);
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
if (item.find('div.content').is(':empty')) {
|
181 |
|
|
item.find('div.content').html(Drupal.settings.dashboard.emptyBlockText);
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
Drupal.attachBehaviors(item);
|
185 |
|
|
},
|
186 |
|
|
'html'
|
187 |
|
|
);
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
item.removeClass("disabled-block");
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
Drupal.behaviors.dashboard.addPlaceholders();
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
$.post(Drupal.settings.dashboard.updatePath, {
|
197 |
|
|
'form_token': Drupal.settings.dashboard.formToken,
|
198 |
|
|
'regions': Drupal.behaviors.dashboard.getOrder
|
199 |
|
|
}
|
200 |
|
|
);
|
201 |
|
|
},
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
getOrder: function () {
|
210 |
|
|
var order = [];
|
211 |
|
|
$('#dashboard div.region').each(function () {
|
212 |
|
|
var region = $(this).parent().attr('id').replace(/-/g, '_');
|
213 |
|
|
var blocks = $(this).sortable('toArray');
|
214 |
|
|
$.each(blocks, function() {
|
215 |
|
|
order.push(region + '[]=' + this);
|
216 |
|
|
});
|
217 |
|
|
});
|
218 |
|
|
order = order.join('&');
|
219 |
|
|
return order;
|
220 |
|
|
}
|
221 |
|
|
};
|
222 |
|
|
|
223 |
|
|
})(jQuery); |