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

Last change on this file since 11056 was 11056, checked in by mistic100, 13 years ago

bug:2278 fixed (merge r10970 r11008 r11039 from trunk) replace FCBKcomplete by TokenInput to avoid 3rd tag issue on autocomplete

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