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

Revision 10111, 20.5 KB checked in by patdenice, 9 years ago (diff)

merge r10110 from trunk to branch 2.2
bug:2251
Bug corrected for fcbkcomplete

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: true,
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  var max_dim = 20;
304  $(".thumbnails img").each(function () {
305    if ($(this).height() > (max_dim-20))
306      max_dim = $(this).height() + 20;
307    if ($(this).width() > (max_dim-20))
308      max_dim = $(this).width() + 20;
309    $("ul.thumbnails span, ul.thumbnails label").css('width', max_dim+'px').css('height', max_dim+'px');
310  });
311
312  checkPermitAction()
313});
314{/literal}{/footer_script}
315
316<div id="batchManagerGlobal">
317
318<h2>{'Batch Manager'|@translate}</h2>
319
320  <form action="{$F_ACTION}" method="post">
321
322  <fieldset>
323    <legend>{'Filter'|@translate}</legend>
324
325    <ul id="filterList">
326      <li id="filter_prefilter" {if !isset($filter.prefilter)}style="display:none"{/if}>
327        <a href="#" class="removeFilter" title="{'remove this filter'|@translate}"><span>[x]</span></a>
328        <input type="checkbox" name="filter_prefilter_use" class="useFilterCheckbox" {if isset($filter.prefilter)}checked="checked"{/if}>
329        {'predefined filter'|@translate}
330        <select name="filter_prefilter">
331          <option value="caddie" {if $filter.prefilter eq 'caddie'}selected="selected"{/if}>{'caddie'|@translate}</option>
332          <option value="last import" {if $filter.prefilter eq 'last import'}selected="selected"{/if}>{'last import'|@translate}</option>
333          <option value="with no album" {if $filter.prefilter eq 'with no album'}selected="selected"{/if}>{'with no album'|@translate}</option>
334{if $ENABLE_SYNCHRONIZATION}
335          <option value="with no virtual album" {if $filter.prefilter eq 'with no virtual album'}selected="selected"{/if}>{'with no virtual album'|@translate}</option>
336{/if}
337          <option value="with no tag" {if $filter.prefilter eq 'with no tag'}selected="selected"{/if}>{'with no tag'|@translate}</option>
338          <option value="duplicates" {if $filter.prefilter eq 'duplicates'}selected="selected"{/if}>{'duplicates'|@translate}</option>
339          <option value="all photos" {if $filter.prefilter eq 'all photos'}selected="selected"{/if}>{'All'|@translate}</option>
340        </select>
341      </li>
342      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
343        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
344        <input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
345        {'album'|@translate}
346        <select style="width:400px" name="filter_category" size="1">
347          {html_options options=$filter_category_options selected=$filter_category_options_selected}
348        </select>
349        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
350      </li>
351      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
352        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
353        <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
354        {'Who can see these photos?'|@translate}
355        <select name="filter_level" size="1">
356          {html_options options=$filter_level_options selected=$filter_level_options_selected}
357        </select>
358      </li>
359    </ul>
360
361    <p class="actionButtons" style="">
362      <select id="addFilter">
363        <option value="-1">{'Add a filter'|@translate}</option>
364        <option disabled="disabled">------------------</option>
365        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
366        <option value="filter_category">{'album'|@translate}</option>
367        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
368      </select>
369<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
370      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
371    </p>
372
373    <p class="actionButtons" id="applyFilterBlock">
374      <input id="applyFilter" class="submit" type="submit" value="{'Refresh photo set'|@translate}" name="submitFilter">
375    </p>
376
377  </fieldset>
378
379  <fieldset>
380
381    <legend>{'Selection'|@translate}</legend>
382
383  {if !empty($thumbnails)}
384  <p id="checkActions">
385    {'Select:'|@translate}
386{if $nb_thumbs_set > $nb_thumbs_page}
387    <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
388    <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
389{else}
390    <a href="#" id="selectAll">{'All'|@translate}</a>,
391{/if}
392    <a href="#" id="selectNone">{'None'|@translate}</a>,
393    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
394
395    <span id="selectedMessage"></span>
396
397    <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
398  </p>
399
400    <ul class="thumbnails">
401      {foreach from=$thumbnails item=thumbnail}
402        {if in_array($thumbnail.ID, $selection)}
403          {assign var='isSelected' value=true}
404        {else}
405          {assign var='isSelected' value=false}
406        {/if}
407
408      <li><span class="wrap1">
409          <label>
410            <span class="wrap2{if $isSelected} thumbSelected{/if}">
411        {if $thumbnail.LEVEL > 0}
412        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
413        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
414        {/if}
415            <span>
416              <img src="{$thumbnail.TN_SRC}"
417                 alt="{$thumbnail.FILE}"
418                 title="{$thumbnail.TITLE|@escape:'html'}"
419                 class="thumbnail">
420            </span></span>
421            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
422          </label>
423          </span>
424      </li>
425      {/foreach}
426    </ul>
427
428  {if !empty($navbar) }
429  <div style="clear:both;">
430
431    <div style="float:left">
432    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
433    </div>
434
435    <div style="float:right;margin-top:10px;">{'display'|@translate}
436      <a href="{$U_DISPLAY}&amp;display=20">20</a>
437      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
438      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
439      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
440      {'photos per page'|@translate}
441    </div>
442  </div>
443  {/if}
444
445  {else}
446  <div>{'No photo in the current set.'|@translate}</div>
447  {/if}
448  </fieldset>
449
450  <fieldset id="action">
451
452    <legend>{'Action'|@translate}</legend>
453      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div>
454      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
455
456    <select name="selectAction">
457      <option value="-1">{'Choose an action'|@translate}</option>
458      <option disabled="disabled">------------------</option>
459  {if isset($show_delete_form) }
460      <option value="delete">{'Delete selected photos'|@translate}</option>
461  {/if}
462      <option value="associate">{'Associate to album'|@translate}</option>
463  {if !empty($dissociate_options)}
464      <option value="dissociate">{'Dissociate from album'|@translate}</option>
465  {/if}
466      <option value="add_tags">{'add tags'|@translate}</option>
467  {if !empty($DEL_TAG_SELECTION)}
468      <option value="del_tags">{'remove tags'|@translate}</option>
469  {/if}
470      <option value="author">{'Set author'|@translate}</option>
471      <option value="title">{'Set title'|@translate}</option>
472      <option value="date_creation">{'Set creation date'|@translate}</option>
473      <option value="level">{'Who can see these photos?'|@translate}</option>
474      <option value="metadata">{'synchronize metadata'|@translate}</option>
475  {if ($IN_CADDIE)}
476      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
477  {else}
478      <option value="add_to_caddie">{'add to caddie'|@translate}</option>
479  {/if}
480  {if !empty($element_set_global_plugins_actions)}
481    {foreach from=$element_set_global_plugins_actions item=action}
482      <option value="{$action.ID}">{$action.NAME}</option>
483    {/foreach}
484  {/if}
485    </select>
486
487    <!-- delete -->
488    <div id="action_delete" class="bulkAction">
489    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
490    </div>
491
492    <!-- associate -->
493    <div id="action_associate" class="bulkAction">
494          <select style="width:400px" name="associate" size="1">
495            {html_options options=$associate_options }
496         </select>
497    </div>
498
499    <!-- dissociate -->
500    <div id="action_dissociate" class="bulkAction">
501          <select style="width:400px" name="dissociate" size="1">
502            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
503          </select>
504    </div>
505
506
507    <!-- add_tags -->
508    <div id="action_add_tags" class="bulkAction">
509<select id="tags" name="add_tags">
510</select>
511    </div>
512
513    <!-- del_tags -->
514    <div id="action_del_tags" class="bulkAction">
515{$DEL_TAG_SELECTION}
516    </div>
517
518    <!-- author -->
519    <div id="action_author" class="bulkAction">
520    <label><input type="checkbox" name="remove_author"> {'remove author'|@translate}</label><br>
521    {assign var='authorDefaultValue' value='Type here the author name'|@translate}
522<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;">
523    </div>   
524
525    <!-- title -->
526    <div id="action_title" class="bulkAction">
527    <label><input type="checkbox" name="remove_title"> {'remove title'|@translate}</label><br>
528    {assign var='titleDefaultValue' value='Type here the title'|@translate}
529<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;">
530    </div>
531
532    <!-- date_creation -->
533    <div id="action_date_creation" class="bulkAction">
534      <label><input type="checkbox" name="remove_date_creation"> {'remove creation date'|@translate}</label><br>
535      <div id="set_date_creation">
536          <select id="date_creation_day" name="date_creation_day">
537             <option value="0">--</option>
538            {section name=day start=1 loop=32}
539              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
540            {/section}
541          </select>
542          <select id="date_creation_month" name="date_creation_month">
543            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
544          </select>
545          <input id="date_creation_year"
546                 name="date_creation_year"
547                 type="text"
548                 size="4"
549                 maxlength="4"
550                 value="{$DATE_CREATION_YEAR}">
551          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
552      </div>
553    </div>
554
555    <!-- level -->
556    <div id="action_level" class="bulkAction">
557        <select name="level" size="1">
558          {html_options options=$level_options selected=$level_options_selected}
559        </select>
560    </div>
561
562    <!-- metadata -->
563    <div id="action_metadata" class="bulkAction">
564    </div>
565
566    <!-- plugins -->
567{if !empty($element_set_global_plugins_actions)}
568  {foreach from=$element_set_global_plugins_actions item=action}
569    <div id="action_{$action.ID}" class="bulkAction">
570    {if !empty($action.CONTENT)}{$action.CONTENT}{/if}
571    </div>
572  {/foreach}
573{/if}
574
575    <p id="applyActionBlock" style="display:none" class="actionButtons">
576      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit"> <span id="applyOnDetails"></span></p>
577
578    </div> <!-- #permitAction -->
579  </fieldset>
580
581  </form>
582
583</div> <!-- #batchManagerGlobal -->
Note: See TracBrowser for help on using the repository browser.