1 | {combine_css path=$SMART_PATH|@cat:"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'} |
---|
6 | var lang = new Array(); |
---|
7 | lang['tags filter'] = "{'tags filter'|@translate}"; |
---|
8 | lang['date filter'] = "{'date filter'|@translate}"; |
---|
9 | lang['limit filter'] = "{'limit filter'|@translate}"; |
---|
10 | lang['remove this filter'] = "{'remove this filter'|@translate}"; |
---|
11 | |
---|
12 | var options = new Array(); |
---|
13 | {capture assign="options_tags"}{html_options options=$options.tags}{/capture} |
---|
14 | {capture assign="options_date"}{html_options options=$options.date}{/capture} |
---|
15 | {capture assign="options_limit"}{html_options options=$options.limit}{/capture} |
---|
16 | options['tags'] = "{$options_tags|escape:javascript}"; |
---|
17 | options['date'] = "{$options_date|escape:javascript}"; |
---|
18 | options['limit'] = "{$options_limit|escape:javascript}"; |
---|
19 | |
---|
20 | {literal} |
---|
21 | jQuery(document).ready(function() { |
---|
22 | $('#addFilter').change(function() { |
---|
23 | add_filter($(this).attr('value')); |
---|
24 | $(this).attr('value', '-1'); |
---|
25 | }); |
---|
26 | |
---|
27 | $('#removeFilters').click(function() { |
---|
28 | $('#filterList li').each(function() { |
---|
29 | $(this).remove(); |
---|
30 | }); |
---|
31 | return false; |
---|
32 | }); |
---|
33 | |
---|
34 | $('input[name="is_smart"]').change(function() { |
---|
35 | $('#SmartAlbum_options').toggle(); |
---|
36 | $('input[name="countImages"]').toggle(); |
---|
37 | $('.count_images_display').toggle(); |
---|
38 | }); |
---|
39 | |
---|
40 | $('input[name="countImages"]').click(function() { |
---|
41 | countImages($(this).closest('form')); |
---|
42 | return false; |
---|
43 | }); |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | function add_filter(type) { |
---|
48 | // add line |
---|
49 | $('<li class="filter_'+ type +'" id="filter_'+ i +'"></li>').appendTo('#filterList'); |
---|
50 | |
---|
51 | //set content |
---|
52 | content = '<a href="#" class="removeFilter" title="'+ lang['remove this filter'] +'"><span>[x]</span></a>'+ |
---|
53 | '<input type="hidden" name="filters['+ i +'][type]" value="'+ type +'"/> '+ lang[type +' filter'] + |
---|
54 | ' <select name="filters['+ i +'][cond]">'+ options[type] +'</select>'; |
---|
55 | |
---|
56 | if (type == 'tags') { |
---|
57 | content += ' <select name="filters['+ i +'][value]" class="tagSelect"></select>'; |
---|
58 | } else { |
---|
59 | content += ' <input type="text" name="filters['+ i +'][value]"/>'; |
---|
60 | } |
---|
61 | |
---|
62 | $('#filter_'+ i).html(content); |
---|
63 | |
---|
64 | // reinit handlers |
---|
65 | init_jquery_handlers(); |
---|
66 | i++; |
---|
67 | } |
---|
68 | |
---|
69 | function init_jquery_handlers() { |
---|
70 | $('.removeFilter').click(function() { |
---|
71 | $(this).parent('li').remove(); |
---|
72 | return false; |
---|
73 | }); |
---|
74 | |
---|
75 | $('.filter_date input[type="text"]').each(function() { |
---|
76 | $(this).datepicker({dateFormat:'yy-mm-dd', firstDay:1}); |
---|
77 | }); |
---|
78 | |
---|
79 | jQuery(".tagSelect").tokenInput( |
---|
80 | {/literal} |
---|
81 | [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}], |
---|
82 | {ldelim} |
---|
83 | hintText: '{'Type in a search term'|@translate}', |
---|
84 | noResultsText: '{'No results'|@translate}', |
---|
85 | searchingText: '{'Searching...'|@translate}', |
---|
86 | animateDropdown: false, |
---|
87 | preventDuplicates: true, |
---|
88 | allowCreation: false |
---|
89 | {literal} |
---|
90 | } |
---|
91 | ); |
---|
92 | } |
---|
93 | |
---|
94 | function countImages(form) { |
---|
95 | {/literal} |
---|
96 | jQuery.post("{$COUNT_SCRIPT_URL}", 'cat_id={$CAT_ID}&'+form.serialize(), |
---|
97 | {literal} |
---|
98 | function success(data) { |
---|
99 | jQuery('.count_images_display').html(data); |
---|
100 | } |
---|
101 | ); |
---|
102 | } |
---|
103 | |
---|
104 | function doBlink(obj,start,finish) { |
---|
105 | jQuery(obj).fadeOut(400).fadeIn(400); |
---|
106 | if(start!=finish) { |
---|
107 | doBlink(obj,start+1,finish); |
---|
108 | } else { |
---|
109 | jQuery(obj).fadeOut(400); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | doBlink('.new_smart', 0, 3); |
---|
114 | init_jquery_handlers(); |
---|
115 | }); |
---|
116 | {/literal} |
---|
117 | {/footer_script} |
---|
118 | |
---|
119 | <div id="batchManagerGlobal"> |
---|
120 | <form action="{$F_ACTION}" method="POST" id="smart"> |
---|
121 | <fieldset> |
---|
122 | |
---|
123 | <legend>{'SmartAlbums'|@translate}</legend> |
---|
124 | |
---|
125 | <label><input type="checkbox" name="is_smart" {if isset($filters) OR isset($new_smart)}checked="checked"{/if}/> {'This album is a SmartAlbum'|@translate}</label> |
---|
126 | |
---|
127 | <div id="SmartAlbum_options" style="margin-top:1em;{if !isset($filters) AND !isset($new_smart)}display:none;{/if}"> |
---|
128 | <ul id="filterList"> |
---|
129 | {counter start=0 assign=i} |
---|
130 | {foreach from=$filters item=filter} |
---|
131 | <li class="filter_{$filter.TYPE}" id="filter_{$i}"> |
---|
132 | <a href="#" class="removeFilter" title="{'remove this filter'|@translate}"><span>[x]</span></a> |
---|
133 | <input type="hidden" name="filters[{$i}][type]" value="{$filter.TYPE}"/> |
---|
134 | {$filter.TYPE|cat:' filter'|@translate} |
---|
135 | |
---|
136 | <select name="filters[{$i}][cond]"> |
---|
137 | {html_options options=$options[$filter.TYPE] selected=$filter.COND} |
---|
138 | </select> |
---|
139 | |
---|
140 | {if $filter.TYPE == 'tags'} |
---|
141 | <select name="filters[{$i}][value]" class="tagSelect"> |
---|
142 | {foreach from=$filter.VALUE item=tag} |
---|
143 | <option value="{$tag.id}" class="selected">{$tag.name}</option> |
---|
144 | {/foreach} |
---|
145 | </select> |
---|
146 | {else} |
---|
147 | <input type="text" name="filters[{$i}][value]" value="{$filter.VALUE}"/> |
---|
148 | {/if} |
---|
149 | </li> |
---|
150 | {counter} |
---|
151 | {/foreach} |
---|
152 | |
---|
153 | {footer_script}var i={$i};{/footer_script} |
---|
154 | </ul> |
---|
155 | |
---|
156 | <p class="actionButtons"> |
---|
157 | <select id="addFilter"> |
---|
158 | <option value="-1">{'Add a filter'|@translate}</option> |
---|
159 | <option disabled="disabled">------------------</option> |
---|
160 | <option value="tags">{'tags filter'|@translate}</option> |
---|
161 | <option value="date">{'date filter'|@translate}</option> |
---|
162 | <option value="limit">{'limit filter'|@translate}</option> |
---|
163 | </select> |
---|
164 | <a id="removeFilters">{'Remove all filters'|@translate}</a> |
---|
165 | {if isset($new_smart)}<span class="new_smart">{'Add filters here'|@translate}</span>{/if} |
---|
166 | </p> |
---|
167 | </div> |
---|
168 | |
---|
169 | <p class="actionButtons" id="applyFilterBlock"> |
---|
170 | <input class="submit" type="submit" value="{'Submit'|@translate}" name="submitFilters"/> |
---|
171 | <input class="submit" type="submit" value="{'Count'|@translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/> |
---|
172 | <span class="count_images_display">{$IMAGE_COUNT}</span> |
---|
173 | </p> |
---|
174 | |
---|
175 | </fieldset> |
---|
176 | </form> |
---|
177 | </div> |
---|