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

Last change on this file since 10421 was 10421, checked in by plg, 10 years ago

bug 2251: auto-complete was not working on second tag if cache=true.

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