1
|
|
|
<?php |
2
|
|
|
require_once(dirname(__FILE__) . '/../../fwolflib.php'); |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Ajax class, select div(layer) |
7
|
|
|
* |
8
|
|
|
* Requirement: |
9
|
|
|
* - jQuery |
10
|
|
|
* |
11
|
|
|
* @deprecated Use Fwlib\Html\Ajax\SelectDiv |
12
|
|
|
* @package fwolflib |
13
|
|
|
* @subpackage class.ajax |
14
|
|
|
* @copyright Copyright © 2011-2013, Fwolf |
15
|
|
|
* @author Fwolf <[email protected]> |
16
|
|
|
* @since 2011-08-09 |
17
|
|
|
*/ |
18
|
|
|
class AjaxSelDiv extends Fwolflib { |
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* constructor |
22
|
|
|
* |
23
|
|
|
* @param array $ar_cfg |
24
|
|
|
*/ |
25
|
|
|
public function __construct ($ar_cfg = array()) { |
26
|
|
|
parent::__construct($ar_cfg); |
27
|
|
|
} // end of func __construct |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get html output |
32
|
|
|
* |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
|
|
public function GetHtml () { |
36
|
|
|
// Init data again |
37
|
|
|
$this->Init(); |
38
|
|
|
|
39
|
|
|
global $s_id_div, $s_id_bg; |
40
|
|
|
$s_html = ''; |
41
|
|
|
|
42
|
|
|
// Html define |
43
|
|
|
$s_html .= $this->GetHtmlCss(); |
44
|
|
|
$s_html .= '<div id=\'' . $s_id_bg . '\'> |
45
|
|
|
<iframe style=\'position: absolute; z-index: -1;\' |
46
|
|
|
frameborder=\'0\' src=\'about:blank\'></iframe> |
47
|
|
|
</div>' . "\n"; |
48
|
|
|
$s_html .= $this->GetHtmlDiv(); |
49
|
|
|
$s_html .= $this->GetHtmlJs(); |
50
|
|
|
|
51
|
|
|
return $s_html; |
52
|
|
|
} // end of func GetHtml |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Get html output, div part |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function GetHtmlCss () { |
61
|
|
|
global $ar_id, $s_id, $s_id_div, $s_id_bg; |
62
|
|
|
global $s_id_close_bottom, $s_id_close_top; |
63
|
|
|
global $s_id_table, $s_id_title, $s_id_clearit, $s_id_tr_hover; |
64
|
|
|
global $s_id_empty, $s_id_loading, $s_id_tip; |
65
|
|
|
global $s_id_row, $s_id_row_tpl; |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
// Css body |
69
|
|
|
$s_css = ''; |
70
|
|
|
$s_css .= '<style type="text/css" media="screen, print"> |
71
|
|
|
<!-- |
72
|
|
|
#' . $s_id_empty . ', #' . $s_id_loading |
73
|
|
|
. ', #' . $s_id_row_tpl . ' { |
74
|
|
|
display: none; |
75
|
|
|
} |
76
|
|
|
#' . $s_id_empty . ' td, #' . $s_id_loading |
77
|
|
|
. ' td, #' . $s_id_tip |
78
|
|
|
. ' td, .' . $s_id . '_col_select { |
79
|
|
|
text-align: center; |
80
|
|
|
} |
81
|
|
|
'; |
82
|
|
|
|
83
|
|
|
foreach ($ar_id as $k) |
84
|
|
|
$s_css .= ' |
85
|
|
|
#' . ${'s_id_' . $k} . ' { |
86
|
|
|
' . $this->aCfg['css-' . $k] . ' |
87
|
|
|
} |
88
|
|
|
'; |
89
|
|
|
|
90
|
|
|
// Css using class |
91
|
|
|
$s_css .= ' |
92
|
|
|
.' . $s_id_row . ' { |
93
|
|
|
' . $this->aCfg['css-row'] . ' |
94
|
|
|
} |
95
|
|
|
.' . $s_id_tr_hover . ' { |
96
|
|
|
' . $this->aCfg['css-tr_hover'] . ' |
97
|
|
|
} |
98
|
|
|
'; |
99
|
|
|
|
100
|
|
|
$s_css .= $this->aCfg['css-add'] . ' |
101
|
|
|
--> |
102
|
|
|
</style> |
103
|
|
|
'; |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
// Append css using js |
107
|
|
|
$s_js = ''; |
108
|
|
|
$s_js .= '<script type=\'text/javascript\'> |
109
|
|
|
<!--//--><![CDATA[//> |
110
|
|
|
<!-- |
111
|
|
|
/* Append css define to <head> */ |
112
|
|
|
$(\'head\').append(\'\ |
113
|
|
|
' . str_replace("\n", "\\\n", $s_css) . '\ |
114
|
|
|
\'); |
115
|
|
|
//--><!]]> |
116
|
|
|
</script> |
117
|
|
|
'; |
118
|
|
|
|
119
|
|
|
return $s_js; |
120
|
|
|
} // end of func GetHtmlCss |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Get html output, div part |
125
|
|
|
* |
126
|
|
|
* @return string |
127
|
|
|
*/ |
128
|
|
|
public function GetHtmlDiv () { |
129
|
|
|
global $ar_id, $s_id, $s_id_div, $s_id_bg; |
130
|
|
|
global $s_id_close_bottom, $s_id_close_top; |
131
|
|
|
global $s_id_table, $s_id_title, $s_id_clearit, $s_id_tr_hover; |
132
|
|
|
global $s_id_empty, $s_id_loading, $s_id_tip; |
133
|
|
|
global $s_id_row, $s_id_row_tpl; |
134
|
|
|
$s_html = ''; |
135
|
|
|
|
136
|
|
|
$s_html .= '<div id=\'' . $s_id_div . '\'> |
137
|
|
|
<div id=\'' . $s_id_title . '\'>' |
138
|
|
|
. $this->aCfg['title'] . '</div> |
139
|
|
|
'; |
140
|
|
|
|
141
|
|
|
if (true == $this->aCfg['show-close-top']) |
142
|
|
|
$s_html .= ' |
143
|
|
|
<div id=\'' . $s_id_close_top . '\'>' |
144
|
|
|
. $this->aCfg['title-close'] . '</div> |
145
|
|
|
'; |
146
|
|
|
|
147
|
|
|
if (true == $this->aCfg['query']) { |
148
|
|
|
$s_html .= ' |
149
|
|
|
<div id=\'' . $s_id_clearit . '\'></div> |
150
|
|
|
|
151
|
|
|
<label>' . $this->aCfg['query-input-title'] . '</label> |
152
|
|
|
<input type=\'text\' id=\'' |
153
|
|
|
. $s_id . '_query\' size=\'' |
154
|
|
|
. $this->aCfg['query-input-size'] . '\' /> |
155
|
|
|
<input type=\'button\' id=\'' |
156
|
|
|
. $s_id . '_submit\' value=\'' |
157
|
|
|
. $this->aCfg['query-submit-title'] . '\' /> |
158
|
|
|
'; |
159
|
|
|
|
160
|
|
|
// Put query url as hidden input, so can edit it when needed |
161
|
|
|
$s_html .= ' |
162
|
|
|
<input type=\'hidden\' id=\'' |
163
|
|
|
. $s_id . '_url\' value=\'' |
164
|
|
|
. $this->aCfg['query-url'] . '\' /> |
165
|
|
|
'; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
$s_html .= ' |
169
|
|
|
<table id=\'' . $s_id_table . '\'> |
170
|
|
|
<thead> |
171
|
|
|
<tr> |
172
|
|
|
'; |
173
|
|
|
|
174
|
|
|
// Data table title |
175
|
|
View Code Duplication |
if (!empty($this->aCfg['list-col'])) |
|
|
|
|
176
|
|
|
foreach ($this->aCfg['list-col'] as $k => $v) |
177
|
|
|
$s_html .= '<th>' . $v . '</th>' . "\n"; |
178
|
|
|
$s_html .= '<th>' . $this->aCfg['sel-title'] . '</th>' . "\n"; |
179
|
|
|
|
180
|
|
|
$s_html .= ' |
181
|
|
|
</tr> |
182
|
|
|
</thead> |
183
|
|
|
<tbody> |
184
|
|
|
<tr id=\'' . $s_id_row_tpl . '\'> |
185
|
|
|
'; |
186
|
|
|
|
187
|
|
|
// Data table rows |
188
|
|
View Code Duplication |
if (!empty($this->aCfg['list-col'])) |
|
|
|
|
189
|
|
|
foreach ($this->aCfg['list-col'] as $k => $v) |
190
|
|
|
$s_html .= '<td class=\'' . $s_id . '_col_' |
191
|
|
|
. $k . '\'></td>' . "\n"; |
192
|
|
|
$s_html .= '<td class=\'' . $s_id . '_col_' |
193
|
|
|
. $this->aCfg['sel-id'] . '\'>' . "\n"; |
194
|
|
|
// Put hidden input here |
195
|
|
View Code Duplication |
if (!empty($this->aCfg['list-hidden'])) |
|
|
|
|
196
|
|
|
foreach ($this->aCfg['list-hidden'] as $k) |
197
|
|
|
$s_html .= '<input type=\'hidden\' class=\'' |
198
|
|
|
. $s_id . '_col_' . $k . '\' />' . "\n"; |
199
|
|
|
|
200
|
|
|
// Assign onclick using js, avoid lost event when cloning in IE. |
201
|
|
|
$s_html .= ' |
202
|
|
|
<a href=\'javascript:void(0);\' |
203
|
|
|
>选择</a> |
204
|
|
|
</td> |
205
|
|
|
</tr> |
206
|
|
|
<tr id=\'' . $s_id_loading . '\'> |
207
|
|
|
<td colspan=\'' . $this->aCfg['sel-col-cnt'] . '\'>' |
208
|
|
|
. $this->aCfg['text-loading'] . '</td> |
209
|
|
|
</tr> |
210
|
|
|
<tr id=\'' . $s_id_empty . '\'> |
211
|
|
|
<td colspan=\'' . $this->aCfg['sel-col-cnt'] . '\'>' |
212
|
|
|
. $this->aCfg['text-empty'] . '</td> |
213
|
|
|
</tr> |
214
|
|
|
<tr id=\'' . $s_id_tip . '\'> |
215
|
|
|
<td colspan=\'' . $this->aCfg['sel-col-cnt'] . '\'>' |
216
|
|
|
. $this->aCfg['text-tip'] |
217
|
|
|
. $this->aCfg['text-tip-add'] . '</td> |
218
|
|
|
</tr> |
219
|
|
|
</tbody> |
220
|
|
|
</table> |
221
|
|
|
'; |
222
|
|
|
|
223
|
|
|
if (true == $this->aCfg['show-close-bottom']) |
224
|
|
|
$s_html .= ' |
225
|
|
|
<div id=\'' . $s_id_close_bottom . '\'>' |
226
|
|
|
. $this->aCfg['title-close'] . '</div> |
227
|
|
|
'; |
228
|
|
|
|
229
|
|
|
$s_html .= '</div> |
230
|
|
|
'; |
231
|
|
|
return $s_html; |
232
|
|
|
} // end of func GetHtmlDiv |
233
|
|
|
|
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get html output, js part |
237
|
|
|
* |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
public function GetHtmlJs () { |
241
|
|
|
global $ar_id, $s_id, $s_id_div, $s_id_bg; |
242
|
|
|
global $s_id_close_bottom, $s_id_close_top; |
243
|
|
|
global $s_id_table, $s_id_title, $s_id_clearit, $s_id_tr_hover; |
244
|
|
|
global $s_id_empty, $s_id_loading, $s_id_tip; |
245
|
|
|
global $s_id_row, $s_id_row_tpl; |
246
|
|
|
$s_js = ''; |
247
|
|
|
|
248
|
|
|
$s_js .= '<script type=\'text/javascript\'> |
249
|
|
|
<!--//--><![CDATA[//> |
250
|
|
|
<!-- |
251
|
|
|
/* Set bg height and width */ |
252
|
|
|
$(\'#' . $s_id_bg . '\') |
253
|
|
|
.css(\'width\', $(document).width()) |
254
|
|
|
.css(\'height\', $(document).height() * 1.2); |
255
|
|
|
$(\'#' . $s_id_bg . ' iframe\') |
256
|
|
|
.css(\'width\', $(document).width()) |
257
|
|
|
.css(\'height\', $(document).height() * 1.2); |
258
|
|
|
|
259
|
|
|
/* Set click action */ |
260
|
|
|
$(\'#' . $this->aCfg['query-id'] . '\').click(function () { |
261
|
|
|
' . $this->aCfg['js-click'] . ' |
262
|
|
|
$(\'#' . $s_id_bg . '\').show(); |
263
|
|
|
$(\'#' . $s_id_div . '\') |
264
|
|
|
.css(\'top\', ((window.innerHeight |
265
|
|
|
|| document.documentElement.offsetHeight) |
266
|
|
|
- $(\'#' . $s_id_div . '\').height()) |
267
|
|
|
/ 3 |
268
|
|
|
+ (document.body.scrollTop |
269
|
|
|
|| document.documentElement.scrollTop) + ' |
270
|
|
|
. $this->aCfg['offset-y'] . ' + \'px\') |
271
|
|
|
.css(\'left\', $(window).width() / 2 |
272
|
|
|
- $(\'#' . $s_id_div . '\').width() / 2 |
273
|
|
|
+ ' . $this->aCfg['offset-x'] . ' + \'px\') |
274
|
|
|
.show(); |
275
|
|
|
'; |
276
|
|
|
// Do query at once when open select div |
277
|
|
|
if (true == $this->aCfg['query-when-click']) |
278
|
|
|
$s_js .= ' |
279
|
|
|
$(\'#' . $s_id . '_submit\').click(); |
280
|
|
|
'; |
281
|
|
|
$s_js .= ' |
282
|
|
|
}); |
283
|
|
|
|
284
|
|
|
/* Set query action */ |
285
|
|
|
$(\'#' . $s_id . '_submit\').click(function () { |
286
|
|
|
'; |
287
|
|
|
|
288
|
|
|
// If do query when user input nothing ? |
289
|
|
|
if (true == $this->aCfg['query-empty']) |
290
|
|
|
$s_js .= ' |
291
|
|
|
if (true) { |
292
|
|
|
'; |
293
|
|
|
else |
294
|
|
|
$s_js .= ' |
295
|
|
|
if (0 < $(\'#' . $s_id . '_query\').val().length) { |
296
|
|
|
'; |
297
|
|
|
|
298
|
|
|
$s_js .= ' |
299
|
|
|
/* Query begin */ |
300
|
|
|
$(\'#' . $s_id_tip . '\').hide(); |
301
|
|
|
$(\'#' . $s_id_loading . '\').show(); |
302
|
|
|
$(\'#' . $s_id_empty . '\').hide(); |
303
|
|
|
$.ajax({ |
304
|
|
|
url: $(\'#' . $s_id . '_url\').val(), |
305
|
|
|
data: {\'' . $this->aCfg['query-var'] . '\': |
306
|
|
|
$(\'#' . $s_id . '_query\').val()}, |
307
|
|
|
dataType: \'' . $this->aCfg['query-datatype'] . '\', |
308
|
|
|
success: function(msg){ |
309
|
|
|
$(\'#' . $s_id_loading . '\').hide(); |
310
|
|
|
$(\'.' . $s_id . '_row\').remove(); |
311
|
|
|
if (0 < msg.length) { |
312
|
|
|
/* Got result */ |
313
|
|
|
$(msg).each(function(){ |
314
|
|
|
tr = $(\'#' . $s_id . '_row_tpl\').clone(); |
315
|
|
|
tr.addClass(\'' . $s_id . '_row\'); |
316
|
|
|
|
317
|
|
|
/* Attach onclick event */ |
318
|
|
|
/* Cloning in IE will lost event */ |
319
|
|
|
$(\'a\', tr).last().click(function () { |
320
|
|
|
' . $this->aCfg['js-sel'] . ' |
321
|
|
|
'; |
322
|
|
|
// When select, write selected value |
323
|
|
View Code Duplication |
if (!empty($this->aCfg['sel-link'])) |
|
|
|
|
324
|
|
|
foreach ($this->aCfg['sel-link'] as $k => $v) |
325
|
|
|
$s_js .= ' |
326
|
|
|
$("#' . $v . '").val( |
327
|
|
|
$(".' . $s_id |
328
|
|
|
. '_col_' . $k . '", |
329
|
|
|
$(this).parent().parent()) |
330
|
|
|
.' . $this->aCfg['list'][$k]['get'] . '()); |
331
|
|
|
'; |
332
|
|
|
|
333
|
|
|
$s_js .= ' |
334
|
|
|
$("#' . $s_id_div . '").hide(); |
335
|
|
|
$("#' . $s_id_bg . '").hide(); |
336
|
|
|
}); |
337
|
|
|
'; |
338
|
|
|
|
339
|
|
|
// Assign result from ajax json to tr |
340
|
|
View Code Duplication |
if (!empty($this->aCfg['list'])) |
|
|
|
|
341
|
|
|
foreach ($this->aCfg['list'] as $k => $v) { |
342
|
|
|
$s_js .= ' |
343
|
|
|
$(\'.' . $s_id . '_col_' . $k . '\' |
344
|
|
|
, tr).' . $v['get'] |
345
|
|
|
. '(this.' . $k . '); |
346
|
|
|
'; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
$s_js .= ' |
350
|
|
|
/* Row bg-color */ |
351
|
|
|
tr.mouseenter(function () { |
352
|
|
|
$(this).addClass(\'' |
353
|
|
|
. $s_id_tr_hover . '\'); |
354
|
|
|
}).mouseleave(function () { |
355
|
|
|
$(this).removeClass(\'' |
356
|
|
|
. $s_id_tr_hover . '\'); |
357
|
|
|
}); |
358
|
|
|
|
359
|
|
|
$(\'#' . $s_id_loading . '\') |
360
|
|
|
.before(tr); |
361
|
|
|
' . $this->aCfg['js-query'] . ' |
362
|
|
|
tr.show(); |
363
|
|
|
}); |
364
|
|
|
} |
365
|
|
|
else { |
366
|
|
|
/* No result */ |
367
|
|
|
$(\'#' . $s_id_empty . '\').show(); |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
}); |
371
|
|
|
} |
372
|
|
|
else { |
373
|
|
|
/* Nothing to query */ |
374
|
|
|
$(\'#' . $s_id_tip . '\').show(); |
375
|
|
|
$(\'#' . $s_id_loading . '\').hide(); |
376
|
|
|
$(\'#' . $s_id_empty . '\').hide(); |
377
|
|
|
} |
378
|
|
|
}); |
379
|
|
|
'; |
380
|
|
|
|
381
|
|
|
// Query when typing |
382
|
|
|
if (true == $this->aCfg['query-typing']) |
383
|
|
|
$s_js .= ' |
384
|
|
|
$(\'#' . $s_id . '_query\').keyup(function () { |
385
|
|
|
$(\'#' . $s_id . '_submit\').click(); |
386
|
|
|
}); |
387
|
|
|
'; |
388
|
|
|
|
389
|
|
|
$s_js .= ' |
390
|
|
|
/* Link to hide select layer */ |
391
|
|
|
$(\'#' . $s_id_close_bottom . ', #' |
392
|
|
|
. $s_id_close_top . '\').click(function () { |
393
|
|
|
$(this).parent().hide(); |
394
|
|
|
$(\'#' . $s_id_bg . '\').hide(); |
395
|
|
|
}); |
396
|
|
|
//--><!]]> |
397
|
|
|
</script> |
398
|
|
|
'; |
399
|
|
|
|
400
|
|
|
return $s_js; |
401
|
|
|
} // end of func GetHtmlJs |
402
|
|
|
|
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Init treatment |
406
|
|
|
*/ |
407
|
|
|
public function Init () { |
408
|
|
|
parent::Init(); |
409
|
|
|
|
410
|
|
|
// Prepare id vars |
411
|
|
|
global $ar_id, $s_id, $s_id_div, $s_id_bg; |
412
|
|
|
global $s_id_close_bottom, $s_id_close_top; |
413
|
|
|
global $s_id_table, $s_id_title, $s_id_clearit, $s_id_tr_hover; |
414
|
|
|
global $s_id_empty, $s_id_loading, $s_id_tip; |
415
|
|
|
global $s_id_row, $s_id_row_tpl; |
416
|
|
|
$s_id = $this->aCfg['id-prefix'] . $this->aCfg['id']; |
417
|
|
|
$ar_id = array('bg', 'close_bottom', 'close_top', 'div', |
418
|
|
|
'table', 'title', 'clearit', |
419
|
|
|
'empty', 'loading', 'tip' |
420
|
|
|
); |
421
|
|
|
foreach ($ar_id as $k) |
422
|
|
|
eval('$s_id_' . $k . ' = $s_id . "_" . "' . $k . '";'); |
423
|
|
|
// Using class |
424
|
|
|
$s_id_tr_hover = $s_id . '_hover'; |
425
|
|
|
$s_id_row = $s_id . '_row'; |
426
|
|
|
$s_id_row_tpl = $s_id . '_row_tpl'; |
427
|
|
|
|
428
|
|
|
// Join select list cols and hidden |
429
|
|
|
$this->aCfg['list'] = array(); |
430
|
|
|
if (!empty($this->aCfg['list-col'])) |
431
|
|
|
foreach ($this->aCfg['list-col'] as $k => $v) { |
432
|
|
|
$this->aCfg['list'][$k] = array( |
433
|
|
|
'title' => $v, |
434
|
|
|
'get' => 'text', // jQuery method to read content |
435
|
|
|
); |
436
|
|
|
} |
437
|
|
|
if (!empty($this->aCfg['list-hidden'])) |
438
|
|
|
foreach ($this->aCfg['list-hidden'] as $k) { |
439
|
|
|
$this->aCfg['list'][$k] = array( |
440
|
|
|
'get' => 'val', // jQuery method to read content |
441
|
|
|
); |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
// Join tips, merge pagesize in. |
445
|
|
|
$this->aCfg['text-tip-add'] = str_replace('{pagesize}' |
446
|
|
|
, $this->aCfg['query-pagesize'] |
447
|
|
|
, $this->aCfg['text-tip-add-tpl']); |
448
|
|
|
$this->aCfg['sel-col-cnt'] = count($this->aCfg['list-col']) + 1; |
449
|
|
|
} // end of Init |
450
|
|
|
|
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Set default config |
454
|
|
|
* |
455
|
|
|
* @return this |
456
|
|
|
*/ |
457
|
|
|
protected function SetCfgDefault () { |
458
|
|
|
parent::SetCfgDefault(); |
459
|
|
|
|
460
|
|
|
$this->SetCfg('id-prefix', 'ajax_sel_div_'); |
|
|
|
|
461
|
|
|
$this->SetCfg('id', '1'); |
|
|
|
|
462
|
|
|
$this->SetCfg('title', '请选择'); |
|
|
|
|
463
|
|
|
$this->SetCfg('title-close', '关闭'); |
|
|
|
|
464
|
|
|
|
465
|
|
|
// Allow query data by user input |
466
|
|
|
$this->SetCfg('query', true); |
|
|
|
|
467
|
|
|
// Id in form, for which click to show select div |
468
|
|
|
$this->SetCfg('query-id', ''); |
|
|
|
|
469
|
|
|
$this->SetCfg('query-input-size', 30); |
|
|
|
|
470
|
|
|
$this->SetCfg('query-input-title', '名称:'); |
|
|
|
|
471
|
|
|
$this->SetCfg('query-submit-title', '查询'); |
|
|
|
|
472
|
|
|
$this->SetCfg('query-pagesize', 10); // Page size |
|
|
|
|
473
|
|
|
|
474
|
|
|
// Json query |
475
|
|
|
// Do query when user input is empty ? |
476
|
|
|
$this->SetCfg('query-empty', true); |
|
|
|
|
477
|
|
|
// Query when user input ? |
478
|
|
|
$this->SetCfg('query-typing', true); |
|
|
|
|
479
|
|
|
// Url to treat ajax request |
480
|
|
|
$this->SetCfg('query-url', ''); |
|
|
|
|
481
|
|
|
// Do query when open select div ? |
482
|
|
|
$this->SetCfg('query-when-click', false); |
|
|
|
|
483
|
|
|
// Var name for value in user input for ajax POST |
484
|
|
|
$this->SetCfg('query-var', 's'); |
|
|
|
|
485
|
|
|
$this->SetCfg('query-datatype', 'json'); |
|
|
|
|
486
|
|
|
|
487
|
|
|
// Show switch |
488
|
|
|
$this->SetCfg('show-close-bottom', true); |
|
|
|
|
489
|
|
|
$this->SetCfg('show-close-top', true); |
|
|
|
|
490
|
|
|
|
491
|
|
|
$this->SetCfg('text-loading', '正在查询,请稍候。'); |
|
|
|
|
492
|
|
|
$this->SetCfg('text-empty', '没有找到相应信息,请更换查询条件。'); |
|
|
|
|
493
|
|
|
$this->SetCfg('text-tip', '请输入准确名称中的连续部分进行查询。'); |
|
|
|
|
494
|
|
|
// Tip will auto appended by page size(add) |
495
|
|
|
$this->SetCfg('text-tip-add', ''); |
|
|
|
|
496
|
|
|
$this->SetCfg('text-tip-add-tpl', '查询结果最多显示 {pagesize} 项。'); |
|
|
|
|
497
|
|
|
|
498
|
|
|
// Select link |
499
|
|
|
$this->SetCfg('sel-id', 'select'); |
|
|
|
|
500
|
|
|
$this->SetCfg('sel-title', '选择'); |
|
|
|
|
501
|
|
|
// Will auto compute later |
502
|
|
|
$this->SetCfg('sel-col-cnt', 0); |
|
|
|
|
503
|
|
|
// When selected, write these data back |
504
|
|
|
$this->SetCfg('sel-link', array( |
|
|
|
|
505
|
|
|
//'id in list' => 'id in form', |
506
|
|
|
)); |
507
|
|
|
|
508
|
|
|
// Select list cols |
509
|
|
|
// Id should fit index of result data array |
510
|
|
|
$this->SetCfg('list-col', array( |
|
|
|
|
511
|
|
|
//id => title, |
512
|
|
|
)); |
513
|
|
|
// Select list hidden value |
514
|
|
|
// Will auto show with 'select' link |
515
|
|
|
$this->SetCfg('list-hidden', array( |
|
|
|
|
516
|
|
|
//id, |
517
|
|
|
)); |
518
|
|
|
|
519
|
|
|
// Div position adjust(based on h/v center) |
520
|
|
|
$this->SetCfg('offset-x', 0); |
|
|
|
|
521
|
|
|
$this->SetCfg('offset-y', 0); |
|
|
|
|
522
|
|
|
|
523
|
|
|
// User added js |
524
|
|
|
// After user click on form input, before default action |
525
|
|
|
$this->SetCfg('js-click', ''); |
|
|
|
|
526
|
|
|
// After treat server result |
527
|
|
|
// After default action and before result show. |
528
|
|
|
$this->SetCfg('js-query', ''); |
|
|
|
|
529
|
|
|
// When user click select link, before default action |
530
|
|
|
$this->SetCfg('js-sel', ''); |
|
|
|
|
531
|
|
|
|
532
|
|
|
|
533
|
|
|
$this->SetCfg('css-bg', ' |
|
|
|
|
534
|
|
|
background: #E5E5E5; |
535
|
|
|
display: none; |
536
|
|
|
filter: alpha(opacity=60); |
537
|
|
|
left: 0px; |
538
|
|
|
opacity: 0.6; |
539
|
|
|
position: absolute; |
540
|
|
|
top: 0px; |
541
|
|
|
z-index: 998; |
542
|
|
|
'); |
543
|
|
|
$this->SetCfg('css-close_bottom', ' |
|
|
|
|
544
|
|
|
cursor: pointer; |
545
|
|
|
margin-top: 0.5em; |
546
|
|
|
text-align: right; |
547
|
|
|
width: 100%; |
548
|
|
|
'); |
549
|
|
|
$this->SetCfg('css-close_top', ' |
|
|
|
|
550
|
|
|
cursor: pointer; |
551
|
|
|
float: right; |
552
|
|
|
'); |
553
|
|
|
$this->SetCfg('css-div', ' |
|
|
|
|
554
|
|
|
background-color: #FFF; |
555
|
|
|
border: 1px solid #999; |
556
|
|
|
display: none; |
557
|
|
|
padding: 0.7em; |
558
|
|
|
position: absolute; |
559
|
|
|
text-align: center; |
560
|
|
|
width: 700px; |
561
|
|
|
z-index: 999; |
562
|
|
|
'); |
563
|
|
|
$this->SetCfg('css-table', ' |
|
|
|
|
564
|
|
|
border: 1px solid; |
565
|
|
|
border-collapse: collapse; |
566
|
|
|
border-spacing: 0; |
567
|
|
|
float: none; |
568
|
|
|
line-height: 1.2em; |
569
|
|
|
text-align: center; |
570
|
|
|
vertical-align: baseline; |
571
|
|
|
width: 100%; |
572
|
|
|
'); |
573
|
|
|
$this->SetCfg('css-title', ' |
|
|
|
|
574
|
|
|
float: left; |
575
|
|
|
font-size: 1.2em; |
576
|
|
|
font-weight: bold; |
577
|
|
|
margin-bottom: 0.7em; |
578
|
|
|
padding-left: 2em; |
579
|
|
|
text-align: center; |
580
|
|
|
width: 90%; |
581
|
|
|
'); |
582
|
|
|
$this->SetCfg('css-tr_hover', ' |
|
|
|
|
583
|
|
|
background-color: #e3e3de; |
584
|
|
|
'); |
585
|
|
|
$this->SetCfg('css-clearit', ' |
|
|
|
|
586
|
|
|
clear: both; |
587
|
|
|
'); |
588
|
|
|
$this->SetCfg('css-empty', ''); |
|
|
|
|
589
|
|
|
$this->SetCfg('css-loading', ''); |
|
|
|
|
590
|
|
|
$this->SetCfg('css-tip', ''); |
|
|
|
|
591
|
|
|
// Css for row using class, not id |
592
|
|
|
$this->SetCfg('css-row', ''); |
|
|
|
|
593
|
|
|
// Css add are user defined, can overwrite upper setting |
594
|
|
|
$this->SetCfg('css-add', ' |
|
|
|
|
595
|
|
|
'); |
596
|
|
|
|
597
|
|
|
return $this; |
598
|
|
|
} // end of func SetCfgDefault |
599
|
|
|
|
600
|
|
|
|
601
|
|
|
} // end of class AjaxSelDiv |
602
|
|
|
?> |
|
|
|
|
603
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.