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

Revision 10166, 20.6 KB checked in by patdenice, 9 years ago (diff)

merge r10164 from trunk to branch 2.2
feature:2238
Bug corrected with Chrome (function is loaded later)

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