source: extensions/SmartAlbums/admin/template/album.tpl @ 16104

Last change on this file since 16104 was 16104, checked in by mistic100, 12 years ago

updated for Piwigo 2.4
new filters : name, author, level, hits

File size: 7.3 KB
Line 
1{combine_css path=$SMART_PATH|@cat:"admin/template/style.css"}
2{include file='include/datepicker.inc.tpl'}
3{combine_script id='jquery.tokeninput' load='async' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
4
5{footer_script require='jquery.tokeninput'}
6var lang = new Array();
7var options = new Array();
8
9{foreach from=$options item=details key=mode}
10  lang['{$mode}_filter'] = '{$mode|cat:'_filter'|@translate|escape:javascript}';
11  {capture assign="option_content"}{html_options options=$details}{/capture}
12  options['{$mode}'] = "{$option_content|escape:javascript}";
13{/foreach}
14
15lang['For "Is (not) in", separate each author by a comma'] = '{'For "Is (not) in", separate each author by a comma'|@translate|escape:javascript}';
16lang['remove this filter'] = '{'remove this filter'|@translate|escape:javascript}';
17{capture assign="option_content"}{html_options options=$level_options selected=0}{/capture}
18options['level_options'] = "{$option_content|escape:javascript}";
19
20{literal}
21$('#addFilter').change(function() {
22  add_filter($(this).attr('value'));
23  $(this).attr('value', '-1');
24});
25 
26$('#removeFilters').click(function() {
27  $('#filterList li').each(function() {
28    $(this).remove();
29  });
30  return false;
31});
32
33$('input[name="is_smart"]').change(function() {
34  $('#SmartAlbum_options').toggle();
35  $('input[name="countImages"]').toggle();
36  $('.count_images_wrapper').toggle();
37});
38
39$('input[name="countImages"]').click(function() {
40  countImages($("#smart"));
41  return false;
42});
43
44
45function add_filter(type) {
46  // add line
47  $('<li class="filter_'+ type +'" id="filter_'+ i +'"></li>').appendTo('#filterList');
48 
49  //set content
50  content =
51    ' <span class="filter-title">'+
52      ' <a href="#" class="removeFilter" title="'+ lang['remove this filter'] +'"><span>[x]</span></a>'+
53      ' <input type="hidden" name="filters['+ i +'][type]" value="'+ type +'"/>&nbsp;'+ lang[type +'_filter'] +
54    '</span>'+
55    ' <span class="filter-cond">'+
56      ' <select name="filters['+ i +'][cond]">'+ options[type] +'</select>'+
57    '</span>'+
58    ' <span class="filter-value">';
59 
60  if (type == 'tags')
61    content+= ' <select name="filters['+ i +'][value]" class="tagSelect"></select>';
62  else if (type == 'level')
63    content+= ' <select name="filters['+ i +'][value]">'+ options['level_options'] +'</select>';
64  else
65    content+= ' <input type="text" name="filters['+ i +'][value]" size="30"/>';
66 
67  if (type == 'author')
68    content+= ' <i>'+ lang['For "Is (not) in", separate each author by a comma'] +'</i>';
69   
70  content+= '</span>';
71 
72  $('#filter_'+ i).html(content);
73 
74  // reinit handlers
75  init_jquery_handlers();
76  i++;
77}
78
79function init_jquery_handlers() { 
80  $('.removeFilter').click(function() {
81    $(this).parents('li').remove();
82    return false;
83  });
84
85  $('.filter_date input[type="text"]').each(function() {
86    $(this).datepicker({dateFormat:'yy-mm-dd', firstDay:1});
87  });
88 
89  jQuery(".tagSelect").tokenInput(
90  {/literal}
91    [{foreach from=$all_tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
92    {ldelim}
93      hintText: '{'Type in a search term'|@translate}',
94      noResultsText: '{'No results'|@translate}',
95      searchingText: '{'Searching...'|@translate}',
96      animateDropdown: false,
97      preventDuplicates: true,
98      allowCreation: false
99  {literal}
100    }
101  );
102}
103
104function countImages(form) {
105{/literal}
106  jQuery.post("{$COUNT_SCRIPT_URL}", 'cat_id={$CAT_ID}&'+form.serialize(),
107{literal}
108    function success(data) {
109      jQuery('.count_images_wrapper').html(data);
110    }
111  );
112}
113
114function doBlink(obj,start,finish) {
115  jQuery(obj).fadeOut(400).fadeIn(400);
116  if(start!=finish) {
117    doBlink(obj,start+1,finish);
118  } else {
119    jQuery(obj).fadeOut(400);
120  }
121}
122 
123init_jquery_handlers();
124{/literal}
125{if isset($new_smart)}doBlink('.new_smart', 0, 3);{/if}
126{/footer_script}
127
128<div class="titrePage">
129  <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|@translate} [SmartAlbum]</h2>
130</div>
131
132<div id="batchManagerGlobal">
133<form action="{$F_ACTION}" method="POST" id="smart">
134  <p style="text-align:left;"><label><input type="checkbox" name="is_smart" {if isset($filters) OR isset($new_smart)}checked="checked"{/if}/> {'This album is a SmartAlbum'|@translate}</label></p>
135
136  <fieldset id="SmartAlbum_options" style="margin-top:1em;{if !isset($filters) AND !isset($new_smart)}display:none;{/if}">
137    <legend>{'Filters'|@translate}</legend>
138     
139    <ul id="filterList">
140      {counter start=0 assign=i}
141      {foreach from=$filters item=filter}
142        <li class="filter_{$filter.TYPE}" id="filter_{$i}">
143          <span class="filter-title">
144            <a href="#" class="removeFilter" title="{'remove this filter'|@translate}"><span>[x]</span></a>
145            <input type="hidden" name="filters[{$i}][type]" value="{$filter.TYPE}"/>
146            {$filter.TYPE|cat:'_filter'|@translate}
147          </span>
148         
149          <span class="filter-cond">
150            <select name="filters[{$i}][cond]">
151              {html_options options=$options[$filter.TYPE] selected=$filter.COND}
152            </select>
153          </span>
154         
155          <span class="filter-value">
156          {if $filter.TYPE == 'tags'}
157            <select name="filters[{$i}][value]" class="tagSelect">
158            {foreach from=$filter.VALUE item=tag}
159              <option value="{$tag.id}" class="selected">{$tag.name}</option>
160            {/foreach}
161            </select>
162          {elseif $filter.TYPE == 'level'}
163            <select name="filters[{$i}][value]">
164              {html_options options=$level_options selected=$filter.VALUE}
165            </select>
166          {else}
167            <input type="text" name="filters[{$i}][value]" value="{$filter.VALUE}" size="30"/>
168          {/if}
169          {if $filter.TYPE == 'author'}
170            <i>{'For "Is (not) in", separate each author by a comma'|@translate}</i>
171          {/if}
172          </span>
173        </li>
174        {counter}
175      {/foreach}
176     
177      {footer_script}var i={$i};{/footer_script}
178    </ul>
179
180    <p class="actionButtons">
181        <select id="addFilter">
182          <option value="-1">{'Add a filter'|@translate}</option>
183          <option disabled="disabled">------------------</option>
184          <option value="tags">{'tags_filter'|@translate}</option>
185          <option value="date">{'date_filter'|@translate}</option>
186          <option value="name">{'name_filter'|@translate}</option>
187          <option value="author">{'author_filter'|@translate}</option>
188          <option value="hit">{'hit_filter'|@translate}</option>
189          <option value="level">{'level_filter'|@translate}</option>
190          <option value="limit">{'limit_filter'|@translate}</option>
191        </select>
192        <a id="removeFilters">{'Remove all filters'|@translate}</a>
193        {if isset($new_smart)}<span class="new_smart">{'Add filters here'|@translate}</span>{/if}
194    </p>
195  </fieldset>
196
197  <p class="actionButtons" id="applyFilterBlock">
198    <input class="submit" type="submit" value="{'Submit'|@translate}" name="submitFilters"/>
199    <input class="submit" type="submit" value="{'Count'|@translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/>
200    <span class="count_images_wrapper" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}><span class="count_image">{$IMAGE_COUNT}</span></span>
201  </p>
202
203</form>
204</div>
Note: See TracBrowser for help on using the repository browser.