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

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