1 | {combine_script id="jquery.ui" require='jquery' path="themes/default/js/ui/jquery.ui.core.js"} |
---|
2 | {combine_script id="jquery.ui.widget" require='jquery.ui' path="themes/default/js/ui/jquery.ui.widget.js"} |
---|
3 | {combine_script id="jquery.ui.mouse" require='jquery.ui.widget' path="themes/default/js/ui/jquery.ui.mouse.js"} |
---|
4 | {combine_script id="jquery.ui.position" require='jquery.ui.widget' path="themes/default/js/ui/jquery.ui.position.js"} |
---|
5 | {combine_script id="jquery.ui.dialog" require='jquery.ui.widget' path="themes/default/js/ui/jquery.ui.dialog.js"} |
---|
6 | {combine_css id="CStat" path="plugins/ColorStat/cstat.css"} |
---|
7 | |
---|
8 | {literal} |
---|
9 | <script type="text/javascript"> |
---|
10 | |
---|
11 | /** |
---|
12 | * include this template in a page and use colorBox.show({options}) to display |
---|
13 | * the dialog box |
---|
14 | * |
---|
15 | */ |
---|
16 | dialogChooseColorBox = function() |
---|
17 | { |
---|
18 | var selectedColors = new Array(); |
---|
19 | var dialogColorOptions = { |
---|
20 | colorList:'', |
---|
21 | mode:'and', |
---|
22 | id:'', |
---|
23 | eventOk:null, |
---|
24 | cBuilder:null, |
---|
25 | }; |
---|
26 | |
---|
27 | /** |
---|
28 | * initialize the dialog box |
---|
29 | */ |
---|
30 | var initDialogBox = function() |
---|
31 | { |
---|
32 | tipColor = new simpleTip(); |
---|
33 | $('.sTip').each( function (index) |
---|
34 | { |
---|
35 | tipColor.doAction('add', this, |
---|
36 | { |
---|
37 | targetPos:'top-middle', |
---|
38 | tipPos:'bottom-middle', |
---|
39 | offsetY:10, |
---|
40 | drawArrow:true |
---|
41 | } |
---|
42 | ); |
---|
43 | } |
---|
44 | ); |
---|
45 | |
---|
46 | $("#iDialogColorChoose") |
---|
47 | .dialog( |
---|
48 | { |
---|
49 | autoOpen: false, |
---|
50 | resizable: false, |
---|
51 | width:720, |
---|
52 | height:400, |
---|
53 | modal: true, |
---|
54 | draggable:true, |
---|
55 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
56 | title: '{/literal}{"cstat_choose_colors"|@translate}{literal}', |
---|
57 | open: function(event, ui) |
---|
58 | { |
---|
59 | |
---|
60 | }, |
---|
61 | buttons: |
---|
62 | { |
---|
63 | '{/literal}{"cstat_ok"|@translate}{literal}': |
---|
64 | function() |
---|
65 | { |
---|
66 | list=''; |
---|
67 | nbColor=$('#iDCCchoosenColors div').length; |
---|
68 | for(i=0;i<nbColor;i++) |
---|
69 | { |
---|
70 | if(list!='') { list+=','; } |
---|
71 | list+=$('#iDCCchoosenColors div').get(i).id.substr(13); |
---|
72 | } |
---|
73 | |
---|
74 | if($('#iDCCOperatorAnd').get(0).checked) |
---|
75 | { |
---|
76 | mode='and'; |
---|
77 | } |
---|
78 | else if($('#iDCCOperatorOr').get(0).checked) |
---|
79 | { |
---|
80 | mode='or'; |
---|
81 | } |
---|
82 | else if($('#iDCCOperatorNot').get(0).checked) |
---|
83 | { |
---|
84 | mode='not'; |
---|
85 | } |
---|
86 | |
---|
87 | if(dialogColorOptions.cBuilder!=null) |
---|
88 | { |
---|
89 | setCBuilderItem(dialogColorOptions.id, list, mode); |
---|
90 | } |
---|
91 | |
---|
92 | if(dialogColorOptions.eventOk!=null) |
---|
93 | { |
---|
94 | dialogColorOptions.eventOk(dialogColorOptions.id, list, mode); |
---|
95 | } |
---|
96 | |
---|
97 | $(this).dialog('close'); |
---|
98 | }, |
---|
99 | '{/literal}{"cstat_cancel"|@translate}{literal}': |
---|
100 | function() |
---|
101 | { |
---|
102 | $(this).dialog('close'); |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | ); |
---|
107 | |
---|
108 | $('#iDCCtableColor td.csSelectable').bind('click', function() { addColorList(this.id.substr(10)); }); |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | * remove a color from the choosen colors list |
---|
113 | * event.data : the color top remove |
---|
114 | */ |
---|
115 | var removeColorList = function(event) |
---|
116 | { |
---|
117 | $('#iDCCselected_'+event.data).remove(); |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | * add a color from the choosen colors list |
---|
122 | */ |
---|
123 | var addColorList = function(color) |
---|
124 | { |
---|
125 | if($('#iDCCselected_'+color).get(0)==null) |
---|
126 | { |
---|
127 | $('#iDCCchoosenColors').append("<div id='iDCCselected_"+color+"' class='cellColorChoose' style='background-color:#"+color+";'></div>"); |
---|
128 | $('#iDCCselected_'+color).bind('click', color, removeColorList); |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | alert("{/literal}{'cstat_color_already_choosen'|@translate}{literal}") |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | |
---|
137 | /** |
---|
138 | * the show() function display and manage a dialog box to choose |
---|
139 | * a set of colors from a color table |
---|
140 | * |
---|
141 | * @param options : properties to manage the dialog box |
---|
142 | * - colorList : a string of hex color, separated with a comma |
---|
143 | * example: 'ff0000,00ff00,0000ff' |
---|
144 | * if set, theses colors are selected when the |
---|
145 | * dialog box is open |
---|
146 | * - id : a string to identify a DOM object ; this parameter |
---|
147 | * is given to the callback when the OK button is pushed |
---|
148 | * - mode : a string to identify the default mode selected |
---|
149 | * values : 'and', 'or', 'not' |
---|
150 | * - eventOK : a callback function, with 2 parameters : id of |
---|
151 | * the given DOM object and the color list |
---|
152 | * - cBuilder : a criteriaBuilder object |
---|
153 | * if set, the dialog box manage automaticaly |
---|
154 | * the criteria builder interface |
---|
155 | */ |
---|
156 | this.show = function (options) |
---|
157 | { |
---|
158 | showDialog(options); |
---|
159 | } |
---|
160 | |
---|
161 | /** |
---|
162 | * private function used to show the dialog box |
---|
163 | */ |
---|
164 | var showDialog = function(options) |
---|
165 | { |
---|
166 | if(options.colorList!=null) |
---|
167 | { |
---|
168 | dialogColorOptions.colorList=options.colorList; |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | dialogColorOptions.colorList=''; |
---|
173 | } |
---|
174 | |
---|
175 | if(options.mode!=null) |
---|
176 | { |
---|
177 | dialogColorOptions.mode=options.mode; |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | dialogColorOptions.mode='and'; |
---|
182 | } |
---|
183 | |
---|
184 | if(options.id!=null) |
---|
185 | { |
---|
186 | dialogColorOptions.id=options.id; |
---|
187 | } |
---|
188 | else |
---|
189 | { |
---|
190 | dialogColorOptions.id=''; |
---|
191 | } |
---|
192 | |
---|
193 | if(options.eventOk!=null) |
---|
194 | { |
---|
195 | dialogColorOptions.eventOk=options.eventOk; |
---|
196 | } |
---|
197 | |
---|
198 | if(options.cBuilder!=null) |
---|
199 | { |
---|
200 | dialogColorOptions.cBuilder=options.cBuilder; |
---|
201 | dialogColorOptions.cBuilder.doAction('setOptions', |
---|
202 | { |
---|
203 | onEdit:function (e) { editCB(e.data); }, |
---|
204 | onDelete:function (e) { deleteCB(e.data); }, |
---|
205 | } |
---|
206 | ); |
---|
207 | } |
---|
208 | |
---|
209 | |
---|
210 | $('#iDCCchoosenColors').html(''); |
---|
211 | |
---|
212 | if(dialogColorOptions.colorList!='') |
---|
213 | { |
---|
214 | selectedColors=dialogColorOptions.colorList.split(','); |
---|
215 | for(i=0;i<selectedColors.length;i++) |
---|
216 | { |
---|
217 | addColorList(selectedColors[i]); |
---|
218 | } |
---|
219 | } |
---|
220 | switch(dialogColorOptions.mode) |
---|
221 | { |
---|
222 | case 'and': |
---|
223 | $('#iDCCOperatorAnd').attr('checked', true); |
---|
224 | break; |
---|
225 | case 'or': |
---|
226 | $('#iDCCOperatorOr').attr('checked', true); |
---|
227 | break; |
---|
228 | case 'not': |
---|
229 | $('#iDCCOperatorNot').attr('checked', true); |
---|
230 | break; |
---|
231 | } |
---|
232 | $("#iDialogColorChoose").dialog('open'); |
---|
233 | } |
---|
234 | |
---|
235 | |
---|
236 | |
---|
237 | /** |
---|
238 | * manage the 'edit' button from criteria builder interface |
---|
239 | * @param String itemId : the itemId |
---|
240 | */ |
---|
241 | var editCB = function (itemId) |
---|
242 | { |
---|
243 | extraData=dialogColorOptions.cBuilder.doAction('getExtraData', itemId); |
---|
244 | showDialog( |
---|
245 | { |
---|
246 | id:itemId, |
---|
247 | colorList:extraData.param.colors, |
---|
248 | mode:extraData.param.mode, |
---|
249 | } |
---|
250 | ); |
---|
251 | } |
---|
252 | |
---|
253 | /** |
---|
254 | * manage the 'delete' button from criteria builder interface |
---|
255 | * @param String itemId : the itemId |
---|
256 | */ |
---|
257 | var deleteCB = function (itemId) |
---|
258 | { |
---|
259 | dialogColorOptions.cBuilder.doAction('delete', itemId); |
---|
260 | } |
---|
261 | |
---|
262 | /** |
---|
263 | * set the content for the cBuilder item |
---|
264 | */ |
---|
265 | var setCBuilderItem = function(id, colorList, mode) |
---|
266 | { |
---|
267 | content="<div>"; |
---|
268 | switch(mode) |
---|
269 | { |
---|
270 | case 'and': |
---|
271 | content+="{/literal}{'cstat_operator_and'|@translate}{literal}"; |
---|
272 | break; |
---|
273 | case 'or': |
---|
274 | content+="{/literal}{'cstat_operator_or'|@translate}{literal}"; |
---|
275 | break; |
---|
276 | case 'not': |
---|
277 | content+="{/literal}{'cstat_operator_not'|@translate}{literal}"; |
---|
278 | break; |
---|
279 | } |
---|
280 | content+="</div>"; |
---|
281 | |
---|
282 | content+="<div style='float:left;'>"; |
---|
283 | selectedColors=colorList.split(','); |
---|
284 | for(i=0;i<selectedColors.length;i++) |
---|
285 | { |
---|
286 | content+="<div class='cellColorChoose' style='background-color:#"+selectedColors[i]+";'></div>"; |
---|
287 | } |
---|
288 | content+="</div>"; |
---|
289 | |
---|
290 | if(id=='') |
---|
291 | { |
---|
292 | //no id:add a new item in the list |
---|
293 | dialogColorOptions.cBuilder.doAction('add', content, criteriaBuilder.makeExtendedData('ColorStat', {mode:mode, colors:colorList} ) ); |
---|
294 | } |
---|
295 | else |
---|
296 | { |
---|
297 | // update item |
---|
298 | dialogColorOptions.cBuilder.doAction('edit', id, content, criteriaBuilder.makeExtendedData('ColorStat', {mode:mode, colors:colorList} ) ); |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | initDialogBox(); |
---|
303 | } |
---|
304 | |
---|
305 | |
---|
306 | </script> |
---|
307 | {/literal} |
---|
308 | |
---|
309 | <div id="iDialogColorChoose" style='display:none;'> |
---|
310 | <table style="padding-top:8px;"> |
---|
311 | <tr> |
---|
312 | <td style='width:350px;' id='iDCCtableColor'>{$datas.colorTable}</td> |
---|
313 | <td style='padding:12px;'> |
---|
314 | <span>{'cstat_choosen_colors'|@translate}</span> |
---|
315 | |
---|
316 | <div id='iDCCchoosenColors' style='height:56px;border:1px solid;margin:2px;padding:4px;'> |
---|
317 | </div> |
---|
318 | |
---|
319 | <div style='text-align:justify;padding:8px;'> |
---|
320 | <label><input type="radio" name="f_operator" id="iDCCOperatorAnd" checked> {'cstat_operator_and'|@translate}</label><br> |
---|
321 | <label><input type="radio" name="f_operator" id="iDCCOperatorOr"> {'cstat_operator_or'|@translate}</label><br> |
---|
322 | <label><input type="radio" name="f_operator" id="iDCCOperatorNot"> {'cstat_operator_not'|@translate}</label> |
---|
323 | </div> |
---|
324 | </td> |
---|
325 | </tr> |
---|
326 | </table> |
---|
327 | </div> |
---|
328 | |
---|
329 | |
---|