1 | {combine_script id="jquery.ui" path="themes/default/js/ui/minified/jquery.ui.core.min.js" require='jquery'} |
---|
2 | {combine_script id="jquery.ui.dialog" path="themes/default/js/ui/minified/jquery.ui.dialog.min.js" require='jquery'} |
---|
3 | |
---|
4 | {literal} |
---|
5 | |
---|
6 | <script type="text/javascript"> |
---|
7 | /** |
---|
8 | * include this template in a page and use dialogChooseASEKeywordBox.show({options}) to display |
---|
9 | * the dialog box |
---|
10 | * |
---|
11 | */ |
---|
12 | dialogChooseASEKeywordBox = function() |
---|
13 | { |
---|
14 | var dialogOptions = { |
---|
15 | id:'', |
---|
16 | eventOk:null, |
---|
17 | cBuilder:null, |
---|
18 | |
---|
19 | values: { |
---|
20 | keyword:'', |
---|
21 | optIgnoreCase:'y', |
---|
22 | optWholeWords:'n', |
---|
23 | searchName:'y', |
---|
24 | searchDesc:'y', |
---|
25 | searchFileName:'n' |
---|
26 | }, |
---|
27 | }; |
---|
28 | |
---|
29 | /** |
---|
30 | * initialize the dialog box |
---|
31 | */ |
---|
32 | var initDialogBox = function() |
---|
33 | { |
---|
34 | $("#iDialogASEKeywordChoose") |
---|
35 | .dialog( |
---|
36 | { |
---|
37 | autoOpen: false, |
---|
38 | resizable: false, |
---|
39 | width:550, |
---|
40 | height:200, |
---|
41 | modal: true, |
---|
42 | draggable:true, |
---|
43 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
44 | title: '{/literal}{"ase_search_keyword"|@translate}{literal}', |
---|
45 | open: function(event, ui) |
---|
46 | { |
---|
47 | }, |
---|
48 | buttons: |
---|
49 | { |
---|
50 | '{/literal}{"ase_ok"|@translate}{literal}': |
---|
51 | function() |
---|
52 | { |
---|
53 | if(checkValidity()) |
---|
54 | { |
---|
55 | dialogOptions.values.keyword=$('#iASEKeywordKeyword').val(); |
---|
56 | dialogOptions.values.optIgnoreCase=$('#iASEKeywordIgnoreCase').attr('checked')?'y':'n'; |
---|
57 | dialogOptions.values.optWholeWords=$('#iASEKeywordWholeWords').attr('checked')?'y':'n'; |
---|
58 | dialogOptions.values.searchName=$('#iASEKeywordSearchName').attr('checked')?'y':'n'; |
---|
59 | dialogOptions.values.searchDesc=$('#iASEKeywordSearchDesc').attr('checked')?'y':'n'; |
---|
60 | dialogOptions.values.searchFileName=$('#iASEKeywordSearchFileName').attr('checked')?'y':'n'; |
---|
61 | |
---|
62 | if(dialogOptions.cBuilder!=null) |
---|
63 | { |
---|
64 | setCBuilderItem(dialogOptions.id, dialogOptions.values); |
---|
65 | } |
---|
66 | |
---|
67 | if(dialogOptions.eventOk!=null) |
---|
68 | { |
---|
69 | dialogOptions.eventOk(dialogOptions.id, dialogOptions.values); |
---|
70 | } |
---|
71 | $(this).dialog('close'); |
---|
72 | } |
---|
73 | }, |
---|
74 | '{/literal}{"ase_cancel"|@translate}{literal}': |
---|
75 | function() |
---|
76 | { |
---|
77 | $(this).dialog('close'); |
---|
78 | } |
---|
79 | } |
---|
80 | } |
---|
81 | ); |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * check the validity of the condition |
---|
86 | * return Boolean : true if OK, otherwise false |
---|
87 | */ |
---|
88 | var checkValidity = function () |
---|
89 | { |
---|
90 | $(".error").removeClass('error'); |
---|
91 | returned=true; |
---|
92 | |
---|
93 | if($('#iASEKeywordKeyword').val().length< {/literal}{$aseConfig.ase_keyword_minLength}{literal} ) |
---|
94 | { |
---|
95 | $("#iASEKeywordKeyword").addClass('error'); |
---|
96 | alert("{/literal}{'ase_error_keyword_length'|@translate}{literal}"); |
---|
97 | returned=false; |
---|
98 | } |
---|
99 | |
---|
100 | if(!$('#iASEKeywordSearchName').attr('checked') && |
---|
101 | !$('#iASEKeywordSearchDesc').attr('checked') && |
---|
102 | !$('#iASEKeywordSearchFileName').attr('checked')) |
---|
103 | { |
---|
104 | $("#iASEKeywordSearchName, #iASEKeywordSearchDesc, #iASEKeywordSearchFileName").parent().addClass('error'); |
---|
105 | alert("{/literal}{'ase_error_no_target'|@translate}{literal}"); |
---|
106 | returned=false; |
---|
107 | } |
---|
108 | |
---|
109 | return(returned); |
---|
110 | } |
---|
111 | |
---|
112 | |
---|
113 | /** |
---|
114 | * the show() function display and manage a dialog box to choose categories |
---|
115 | * and the kind of test to apply |
---|
116 | * |
---|
117 | * @param options : properties to manage the dialog box |
---|
118 | * - id : a string to identify a DOM object ; this parameter |
---|
119 | * is given to the callback when the OK button is pushed |
---|
120 | * - values : an object with 3 properties |
---|
121 | * - keyword : the keyword to find |
---|
122 | * - optIgnoreCase : ignore case or not |
---|
123 | * - optWholeWords : search whol words only or not |
---|
124 | * - searchName : search inside picture name |
---|
125 | * - searchDesc : search inside picture desc |
---|
126 | * - searchFileName : search inside picture filename |
---|
127 | * - eventOK : a callback function, with 2 parameters : id of |
---|
128 | * the given DOM object and values parameted |
---|
129 | * - cBuilder : a criteriaBuilder object |
---|
130 | * if set, the dialog box manage automaticaly |
---|
131 | * the criteria builder interface |
---|
132 | */ |
---|
133 | this.show = function (options) |
---|
134 | { |
---|
135 | showDialog(options); |
---|
136 | } |
---|
137 | |
---|
138 | /** |
---|
139 | * private function used to show the dialog box |
---|
140 | */ |
---|
141 | var showDialog = function(options) |
---|
142 | { |
---|
143 | if(options.id!=null) |
---|
144 | { |
---|
145 | dialogOptions.id=options.id; |
---|
146 | } |
---|
147 | else |
---|
148 | { |
---|
149 | dialogOptions.id=''; |
---|
150 | } |
---|
151 | |
---|
152 | if(options.eventOk!=null) |
---|
153 | { |
---|
154 | dialogOptions.eventOk=options.eventOk; |
---|
155 | } |
---|
156 | |
---|
157 | if(options.cBuilder!=null) |
---|
158 | { |
---|
159 | dialogOptions.cBuilder=options.cBuilder; |
---|
160 | dialogOptions.cBuilder.doAction('setOptions', |
---|
161 | { |
---|
162 | onEdit:function (e) { editCB(e.data); }, |
---|
163 | onDelete:function (e) { deleteCB(e.data); }, |
---|
164 | } |
---|
165 | ); |
---|
166 | } |
---|
167 | |
---|
168 | if(options.values!=null) |
---|
169 | { |
---|
170 | dialogOptions.values=jQuery.extend(dialogOptions.values, options.values); |
---|
171 | } |
---|
172 | else |
---|
173 | { |
---|
174 | dialogOptions.values.keyword=''; |
---|
175 | dialogOptions.values.optIgnoreCase='y'; |
---|
176 | dialogOptions.values.optWholeWords='n'; |
---|
177 | dialogOptions.values.searchName='y'; |
---|
178 | dialogOptions.values.searchDesc='y'; |
---|
179 | dialogOptions.values.searchFileName='n'; |
---|
180 | } |
---|
181 | |
---|
182 | $('#iASEKeywordKeyword').val(dialogOptions.values.keyword); |
---|
183 | $('#iASEKeywordIgnoreCase').attr('checked', dialogOptions.values.optIgnoreCase=='y'); |
---|
184 | $('#iASEKeywordWholeWords').attr('checked', dialogOptions.values.optWholeWords=='y'); |
---|
185 | $('#iASEKeywordSearchName').attr('checked', dialogOptions.values.searchName=='y'); |
---|
186 | $('#iASEKeywordSearchDesc').attr('checked', dialogOptions.values.searchDesc=='y'); |
---|
187 | $('#iASEKeywordSearchFileName').attr('checked', dialogOptions.values.searchFileName=='y'); |
---|
188 | |
---|
189 | |
---|
190 | $("#iDialogASEKeywordChoose").dialog('open'); |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | /** |
---|
196 | * manage the 'edit' button from criteria builder interface |
---|
197 | * @param String itemId : the itemId |
---|
198 | */ |
---|
199 | var editCB = function (itemId) |
---|
200 | { |
---|
201 | extraData=dialogOptions.cBuilder.doAction('getExtraData', itemId); |
---|
202 | showDialog( |
---|
203 | { |
---|
204 | id:itemId, |
---|
205 | values: |
---|
206 | { |
---|
207 | keyword:extraData.param.keyword, |
---|
208 | optIgnoreCase:extraData.param.optIgnoreCase, |
---|
209 | optWholeWords:extraData.param.optWholeWords, |
---|
210 | searchName:extraData.param.searchName, |
---|
211 | searchDesc:extraData.param.searchDesc, |
---|
212 | searchFileName:extraData.param.searchFileName |
---|
213 | }, |
---|
214 | } |
---|
215 | ); |
---|
216 | } |
---|
217 | |
---|
218 | /** |
---|
219 | * manage the 'delete' button from criteria builder interface |
---|
220 | * @param String itemId : the itemId |
---|
221 | */ |
---|
222 | var deleteCB = function (itemId) |
---|
223 | { |
---|
224 | dialogOptions.cBuilder.doAction('delete', itemId); |
---|
225 | } |
---|
226 | |
---|
227 | /** |
---|
228 | * set the content for the cBuilder item |
---|
229 | */ |
---|
230 | var setCBuilderItem = function(id) |
---|
231 | { |
---|
232 | var content="<div>{/literal}{'ase_search_the_keyword'|@translate}{literal} "; |
---|
233 | |
---|
234 | content+="<span style='font-style:italic;text-decoration:underline;'>"+dialogOptions.values.keyword+"</span> :"; |
---|
235 | |
---|
236 | if(dialogOptions.values.searchName=='y') content+="<br> - {/literal}{'ase_search_into_name'|@translate}{literal}"; |
---|
237 | if(dialogOptions.values.searchDesc=='y') content+="<br> - {/literal}{'ase_search_into_desc'|@translate}{literal}"; |
---|
238 | if(dialogOptions.values.searchFileName=='y') content+="<br> - {/literal}{'ase_search_into_filename'|@translate}{literal}"; |
---|
239 | |
---|
240 | if(dialogOptions.values.optIgnoreCase=='y') content+="<br> - {/literal}{'ase_search_with_case_ignored'|@translate}{literal}"; |
---|
241 | if(dialogOptions.values.optWholeWords=='y') content+="<br> - {/literal}{'ase_search_with_whole_words'|@translate}{literal}"; |
---|
242 | |
---|
243 | |
---|
244 | content+="</div>"; |
---|
245 | |
---|
246 | if(id=='') |
---|
247 | { |
---|
248 | //no id:add a new item in the list |
---|
249 | dialogOptions.cBuilder.doAction( |
---|
250 | 'add', |
---|
251 | content, |
---|
252 | criteriaBuilder.makeExtendedData( |
---|
253 | 'ASEKeyword', |
---|
254 | { |
---|
255 | keyword:dialogOptions.values.keyword, |
---|
256 | optIgnoreCase:dialogOptions.values.optIgnoreCase, |
---|
257 | optWholeWords:dialogOptions.values.optWholeWords, |
---|
258 | searchName:dialogOptions.values.searchName, |
---|
259 | searchDesc:dialogOptions.values.searchDesc, |
---|
260 | searchFileName:dialogOptions.values.searchFileName |
---|
261 | } |
---|
262 | ) |
---|
263 | ); |
---|
264 | } |
---|
265 | else |
---|
266 | { |
---|
267 | // update item |
---|
268 | dialogOptions.cBuilder.doAction( |
---|
269 | 'edit', |
---|
270 | id, |
---|
271 | content, |
---|
272 | criteriaBuilder.makeExtendedData( |
---|
273 | 'ASEKeyword', |
---|
274 | { |
---|
275 | keyword:dialogOptions.values.keyword, |
---|
276 | optIgnoreCase:dialogOptions.values.optIgnoreCase, |
---|
277 | optWholeWords:dialogOptions.values.optWholeWords, |
---|
278 | searchName:dialogOptions.values.searchName, |
---|
279 | searchDesc:dialogOptions.values.searchDesc, |
---|
280 | searchFileName:dialogOptions.values.searchFileName |
---|
281 | } |
---|
282 | ) |
---|
283 | ); |
---|
284 | } |
---|
285 | } |
---|
286 | |
---|
287 | initDialogBox(); |
---|
288 | } |
---|
289 | |
---|
290 | |
---|
291 | </script> |
---|
292 | {/literal} |
---|
293 | |
---|
294 | <div id="iDialogASEKeywordChoose" style='display:none;'> |
---|
295 | |
---|
296 | <table class="formtable"> |
---|
297 | <tr> |
---|
298 | <td>{'ase_keyword'|@translate}</td> |
---|
299 | <td> |
---|
300 | <input type="text" id="iASEKeywordKeyword"><br> |
---|
301 | <label><input type="checkbox" id='iASEKeywordIgnoreCase'> {'ase_ignore_case'|@translate}<label><br> |
---|
302 | <label><input type="checkbox" id='iASEKeywordWholeWords'> {'ase_whole_words_only'|@translate}<label> |
---|
303 | </td> |
---|
304 | </tr> |
---|
305 | |
---|
306 | <tr> |
---|
307 | <td>{'ase_search_into'|@translate}</td> |
---|
308 | <td> |
---|
309 | <label><input type="checkbox" id='iASEKeywordSearchName'> {'ase_picture_name'|@translate}<label><br> |
---|
310 | <label><input type="checkbox" id='iASEKeywordSearchDesc'> {'ase_picture_desc'|@translate}<label><br> |
---|
311 | <label><input type="checkbox" id='iASEKeywordSearchFileName'> {'ase_picture_filename'|@translate}<label> |
---|
312 | </td> |
---|
313 | </tr> |
---|
314 | |
---|
315 | </table> |
---|
316 | |
---|
317 | </div> |
---|
318 | |
---|
319 | |
---|