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 dialogChooseASEHDBox.show({options}) to display |
---|
9 | * the dialog box |
---|
10 | * |
---|
11 | */ |
---|
12 | dialogChooseASEHDBox = function() |
---|
13 | { |
---|
14 | var dialogOptions = { |
---|
15 | id:'', |
---|
16 | eventOk:null, |
---|
17 | cBuilder:null, |
---|
18 | |
---|
19 | values: { |
---|
20 | withHD:'y' |
---|
21 | }, |
---|
22 | }; |
---|
23 | |
---|
24 | /** |
---|
25 | * initialize the dialog box |
---|
26 | */ |
---|
27 | var initDialogBox = function() |
---|
28 | { |
---|
29 | $("#iDialogASEHDChoose") |
---|
30 | .dialog( |
---|
31 | { |
---|
32 | autoOpen: false, |
---|
33 | resizable: false, |
---|
34 | width:350, |
---|
35 | height:100, |
---|
36 | modal: true, |
---|
37 | draggable:true, |
---|
38 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
39 | title: '{/literal}{"ase_search_hd"|@translate}{literal}', |
---|
40 | open: function(event, ui) |
---|
41 | { |
---|
42 | }, |
---|
43 | buttons: |
---|
44 | { |
---|
45 | '{/literal}{"ase_ok"|@translate}{literal}': |
---|
46 | function() |
---|
47 | { |
---|
48 | if(checkValidity()) |
---|
49 | { |
---|
50 | dialogOptions.values.withHD=$('[name=fASEHDWithHD]:checked').val(); |
---|
51 | |
---|
52 | if(dialogOptions.cBuilder!=null) |
---|
53 | { |
---|
54 | setCBuilderItem(dialogOptions.id, dialogOptions.values); |
---|
55 | } |
---|
56 | |
---|
57 | if(dialogOptions.eventOk!=null) |
---|
58 | { |
---|
59 | dialogOptions.eventOk(dialogOptions.id, dialogOptions.values); |
---|
60 | } |
---|
61 | $(this).dialog('close'); |
---|
62 | } |
---|
63 | }, |
---|
64 | '{/literal}{"ase_cancel"|@translate}{literal}': |
---|
65 | function() |
---|
66 | { |
---|
67 | $(this).dialog('close'); |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | ); |
---|
72 | } |
---|
73 | |
---|
74 | /** |
---|
75 | * check the validity of the condition |
---|
76 | * return Boolean : true if OK, otherwise false |
---|
77 | */ |
---|
78 | var checkValidity = function () |
---|
79 | { |
---|
80 | $(".error").removeClass('error'); |
---|
81 | returned=true; |
---|
82 | return(returned); |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | /** |
---|
87 | * the show() function display and manage a dialog box to choose categories |
---|
88 | * and the kind of test to apply |
---|
89 | * |
---|
90 | * @param options : properties to manage the dialog box |
---|
91 | * - id : a string to identify a DOM object ; this parameter |
---|
92 | * is given to the callback when the OK button is pushed |
---|
93 | * - values : an object with 3 properties |
---|
94 | * - withHD : with our without HD picture |
---|
95 | * - eventOK : a callback function, with 2 parameters : id of |
---|
96 | * the given DOM object and values parameted |
---|
97 | * - cBuilder : a criteriaBuilder object |
---|
98 | * if set, the dialog box manage automaticaly |
---|
99 | * the criteria builder interface |
---|
100 | */ |
---|
101 | this.show = function (options) |
---|
102 | { |
---|
103 | showDialog(options); |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * private function used to show the dialog box |
---|
108 | */ |
---|
109 | var showDialog = function(options) |
---|
110 | { |
---|
111 | if(options.id!=null) |
---|
112 | { |
---|
113 | dialogOptions.id=options.id; |
---|
114 | } |
---|
115 | else |
---|
116 | { |
---|
117 | dialogOptions.id=''; |
---|
118 | } |
---|
119 | |
---|
120 | if(options.eventOk!=null) |
---|
121 | { |
---|
122 | dialogOptions.eventOk=options.eventOk; |
---|
123 | } |
---|
124 | |
---|
125 | if(options.cBuilder!=null) |
---|
126 | { |
---|
127 | dialogOptions.cBuilder=options.cBuilder; |
---|
128 | dialogOptions.cBuilder.doAction('setOptions', |
---|
129 | { |
---|
130 | onEdit:function (e) { editCB(e.data); }, |
---|
131 | onDelete:function (e) { deleteCB(e.data); }, |
---|
132 | } |
---|
133 | ); |
---|
134 | } |
---|
135 | |
---|
136 | if(options.values!=null) |
---|
137 | { |
---|
138 | dialogOptions.values=jQuery.extend(dialogOptions.values, options.values); |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | dialogOptions.values.withHD='y'; |
---|
143 | } |
---|
144 | |
---|
145 | $('#iASEHDWithHDY').attr('checked', dialogOptions.values.withHD=='y'); |
---|
146 | $('#iASEHDWithHDN').attr('checked', dialogOptions.values.withHD=='n'); |
---|
147 | |
---|
148 | $("#iDialogASEHDChoose").dialog('open'); |
---|
149 | } |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | /** |
---|
154 | * manage the 'edit' button from criteria builder interface |
---|
155 | * @param String itemId : the itemId |
---|
156 | */ |
---|
157 | var editCB = function (itemId) |
---|
158 | { |
---|
159 | extraData=dialogOptions.cBuilder.doAction('getExtraData', itemId); |
---|
160 | showDialog( |
---|
161 | { |
---|
162 | id:itemId, |
---|
163 | values: |
---|
164 | { |
---|
165 | withHD:extraData.param.withHD, |
---|
166 | }, |
---|
167 | } |
---|
168 | ); |
---|
169 | } |
---|
170 | |
---|
171 | /** |
---|
172 | * manage the 'delete' button from criteria builder interface |
---|
173 | * @param String itemId : the itemId |
---|
174 | */ |
---|
175 | var deleteCB = function (itemId) |
---|
176 | { |
---|
177 | dialogOptions.cBuilder.doAction('delete', itemId); |
---|
178 | } |
---|
179 | |
---|
180 | /** |
---|
181 | * set the content for the cBuilder item |
---|
182 | */ |
---|
183 | var setCBuilderItem = function(id) |
---|
184 | { |
---|
185 | var content="<div>{/literal}{'ase_the_picture'|@translate}{literal} "; |
---|
186 | |
---|
187 | if(dialogOptions.values.withHD=='y') |
---|
188 | { |
---|
189 | content+="{/literal}{'ase_picture_with_hd'|@translate}{literal}"; |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | content+="{/literal}{'ase_picture_without_hd'|@translate}{literal}"; |
---|
194 | } |
---|
195 | |
---|
196 | |
---|
197 | content+="</div>"; |
---|
198 | |
---|
199 | if(id=='') |
---|
200 | { |
---|
201 | //no id:add a new item in the list |
---|
202 | dialogOptions.cBuilder.doAction( |
---|
203 | 'add', |
---|
204 | content, |
---|
205 | criteriaBuilder.makeExtendedData( |
---|
206 | 'ASEHD', |
---|
207 | { |
---|
208 | withHD:dialogOptions.values.withHD, |
---|
209 | } |
---|
210 | ) |
---|
211 | ); |
---|
212 | } |
---|
213 | else |
---|
214 | { |
---|
215 | // update item |
---|
216 | dialogOptions.cBuilder.doAction( |
---|
217 | 'edit', |
---|
218 | id, |
---|
219 | content, |
---|
220 | criteriaBuilder.makeExtendedData( |
---|
221 | 'ASEHD', |
---|
222 | { |
---|
223 | withHD:dialogOptions.values.withHD |
---|
224 | } |
---|
225 | ) |
---|
226 | ); |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | initDialogBox(); |
---|
231 | } |
---|
232 | |
---|
233 | |
---|
234 | </script> |
---|
235 | {/literal} |
---|
236 | |
---|
237 | <div id="iDialogASEHDChoose" style='display:none;'> |
---|
238 | |
---|
239 | <table class="formtable"> |
---|
240 | <tr> |
---|
241 | <td>{'ase_the_picture'|@translate}</td> |
---|
242 | <td> |
---|
243 | <label><input type="radio" id='iASEHDWithHDY' name="fASEHDWithHD" value='y'> {'ase_picture_with_hd'|@translate}<label><br> |
---|
244 | <label><input type="radio" id='iASEHDWithHDN' name="fASEHDWithHD" value='n'> {'ase_picture_without_hd'|@translate}<label> |
---|
245 | </td> |
---|
246 | </tr> |
---|
247 | |
---|
248 | </table> |
---|
249 | |
---|
250 | </div> |
---|
251 | |
---|
252 | |
---|