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

Last change on this file since 27266 was 27266, checked in by mistic100, 10 years ago

allow to choose the sort order when using limit filter

File size: 11.5 KB
Line 
1{combine_css path=$SMART_PATH|cat:'admin/template/style.css'}
2{include file='include/datepicker.inc.tpl'}
3{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
4
5{combine_css path='themes/default/js/plugins/jquery.tokeninput.css'}
6{combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
7
8{combine_css path='themes/default/js/plugins/chosen.css'}
9{combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'}
10
11{combine_css path='themes/default/js/ui/theme/jquery.ui.slider.css'}
12{combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'}
13
14
15{footer_script require='jquery'}
16var addFilter = (function($){
17  var count=0,
18      limit_count=0,
19      level_count=0;
20
21  // MAIN EVENT HANDLERS
22  $('#addFilter').change(function() {
23    if ($(this).val() != -1) {
24      add_filter($(this).val());
25      $(this).val(-1);
26    }
27  });
28
29  $('#removeFilters').click(function() {
30    $('#filtersList li:not(.empty)').remove();
31    $('#filtersList li.empty').show();
32
33    $("#addFilter option[value='limit']").removeAttr('disabled');
34    $("#addFilter option[value='level']").removeAttr('disabled');
35
36    limit_level=0;
37    level_count=0;
38
39    return false;
40  });
41
42  $('input[name="is_smart"]').change(function() {
43    $('#SmartAlbum_options').toggle();
44    $('input[name="countImages"]').toggle();
45    $('.count_images_wrapper').toggle();
46  });
47
48  $('input[name="countImages"]').click(function() {
49    countImages($("#smart"));
50    return false;
51  });
52
53
54  // ADD FILTER FUNCTIONS
55  function add_filter(type, cond, value) {
56    count++;
57
58    $('#filtersList li.empty').hide();
59
60    var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count),
61        $block = $($.parseHTML(content)).appendTo("#filtersList");
62
63    if (cond) {
64      select_cond($block, type, cond);
65    }
66
67    if (value) {
68      if (type == "tags") {
69        $block.find(".filter-value .tagSelect").html(value);
70      }
71      else if (type == "album") {
72        select_options($block, value);
73      }
74      else if (type == "level") {
75        select_options($block, value);
76      }
77      else if (type != "dimensions") {
78        $block.find(".filter-value input").val(value);
79      }
80    }
81
82    init_jquery_handlers($block);
83
84    if (type == "dimensions") {
85      select_dimensions($block, cond, value);
86    }
87
88    if (type == 'limit') {
89      limit_count=1;
90      $("#addFilter option[value='limit']").attr('disabled','disabled');
91    }
92    else if (type == 'level') {
93      level_count=1;
94      $("#addFilter option[value='level']").attr('disabled','disabled');
95    }
96  }
97
98  function select_cond($block, type, cond) {
99    $block.find(".filter-cond option").removeAttr('selected');
100    $block.find(".filter-cond option[value='"+cond+"']").attr('selected', 'selected');
101  }
102
103  function select_dimensions($block, cond, value) {
104    cond = cond || 'width';
105    var values;
106
107    $block.find(">.filter-value>span").hide();
108    $block.find(".dimension_"+cond).show();
109
110    if (value) {
111      values = value.split(',');
112    }
113    else {
114      values = $block.find(".filter_dimension_"+cond+"_slider").slider("values");
115    }
116    $block.find(".filter_dimension_"+cond+"_slider").slider("values", values);
117  }
118
119  function select_options($block, value) {
120    var values = value.split(',');
121    for (var j in values) {
122      $block.find(".filter-value option[value='"+ values[j] +"']").attr('selected', 'selected');
123    }
124  }
125
126
127  // DECLARE JQUERY PLUGINS AND VERSATILE HANDLERS
128  function init_jquery_handlers($block) {
129    // remove filter
130    $block.find(".removeFilter").click(function() {
131      var type = $(this).next("input").val();
132
133      if (type == 'limit') {
134        limit_count=1;
135        $("#addFilter option[value='limit']").removeAttr('disabled');
136      }
137      else if (type == 'level') {
138        level_count=1;
139        $("#addFilter option[value='level']").removeAttr('disabled');
140      }
141
142      $(this).parents('li').remove();
143      return false;
144    });
145
146    // date filter
147    if ($block.hasClass('filter_date')) {
148      $block.find("input[type='text']").each(function() {
149        $(this).datepicker({
150          dateFormat:'yy-mm-dd',
151          firstDay:1
152        });
153      });
154    }
155
156    // tags filter
157    if ($block.hasClass('filter_tags')) {
158      $block.find(".tagSelect").tokenInput(
159        [{foreach from=$all_tags item=tag name=tags}{ name:"{$tag.name|escape:javascript}", id:"{$tag.id}" }{if !$smarty.foreach.tags.last},{/if}{/foreach}],
160        {
161          hintText: '{'Type in a search term'|translate}',
162          noResultsText: '{'No results'|translate}',
163          searchingText: '{'Searching...'|translate}',
164          animateDropdown: false,
165          preventDuplicates: true,
166          allowFreeTagging: false
167        }
168      );
169    }
170
171    // album filter
172    if ($block.hasClass('filter_album')) {
173      $block.find(".albumSelect").chosen();
174    }
175
176    // dimension filter
177    if ($block.hasClass('filter_dimensions')) {
178      $block.find(".filter-cond select").change(function() {
179        select_dimensions($block, $(this).val());
180      });
181
182      $block.find(".filter_dimension_width_slider").slider({
183        range: true,
184        min: {$dimensions.bounds.min_width},
185        max: {$dimensions.bounds.max_width},
186        values: [{$dimensions.bounds.min_width}, {$dimensions.bounds.max_width}],
187        slide: function(event, ui) {
188          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
189        },
190        change: function(event, ui) {
191          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
192        }
193      });
194
195      $block.find(".filter_dimension_height_slider").slider({
196        range: true,
197        min: {$dimensions.bounds.min_height},
198        max: {$dimensions.bounds.max_height},
199        values: [{$dimensions.bounds.min_height}, {$dimensions.bounds.max_height}],
200        slide: function(event, ui) {
201          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
202        },
203        change: function(event, ui) {
204          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
205        }
206      });
207
208      $block.find(".filter_dimension_ratio_slider").slider({
209        range: true,
210        step: 0.01,
211        min: {$dimensions.bounds.min_ratio},
212        max: {$dimensions.bounds.max_ratio},
213        values: [{$dimensions.bounds.min_ratio}, {$dimensions.bounds.max_ratio}],
214        slide: function(event, ui) {
215          change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|translate}");
216        },
217        change: function(event, ui) {
218          change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|translate}");
219        }
220      });
221
222      $block.find("a.dimensions-choice").click(function() {
223        $block.find(".filter_dimension_"+ $(this).data("type") +"_slider").slider("values",
224          [$(this).data("min"), $(this).data("max")]
225        );
226      });
227    }
228  }
229
230
231  // GENERAL FUNCTIONS
232  function change_dimension_info($block, values, text) {
233    $block.find("input[name$='[value][min]']").val(values[0]);
234    $block.find("input[name$='[value][max]']").val(values[1]);
235    $block.find(".filter_dimension_info").html(sprintf(text, values[0], values[1]));
236  }
237
238  function countImages(form) {
239    jQuery.post("{$COUNT_SCRIPT_URL}", 'cat_id={$CAT_ID}&'+form.serialize(),
240      function success(data) {
241        jQuery('.count_images_wrapper').html(data);
242      }
243    );
244  }
245
246  return add_filter; // expose add_filter method
247}(jQuery));
248
249{if isset($new_smart)}
250function doBlink(obj, start, finish) {
251  jQuery(obj).fadeOut(400).fadeIn(400);
252
253  if (start != finish) {
254    doBlink(obj,start+1,finish);
255  }
256  else {
257    jQuery(obj).fadeOut(400);
258  }
259}
260
261doBlink('.new_smart', 0, 3);
262{/if}
263{/footer_script}
264
265
266<div class="titrePage">
267  <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|translate} [SmartAlbum]</h2>
268</div>
269
270<noscript>
271  <div class="errors"><ul><li>JavaScript required!</li></ul></div>
272</noscript>
273
274<div id="batchManagerGlobal">
275<form action="{$F_ACTION}" method="POST" id="smart">
276  <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>
277
278  <fieldset id="SmartAlbum_options" style="margin-top:1em;{if !isset($filters) AND !isset($new_smart)}display:none;{/if}">
279    <legend>{'Filters'|translate}</legend>
280   
281    <div>
282      <label><input type="radio" name="filters[0][value]" value="and" {if $filter_mode=='and'}checked="checked"{/if}> {'Photos must match all filters'|translate}</label>
283      <label><input type="radio" name="filters[0][value]" value="or" {if $filter_mode=='or'}checked="checked"{/if}> {'Photos must match at least one filter'|translate}</label>
284      <input type="hidden" name="filters[0][type]" value="mode">
285      <input type="hidden" name="filters[0][cond]" value="mode">
286    </div>
287
288    <fieldset>
289    <ul id="filtersList">
290      <li class="empty">{'No filter'|translate}</li>
291    {foreach from=$filters item=filter}{strip}
292      {if $filter.type == 'tags'}
293        {capture assign='value'}{foreach from=$filter.value item=tag}<option value="{$tag.id}" class="selected">{$tag.name}</option>{/foreach}{/capture}
294      {else}
295        {assign var='value' value=$filter.value}
296      {/if}
297
298      {if $filter.type == 'limit'}
299        {footer_script}
300        limit_count=1;
301        $("#addFilter option[value='limit']").attr('disabled','disabled');
302        {/footer_script}
303      {elseif $filter.type == 'level'}
304        {footer_script}
305        level_count=1;
306        $("#addFilter option[value='level']").attr('disabled','disabled');
307        {/footer_script}
308      {/if}
309
310      {footer_script}addFilter('{$filter.type}', '{$filter.cond}', '{$value|escape:javascript}');{/footer_script}
311    {/strip}{/foreach}
312    </ul>
313    </fieldset>
314
315    <p class="actionButtons">
316      <select id="addFilter">
317        <option value="-1">{'Add a filter'|translate}</option>
318        <option disabled="disabled">------------------</option>
319        <option value="tags">{'Tags'|translate}</option>
320        <option value="date">{'Date'|translate}</option>
321        <option value="name">{'Photo name'|translate}</option>
322        <option value="album">{'Album'|translate}</option>
323        <option value="dimensions">{'Dimensions'|translate}</option>
324        <option value="author">{'Author'|translate}</option>
325        <option value="hit">{'Hits'|translate}</option>
326        <option value="rating_score">{'Rating score'|translate}</option>
327        <option value="level">{'Privacy level'|translate}</option>
328        <option value="limit">{'Max. number of photos'|translate}</option>
329      </select>
330      <a id="removeFilters">{'Remove all filters'|translate}</a>
331      {if isset($new_smart)}<span class="new_smart">{'Add filters here'|translate}</span>{/if}
332    </p>
333  </fieldset>
334
335  <p class="actionButtons" id="applyFilterBlock">
336    <input class="submit" type="submit" value="{'Save'|translate}" name="submitFilters"/>
337    <input class="submit" type="submit" value="{'Count'|translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/>
338    <span class="count_images_wrapper" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}><span class="count_image">{$IMAGE_COUNT}</span></span>
339  </p>
340
341</form>
342</div>
343
344<div id="filtersRepo" style="display:none;">
345  {include file=$SMART_ABS_PATH|cat:'admin/template/filters.inc.tpl'}
346</div>
Note: See TracBrowser for help on using the repository browser.