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="jquery.tipTip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.tipTip.minified.js"} |
---|
4 | |
---|
5 | {known_script id="gpc.pagesNavigator" src=$ROOT_URL|@cat:"plugins/GrumPluginClasses/js/pagesNavigator.packed.js"} |
---|
6 | |
---|
7 | |
---|
8 | {literal} |
---|
9 | <script type="text/javascript"> |
---|
10 | var cb=null; |
---|
11 | |
---|
12 | interfaceManager = function(optionsToSet) |
---|
13 | { |
---|
14 | var pn=null; |
---|
15 | var requestNumber=0; |
---|
16 | |
---|
17 | options = |
---|
18 | { |
---|
19 | requestCriterionsVisible:'', |
---|
20 | requestCriterionsHidden:'', |
---|
21 | requestResult:'', |
---|
22 | requestResultContent:'', |
---|
23 | requestResultNfo:'', |
---|
24 | requestResultPagesNavigator:'', |
---|
25 | requestResultRequestNumber:0, |
---|
26 | onPageChange:null, |
---|
27 | numberPerPage:30, |
---|
28 | }; |
---|
29 | |
---|
30 | /** |
---|
31 | * |
---|
32 | */ |
---|
33 | this.doAction = function(fct) |
---|
34 | { |
---|
35 | switch(fct) |
---|
36 | { |
---|
37 | case 'queryResult': |
---|
38 | /* function 'queryResult' : when query is executed, prepare the interface |
---|
39 | */ |
---|
40 | if(arguments.length==3) |
---|
41 | { |
---|
42 | displayQueryResult(arguments[1], arguments[2]); |
---|
43 | } |
---|
44 | break; |
---|
45 | case 'queryPage': |
---|
46 | /* function 'queryPage' : display returned page |
---|
47 | */ |
---|
48 | if(arguments.length==3) |
---|
49 | { |
---|
50 | displayQueryPage(arguments[1], arguments[2]); |
---|
51 | } |
---|
52 | break; |
---|
53 | case 'show': |
---|
54 | /* function 'show' : show/hide the query/result |
---|
55 | */ |
---|
56 | if(arguments.length==2) |
---|
57 | { |
---|
58 | show(arguments[1]); |
---|
59 | } |
---|
60 | break; |
---|
61 | case 'setOptions': |
---|
62 | /* function 'setOptions' : allows to set options after the object was |
---|
63 | * created |
---|
64 | */ |
---|
65 | if(arguments.length==2) |
---|
66 | { |
---|
67 | setOptions(arguments[1]); |
---|
68 | } |
---|
69 | break; |
---|
70 | case 'fillCaddie': |
---|
71 | /* function 'fillCaddie' : allows to fill the caddie with the search result |
---|
72 | * |
---|
73 | */ |
---|
74 | if(arguments.length==2) |
---|
75 | { |
---|
76 | fillCaddie(arguments[1], this.getRequestNumber()); |
---|
77 | } |
---|
78 | break; |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | /** |
---|
83 | * returns the current request number |
---|
84 | */ |
---|
85 | this.getRequestNumber = function () |
---|
86 | { |
---|
87 | return(requestNumber); |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * returns the number of items per page |
---|
92 | */ |
---|
93 | this.getNumberPerPage = function () |
---|
94 | { |
---|
95 | return(options.numberPerPage); |
---|
96 | } |
---|
97 | |
---|
98 | /** |
---|
99 | * this function show/hide the different panels |
---|
100 | * 'buildQuery' : hide the result panel and display the panel to build query |
---|
101 | * 'resultQuery' : hide the panel to build query and display the result panel |
---|
102 | */ |
---|
103 | var show = function(mode) |
---|
104 | { |
---|
105 | switch(mode) |
---|
106 | { |
---|
107 | case 'buildQuery': |
---|
108 | $('.'+options.requestCriterionsVisible).css('display', 'block'); |
---|
109 | $('.'+options.requestCriterionsHidden).css('display', 'none'); |
---|
110 | $('.'+options.requestResult).css('display', 'none'); |
---|
111 | break; |
---|
112 | case 'resultQuery': |
---|
113 | $('#iResultQueryContent').html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>"); |
---|
114 | $('.'+options.requestCriterionsVisible).css('display', 'none'); |
---|
115 | $('.'+options.requestCriterionsHidden).css('display', 'block'); |
---|
116 | $('.'+options.requestResult).css('display', 'block'); |
---|
117 | break; |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * this function display the number of items found and prepare the page |
---|
123 | * navigator |
---|
124 | * |
---|
125 | * @param String nfo : 2 information separated with a semi-colon ';' |
---|
126 | * requestNumber;numberOfItems |
---|
127 | */ |
---|
128 | var displayQueryResult = function (isSuccess, nfo) |
---|
129 | { |
---|
130 | if(isSuccess) |
---|
131 | { |
---|
132 | nfo=nfo.split(';'); |
---|
133 | |
---|
134 | requestNumber=nfo[0]; |
---|
135 | $('#iResultQueryNfo').html(nfo[1]); |
---|
136 | pn.doAction('setOptions', { numberItem:nfo[1], defaultPage:1 } ); |
---|
137 | show('resultQuery'); |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | //$('#'+options.requestResultContent).html(""); |
---|
142 | show('buildQuery'); |
---|
143 | alert('{/literal}{"gpc_something_is_wrong_on_the_server_side"|@translate}{literal}'); |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | |
---|
148 | /** |
---|
149 | * this function display the number of items found and prepare the page |
---|
150 | * navigator |
---|
151 | * |
---|
152 | * @param String nfo : 2 information separated with a semi-colon ';' |
---|
153 | * requestNumber;numberOfItems |
---|
154 | */ |
---|
155 | var displayQueryPage = function (isSuccess, nfo) |
---|
156 | { |
---|
157 | if(isSuccess) |
---|
158 | { |
---|
159 | $('#iResultQueryContent').html(nfo); |
---|
160 | $('.tiptip').tipTip( |
---|
161 | { |
---|
162 | 'delay' : 0, |
---|
163 | 'fadeIn' : 0, |
---|
164 | 'fadeOut' : 0, |
---|
165 | 'edgeOffset' : 5, |
---|
166 | } |
---|
167 | ); |
---|
168 | } |
---|
169 | else |
---|
170 | { |
---|
171 | alert('{/literal}{"gpc_something_is_wrong_on_the_server_side"|@translate}{literal}'); |
---|
172 | } |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | /** |
---|
177 | * |
---|
178 | * @param Object optionsToSet : set the given options |
---|
179 | */ |
---|
180 | var setOptions = function(optionsToSet) |
---|
181 | { |
---|
182 | if(typeof optionsToSet=='object') |
---|
183 | { |
---|
184 | options = jQuery.extend(options, optionsToSet); |
---|
185 | } |
---|
186 | } |
---|
187 | |
---|
188 | /** |
---|
189 | * initialize the object |
---|
190 | */ |
---|
191 | var init = function (optionsToSet) |
---|
192 | { |
---|
193 | setOptions(optionsToSet); |
---|
194 | |
---|
195 | pn = new pagesNavigator(options.requestResultPagesNavigator, |
---|
196 | { |
---|
197 | itemPerPage:options.numberPerPage, |
---|
198 | displayNumPage:9, |
---|
199 | classActive:'pnActive{/literal}{$datas.themeName}{literal}', |
---|
200 | classInactive:'pnInactive{/literal}{$datas.themeName}{literal}', |
---|
201 | onPageChange: function (page) |
---|
202 | { |
---|
203 | if(options.onPageChange!=null && jQuery.isFunction(options.onPageChange)) |
---|
204 | { |
---|
205 | options.onPageChange(requestNumber, page, options.numberPerPage); |
---|
206 | } |
---|
207 | }, |
---|
208 | } |
---|
209 | ); |
---|
210 | |
---|
211 | requestNumber=options.requestResultRequestNumber; |
---|
212 | } |
---|
213 | |
---|
214 | /** |
---|
215 | * fill the caddie with the search results |
---|
216 | * @param String mode : 'add' or 'fill' |
---|
217 | */ |
---|
218 | var fillCaddie = function (mode, requestNumber) |
---|
219 | { |
---|
220 | $('#iMenuCaddieImg').css('display', 'inline-block'); |
---|
221 | $('#iMenuCaddieItems ul').css('display', 'none'); |
---|
222 | |
---|
223 | $.ajax( |
---|
224 | { |
---|
225 | type: "POST", |
---|
226 | url: "plugins/GrumPluginClasses/gpc_ajax.php", |
---|
227 | async: true, |
---|
228 | data: { ajaxfct:"admin.rbuilder.fillCaddie", fillMode:mode, requestNumber:requestNumber }, |
---|
229 | success: |
---|
230 | function(msg) |
---|
231 | { |
---|
232 | $('#iMenuCaddieImg').css('display', 'none'); |
---|
233 | $('#iMenuCaddieItems ul').css('display', 'block'); |
---|
234 | alert('{/literal}{"gpc_the_caddie_is_updated"|@translate}{literal}'); |
---|
235 | }, |
---|
236 | error: |
---|
237 | function(msg) |
---|
238 | { |
---|
239 | $('#iMenuCaddieImg').css('display', 'none'); |
---|
240 | $('#iMenuCaddieItems ul').css('display', 'block'); |
---|
241 | alert('{/literal}{"gpc_something_is_wrong_on_the_server_side"|@translate}{literal}'); |
---|
242 | }, |
---|
243 | } |
---|
244 | ); |
---|
245 | } |
---|
246 | |
---|
247 | init(optionsToSet); |
---|
248 | } |
---|
249 | |
---|
250 | |
---|
251 | function init() |
---|
252 | { |
---|
253 | im = new interfaceManager( |
---|
254 | { |
---|
255 | requestCriterionsVisible:'cRequestCriterions', |
---|
256 | requestCriterionsHidden:'cModifyRequest', |
---|
257 | requestResult:'cResultQuery', |
---|
258 | requestResultContent:'iResultQueryContent', |
---|
259 | requestResultNfo:'iResultQueryNfo', |
---|
260 | requestResultPagesNavigator:'iPagesNavigator', |
---|
261 | } |
---|
262 | ); |
---|
263 | |
---|
264 | requestBuilderOptions.imgEditUrl='{/literal}{$ROOT_URL}{$themeconf.admin_icon_dir}{literal}/edit_s.png'; |
---|
265 | requestBuilderOptions.imgDeleteUrl='{/literal}{$ROOT_URL}{$themeconf.admin_icon_dir}{literal}/delete.png'; |
---|
266 | requestBuilderOptions.classGroup='gcBorderInput gcTextInput'; |
---|
267 | requestBuilderOptions.classItem='gcBgInput gcTextInput'; |
---|
268 | requestBuilderOptions.classOperator='cbOperator cbOperatorBg{/literal}{$datas.themeName}{literal} gcLinkHover'; |
---|
269 | requestBuilderOptions.onRequestSuccess = function (msg) { im.doAction('queryResult', true, msg); cb.doAction('getPage', im.getRequestNumber(), 1, im.getNumberPerPage()); }; |
---|
270 | requestBuilderOptions.onRequestError = function (msg) { im.doAction('queryResult', false, msg); }; |
---|
271 | requestBuilderOptions.onGetPageSuccess = function (msg) { im.doAction('queryPage', true, msg); }; |
---|
272 | requestBuilderOptions.onGetPageError = function (msg) { im.doAction('queryPage', false, msg); }; |
---|
273 | |
---|
274 | cb = new criteriaBuilder('iListSelectedCriterions', requestBuilderOptions); |
---|
275 | |
---|
276 | im.doAction('setOptions', |
---|
277 | { |
---|
278 | onPageChange: |
---|
279 | function (requestNumber, page, numberPerPage) |
---|
280 | { |
---|
281 | $('#iResultQueryContent').html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>"); |
---|
282 | cb.doAction('getPage', requestNumber, page, numberPerPage); |
---|
283 | } |
---|
284 | } |
---|
285 | ); |
---|
286 | } |
---|
287 | |
---|
288 | |
---|
289 | |
---|
290 | </script> |
---|
291 | {/literal} |
---|
292 | |
---|
293 | {foreach from=$datas.dialogBox item=dialogBox} |
---|
294 | {$dialogBox.content} |
---|
295 | {/foreach} |
---|
296 | <div id='iRBCaddieNfo'></div> |
---|
297 | |
---|
298 | <form> |
---|
299 | <fieldset> |
---|
300 | <legend>{'gpc_rb_search_criterion'|@translate}</legend> |
---|
301 | |
---|
302 | <div id='iRequestCriterions' class='cRequestCriterions'> |
---|
303 | <div style='width:100%;min-height:250px;margin-bottom:8px;'> |
---|
304 | <ul id='iListSelectedCriterions'> |
---|
305 | </ul> |
---|
306 | </div> |
---|
307 | |
---|
308 | <div id='iMenuCriterions' > |
---|
309 | <div id='iMenuCTitle' class='gcLink gcBgInput cbButtons'>{'gpc_rb_add_criterions'|@translate} ⇓</div> |
---|
310 | <div id='iMenuCItems'> |
---|
311 | <ul class='gcBgInput'> |
---|
312 | {foreach from=$datas.dialogBox item=dialogBox} |
---|
313 | <li class='gcBgInput'><a onclick="{$dialogBox.handle}.show({literal}{cBuilder:cb}{/literal});">{$dialogBox.label}</a></li> |
---|
314 | {/foreach} |
---|
315 | </ul> |
---|
316 | </div> |
---|
317 | </div> |
---|
318 | |
---|
319 | <div class='gcBgInput cbButtons'>{literal}<a onclick="cb.doAction('clear');">{/literal}{'gpc_rb_clear_criterions'|@translate}</a></div> |
---|
320 | </div> |
---|
321 | <div class='cModifyRequest' style='display:none;'> |
---|
322 | <div class='gcBgInput cbButtons'>{literal}<a onclick="im.doAction('show', 'buildQuery');">{/literal}{'gpc_rb_do_modify_request'|@translate}</a></div> |
---|
323 | </div> |
---|
324 | |
---|
325 | </fieldset> |
---|
326 | |
---|
327 | <input type="button" class='cRequestCriterions' style="margin-left:1em;" onclick="cb.doAction('send');" value="{'gpc_rb_search'|@translate}"> |
---|
328 | </form> |
---|
329 | |
---|
330 | <fieldset id='iResultQuery' style='display:none;' class='cResultQuery'> |
---|
331 | <legend>{'gpc_rb_result_query'|@translate}</legend> |
---|
332 | |
---|
333 | <div id='iResultQueryContent' style='width:100%;min-height:250px;max-height:450px;overflow:auto;margin-bottom:8px;'></div> |
---|
334 | |
---|
335 | <div class='gcBgInput gcTextInput'> |
---|
336 | <div id='iPagesNavigator' style='float:right;'></div> |
---|
337 | <div style='text-align:left;padding:4px;'> |
---|
338 | {'gpc_rb_number_of_item_found'|@translate} : <span id='iResultQueryNfo'></span> |
---|
339 | |
---|
340 | {if is_admin()} |
---|
341 | <div id='iMenuCaddie' style='display:inline-block;'> |
---|
342 | <div id='iMenuCaddieBar'> |
---|
343 | <div id='iMenuCaddieText' class='gcLink gcBgInput'>{'gpc_manage_caddie'|@translate}⇓ |
---|
344 | <div id='iMenuCaddieImg' style='display:none;width:16px;height:16px;background:url(./plugins/GrumPluginClasses/icons/processing.gif) no-repeat 0 0 transparent;'> </div> |
---|
345 | <div id='iMenuCaddieItems'> |
---|
346 | <ul class='gcBgInput'> |
---|
347 | <li class='gcBgInput'><a onclick="im.doAction('fillCaddie', 'add');">{'gpc_add_caddie'|@translate}</a></li> |
---|
348 | <li class='gcBgInput'><a onclick="im.doAction('fillCaddie', 'replace');">{'gpc_replace_caddie'|@translate}</a></li> |
---|
349 | </ul> |
---|
350 | </div> |
---|
351 | </div> |
---|
352 | </div> |
---|
353 | {/if} |
---|
354 | |
---|
355 | </div> |
---|
356 | </div> |
---|
357 | |
---|
358 | </fieldset> |
---|
359 | |
---|
360 | |
---|
361 | <script type="text/javascript"> |
---|
362 | {foreach from=$datas.dialogBox item=dialogBox} |
---|
363 | var {$dialogBox.handle}=new {$dialogBox.dialogBoxClass}(); |
---|
364 | {/foreach} |
---|
365 | |
---|
366 | init(); |
---|
367 | </script> |
---|