source: extensions/bulk_manager/element_set_global.tpl @ 22240

Last change on this file since 22240 was 6773, checked in by plg, 14 years ago

feature 1803 added: single click to select all photos of the current set.

Next to the "select actions", always displays either "no photo selected" or
"23 of 41 photos selected" or "All 41 photos selected".

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