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

Last change on this file since 16011 was 16011, checked in by grum, 12 years ago

feature:2638- compatibility with Piwigo 2.4

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