source: extensions/ASearchEngine/templates/ase_dialog_tag_choose.tpl @ 7450

Last change on this file since 7450 was 7374, checked in by grum, 13 years ago

Add search by tag ; improve css theming ; add en_Uk language

  • Property svn:executable set to *
File size: 7.4 KB
Line 
1{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
2{known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
3{known_script id="gpc.tagSelector" src=$ROOT_URL|@cat:"plugins/GrumPluginClasses/js/ui.tagSelector.packed.js"}
4
5{literal}
6
7<script type="text/javascript">
8/**
9 * include this template in a page and use dialogChooseASETagBox.show({options}) to display
10 * the dialog box
11 *
12 */
13dialogChooseASETagBox = function()
14{
15  var dialogOptions = {
16      id:'',
17      eventOk:null,
18      cBuilder:null,
19
20      values: {
21        tags:[],
22        method:'AND'
23      },
24    };
25
26  /**
27   * initialize the dialog box
28   */
29  var initDialogBox = function()
30  {
31    $("#iDialogASETagChoose")
32    .dialog(
33      {
34        autoOpen: false,
35        resizable: false,
36        width:550,
37        height:200,
38        modal: true,
39        draggable:true,
40        dialogClass: 'gcBgTabSheet gcBorder',
41        title: '{/literal}{"ase_search_tags"|@translate}{literal}',
42        open: function(event, ui)
43        {
44        },
45        buttons:
46        {
47          '{/literal}{"ase_ok"|@translate}{literal}':
48            function()
49            {
50              if(checkValidity())
51              {
52                dialogOptions.values.tags=$("#iBDTagTags").tagSelector('value');
53                dialogOptions.values.method=$('[name=fBDTagMethod]:checked').val();
54
55                if(dialogOptions.cBuilder!=null)
56                {
57                  setCBuilderItem(dialogOptions.id, dialogOptions.values);
58                }
59
60                if(dialogOptions.eventOk!=null)
61                {
62                  dialogOptions.eventOk(dialogOptions.id, dialogOptions.values);
63                }
64                $(this).dialog('close');
65              }
66            },
67          '{/literal}{"ase_cancel"|@translate}{literal}':
68            function()
69            {
70              $(this).dialog('close');
71            }
72        }
73      }
74    );
75
76    $("#iBDTagTags").tagSelector(
77      {
78        listMaxWidth:400,
79        listMaxHeight:350,
80        maximumTagLoaded:150,
81        filter:'affected',
82        {/literal}
83        textStart:"{'ase_tag_start_to_type_text'|@translate}",
84        textDisplay:"{'ase_tag_x_tags_display'|@translate}",
85        textFound:"{'ase_tag_x_tags_found'|@translate}",
86          {if is_admin()}
87        mode:'admin',
88          {else}
89        mode:'public',
90          {/if}
91        {literal}
92      }
93    );
94
95  }
96
97  /**
98   * check the validity of the condition
99   * return Boolean : true if OK, otherwise false
100   */
101  var checkValidity = function ()
102  {
103    $(".error").removeClass('error');
104    returned=true;
105
106    if($('#iBDTagTags').tagSelector('numberOfTags')==0)
107    {
108      $('#iBDTagTags').addClass('error');
109      returned=false;
110      alert("{/literal}{'ase_error_no_tags_selected'|@translate}{literal}");
111    }
112    return(returned);
113  }
114
115
116  /**
117   * the show() function display and manage a dialog box to choose categories
118   * and the kind of test to apply
119   *
120   * @param options : properties to manage the dialog box
121   *                  - id : a string to identify a DOM object ; this parameter
122   *                         is given to the callback when the OK button is pushed
123   *                  - values : an object with 3 properties
124   *                               - withHD : with our without HD picture
125   *                  - eventOK : a callback function, with 2 parameters : id of
126   *                              the given DOM object and values parameted
127   *                  - cBuilder : a criteriaBuilder object
128   *                               if set, the dialog box manage automaticaly
129   *                               the criteria builder interface
130   */
131  this.show = function (options)
132  {
133    showDialog(options);
134  }
135
136  /**
137   * private function used to show the dialog box
138   */
139  var showDialog = function(options)
140  {
141    if(options.id!=null)
142    {
143      dialogOptions.id=options.id;
144    }
145    else
146    {
147      dialogOptions.id='';
148    }
149
150    if(options.eventOk!=null)
151    {
152      dialogOptions.eventOk=options.eventOk;
153    }
154
155    if(options.cBuilder!=null)
156    {
157      dialogOptions.cBuilder=options.cBuilder;
158      dialogOptions.cBuilder.doAction('setOptions',
159        {
160          onEdit:function (e) { editCB(e.data); },
161          onDelete:function (e) { deleteCB(e.data); },
162        }
163      );
164    }
165
166    if(options.values!=null)
167    {
168      dialogOptions.values=jQuery.extend(dialogOptions.values, options.values);
169    }
170    else
171    {
172      dialogOptions.values.tags=[];
173      dialogOptions.values.method='AND';
174    }
175
176    $("#iBDTagTags").tagSelector('value', 'clear').tagSelector('value', dialogOptions.values.tags);
177    $('#iBDTagMethodAND').attr('checked', dialogOptions.values.method=='AND');
178    $('#iBDTagMethodOR').attr('checked', dialogOptions.values.method=='OR');
179
180    $("#iDialogASETagChoose").dialog('open');
181  }
182
183
184
185  /**
186   * manage the 'edit' button from criteria builder interface
187   * @param String itemId : the itemId
188   */
189  var editCB = function (itemId)
190  {
191    extraData=dialogOptions.cBuilder.doAction('getExtraData', itemId);
192    showDialog(
193      {
194        id:itemId,
195        values:
196          {
197            tags:extraData.param.tags,
198            method:extraData.param.method,
199          },
200      }
201    );
202  }
203
204  /**
205   * manage the 'delete' button from criteria builder interface
206   * @param String itemId : the itemId
207   */
208  var deleteCB = function (itemId)
209  {
210    dialogOptions.cBuilder.doAction('delete', itemId);
211  }
212
213  /**
214   * set the content for the cBuilder item
215   */
216  var setCBuilderItem = function(id)
217  {
218    var content="";
219
220    for(var i=0;i<dialogOptions.values.tags.length;i++)
221    {
222      if(content!='') content+=', ';
223      content+=dialogOptions.values.tags[i].name;
224    }
225
226
227    if(dialogOptions.values.method=='AND')
228    {
229      content="<div>{/literal}{'ase_tag_method_and_text'|@translate}{literal}&nbsp;<span style='font-style:italic;'>"+content+"</span>";
230    }
231    else
232    {
233      content="<div>{/literal}{'ase_tag_method_or_text'|@translate}{literal}&nbsp;<span style='font-style:italic;'>"+content+"</span>";
234    }
235
236    content+="</div>";
237
238    if(id=='')
239    {
240      //no id:add a new item in the list
241      dialogOptions.cBuilder.doAction(
242        'add',
243        content,
244        criteriaBuilder.makeExtendedData(
245          'ASETag',
246          {
247            tags:dialogOptions.values.tags,
248            method:dialogOptions.values.method,
249          }
250        )
251      );
252    }
253    else
254    {
255      // update item
256      dialogOptions.cBuilder.doAction(
257        'edit',
258        id,
259        content,
260        criteriaBuilder.makeExtendedData(
261          'ASETag',
262          {
263            tags:dialogOptions.values.tags,
264            method:dialogOptions.values.method,
265          }
266        )
267      );
268    }
269  }
270
271  initDialogBox();
272}
273
274
275</script>
276{/literal}
277
278<div id="iDialogASETagChoose" style='display:none;'>
279
280  <table class="formtable">
281    <tr>
282      <td>{'ase_tags'|@translate}</td>
283      <td>
284        <div id="iBDTagTags" style="width:400px;"></div>
285      </td>
286    </tr>
287
288    <tr>
289      <td></td>
290      <td>
291        <label><input type='radio' id='iBDTagMethodAND' name='fBDTagMethod' value="AND">&nbsp;{'ase_tag_method_and'|@translate}</label><br>
292        <label><input type='radio' id='iBDTagMethodOR' name='fBDTagMethod' value="OR">&nbsp;{'ase_tag_method_or'|@translate}</label><br>
293      </td>
294    </tr>
295
296  </table>
297
298</div>
299
300
Note: See TracBrowser for help on using the repository browser.