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