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

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

add album filter

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