source: trunk/admin/themes/default/template/batch_manager_global.tpl @ 9064

Revision 9064, 20.7 KB checked in by plg, 9 years ago (diff)

bug 2177 fixed: automatically select thumbnails on current page when selecting
the whole set.

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]").click(function () {
148    $("[id^=action_]").hide();
149    $("#action_"+$(this).attr("value")).show();
150  });
151
152  $(".wrap1 label").click(function () {
153    $("input[name=setSelected]").attr('checked', false);
154
155    var wrap2 = $(this).children(".wrap2");
156    var checkbox = $(this).children("input[type=checkbox]");
157
158    if ($(checkbox).is(':checked')) {
159      $(wrap2).addClass("thumbSelected");
160    }
161    else {
162      $(wrap2).removeClass('thumbSelected');
163    }
164
165    checkPermitAction();
166  });
167
168  $("#selectAll").click(function () {
169    $("input[name=setSelected]").attr('checked', false);
170    selectPageThumbnails();
171    checkPermitAction();
172    return false;
173  });
174
175  function selectPageThumbnails() {
176    $(".thumbnails label").each(function() {
177      var wrap2 = $(this).children(".wrap2");
178      var checkbox = $(this).children("input[type=checkbox]");
179
180      $(checkbox).attr('checked', true);
181      $(wrap2).addClass("thumbSelected");
182    });
183  }
184
185  $("#selectNone").click(function () {
186    $("input[name=setSelected]").attr('checked', false);
187
188    $(".thumbnails label").each(function() {
189      var wrap2 = $(this).children(".wrap2");
190      var checkbox = $(this).children("input[type=checkbox]");
191
192      $(checkbox).attr('checked', false);
193      $(wrap2).removeClass("thumbSelected");
194    });
195    checkPermitAction();
196    return false;
197  });
198
199  $("#selectInvert").click(function () {
200    $("input[name=setSelected]").attr('checked', false);
201
202    $(".thumbnails label").each(function() {
203      var wrap2 = $(this).children(".wrap2");
204      var checkbox = $(this).children("input[type=checkbox]");
205
206      $(checkbox).attr('checked', !$(checkbox).is(':checked'));
207
208      if ($(checkbox).is(':checked')) {
209        $(wrap2).addClass("thumbSelected");
210      }
211      else {
212        $(wrap2).removeClass('thumbSelected');
213      }
214    });
215    checkPermitAction();
216    return false;
217  });
218
219  $("#selectSet").click(function () {
220    selectPageThumbnails();
221    $("input[name=setSelected]").attr('checked', true);
222    checkPermitAction();
223    return false;
224  });
225
226  $("input[name=remove_author]").click(function () {
227    if ($(this).is(':checked')) {
228      $("input[name=author]").hide();
229    }
230    else {
231      $("input[name=author]").show();
232    }
233  });
234
235  $("input[name=remove_title]").click(function () {
236    if ($(this).is(':checked')) {
237      $("input[name=title]").hide();
238    }
239    else {
240      $("input[name=title]").show();
241    }
242  });
243
244  $("input[name=remove_date_creation]").click(function () {
245    if ($(this).is(':checked')) {
246      $("#set_date_creation").hide();
247    }
248    else {
249      $("#set_date_creation").show();
250    }
251  });
252
253  $("select[name=selectAction]").change(function() {
254    if ($(this).val() != -1) {
255      $("#applyActionBlock").show();
256    }
257    else {
258      $("#applyActionBlock").hide();
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{/literal}{/footer_script}
308
309{literal}
310<style>
311#action p {text-align:left;}
312.bulkAction {text-align:left;margin:15px 0;padding:0;}
313#action_del_tags ul.tagSelection {margin:0 !important; width:620px;}
314#selectAction {}
315#checkActions {text-align:left; margin:0 0 20px 0;}
316.content ul.thumbnails span.wrap1 {margin:5px}
317.content ul.thumbnails span.wrap2 {border:0;background-color:#ddd;}
318.content ul.thumbnails span.wrap2:hover {background-color:#7CBA0F;}
319.thumbSelected {background-color:#C2F5C2 !important}
320
321#selectedMessage {background-color:#C2F5C2; padding:5px; -moz-border-radius:5px;}
322#selectSet a {border-bottom:1px dotted}
323#applyOnDetails {font-style:italic;}
324
325.actionButtons {text-align:left;}
326#filterList {padding-left:5px;}
327#filterList li {margin-bottom:5px; list-style-type:none;}
328a.removeFilter {background: url(admin/themes/default/icon/remove_filter.png) no-repeat top left;width:7px;height:7px;display:inline-block}
329a.removeFilter:hover {background: url(admin/themes/default/icon/remove_filter_hover.png); border:none;}
330.removeFilter span {display:none}
331#applyFilterBlock {margin-top:20px;}
332.useFilterCheckbox {display:none}
333</style>
334{/literal}
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          <option value="caddie" {if $filter.prefilter eq 'caddie'}selected="selected"{/if}>{'caddie'|@translate}</option>
350          <option value="last import" {if $filter.prefilter eq 'last import'}selected="selected"{/if}>{'last import'|@translate}</option>
351          <option value="with no album" {if $filter.prefilter eq 'with no album'}selected="selected"{/if}>{'with no album'|@translate}</option> -->
352{if $ENABLE_SYNCHRONIZATION}
353          <option value="with no virtual album" {if $filter.prefilter eq 'with no virtual album'}selected="selected"{/if}>{'with no virtual album'|@translate}</option>
354{/if}
355          <option value="with no tag" {if $filter.prefilter eq 'with no tag'}selected="selected"{/if}>{'with no tag'|@translate}</option>
356          <option value="duplicates" {if $filter.prefilter eq 'duplicates'}selected="selected"{/if}>{'duplicates'|@translate}</option>
357        </select>
358      </li>
359      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
360        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
361        <input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
362        {'album'|@translate}
363        <select style="width:400px" name="filter_category" size="1">
364          {html_options options=$filter_category_options selected=$filter_category_options_selected}
365        </select>
366        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
367      </li>
368      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
369        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
370        <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
371        {'Who can see these photos?'|@translate}
372        <select name="filter_level" size="1">
373          {html_options options=$filter_level_options selected=$filter_level_options_selected}
374        </select>
375      </li>
376    </ul>
377
378    <p class="actionButtons" style="">
379      <select id="addFilter">
380        <option value="-1">{'Add a filter'|@translate}</option>
381        <option disabled="disabled">------------------</option>
382        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
383        <option value="filter_category">{'album'|@translate}</option>
384        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
385      </select>
386<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
387      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
388    </p>
389
390    <p class="actionButtons" id="applyFilterBlock">
391      <input id="applyFilter" class="submit" type="submit" value="{'Refresh photo set'|@translate}" name="submitFilter">
392    </p>
393
394  </fieldset>
395
396  <fieldset>
397
398    <legend>{'Selection'|@translate}</legend>
399
400  {if !empty($thumbnails)}
401  <p id="checkActions">
402    {'Select:'|@translate}
403{if $nb_thumbs_set > $nb_thumbs_page}
404    <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
405    <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
406{else}
407    <a href="#" id="selectAll">{'All'|@translate}</a>,
408{/if}
409    <a href="#" id="selectNone">{'None'|@translate}</a>,
410    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
411
412    <span id="selectedMessage"></span>
413
414    <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
415  </p>
416
417    <ul class="thumbnails">
418      {foreach from=$thumbnails item=thumbnail}
419        {if in_array($thumbnail.ID, $selection)}
420          {assign var='isSelected' value=true}
421        {else}
422          {assign var='isSelected' value=false}
423        {/if}
424
425      <li><span class="wrap1">
426          <label>
427            <span class="wrap2{if $isSelected} thumbSelected{/if}">
428        {if $thumbnail.LEVEL > 0}
429        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
430        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
431        {/if}
432            <span>
433              <img src="{$thumbnail.TN_SRC}"
434                 alt="{$thumbnail.FILE}"
435                 title="{$thumbnail.TITLE|@escape:'html'}"
436                 class="thumbnail">
437            </span></span>
438            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
439          </label>
440          </span>
441      </li>
442      {/foreach}
443    </ul>
444
445  {if !empty($navbar) }
446  <div style="clear:both;">
447
448    <div style="float:left">
449    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
450    </div>
451
452    <div style="float:right;margin-top:10px;">{'display'|@translate}
453      <a href="{$U_DISPLAY}&amp;display=20">20</a>
454      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
455      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
456      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
457      {'photos per page'|@translate}
458    </div>
459  </div>
460  {/if}
461
462  {else}
463  <div>{'No photo in the current set.'|@translate}</div>
464  {/if}
465  </fieldset>
466
467  <fieldset id="action">
468
469    <legend>{'Action'|@translate}</legend>
470      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div>
471      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
472
473    <select name="selectAction">
474      <option value="-1">{'Choose an action'|@translate}</option>
475      <option disabled="disabled">------------------</option>
476  {if isset($show_delete_form) }
477      <option value="delete">{'Delete selected photos'|@translate}</option>
478  {/if}
479      <option value="associate">{'Associate to album'|@translate}</option>
480  {if !empty($dissociate_options)}
481      <option value="dissociate">{'Dissociate from album'|@translate}</option>
482  {/if}
483      <option value="add_tags">{'add tags'|@translate}</option>
484  {if !empty($DEL_TAG_SELECTION)}
485      <option value="del_tags">{'remove tags'|@translate}</option>
486  {/if}
487      <option value="author">{'Set author'|@translate}</option>
488      <option value="title">{'Set title'|@translate}</option>
489      <option value="date_creation">{'Set creation date'|@translate}</option>
490      <option value="level">{'Who can see these photos?'|@translate}</option>
491      <option value="metadata">{'synchronize metadata'|@translate}</option>
492  {if ($IN_CADDIE)}
493      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
494  {else}
495      <option value="add_to_caddie">{'add to caddie'|@translate}</option>
496  {/if}
497    </select>
498
499    <!-- delete -->
500    <div id="action_delete" class="bulkAction">
501    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
502    </div>
503
504    <!-- associate -->
505    <div id="action_associate" class="bulkAction">
506          <select style="width:400px" name="associate" size="1">
507            {html_options options=$associate_options }
508         </select>
509    </div>
510
511    <!-- dissociate -->
512    <div id="action_dissociate" class="bulkAction">
513          <select style="width:400px" name="dissociate" size="1">
514            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
515          </select>
516    </div>
517
518
519    <!-- add_tags -->
520    <div id="action_add_tags" class="bulkAction">
521<select id="tags" name="add_tags">
522</select>
523    </div>
524
525    <!-- del_tags -->
526    <div id="action_del_tags" class="bulkAction">
527{$DEL_TAG_SELECTION}
528    </div>
529
530    <!-- author -->
531    <div id="action_author" class="bulkAction">
532    <label><input type="checkbox" name="remove_author"> {'remove author'|@translate}</label><br>
533    {assign var='authorDefaultValue' value='Type here the author name'|@translate}
534<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;">
535    </div>   
536
537    <!-- title -->
538    <div id="action_title" class="bulkAction">
539    <label><input type="checkbox" name="remove_title"> {'remove title'|@translate}</label><br>
540    {assign var='titleDefaultValue' value='Type here the title'|@translate}
541<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;">
542    </div>
543
544    <!-- date_creation -->
545    <div id="action_date_creation" class="bulkAction">
546      <label><input type="checkbox" name="remove_date_creation"> {'remove creation date'|@translate}</label><br>
547      <div id="set_date_creation">
548          <select id="date_creation_day" name="date_creation_day">
549             <option value="0">--</option>
550            {section name=day start=1 loop=32}
551              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
552            {/section}
553          </select>
554          <select id="date_creation_month" name="date_creation_month">
555            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
556          </select>
557          <input id="date_creation_year"
558                 name="date_creation_year"
559                 type="text"
560                 size="4"
561                 maxlength="4"
562                 value="{$DATE_CREATION_YEAR}">
563          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
564      </div>
565    </div>
566
567    <!-- level -->
568    <div id="action_level" class="bulkAction">
569        <select name="level" size="1">
570          {html_options options=$level_options selected=$level_options_selected}
571        </select>
572    </div>
573
574    <!-- metadata -->
575    <div id="action_metadata" class="bulkAction">
576    </div>
577
578    <p id="applyActionBlock" style="display:none" class="actionButtons">
579      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit"> <span id="applyOnDetails"></span></p>
580
581    </div> <!-- #permitAction -->
582  </fieldset>
583
584  </form>
Note: See TracBrowser for help on using the repository browser.