1 | {known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"} |
---|
2 | {known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js"} |
---|
3 | {known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"} |
---|
4 | {known_script id="maps.google.com/api" src="http://maps.google.com/maps/api/js?sensor=false"} |
---|
5 | |
---|
6 | |
---|
7 | {literal} |
---|
8 | |
---|
9 | <script type="text/javascript"> |
---|
10 | |
---|
11 | |
---|
12 | function assocManager () |
---|
13 | { |
---|
14 | var properties = { |
---|
15 | id:'', |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | /** |
---|
20 | * initialize the page |
---|
21 | */ |
---|
22 | this.init = function () |
---|
23 | { |
---|
24 | |
---|
25 | $('#iDialogEdit') |
---|
26 | .dialog( |
---|
27 | { |
---|
28 | autoOpen:false, |
---|
29 | width:800, |
---|
30 | height:450, |
---|
31 | modal: true, |
---|
32 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
33 | title: '{/literal}{"gmaps_manage_assoc"|@translate}{literal}', |
---|
34 | buttons: |
---|
35 | { |
---|
36 | '{/literal}{"gmaps_ok"|@translate}{literal}': |
---|
37 | function() |
---|
38 | { |
---|
39 | if(checkValidity()) doUpdate(); |
---|
40 | }, |
---|
41 | '{/literal}{"gmaps_cancel"|@translate}{literal}': |
---|
42 | function() |
---|
43 | { |
---|
44 | $('#iDialogEdit').dialog("close"); |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | ); |
---|
49 | |
---|
50 | $('#iBDAssocMapId').bind('change', changeMapDisplayType); |
---|
51 | |
---|
52 | loadList(); |
---|
53 | |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * called when the map is changed |
---|
58 | * refresh the icon list |
---|
59 | */ |
---|
60 | var changeMapDisplayType = function () |
---|
61 | { |
---|
62 | switch($('#iBDAssocMapId option:selected').attr('dtype')) |
---|
63 | { |
---|
64 | case 'IC': |
---|
65 | case 'IP': |
---|
66 | $('#iBDAssocIconRow').show(); |
---|
67 | break; |
---|
68 | case 'MP': |
---|
69 | $('#iBDAssocIconRow').hide(); |
---|
70 | break; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | /** |
---|
76 | * manage the tabsheet |
---|
77 | * |
---|
78 | * @param String tabsheet : id of the tabsheet to display |
---|
79 | */ |
---|
80 | this.displayTab = function (tabsheet) |
---|
81 | { |
---|
82 | switch(tabsheet) |
---|
83 | { |
---|
84 | case 'integration': |
---|
85 | $('#iTabIntegration').css('display', 'block'); |
---|
86 | $('#iTabAssoc').css('display', 'none'); |
---|
87 | break; |
---|
88 | case 'assoc': |
---|
89 | $('#iTabIntegration').css('display', 'none'); |
---|
90 | $('#iTabAssoc').css('display', 'block'); |
---|
91 | break; |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | /** |
---|
97 | * open the dialog box to edit the association properties |
---|
98 | * |
---|
99 | * @param String id : if set to '' => open dialogbox in 'add' mode |
---|
100 | * otherwise edit the given association |
---|
101 | */ |
---|
102 | this.editAssoc = function (id) |
---|
103 | { |
---|
104 | properties.id=id; |
---|
105 | updateDialog(''); |
---|
106 | this.displayTab('assoc'); |
---|
107 | // >> because li items don't have id... :-( |
---|
108 | $('#itab2 li').removeClass('selected_tab').addClass('normal_tab'); |
---|
109 | $('#itab2 li:first').addClass('selected_tab'); |
---|
110 | // << |
---|
111 | |
---|
112 | $('#iDialogEdit') |
---|
113 | .bind('dialogopen', function () |
---|
114 | { |
---|
115 | if(properties.id!='') |
---|
116 | { |
---|
117 | displayProcessing(true); |
---|
118 | |
---|
119 | $.ajax( |
---|
120 | { |
---|
121 | type: "POST", |
---|
122 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
123 | async: true, |
---|
124 | data: { ajaxfct:"admin.assoc.getAssoc", id:properties.id }, |
---|
125 | success: |
---|
126 | function(msg) |
---|
127 | { |
---|
128 | updateDialog(msg); |
---|
129 | displayProcessing(false); |
---|
130 | } |
---|
131 | } |
---|
132 | ); |
---|
133 | } |
---|
134 | } |
---|
135 | ) |
---|
136 | .dialog("open"); |
---|
137 | } |
---|
138 | |
---|
139 | /** |
---|
140 | * delete an association |
---|
141 | * |
---|
142 | * @param String id : id of the association to delete |
---|
143 | */ |
---|
144 | this.deleteAssoc = function (id) |
---|
145 | { |
---|
146 | $('#iDialogDelete') |
---|
147 | .html('<br>{/literal}{"gmaps_pleaseConfirmAssoc"|@translate}{literal}') |
---|
148 | .dialog( |
---|
149 | { |
---|
150 | autoOpen:true, |
---|
151 | modal: true, |
---|
152 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
153 | title: '{/literal}{"gmaps_deleteAssoc"|@translate}{literal}', |
---|
154 | buttons: |
---|
155 | { |
---|
156 | '{/literal}{"gmaps_delete"|@translate}{literal}': |
---|
157 | function() |
---|
158 | { |
---|
159 | $(this).html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>"); |
---|
160 | $.ajax( |
---|
161 | { |
---|
162 | type: "POST", |
---|
163 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
164 | async: true, |
---|
165 | data: { ajaxfct:"admin.assoc.deleteAssoc", id:id }, |
---|
166 | success: |
---|
167 | function(msg) |
---|
168 | { |
---|
169 | $('#iDialogDelete').dialog("destroy"); |
---|
170 | loadList(); |
---|
171 | } |
---|
172 | } |
---|
173 | ); |
---|
174 | }, |
---|
175 | '{/literal}{"gmaps_cancel"|@translate}{literal}': |
---|
176 | function() |
---|
177 | { |
---|
178 | $('#iDialogDelete').dialog("destroy"); |
---|
179 | } |
---|
180 | } |
---|
181 | } |
---|
182 | ); |
---|
183 | } |
---|
184 | |
---|
185 | /** |
---|
186 | * update values of the dialog box |
---|
187 | * |
---|
188 | * @param String items : json string ; if empty assume to reset all fields |
---|
189 | * with blank |
---|
190 | */ |
---|
191 | var updateDialog = function (items) |
---|
192 | { |
---|
193 | if(items=='') |
---|
194 | { |
---|
195 | $('#iBDAssocCatId').val(0); |
---|
196 | $('#iBDAssocMapId').val($('#iBDAssocMapId option:first').val()); |
---|
197 | $('#iBDAssocApplySubCat').val('y'); |
---|
198 | $('#iBDAssocKmlFileUrl').val(''); |
---|
199 | $('#iBDAssocIcon').val($('#iBDAssocIcon option:visible:first').val()); |
---|
200 | $('#iBDAssocTitle').val(''); |
---|
201 | } |
---|
202 | else |
---|
203 | { |
---|
204 | tmp=$.parseJSON(items); |
---|
205 | |
---|
206 | $('#iBDAssocCatId').val(tmp.categoryId); |
---|
207 | $('#iBDAssocMapId').val(tmp.mapId); |
---|
208 | $('#iBDAssocApplySubCat').val(tmp.applySubCat); |
---|
209 | $('#iBDAssocKmlFileUrl').val(tmp.kmlFileUrl); |
---|
210 | $('#iBDAssocIcon').val(tmp.icon); |
---|
211 | $('#iBDAssocTitle').val(tmp.title); |
---|
212 | } |
---|
213 | |
---|
214 | changeMapDisplayType(); |
---|
215 | } |
---|
216 | |
---|
217 | /** |
---|
218 | * reload the assocation list |
---|
219 | */ |
---|
220 | var loadList = function () |
---|
221 | { |
---|
222 | $('#iListAssoc').html("<br>{/literal}{'gmaps_loading'|@translate}{literal}<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>"); |
---|
223 | |
---|
224 | $.ajax( |
---|
225 | { |
---|
226 | type: "POST", |
---|
227 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
228 | async: true, |
---|
229 | data: { ajaxfct:"admin.assoc.getList" }, |
---|
230 | success: |
---|
231 | function(msg) |
---|
232 | { |
---|
233 | $("#iListAssoc").html(msg); |
---|
234 | } |
---|
235 | } |
---|
236 | ); |
---|
237 | } |
---|
238 | |
---|
239 | |
---|
240 | /** |
---|
241 | * check for the validity of the map settings |
---|
242 | */ |
---|
243 | var checkValidity = function () |
---|
244 | { |
---|
245 | $('.error').removeClass('error'); |
---|
246 | ok=true; |
---|
247 | /* |
---|
248 | if(checkIdValidity($('#iBDMapId').val())==false) |
---|
249 | { |
---|
250 | $('#iBDMapId').addClass('error'); |
---|
251 | alert('{/literal}{"gmaps_invalidId"|@translate}{literal}'); |
---|
252 | ok=false; |
---|
253 | } |
---|
254 | */ |
---|
255 | return(ok); |
---|
256 | } |
---|
257 | |
---|
258 | /** |
---|
259 | * send assoc update to the server, and close the dialog box if everything |
---|
260 | * is ok |
---|
261 | */ |
---|
262 | var doUpdate = function () |
---|
263 | { |
---|
264 | displayProcessing(true); |
---|
265 | |
---|
266 | // build datas |
---|
267 | datas = { |
---|
268 | categoryId:$('#iBDAssocCatId').val(), |
---|
269 | mapId:$('#iBDAssocMapId').val(), |
---|
270 | applySubCat:$('#iBDAssocApplySubCat').val(), |
---|
271 | kmlFileUrl:$('#iBDAssocKmlFileUrl').val(), |
---|
272 | icon:$('#iBDAssocIcon').val(), |
---|
273 | title:$('#iBDAssocTitle').val(), |
---|
274 | } |
---|
275 | |
---|
276 | $.ajax( |
---|
277 | { |
---|
278 | type: "POST", |
---|
279 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
280 | async: true, |
---|
281 | data: { ajaxfct:"admin.assoc.setAssoc", id:properties.id, datas:datas }, |
---|
282 | success: |
---|
283 | function(msg) |
---|
284 | { |
---|
285 | displayProcessing(false); |
---|
286 | |
---|
287 | if(msg.match(/^[0-9]+$/i)!=null) |
---|
288 | { |
---|
289 | // result Ok ! => close the dialog box and reload the list |
---|
290 | $('#iDialogEdit').dialog("close"); |
---|
291 | loadList(); |
---|
292 | } |
---|
293 | else |
---|
294 | { |
---|
295 | returned=msg.split('!'); |
---|
296 | if(returned[0]!='') $('#'+returned[0]).addClass('error'); |
---|
297 | alert(returned[1]); |
---|
298 | } |
---|
299 | } |
---|
300 | } |
---|
301 | ); |
---|
302 | } |
---|
303 | |
---|
304 | /** |
---|
305 | * display or hide the processing flower |
---|
306 | */ |
---|
307 | var displayProcessing = function (visible) |
---|
308 | { |
---|
309 | if(visible) |
---|
310 | { |
---|
311 | $('#iBDProcessing').css("display", "block"); |
---|
312 | } |
---|
313 | else |
---|
314 | { |
---|
315 | $('#iBDProcessing').css("display", "none"); |
---|
316 | } |
---|
317 | } |
---|
318 | |
---|
319 | this.init(); |
---|
320 | } |
---|
321 | |
---|
322 | |
---|
323 | </script> |
---|
324 | |
---|
325 | {/literal} |
---|
326 | |
---|
327 | |
---|
328 | |
---|
329 | <h2>{'gmaps_associate_category_maps'|@translate}</h2> |
---|
330 | |
---|
331 | |
---|
332 | <div class='addMap'> |
---|
333 | <a onclick="am.editAssoc('');">{'gmaps_add_a_new_association'|@translate}</a> |
---|
334 | </div> |
---|
335 | |
---|
336 | |
---|
337 | <table id='iHeaderListMaps' class="littlefont"> |
---|
338 | <tr> |
---|
339 | <th>{'gmaps_category'|@translate}</th> |
---|
340 | <th style="width:90px;">{'gmaps_apply_subcat'|@translate}</th> |
---|
341 | <th style="width:90px;">{'gmaps_mapType'|@translate}</th> |
---|
342 | <th style="width:356px;">{'gmaps_map'|@translate}</th> |
---|
343 | <th style="width:90px;">{'gmaps_map_kmlfile'|@translate}</th> |
---|
344 | <th width="40px"> </th> |
---|
345 | </tr> |
---|
346 | </table> |
---|
347 | |
---|
348 | |
---|
349 | |
---|
350 | <div id='iListAssoc' class="{$themeconf.name}"> |
---|
351 | </div> |
---|
352 | <div id="iListAssocNb"></div> |
---|
353 | |
---|
354 | <div id="iDialogDelete"> |
---|
355 | </div> |
---|
356 | |
---|
357 | <div id="iDialogEdit"> |
---|
358 | <div id='iBDProcessing' style="display:none;position:absolute;width:100%;height:100%;background:#000000;opacity:0.75"> |
---|
359 | <img src="plugins/GrumPluginClasses/icons/processing.gif" style="margin-top:100px;"> |
---|
360 | </div> |
---|
361 | |
---|
362 | {$mapTabsheet} |
---|
363 | <form> |
---|
364 | |
---|
365 | <div id='iTabsContainer' style='height:100px;'> |
---|
366 | |
---|
367 | |
---|
368 | <div id='iTabAssoc' style='display:none;'> |
---|
369 | <table class="formtable"> |
---|
370 | <tr> |
---|
371 | <td>{'gmaps_map'|@translate}</td> |
---|
372 | <td> |
---|
373 | <select id='iBDAssocMapId'> |
---|
374 | {foreach from=$datas.maps key=group item=mapGroup} |
---|
375 | <optgroup label="{'gmaps_displayTypeShort'|cat:$group|@translate}"> |
---|
376 | {foreach from=$mapGroup item=map} |
---|
377 | <option value='{$map.id}' dtype='{$group}'>{$map.name}</option> |
---|
378 | {/foreach} |
---|
379 | </optgroup> |
---|
380 | {/foreach} |
---|
381 | </select> |
---|
382 | </td> |
---|
383 | </tr> |
---|
384 | |
---|
385 | <tr> |
---|
386 | <td>{'gmaps_category'|@translate}</td> |
---|
387 | <td> |
---|
388 | <select id='iBDAssocCatId'> |
---|
389 | {foreach from=$datas.cats item=cat} |
---|
390 | <option value='{$cat.id}'>{$cat.name}</option> |
---|
391 | {/foreach} |
---|
392 | </select> |
---|
393 | </td> |
---|
394 | </tr> |
---|
395 | |
---|
396 | <tr> |
---|
397 | <td>{'gmaps_apply_subcat'|@translate}</td> |
---|
398 | <td> |
---|
399 | <select id='iBDAssocApplySubCat'> |
---|
400 | <option value='y'>{'gmaps_y'|@translate}</option> |
---|
401 | <option value='n'>{'gmaps_n'|@translate}</option> |
---|
402 | </select> |
---|
403 | </td> |
---|
404 | </tr> |
---|
405 | |
---|
406 | </table> |
---|
407 | </div> |
---|
408 | |
---|
409 | |
---|
410 | <div id='iTabIntegration' style='display:none;'> |
---|
411 | <table class='formtable'> |
---|
412 | |
---|
413 | <tr id='iBDAssocTitleRow'> |
---|
414 | <td>{'gmaps_map_title'|@translate}</td> |
---|
415 | <td> |
---|
416 | <input type="text" id='iBDAssocTitle' value='{$datas.title}' maxlength='200' size='55'> |
---|
417 | </td> |
---|
418 | </tr> |
---|
419 | |
---|
420 | <tr id='iBDAssocIconRow'> |
---|
421 | <td>{'gmaps_map_icon'|@translate}</td> |
---|
422 | <td> |
---|
423 | <select id='iBDAssocIcon'> |
---|
424 | {foreach from=$datas.icons item=icon} |
---|
425 | <option class='{$icon.type}' value='{$icon.file}'>{$icon.file}</option> |
---|
426 | {/foreach} |
---|
427 | </select> |
---|
428 | </td> |
---|
429 | </tr> |
---|
430 | |
---|
431 | <tr> |
---|
432 | <td>{'gmaps_map_associate_kmlfile'|@translate}</td> |
---|
433 | <td> |
---|
434 | <input type="text" id="iBDAssocKmlFileUrl" maxlength='255' size='55' value=""> |
---|
435 | </td> |
---|
436 | </tr> |
---|
437 | |
---|
438 | |
---|
439 | </table> |
---|
440 | </div> |
---|
441 | |
---|
442 | </div> |
---|
443 | |
---|
444 | </form> |
---|
445 | </div> |
---|
446 | |
---|
447 | |
---|
448 | |
---|
449 | |
---|
450 | |
---|
451 | {literal} |
---|
452 | <script type="text/javascript"> |
---|
453 | var am=new assocManager(); |
---|
454 | </script> |
---|
455 | {/literal} |
---|
456 | |
---|