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