source: extensions/SmartAlbums/template/cat_modify.tpl @ 11334

Last change on this file since 11334 was 11334, checked in by mistic100, 13 years ago

private items are not displayed in SmartAlbums (according to user permissions)

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