1 | |
---|
2 | |
---|
3 | {literal} |
---|
4 | <script type="text/javascript"> |
---|
5 | |
---|
6 | function init() |
---|
7 | { |
---|
8 | $("#iGroups") |
---|
9 | .html( |
---|
10 | $.ajax( |
---|
11 | { |
---|
12 | type: "POST", |
---|
13 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
14 | async: false, |
---|
15 | data: { ajaxfct:"groupGetList" } |
---|
16 | } |
---|
17 | ).responseText |
---|
18 | ) |
---|
19 | .sortable( |
---|
20 | { |
---|
21 | connectWith: '.connectedSortable', |
---|
22 | cursor: 'move', |
---|
23 | opacity:0.6, |
---|
24 | items: 'li.groupItems', |
---|
25 | axis:'y', |
---|
26 | tolerance:'intersect', |
---|
27 | start: function (event, ui) |
---|
28 | { |
---|
29 | manageGroup(event.originalTarget.id.substr(8), 'n'); |
---|
30 | }, |
---|
31 | update: function (event, ui) |
---|
32 | { |
---|
33 | list=""; |
---|
34 | $("#iGroups li").each( |
---|
35 | function () |
---|
36 | { |
---|
37 | if(list!="") list+=";"; |
---|
38 | list+=this.id.substr(8); |
---|
39 | } |
---|
40 | ); |
---|
41 | list=list.substr(0, list.lastIndexOf(';')); |
---|
42 | $.ajax( |
---|
43 | { |
---|
44 | type: "POST", |
---|
45 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
46 | async: false, |
---|
47 | data: { ajaxfct:"groupSetOrder", listGroup:list } |
---|
48 | } |
---|
49 | ).responseText; |
---|
50 | } |
---|
51 | } |
---|
52 | ); |
---|
53 | } |
---|
54 | |
---|
55 | function initSubList(groupId) |
---|
56 | { |
---|
57 | $("#iGroupId"+groupId+"_tags").sortable( |
---|
58 | { |
---|
59 | connectWith: '.g'+groupId+'_connectedSortableTags', |
---|
60 | cursor: 'move', |
---|
61 | opacity:0.6, |
---|
62 | items: 'li', |
---|
63 | axis:'y', |
---|
64 | tolerance:'pointer', |
---|
65 | containment: 'parent', |
---|
66 | update: function (event, ui) |
---|
67 | { |
---|
68 | list=""; |
---|
69 | $("#iGroupId"+groupId+"_tags li").each( |
---|
70 | function () |
---|
71 | { |
---|
72 | if(list!="") list+=";"; |
---|
73 | list+=this.id.substr(this.id.indexOf('t')+1); |
---|
74 | } |
---|
75 | ); |
---|
76 | list=list.substr(0, list.lastIndexOf(';')); |
---|
77 | $.ajax( |
---|
78 | { |
---|
79 | type: "POST", |
---|
80 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
81 | async: false, |
---|
82 | data: { ajaxfct:"groupSetOrderedTagList", id:groupId, listTag:list } |
---|
83 | } |
---|
84 | ).responseText; |
---|
85 | } |
---|
86 | |
---|
87 | } |
---|
88 | ); |
---|
89 | } |
---|
90 | |
---|
91 | function loadGroupTags(groupId) |
---|
92 | { |
---|
93 | $("#iGroupId"+groupId+"_tags").html( |
---|
94 | $.ajax( |
---|
95 | { |
---|
96 | type: "POST", |
---|
97 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
98 | async: false, |
---|
99 | data: { ajaxfct:"groupGetOrderedTagList", id:groupId } |
---|
100 | } |
---|
101 | ).responseText |
---|
102 | ); |
---|
103 | } |
---|
104 | |
---|
105 | function manageGroup(groupId, force) |
---|
106 | { |
---|
107 | if(force=='y') |
---|
108 | { |
---|
109 | currentVisibility='hidden'; |
---|
110 | } |
---|
111 | else if(force=='n') |
---|
112 | { |
---|
113 | currentVisibility='visible'; |
---|
114 | } |
---|
115 | else |
---|
116 | { |
---|
117 | currentVisibility=$("#iGroupId"+groupId+"_content").css('visibility'); |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | if(currentVisibility=='visible') |
---|
122 | { |
---|
123 | $("div[name=fGroupId"+groupId+"_content]").css( |
---|
124 | { |
---|
125 | visibility:"hidden", |
---|
126 | height:"0px" |
---|
127 | } |
---|
128 | ); |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | $("div[name=fGroupId"+groupId+"_content]").css( |
---|
133 | { |
---|
134 | visibility:"visible", |
---|
135 | height:"auto" |
---|
136 | } |
---|
137 | ); |
---|
138 | loadGroupTags(groupId); |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | function deleteGroup(groupId) |
---|
143 | { |
---|
144 | if(groupId!="") |
---|
145 | { |
---|
146 | groupName=$("#iGroupName"+groupId).val(); |
---|
147 | $("#dialog") |
---|
148 | .html("") |
---|
149 | .dialog( |
---|
150 | { |
---|
151 | resizable: true, |
---|
152 | width:480, |
---|
153 | height:120, |
---|
154 | modal: true, |
---|
155 | draggable:true, |
---|
156 | title: "{/literal}{'g003_deleting_a_group'|@translate}{literal}", |
---|
157 | overlay: |
---|
158 | { |
---|
159 | backgroundColor: '#000', |
---|
160 | opacity: 0.5 |
---|
161 | }, |
---|
162 | buttons: |
---|
163 | { |
---|
164 | '{/literal}{"g003_yes"|@translate}{literal}': |
---|
165 | function() |
---|
166 | { |
---|
167 | $.ajax( |
---|
168 | { |
---|
169 | type: "POST", |
---|
170 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
171 | async: false, |
---|
172 | data: { ajaxfct:"groupDelete", id:groupId } |
---|
173 | } |
---|
174 | ).responseText; |
---|
175 | $("#iGroups").html( |
---|
176 | $.ajax( |
---|
177 | { |
---|
178 | type: "POST", |
---|
179 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
180 | async: false, |
---|
181 | data: { ajaxfct:"groupGetList" } |
---|
182 | } |
---|
183 | ).responseText |
---|
184 | ); |
---|
185 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
186 | }, |
---|
187 | '{/literal}{"g003_no"|@translate}{literal}': |
---|
188 | function() |
---|
189 | { |
---|
190 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
191 | } |
---|
192 | } |
---|
193 | } |
---|
194 | ) |
---|
195 | .html("<div class='dialogForm'>{/literal}{'g003_confirm_group_delete'|@translate}{literal}</div>".replace("%s", "<i>"+groupName+"</i>", "gi")); |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | function editGroup(groupId) |
---|
200 | { |
---|
201 | if(groupId=="") |
---|
202 | { |
---|
203 | dialogTitle="{/literal}{'g003_adding_a_group'|@translate}{literal}"; |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | dialogTitle="{/literal}{'g003_editing_a_group'|@translate}{literal}"; |
---|
208 | } |
---|
209 | |
---|
210 | $("#dialog") |
---|
211 | .html("") |
---|
212 | .dialog( |
---|
213 | { |
---|
214 | resizable: true, |
---|
215 | width:480, |
---|
216 | height:120, |
---|
217 | modal: true, |
---|
218 | draggable:true, |
---|
219 | title: dialogTitle, |
---|
220 | overlay: |
---|
221 | { |
---|
222 | backgroundColor: '#000', |
---|
223 | opacity: 0.5 |
---|
224 | }, |
---|
225 | buttons: |
---|
226 | { |
---|
227 | '{/literal}{"g003_ok"|@translate}{literal}': |
---|
228 | function() |
---|
229 | { |
---|
230 | list=""; |
---|
231 | $("form.dialogForm input[type='hidden']").each( |
---|
232 | function () |
---|
233 | { |
---|
234 | if(list!="") list+="\n"; |
---|
235 | list+=this.id.substr(6)+"="+this.value; |
---|
236 | } |
---|
237 | ) |
---|
238 | |
---|
239 | $.ajax( |
---|
240 | { |
---|
241 | type: "POST", |
---|
242 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
243 | async: false, |
---|
244 | data: { ajaxfct:"groupSetNames", id:groupId, listNames:list } |
---|
245 | } |
---|
246 | ).responseText; |
---|
247 | $("#iGroups").html( |
---|
248 | $.ajax( |
---|
249 | { |
---|
250 | type: "POST", |
---|
251 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
252 | async: false, |
---|
253 | data: { ajaxfct:"groupGetList" } |
---|
254 | } |
---|
255 | ).responseText |
---|
256 | ); |
---|
257 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
258 | }, |
---|
259 | '{/literal}{"g003_cancel"|@translate}{literal}': |
---|
260 | function() |
---|
261 | { |
---|
262 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
263 | } |
---|
264 | } |
---|
265 | } |
---|
266 | ) |
---|
267 | .html( |
---|
268 | $.ajax( |
---|
269 | { |
---|
270 | type: "POST", |
---|
271 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
272 | async: false, |
---|
273 | data: { ajaxfct:"groupGetNames", id:groupId } |
---|
274 | } |
---|
275 | ).responseText |
---|
276 | ); |
---|
277 | } |
---|
278 | |
---|
279 | |
---|
280 | function editGroupList(groupId) |
---|
281 | { |
---|
282 | $("#dialog") |
---|
283 | .html("") |
---|
284 | .dialog( |
---|
285 | { |
---|
286 | resizable: false, |
---|
287 | width:480, |
---|
288 | height:320, |
---|
289 | modal: true, |
---|
290 | draggable:true, |
---|
291 | title: '{/literal}{"g003_add_delete_tags"|@translate}{literal}', |
---|
292 | overlay: |
---|
293 | { |
---|
294 | backgroundColor: '#000', |
---|
295 | opacity: 0.5 |
---|
296 | }, |
---|
297 | open: function(event, ui) |
---|
298 | { |
---|
299 | bH=$("div.ui-dialog-buttonpane").get(0).clientHeight; |
---|
300 | $("#dialog").css('height', (this.clientHeight-bH)+"px"); |
---|
301 | }, |
---|
302 | buttons: |
---|
303 | { |
---|
304 | '{/literal}{"g003_ok"|@translate}{literal}': |
---|
305 | function() |
---|
306 | { |
---|
307 | list=""; |
---|
308 | $("#dialog table input").each( |
---|
309 | function () |
---|
310 | { |
---|
311 | if(this.checked) |
---|
312 | { |
---|
313 | if(list!="") list+=","; |
---|
314 | list+=this.id.substr(6); |
---|
315 | } |
---|
316 | } |
---|
317 | ) |
---|
318 | |
---|
319 | $.ajax( |
---|
320 | { |
---|
321 | type: "POST", |
---|
322 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
323 | async: false, |
---|
324 | data: { ajaxfct:"groupSetTagList", id:groupId, listTag:list } |
---|
325 | } |
---|
326 | ).responseText; |
---|
327 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
328 | loadGroupTags(groupId); |
---|
329 | }, |
---|
330 | '{/literal}{"g003_cancel"|@translate}{literal}': |
---|
331 | function() |
---|
332 | { |
---|
333 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
334 | } |
---|
335 | } |
---|
336 | } |
---|
337 | ) |
---|
338 | .html( |
---|
339 | $.ajax( |
---|
340 | { |
---|
341 | type: "POST", |
---|
342 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
343 | async: false, |
---|
344 | data: { ajaxfct:"groupGetTagList", id:groupId } |
---|
345 | } |
---|
346 | ).responseText |
---|
347 | ); |
---|
348 | } |
---|
349 | |
---|
350 | </script> |
---|
351 | {/literal} |
---|
352 | |
---|
353 | |
---|
354 | <h3>{'g003_display_management'|@translate}</h3> |
---|
355 | |
---|
356 | <div class="addGroup"> |
---|
357 | <a onclick="editGroup('');">{'g003_add_a_group'|@translate}</a> |
---|
358 | </div> |
---|
359 | |
---|
360 | |
---|
361 | <div id="dialog"></div> |
---|
362 | |
---|
363 | |
---|
364 | <div id="iGroupContainer"> |
---|
365 | <ul class="connectedSortable" id="iGroups"> |
---|
366 | </ul> |
---|
367 | </div> |
---|
368 | |
---|
369 | |
---|
370 | <script type="text/javascript"> |
---|
371 | init(); |
---|
372 | {foreach from=$datas.groups key=name item=data} |
---|
373 | initSubList({$data.id}); |
---|
374 | {/foreach} |
---|
375 | </script> |
---|