source: extensions/GMaps/admin/gmaps_category_maps.tpl @ 7132

Last change on this file since 7132 was 7132, checked in by grum, 14 years ago

KML files manager implemented + fixe some small bugs + forgotten file for the search page

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