source: branches/2.2/admin/themes/default/template/batch_manager_global.tpl @ 11854

Last change on this file since 11854 was 11854, checked in by rvelices, 13 years ago

feature 2387: addd a filter by tag in the batch manager (merge from trunk)

File size: 20.9 KB
Line 
1{include file='include/tag_selection.inc.tpl'}
2{include file='include/datepicker.inc.tpl'}
3
4{footer_script}{literal}
5  pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#date_creation_year", "#date_creation_linked_date", "#date_creation_action_set");
6{/literal}{/footer_script}
7
8{combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
9
10{footer_script require='jquery.tokeninput'}
11jQuery(document).ready(function() {ldelim}
12        var tag_src = [{foreach from=$tags item=tag name=tags}{ldelim}name:"{$tag.name|@escape:'javascript'}",id:"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}];
13  jQuery("#tags").tokenInput(
14    tag_src,
15    {ldelim}
16      hintText: '{'Type in a search term'|@translate}',
17      noResultsText: '{'No results'|@translate}',
18      searchingText: '{'Searching...'|@translate}',
19      newText: ' ({'new'|@translate})',
20      animateDropdown: false,
21      preventDuplicates: true,
22      allowCreation: true
23    }
24  );
25       
26  jQuery("#tagsFilter").tokenInput(
27    tag_src,
28    {ldelim}
29      hintText: '{'Type in a search term'|@translate}',
30      noResultsText: '{'No results'|@translate}',
31      searchingText: '{'Searching...'|@translate}',
32      animateDropdown: false,
33      preventDuplicates: true,
34      allowCreation: false
35    }
36  );
37
38});
39{/footer_script}
40
41{footer_script}
42var nb_thumbs_page = {$nb_thumbs_page};
43var nb_thumbs_set = {$nb_thumbs_set};
44var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
45
46var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
47var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
48var selectedMessage_all = "{'All %d photos are selected'|@translate}";
49{literal}
50function str_repeat(i, m) {
51        for (var o = []; m > 0; o[--m] = i);
52        return o.join('');
53}
54
55function sprintf() {
56        var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
57        while (f) {
58                if (m = /^[^\x25]+/.exec(f)) {
59                        o.push(m[0]);
60                }
61                else if (m = /^\x25{2}/.exec(f)) {
62                        o.push('%');
63                }
64                else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
65                        if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
66                                throw('Too few arguments.');
67                        }
68                        if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
69                                throw('Expecting number but found ' + typeof(a));
70                        }
71                        switch (m[7]) {
72                                case 'b': a = a.toString(2); break;
73                                case 'c': a = String.fromCharCode(a); break;
74                                case 'd': a = parseInt(a); break;
75                                case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
76                                case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
77                                case 'o': a = a.toString(8); break;
78                                case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
79                                case 'u': a = Math.abs(a); break;
80                                case 'x': a = a.toString(16); break;
81                                case 'X': a = a.toString(16).toUpperCase(); break;
82                        }
83                        a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
84                        c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
85                        x = m[5] - String(a).length - s.length;
86                        p = m[5] ? str_repeat(c, x) : '';
87                        o.push(s + (m[4] ? a + p : p + a));
88                }
89                else {
90                        throw('Huh ?!');
91                }
92                f = f.substring(m[0].length);
93        }
94        return o.join('');
95}
96
97$(document).ready(function() {
98  function checkPermitAction() {
99    var nbSelected = 0;
100    if ($("input[name=setSelected]").is(':checked')) {
101      nbSelected = nb_thumbs_set;
102    }
103    else {
104      $(".thumbnails input[type=checkbox]").each(function() {
105         if ($(this).is(':checked')) {
106           nbSelected++;
107         }
108      });
109    }
110
111    if (nbSelected == 0) {
112      $("#permitAction").hide();
113      $("#forbidAction").show();
114    }
115    else {
116      $("#permitAction").show();
117      $("#forbidAction").hide();
118    }
119
120    $("#applyOnDetails").text(
121      sprintf(
122        applyOnDetails_pattern,
123        nbSelected
124      )
125    );
126
127    // display the number of currently selected photos in the "Selection" fieldset
128    if (nbSelected == 0) {
129      $("#selectedMessage").text(
130        sprintf(
131          selectedMessage_none,
132          nb_thumbs_set
133        )
134      );
135    }
136    else if (nbSelected == nb_thumbs_set) {
137      $("#selectedMessage").text(
138        sprintf(
139          selectedMessage_all,
140          nb_thumbs_set
141        )
142      );
143    }
144    else {
145      $("#selectedMessage").text(
146        sprintf(
147          selectedMessage_pattern,
148          nbSelected,
149          nb_thumbs_set
150        )
151      );
152    }
153  }
154
155  $('img.thumbnail').tipTip({
156    'delay' : 0,
157    'fadeIn' : 200,
158    'fadeOut' : 200
159  });
160
161  $("[id^=action_]").hide();
162
163  $("select[name=selectAction]").change(function () {
164    $("[id^=action_]").hide();
165    $("#action_"+$(this).attr("value")).show();
166
167    if ($(this).val() != -1) {
168      $("#applyActionBlock").show();
169    }
170    else {
171      $("#applyActionBlock").hide();
172    }
173  });
174
175  $(".wrap1 label").click(function () {
176    $("input[name=setSelected]").attr('checked', false);
177
178    var wrap2 = $(this).children(".wrap2");
179    var checkbox = $(this).children("input[type=checkbox]");
180
181    if ($(checkbox).is(':checked')) {
182      $(wrap2).addClass("thumbSelected");
183    }
184    else {
185      $(wrap2).removeClass('thumbSelected');
186    }
187
188    checkPermitAction();
189  });
190
191  $("#selectAll").click(function () {
192    $("input[name=setSelected]").attr('checked', false);
193    selectPageThumbnails();
194    checkPermitAction();
195    return false;
196  });
197
198  function selectPageThumbnails() {
199    $(".thumbnails label").each(function() {
200      var wrap2 = $(this).children(".wrap2");
201      var checkbox = $(this).children("input[type=checkbox]");
202
203      $(checkbox).attr('checked', true);
204      $(wrap2).addClass("thumbSelected");
205    });
206  }
207
208  $("#selectNone").click(function () {
209    $("input[name=setSelected]").attr('checked', false);
210
211    $(".thumbnails label").each(function() {
212      var wrap2 = $(this).children(".wrap2");
213      var checkbox = $(this).children("input[type=checkbox]");
214
215      $(checkbox).attr('checked', false);
216      $(wrap2).removeClass("thumbSelected");
217    });
218    checkPermitAction();
219    return false;
220  });
221
222  $("#selectInvert").click(function () {
223    $("input[name=setSelected]").attr('checked', false);
224
225    $(".thumbnails label").each(function() {
226      var wrap2 = $(this).children(".wrap2");
227      var checkbox = $(this).children("input[type=checkbox]");
228
229      $(checkbox).attr('checked', !$(checkbox).is(':checked'));
230
231      if ($(checkbox).is(':checked')) {
232        $(wrap2).addClass("thumbSelected");
233      }
234      else {
235        $(wrap2).removeClass('thumbSelected');
236      }
237    });
238    checkPermitAction();
239    return false;
240  });
241
242  $("#selectSet").click(function () {
243    selectPageThumbnails();
244    $("input[name=setSelected]").attr('checked', true);
245    checkPermitAction();
246    return false;
247  });
248
249  $("input[name=remove_author]").click(function () {
250    if ($(this).is(':checked')) {
251      $("input[name=author]").hide();
252    }
253    else {
254      $("input[name=author]").show();
255    }
256  });
257
258  $("input[name=remove_title]").click(function () {
259    if ($(this).is(':checked')) {
260      $("input[name=title]").hide();
261    }
262    else {
263      $("input[name=title]").show();
264    }
265  });
266
267  $("input[name=remove_date_creation]").click(function () {
268    if ($(this).is(':checked')) {
269      $("#set_date_creation").hide();
270    }
271    else {
272      $("#set_date_creation").show();
273    }
274  });
275
276  $(".removeFilter").click(function () {
277    var filter = $(this).parent('li').attr("id");
278    filter_disable(filter);
279
280    return false;
281  });
282
283  function filter_enable(filter) {
284    /* show the filter*/
285    $("#"+filter).show();
286
287    /* check the checkbox to declare we use this filter */
288    $("input[type=checkbox][name="+filter+"_use]").attr("checked", true);
289
290    /* forbid to select this filter in the addFilter list */
291    $("#addFilter").children("option[value="+filter+"]").attr("disabled", "disabled");
292  }
293
294  $("#addFilter").change(function () {
295    var filter = $(this).attr("value");
296    filter_enable(filter);
297    $(this).attr("value", -1);
298  });
299
300  function filter_disable(filter) {
301    /* hide the filter line */
302    $("#"+filter).hide();
303
304    /* uncheck the checkbox to declare we do not use this filter */
305    $("input[name="+filter+"_use]").removeAttr("checked");
306
307    /* give the possibility to show it again */
308    $("#addFilter").children("option[value="+filter+"]").removeAttr("disabled");
309  }
310
311  $("#removeFilters").click(function() {
312    $("#filterList li").each(function() {
313      var filter = $(this).attr("id");
314      filter_disable(filter);
315    });
316    return false;
317  });
318
319  checkPermitAction()
320});
321
322jQuery(window).load(function() {
323  var max_dim = 20;
324  $(".thumbnails img").each(function () {
325    if ($(this).height() > (max_dim-20))
326      max_dim = $(this).height() + 20;
327    if ($(this).width() > (max_dim-20))
328      max_dim = $(this).width() + 20;
329    $("ul.thumbnails span, ul.thumbnails label").css('width', max_dim+'px').css('height', max_dim+'px');
330  });
331});
332{/literal}{/footer_script}
333
334<div id="batchManagerGlobal">
335
336<h2>{'Batch Manager'|@translate}</h2>
337
338  <form action="{$F_ACTION}" method="post">
339
340  <fieldset>
341    <legend>{'Filter'|@translate}</legend>
342
343    <ul id="filterList">
344      <li id="filter_prefilter" {if !isset($filter.prefilter)}style="display:none"{/if}>
345        <a href="#" class="removeFilter" title="{'remove this filter'|@translate}"><span>[x]</span></a>
346        <input type="checkbox" name="filter_prefilter_use" class="useFilterCheckbox" {if isset($filter.prefilter)}checked="checked"{/if}>
347        {'predefined filter'|@translate}
348        <select name="filter_prefilter">
349          {foreach from=$prefilters item=prefilter}
350          <option value="{$prefilter.ID}" {if $filter.prefilter eq $prefilter.ID}selected="selected"{/if}>{$prefilter.NAME}</option>
351          {/foreach}
352        </select>
353      </li>
354      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
355        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
356        <input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
357        {'album'|@translate}
358        <select style="width:400px" name="filter_category" size="1">
359          {html_options options=$filter_category_options selected=$filter_category_options_selected}
360        </select>
361        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
362      </li>
363                        <li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
364                                <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
365                                <input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
366                                {'Tags'|@translate}
367                                <select id="tagsFilter" name="filter_tags">
368                                        {foreach from=$filter_tags item=tag}
369                                        <option value="{$tag.id}">{$tag.name}</option>
370                                        {/foreach}
371                                </select>
372                        </li>
373      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
374        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
375        <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
376        {'Who can see these photos?'|@translate}
377        <select name="filter_level" size="1">
378          {html_options options=$filter_level_options selected=$filter_level_options_selected}
379        </select>
380      </li>
381    </ul>
382
383    <p class="actionButtons" style="">
384      <select id="addFilter">
385        <option value="-1">{'Add a filter'|@translate}</option>
386        <option disabled="disabled">------------------</option>
387        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
388        <option value="filter_category">{'album'|@translate}</option>
389                                <option value="filter_tags">{'Tags'|@translate}</option>
390        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
391      </select>
392<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
393      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
394    </p>
395
396    <p class="actionButtons" id="applyFilterBlock">
397      <input id="applyFilter" class="submit" type="submit" value="{'Refresh photo set'|@translate}" name="submitFilter">
398    </p>
399
400  </fieldset>
401
402  <fieldset>
403
404    <legend>{'Selection'|@translate}</legend>
405
406  {if !empty($thumbnails)}
407  <p id="checkActions">
408    {'Select:'|@translate}
409{if $nb_thumbs_set > $nb_thumbs_page}
410    <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
411    <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
412{else}
413    <a href="#" id="selectAll">{'All'|@translate}</a>,
414{/if}
415    <a href="#" id="selectNone">{'None'|@translate}</a>,
416    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
417
418    <span id="selectedMessage"></span>
419
420    <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
421  </p>
422
423    <ul class="thumbnails">
424      {foreach from=$thumbnails item=thumbnail}
425        {if in_array($thumbnail.ID, $selection)}
426          {assign var='isSelected' value=true}
427        {else}
428          {assign var='isSelected' value=false}
429        {/if}
430
431      <li><span class="wrap1">
432          <label>
433            <span class="wrap2{if $isSelected} thumbSelected{/if}">
434        {if $thumbnail.LEVEL > 0}
435        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
436        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
437        {/if}
438            <span>
439              <img src="{$thumbnail.TN_SRC}"
440                 alt="{$thumbnail.FILE}"
441                 title="{$thumbnail.TITLE|@escape:'html'}"
442                 class="thumbnail">
443            </span></span>
444            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
445          </label>
446          </span>
447      </li>
448      {/foreach}
449    </ul>
450
451  {if !empty($navbar) }
452  <div style="clear:both;">
453
454    <div style="float:left">
455    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
456    </div>
457
458    <div style="float:right;margin-top:10px;">{'display'|@translate}
459      <a href="{$U_DISPLAY}&amp;display=20">20</a>
460      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
461      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
462      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
463      {'photos per page'|@translate}
464    </div>
465  </div>
466  {/if}
467
468  {else}
469  <div>{'No photo in the current set.'|@translate}</div>
470  {/if}
471  </fieldset>
472
473  <fieldset id="action">
474
475    <legend>{'Action'|@translate}</legend>
476      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div>
477      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
478
479    <select name="selectAction">
480      <option value="-1">{'Choose an action'|@translate}</option>
481      <option disabled="disabled">------------------</option>
482  {if isset($show_delete_form) }
483      <option value="delete">{'Delete selected photos'|@translate}</option>
484  {/if}
485      <option value="associate">{'Associate to album'|@translate}</option>
486  {if !empty($dissociate_options)}
487      <option value="dissociate">{'Dissociate from album'|@translate}</option>
488  {/if}
489      <option value="add_tags">{'add tags'|@translate}</option>
490  {if !empty($DEL_TAG_SELECTION)}
491      <option value="del_tags">{'remove tags'|@translate}</option>
492  {/if}
493      <option value="author">{'Set author'|@translate}</option>
494      <option value="title">{'Set title'|@translate}</option>
495      <option value="date_creation">{'Set creation date'|@translate}</option>
496      <option value="level">{'Who can see these photos?'|@translate}</option>
497      <option value="metadata">{'synchronize metadata'|@translate}</option>
498  {if ($IN_CADDIE)}
499      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
500  {else}
501      <option value="add_to_caddie">{'add to caddie'|@translate}</option>
502  {/if}
503  {if !empty($element_set_global_plugins_actions)}
504    {foreach from=$element_set_global_plugins_actions item=action}
505      <option value="{$action.ID}">{$action.NAME}</option>
506    {/foreach}
507  {/if}
508    </select>
509
510    <!-- delete -->
511    <div id="action_delete" class="bulkAction">
512    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
513    </div>
514
515    <!-- associate -->
516    <div id="action_associate" class="bulkAction">
517          <select style="width:400px" name="associate" size="1">
518            {html_options options=$associate_options }
519         </select>
520    </div>
521
522    <!-- dissociate -->
523    <div id="action_dissociate" class="bulkAction">
524          <select style="width:400px" name="dissociate" size="1">
525            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
526          </select>
527    </div>
528
529
530    <!-- add_tags -->
531    <div id="action_add_tags" class="bulkAction">
532<select id="tags" name="add_tags">
533</select>
534    </div>
535
536    <!-- del_tags -->
537    <div id="action_del_tags" class="bulkAction">
538{$DEL_TAG_SELECTION}
539    </div>
540
541    <!-- author -->
542    <div id="action_author" class="bulkAction">
543    <label><input type="checkbox" name="remove_author"> {'remove author'|@translate}</label><br>
544    {assign var='authorDefaultValue' value='Type here the author name'|@translate}
545<input type="text" class="large" name="author" value="{$authorDefaultValue}" onfocus="this.value=(this.value=='{$authorDefaultValue}') ? '' : this.value;" onblur="this.value=(this.value=='') ? '{$authorDefaultValue}' : this.value;">
546    </div>   
547
548    <!-- title -->
549    <div id="action_title" class="bulkAction">
550    <label><input type="checkbox" name="remove_title"> {'remove title'|@translate}</label><br>
551    {assign var='titleDefaultValue' value='Type here the title'|@translate}
552<input type="text" class="large" name="title" value="{$titleDefaultValue}" onfocus="this.value=(this.value=='{$titleDefaultValue}') ? '' : this.value;" onblur="this.value=(this.value=='') ? '{$titleDefaultValue}' : this.value;">
553    </div>
554
555    <!-- date_creation -->
556    <div id="action_date_creation" class="bulkAction">
557      <label><input type="checkbox" name="remove_date_creation"> {'remove creation date'|@translate}</label><br>
558      <div id="set_date_creation">
559          <select id="date_creation_day" name="date_creation_day">
560             <option value="0">--</option>
561            {section name=day start=1 loop=32}
562              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
563            {/section}
564          </select>
565          <select id="date_creation_month" name="date_creation_month">
566            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
567          </select>
568          <input id="date_creation_year"
569                 name="date_creation_year"
570                 type="text"
571                 size="4"
572                 maxlength="4"
573                 value="{$DATE_CREATION_YEAR}">
574          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
575      </div>
576    </div>
577
578    <!-- level -->
579    <div id="action_level" class="bulkAction">
580        <select name="level" size="1">
581          {html_options options=$level_options selected=$level_options_selected}
582        </select>
583    </div>
584
585    <!-- metadata -->
586    <div id="action_metadata" class="bulkAction">
587    </div>
588
589    <!-- plugins -->
590{if !empty($element_set_global_plugins_actions)}
591  {foreach from=$element_set_global_plugins_actions item=action}
592    <div id="action_{$action.ID}" class="bulkAction">
593    {if !empty($action.CONTENT)}{$action.CONTENT}{/if}
594    </div>
595  {/foreach}
596{/if}
597
598    <p id="applyActionBlock" style="display:none" class="actionButtons">
599      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit"> <span id="applyOnDetails"></span></p>
600
601    </div> <!-- #permitAction -->
602  </fieldset>
603
604  </form>
605
606</div> <!-- #batchManagerGlobal -->
Note: See TracBrowser for help on using the repository browser.