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

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

Packing js files +using GPC 3.3.0 categorySelector

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