source: trunk/admin/themes/default/template/configuration.tpl @ 13079

Revision 13024, 16.6 KB checked in by plg, 8 years ago (diff)

smarter use of jQuery closure to manage conditional display of options

  • Property svn:eol-style set to LF
Line 
1{footer_script}{literal}
2jQuery(document).ready(function(){
3  jQuery("#activate_comments").change(function(){
4    if ($(this).is(':checked')) {
5      jQuery("#comments_param_warp").show();
6    } else {
7      jQuery("#comments_param_warp").hide();
8    }
9  });
10
11  var targets = {
12    'input[name="rate"]' : '#rate_anonymous',
13    'input[name="allow_user_registration"]' : '#email_admin_on_new_user',
14    'input[name="comments_validation"]' : '#email_admin_on_comment_validation',
15    'input[name="user_can_edit_comment"]' : '#email_admin_on_comment_edition',
16    'input[name="user_can_delete_comment"]' : '#email_admin_on_comment_deletion',
17  };
18
19  for (selector in targets) {
20    var target = targets[selector];
21
22    jQuery(target).toggle(jQuery(selector).is(':checked'));
23
24    (function(target){
25      jQuery(selector).bind('change', function() {
26        jQuery(target).toggle($(this).is(':checked'));
27      });
28    })(target);
29  };
30});
31{/literal}{/footer_script}
32
33<div class="titrePage">
34  <h2>{'Piwigo configuration'|@translate} {$TABSHEET_TITLE}</h2>
35</div>
36
37{if !isset($default)}
38<form method="post" action="{$F_ACTION}" class="properties">
39{/if}
40<div id="configContent">
41{if isset($main)}
42<fieldset id="mainConf">
43  <legend></legend>
44  <ul>
45    <li>
46     
47        <label for="gallery_title">{'Gallery title'|@translate}</label>
48      <br>
49      <input type="text" maxlength="255" size="50" name="gallery_title" id="gallery_title" value="{$main.CONF_GALLERY_TITLE}">
50    </li>
51
52    <li>
53     
54        <label for="page_banner">{'Page banner'|@translate}</label>
55      <br>
56      <textarea rows="5" cols="50" class="description" name="page_banner" id="page_banner">{$main.CONF_PAGE_BANNER}</textarea>
57    </li>
58
59    <li>
60      <label>
61        <input type="checkbox" name="rate" {if ($main.rate)}checked="checked"{/if}>
62        {'Allow rating'|@translate}
63      </label>
64    </li>
65
66    <li id="rate_anonymous">
67      <label>
68        <input type="checkbox" name="rate_anonymous" {if ($main.rate_anonymous)}checked="checked"{/if}>
69        {'Rating by guests'|@translate}
70      </label>
71    </li>
72
73    <li>
74      <label>
75        <input type="checkbox" name="allow_user_registration" {if ($main.allow_user_registration)}checked="checked"{/if}>
76        {'Allow user registration'|@translate}
77      </label>
78    </li>
79
80    <li id="email_admin_on_new_user">
81      <label>
82        <input type="checkbox" name="email_admin_on_new_user" {if ($main.email_admin_on_new_user)}checked="checked"{/if}>
83        {'Email admins when a new user registers'|@translate}
84      </label>
85    </li>
86
87    <li>
88      <label>
89        <input type="checkbox" name="allow_user_customization" {if ($main.allow_user_customization)}checked="checked"{/if}>
90        {'Allow user customization'|@translate}
91      </label>
92    </li>
93
94    <li>
95      <label>
96        <input type="checkbox" name="obligatory_user_mail_address" {if ($main.obligatory_user_mail_address)}checked="checked"{/if}>
97        {'Mail address is obligatory for all users'|@translate}
98      </label>
99    </li>
100
101    <li>
102      <label>{'Week starts on'|@translate}
103      {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}</label>
104    </li>
105   
106    <li>
107        <label>{'Default photos order'|@translate}</label>
108       
109        {foreach from=$main.order_by item=order}
110        <span class="filter {if $ORDER_BY_IS_CUSTOM}transparent{/if}">         
111          <select name="order_by_field[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
112            {html_options options=$main.order_field_options selected=$order.FIELD }
113          </select>
114          <select name="order_by_direction[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
115            {html_options options=$main.order_direction_options selected=$order.DIRECTION }
116          </select> 
117          <a class="removeFilter">{'delete'|@translate}</a>
118        </span>
119        {/foreach}
120       
121        {if !$ORDER_BY_IS_CUSTOM}
122          <a class="addFilter">{'Add a criteria'|@translate}</a>
123        {else}
124          <span class="order_by_is_custom">{'You can\'t define a default photo order because you have a custom setting in your local configuration.'|@translate}</span>
125        {/if}
126    </li>
127   
128{if !$ORDER_BY_IS_CUSTOM}
129{footer_script require='jquery'}
130// counters for displaying of addFilter link
131fields = {$main.order_by|@count}; max_fields = {$main.order_field_options|@count}; max_fields--;
132
133{literal}
134function updateAddFilterLink() {
135  if (fields >= max_fields) {
136    $('.addFilter').css('display', 'none');
137  } else {
138    $('.addFilter').css('display', '');
139  }
140}
141
142function updateRemoveFilterTrigger() {
143  $(".removeFilter").click(function () {
144    $(this).parent('span.filter').remove();
145    fields--;
146    updateAddFilterLink();
147  });
148}
149
150jQuery(document).ready(function () {
151  $('.addFilter').click(function() {
152    rel = $(this).attr('rel');
153    $(this).prev('span.filter').clone().insertBefore($(this));
154    $(this).prev('span.filter').children('select[name="order_by_field[]"]').val('');
155    $(this).prev('span.filter').children('select[name="order_by_direction[]"]').val('ASC');
156   
157    fields++;
158    updateAddFilterLink(); 
159    updateRemoveFilterTrigger();
160  });
161 
162  updateRemoveFilterTrigger();
163  updateAddFilterLink();
164});
165{/literal}
166{/footer_script}
167{/if}
168
169    <li>
170      <strong>{'Save visits in history for'|@translate}</strong>
171
172      <label>
173        <input type="checkbox" name="history_guest" {if ($main.history_guest)}checked="checked"{/if}>
174        {'simple visitors'|@translate}
175      </label>
176
177      <label>
178        <input type="checkbox" name="log" {if ($main.log)}checked="checked"{/if}>
179        {'registered users'|@translate}
180      </label>
181
182      <label>
183        <input type="checkbox" name="history_admin" {if ($main.history_admin)}checked="checked"{/if}>
184        {'administrators'|@translate}
185      </label>
186
187    </li>
188  </ul>
189</fieldset>
190{/if}
191
192{if isset($comments)}
193<fieldset id="commentsConf">
194  <legend></legend>
195  <ul>
196    <li>
197      <label>
198        <input type="checkbox" name="activate_comments" id="activate_comments"{if ($comments.activate_comments)}checked="checked"{/if}>
199        {'Activate comments'|@translate}
200      </label>
201    </li>
202  </ul>
203 
204  <ul id="comments_param_warp"{if not ($comments.activate_comments)} style="display:none;"{/if}>
205    <li>
206      <label>
207        <input type="checkbox" name="comments_forall" {if ($comments.comments_forall)}checked="checked"{/if}>
208        {'Comments for all'|@translate}
209      </label>
210    </li>
211
212    <li>
213      <label>
214        {'Number of comments per page'|@translate}
215        <input type="text" size="3" maxlength="4" name="nb_comment_page" id="nb_comment_page" value="{$comments.NB_COMMENTS_PAGE}">
216      </label>
217    </li>
218   
219    <li>
220      <label>
221        {'Default comments order'|@translate}
222        <select name="comments_order">
223          {html_options options=$comments.comments_order_options selected=$comments.comments_order}
224        </select>
225      </label>
226    </li>
227
228    <li>
229      <label>
230        <input type="checkbox" name="comments_validation" {if ($comments.comments_validation)}checked="checked"{/if}>
231        {'Validation'|@translate}
232      </label>
233    </li>
234
235    <li>
236      <label>
237        <input type="checkbox" name="user_can_edit_comment" {if ($comments.user_can_edit_comment)}checked="checked"{/if}>
238        {'Allow users to edit their own comments'|@translate}
239      </label>
240    </li>
241    <li>
242      <label>
243        <input type="checkbox" name="user_can_delete_comment" {if ($comments.user_can_delete_comment)}checked="checked"{/if}>
244        {'Allow users to delete their own comments'|@translate}
245      </label>
246    </li>
247
248    <li id="notifyAdmin">
249      <strong>{'Notify administrators when a comment is'|@translate}</strong>
250
251      <label id="email_admin_on_comment_validation">
252        <input type="checkbox" name="email_admin_on_comment_validation" {if ($comments.email_admin_on_comment_validation)}checked="checked"{/if}> {'pending validation'|@translate}
253      </label>
254
255      <label>
256        <input type="checkbox" name="email_admin_on_comment" {if ($comments.email_admin_on_comment)}checked="checked"{/if}> {'added'|@translate}
257      </label>
258
259      <label id="email_admin_on_comment_edition">
260        <input type="checkbox" name="email_admin_on_comment_edition" {if ($comments.email_admin_on_comment_edition)}checked="checked"{/if}> {'modified'|@translate}
261      </label>
262
263      <label id="email_admin_on_comment_deletion">
264        <input type="checkbox" name="email_admin_on_comment_deletion" {if ($comments.email_admin_on_comment_deletion)}checked="checked"{/if}> {'deleted'|@translate}
265      </label>
266    </li>
267  </ul>
268</fieldset>
269{/if}
270
271{if isset($sizes)}
272
273{footer_script}{literal}
274jQuery(document).ready(function(){
275  function toggleResizeFields(prefix) {
276    var checkbox = jQuery("#"+prefix+"_resize");
277    var needToggle = jQuery("input[name^="+prefix+"_]").not(checkbox).parents('tr');
278
279    if (jQuery(checkbox).is(':checked')) {
280      needToggle.show();
281    }
282    else {
283      needToggle.hide();
284    }
285  }
286
287  toggleResizeFields("original");
288  jQuery("#original_resize").click(function () {toggleResizeFields("original")});
289});
290{/literal}{/footer_script}
291
292<fieldset id="sizesConf">
293  <legend>{'Original Size'|@translate}</legend>
294
295  <table>
296    <tr>
297      <th><label for="original_resize">{'Resize after upload'|@translate}</label></th>
298      <td><input type="checkbox" name="original_resize" id="original_resize" {if ($sizes.original_resize)}checked="checked"{/if}></td>
299    </tr>
300    <tr>
301      <th>{'Maximum Width'|@translate}</th>
302      <td><input type="text" name="original_resize_maxwidth" value="{$sizes.original_resize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
303    </tr>
304    <tr>
305      <th>{'Maximum Height'|@translate}</th>
306      <td><input type="text" name="original_resize_maxheight" value="{$sizes.original_resize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
307    </tr>
308    <tr>
309      <th>{'Image Quality'|@translate}</th>
310      <td><input type="text" name="original_resize_quality" value="{$sizes.original_resize_quality}" size="3" maxlength="3"> %</td>
311    </tr>
312  </table>
313
314</fieldset>
315{/if}
316
317{if isset($display)}
318<fieldset id="indexDisplayConf">
319  <legend>{'Main Page'|@translate}</legend>
320  <ul>
321    <li>
322      <label>
323        <input type="checkbox" name="menubar_filter_icon" {if ($display.menubar_filter_icon)}checked="checked"{/if}>
324        {'display only recently posted photos'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
325      </label>
326    </li>   
327   
328    <li>
329      <label>
330        <input type="checkbox" name="index_new_icon" {if ($display.index_new_icon)}checked="checked"{/if}>
331        {'Activate icon "new" next to albums and pictures'|@translate}
332      </label>
333    </li>
334
335    <li>
336      <label>
337        <input type="checkbox" name="index_sort_order_input" {if ($display.index_sort_order_input)}checked="checked"{/if}>
338        {'Sort order'|@translate|@string_format:$pwg->l10n('Activate icon "%s"')}
339      </label>
340    </li>
341
342    <li>
343      <label>
344        <input type="checkbox" name="index_flat_icon" {if ($display.index_flat_icon)}checked="checked"{/if}>
345        {'display all photos in all sub-albums'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
346      </label>
347    </li>
348
349    <li>
350      <label>
351        <input type="checkbox" name="index_posted_date_icon" {if ($display.index_posted_date_icon)}checked="checked"{/if}>
352        {'display a calendar by posted date'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
353      </label>
354    </li>
355
356    <li>
357      <label>
358        <input type="checkbox" name="index_created_date_icon" {if ($display.index_created_date_icon)}checked="checked"{/if}>
359        {'display a calendar by creation date'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
360      </label>
361    </li>
362
363    <li>
364      <label>
365        <input type="checkbox" name="index_slideshow_icon" {if ($display.index_slideshow_icon)}checked="checked"{/if}>
366        {'slideshow'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
367      </label>
368    </li>
369  </ul>
370</fieldset>
371
372<fieldset id="pictureDisplayConf">
373  <legend>{'Photo Page'|@translate}</legend>
374  <ul>
375    <li>
376      <label>
377        <input type="checkbox" name="picture_slideshow_icon" {if ($display.picture_slideshow_icon)}checked="checked"{/if}>
378        {'slideshow'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
379      </label>
380    </li>
381
382    <li>
383      <label>
384        <input type="checkbox" name="picture_metadata_icon" {if ($display.picture_metadata_icon)}checked="checked"{/if}>
385        {'Show file metadata'|@translate|@string_format:$pwg->l10n('Activate icon "%s"')}
386      </label>
387    </li>
388
389    <li>
390      <label>
391        <input type="checkbox" name="picture_download_icon" {if ($display.picture_download_icon)}checked="checked"{/if}>
392        {'Download this file'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
393      </label>
394    </li>
395
396    <li>
397      <label>
398        <input type="checkbox" name="picture_favorite_icon" {if ($display.picture_favorite_icon)}checked="checked"{/if}>
399        {'add this photo to your favorites'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
400      </label>
401    </li>
402
403    <li>
404      <label>
405        <input type="checkbox" name="picture_navigation_icons" {if ($display.picture_navigation_icons)}checked="checked"{/if}>
406        {'Activate Navigation Bar'|@translate}
407      </label>
408    </li>
409
410    <li>
411      <label>
412        <input type="checkbox" name="picture_navigation_thumb" {if ($display.picture_navigation_thumb)}checked="checked"{/if}>
413        {'Activate Navigation Thumbnails'|@translate}
414      </label>
415    </li>
416   
417    <li>
418      <label>
419        <input type="checkbox" name="picture_menu" {if ($display.picture_menu)}checked="checked"{/if}>
420        {'Show menubar'|@translate}
421      </label>
422    </li>
423  </ul>
424</fieldset>
425
426<fieldset id="pictureInfoConf">
427  <legend>{'Photo Properties'|@translate}</legend>
428  <ul>
429    <li>
430      <label>
431        <input type="checkbox" name="picture_informations[author]" {if ($display.picture_informations.author)}checked="checked"{/if}>
432        {'Author'|@translate}
433      </label>
434    </li>
435
436    <li>
437      <label>
438        <input type="checkbox" name="picture_informations[created_on]" {if ($display.picture_informations.created_on)}checked="checked"{/if}>
439        {'Created on'|@translate}
440      </label>
441    </li>
442
443    <li>
444      <label>
445        <input type="checkbox" name="picture_informations[posted_on]" {if ($display.picture_informations.posted_on)}checked="checked"{/if}>
446        {'Posted on'|@translate}
447      </label>
448    </li>
449
450    <li>
451      <label>
452        <input type="checkbox" name="picture_informations[dimensions]" {if ($display.picture_informations.dimensions)}checked="checked"{/if}>
453        {'Dimensions'|@translate}
454      </label>
455    </li>
456
457    <li>
458      <label>
459        <input type="checkbox" name="picture_informations[file]" {if ($display.picture_informations.file)}checked="checked"{/if}>
460        {'File'|@translate}
461      </label>
462    </li>
463
464    <li>
465      <label>
466        <input type="checkbox" name="picture_informations[filesize]" {if ($display.picture_informations.filesize)}checked="checked"{/if}>
467        {'Filesize'|@translate}
468      </label>
469    </li>
470
471    <li>
472      <label>
473        <input type="checkbox" name="picture_informations[tags]" {if ($display.picture_informations.tags)}checked="checked"{/if}>
474        {'Tags'|@translate}
475      </label>
476    </li>
477
478    <li>
479      <label>
480        <input type="checkbox" name="picture_informations[categories]" {if ($display.picture_informations.categories)}checked="checked"{/if}>
481        {'Albums'|@translate}
482      </label>
483    </li>
484
485    <li>
486      <label>
487        <input type="checkbox" name="picture_informations[visits]" {if ($display.picture_informations.visits)}checked="checked"{/if}>
488        {'Visits'|@translate}
489      </label>
490    </li>
491
492    <li>
493      <label>
494        <input type="checkbox" name="picture_informations[rating_score]" {if ($display.picture_informations.rating_score)}checked="checked"{/if}>
495        {'Rating score'|@translate}
496      </label>
497    </li>
498
499    <li>
500      <label>
501        <input type="checkbox" name="picture_informations[privacy_level]" {if ($display.picture_informations.privacy_level)}checked="checked"{/if}>
502        {'Who can see this photo?'|@translate} ({'available for administrators only'|@translate})
503      </label>
504    </li>
505  </ul>
506</fieldset>
507{/if}
508
509{if !isset($default)}
510  <p>
511    <input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}">
512    <input class="submit" type="reset" name="reset" value="{'Reset'|@translate}">
513  </p>
514</form>
515{/if}
516
517</div> <!-- configContent -->
518
519{if isset($default)}
520{$PROFILE_CONTENT}
521{/if}
Note: See TracBrowser for help on using the repository browser.