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

Revision 26741, 11.2 KB checked in by mistic100, 6 years ago (diff)

partially revert r26725, not suitable solution

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