kritbit

kritbit Commit Details


Date:2015-11-22 10:40:03 (9 years 1 month ago)
Author:Natalie Adams
Branch:master
Commit:a1222a55ee727e2dade12ed74eee1d89d9be6362
Parents: 6bc8bc3d81c4021869126eb6bcbd2117fa844928
Message:Removing flexigrid Adding dynatable for history view updating runcommand

Changes:

File differences

README.md
3232
3333
3434
35
3536
3637
- [jQuery](https://jquery.com/)
- [jQuery confirm](http://craftpip.github.io/jquery-confirm/)
- [bootstrap fullscreen](http://craftpip.github.io/bootstrap-fullscreen-select/)
- [dynatable](http://www.dynatable.com/)
Made with <3 by Nathan Adams
scripts/runcommand.py
106106
107107
108108
109
109
110110
111
112111
113112
nonce = ''.join(random.SystemRandom().choice(string.hexdigits + string.digits) for _ in range(10))
message = {}
message["nonce"] = nonce
message["message"] = json.dumps({"output":out, "time_taken": total, "result": exitcode})
message["message"] = json.dumps({"output":out, "time_taken": total, "result": 1})
message["signature"] = hashlib.sha256(message["message"] + nonce + HASH).hexdigest()
print hashlib.sha256(message["message"]).hexdigest()
message["message"] = encrypt(SHARED_KEY, message["message"])
print curl_post(URL, {"data": json.dumps(message)}).getvalue()
web/application/views/base.html
88
99
1010
11
1112
1213
1314
......
1920
2021
2122
23
2224
2325
2426
<link rel="stylesheet" type="text/css" href="/media/css/jqueryui.css" />
<link rel="stylesheet" type="text/css" href="/media/css/jquery-confirm.min.css" />
<link rel="stylesheet" type="text/css" href="/media/css/jquery.dynatable.css" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="/media/js/jquery-confirm.min.js"></script>
<script src="/media/js/jquery.dynatable.js"></script>
<title>{{title}}</title>
<style type="text/css">
.text-center {
web/application/views/history.html
3030
3131
3232
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
5880
5981
<hr>
<table align="center" style="width: 60%;" class="table table-hover">
<thead>
<tr>
<th>Output</th>
<th>Run Date</th>
<th>Time Taken</th>
<th>Result</th>
</tr>
</thead>
<tbody>
{% if !histories %}
<tr>
<td align="center" colspan="4">No results</td>
</tr>
{% endif %}
{% for history in histories %}
<tr>
<td><a class="btn btn-default" href="/history/log/{{job.id}}/{{history.id}}/" role="button">View</a></td>
<td>{{history.run_date}}</td>
<td>{{history.time_taken}}</td>
<td>{{history.result}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div style="width: 50%; margin: 0 auto;">
<table align="center" style="width: 60%;" class="table table-hover results">
<thead>
<tr>
<th>Output</th>
<th>Run Date</th>
<th>Time Taken</th>
<th>Result</th>
</tr>
</thead>
<tbody>
{% if !histories %}
<tr>
<td align="center" colspan="4">No results</td>
</tr>
{% endif %}
{% for history in histories %}
{% if history.result != 0 %}
<tr class="danger">
{% else %}
<tr>
{% endif %}
<td><a class="btn btn-default" href="/history/log/{{job.id}}/{{history.id}}/" role="button">View</a></td>
<td>{{history.run_date}}</td>
<td>{{history.time_taken}}</td>
<td>{{history.result}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if histories %}
<script type="text/javascript">
$(function () {
$.dynatableSetup({
features: {
search: true,
pushState: false
}
});
$(".results").dynatable();
});
</script>
{% endif %}
{% endblock %}
web/application/views/main.html
2222
2323
2424
25
26
27
2528
29
2630
2731
2832
......
4751
4852
4953
54
5055
5156
5257
</thead>
<tbody>
{% for job in jobs %}
{% if job.last_result != 0 %}
<tr class="danger">
{% else %}
<tr>
{% endif %}
<td><a class="btn btn-default" href="/job/edit/{{job.id}}" role="button">Edit</a></td>
<td>{{job.jobName}}</td>
<td>{{job.getRunType}}</td>
title: 'Confirm',
content: "Are you sure you want to delete this job?"
});
});
</script>
web/media/css/flexigrid.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
@charset "UTF-8";
/* CSS Document */
.flexigrid {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
line-height: normal;
position: relative;
border: 0px solid #eee;
overflow: hidden;
color: #000;
}
.flexigrid.hideBody {
height: 26px !important;
border-bottom: 1px solid #ccc;
}
.ie6fullwidthbug {
border-right: 0px solid #ccc;
padding-right: 2px;
}
.flexigrid div.nDiv {
background: #eee url(images/line.gif) repeat-y -1px top;
border: 1px solid #ccc;
border-top: 0px;
overflow: auto;
left: 0px;
position: absolute;
z-index: 999;
float: left;
}
.flexigrid div.nDiv table {
margin: 2px;
}
.flexigrid div.hDivBox {
float: left;
padding-right: 40px;
}
.flexigrid div.bDiv table {
margin-bottom: 10px;
}
.flexigrid div.bDiv table.autoht {
border-bottom: 0px;
margin-bottom: 0px;
}
.flexigrid div.nDiv td {
padding: 2px 3px;
border: 1px solid #eee;
cursor: default;
}
.flexigrid div.nDiv tr:hover td,.flexigrid div.nDiv tr.ndcolover td {
background: #d5effc url(images/hl.png) repeat-x top;
border: 1px solid #a8d8eb;
}
.flexigrid div.nDiv td.ndcol1 {
border-right: 1px solid #ccc;
}
.flexigrid div.nDiv td.ndcol2 {
border-left: 1px solid #fff;
padding-right: 10px;
}
.flexigrid div.nDiv tr:hover td.ndcol1,.flexigrid div.nDiv tr.ndcolover td.ndcol1
{
border-right: 1px solid #d2e3ec;
}
.flexigrid div.nDiv tr:hover td.ndcol2,.flexigrid div.nDiv tr.ndcolover td.ndcol2
{
border-left: 1px solid #eef8ff;
}
.flexigrid div.nBtn {
position: absolute;
height: 24px;
width: 14px;
z-index: 900;
background: #fafafa url(images/fhbg.gif) repeat-x bottom;
border: 0px solid #ccc;
border-left: 1px solid #ccc;
top: 0px;
left: 0px;
margin-top: 1px;
cursor: pointer;
display: none;
}
.flexigrid div.nBtn div {
height: 24px;
width: 12px;
border-left: 1px solid #fff;
float: left;
background: url(images/ddn.png) no-repeat center;
}
.flexigrid div.nBtn.srtd {
background: url(images/wbg.gif) repeat-x 0px -1px;
}
.flexigrid div.mDiv {
background: url(images/wbg.gif) repeat-x top;
border: 1px solid #ccc;
border-bottom: 0px;
border-top: 0px;
font-weight: bold;
display: block;
overflow: hidden;
white-space: nowrap;
position: relative;
}
.flexigrid div.mDiv div {
padding: 6px;
white-space: nowrap;
}
.flexigrid div.mDiv div.ptogtitle {
position: absolute;
top: 4px;
right: 3px;
padding: 0px;
height: 16px;
width: 16px;
overflow: hidden;
border: 1px solid #ccc;
cursor: pointer;
}
.flexigrid div.mDiv div.ptogtitle:hover {
background-position: left -2px;
border-color: #bbb;
}
.flexigrid div.mDiv div.ptogtitle span {
display: block;
border-left: 1px solid #eee;
border-top: 1px solid #fff;
border-bottom: 1px solid #ddd;
width: 14px;
height: 14px;
background: url(images/uup.png) no-repeat center;
}
.flexigrid div.mDiv div.ptogtitle.vsble span {
background: url(images/ddn.png) no-repeat center;
}
.flexigrid div.tDiv /*toolbar*/ {
background: #fafafa url(images/bg.gif) repeat-x top;
position: relative;
border: 1px solid #ccc;
border-bottom: 0px;
overflow: hidden;
}
.flexigrid div.tDiv2 {
float: left;
clear: both;
padding: 1px;
}
.flexigrid div.sDiv /*toolbar*/ {
background: #fafafa url(images/bg.gif) repeat-x top;
position: relative;
border: 1px solid #ccc;
border-top: 0px;
overflow: hidden;
display: none;
}
.flexigrid div.sDiv2 {
float: left;
clear: both;
padding: 5px;
padding-left: 5px;
width: 1024px;
}
.flexigrid div.sDiv2 input,.flexigrid div.sDiv2 select {
vertical-align: middle;
}
.flexigrid div.btnseparator {
float: left;
height: 22px;
border-left: 1px solid #ccc;
border-right: 1px solid #fff;
margin: 1px;
}
.flexigrid div.fbutton {
float: left;
display: block;
cursor: pointer;
padding: 1px;
}
.flexigrid div.fbutton div {
float: left;
padding: 1px 3px;
}
.flexigrid div.fbutton span {
float: left;
display: block;
padding: 3px;
}
.flexigrid div.fbutton:hover,.flexigrid div.fbutton.fbOver {
padding: 0px;
border: 1px solid #ccc;
}
.flexigrid div.fbutton:hover div,.flexigrid div.fbutton.fbOver div {
padding: 0px 2px;
border-left: 1px solid #fff;
border-top: 1px solid #fff;
border-right: 1px solid #eee;
border-bottom: 1px solid #eee;
}
/* end toolbar*/
.flexigrid div.hDiv {
background: #fafafa url(images/fhbg.gif) repeat-x bottom;
position: relative;
border: 1px solid #ccc;
border-bottom: 0px;
overflow: hidden;
}
.flexigrid div.hDiv table {
border-right: 1px solid #fff;
}
.flexigrid div.cDrag {
float: left;
position: absolute;
z-index: 2;
overflow: visible;
}
.flexigrid div.cDrag div {
float: left;
background: none;
display: block;
position: absolute;
height: 24px;
width: 5px;
cursor: col-resize;
}
.flexigrid div.cDrag div:hover,.flexigrid div.cDrag div.dragging {
background: url(images/line.gif) repeat-y 2px center;
}
.flexigrid div.iDiv {
border: 1px solid #316ac5;
position: absolute;
overflow: visible;
background: none;
}
.flexigrid div.iDiv input,.flexigrid div.iDiv select,.flexigrid div.iDiv textarea
{
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
}
.flexigrid div.iDiv input.tb {
border: 0px;
padding: 0px;
width: 100%;
height: 100%;
padding: 0px;
background: none;
}
.flexigrid div.bDiv {
border: 1px solid #ccc;
border-top: 0px;
background: #fff;
overflow: auto;
position: relative;
}
.flexigrid div.bDiv table {
border-bottom: 1px solid #ccc;
}
.flexigrid div.hGrip {
position: absolute;
top: 0px;
right: 0px;
height: 5px;
width: 5px;
background: url(images/line.gif) repeat-x center;
margin-right: 1px;
cursor: col-resize;
}
.flexigrid div.hGrip:hover,.flexigrid div.hGrip.hgOver {
border-right: 1px solid #999;
margin-right: 0px;
}
.flexigrid div.vGrip {
height: 5px;
overflow: hidden;
position: relative;
background: #fafafa url(images/wbg.gif) repeat-x 0px -1px;
border: 1px solid #ccc;
border-top: 0px;
text-align: center;
cursor: row-resize;
}
.flexigrid div.vGrip span {
display: block;
margin: 1px auto;
width: 20px;
height: 1px;
overflow: hidden;
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
background: none;
}
.flexigrid div.hDiv th,.flexigrid div.bDiv td
/* common cell properties*/ {
text-align: left;
border-right: 1px solid #ddd;
border-left: 1px solid #fff;
overflow: hidden;
vertical-align: top !important;
padding-left: 0;
padding-right: 0;
}
.flexigrid div.hDiv th div,.flexigrid div.bDiv td div,div.colCopy div
/* common inner cell properties*/ {
padding: 5px;
border-left: 0px solid #fff;
}
.flexigrid div.hDiv th,div.colCopy {
font-weight: normal;
height: 24px;
cursor: default;
white-space: nowrap;
overflow: hidden;
}
div.colCopy {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
background: #fafafa url(images/fhbg.gif) repeat-x bottom;
border: 1px solid #ccc;
border-bottom: 0px;
overflow: hidden;
}
.flexigrid div.hDiv th.sorted {
background: url(images/wbg.gif) repeat-x 0px -1px;
border-bottom: 0px solid #ccc;
}
.flexigrid div.hDiv th.thOver {
}
.flexigrid div.hDiv th.thOver div,.flexigrid div.hDiv th.sorted.thOver div
{
border-bottom: 1px solid orange;
padding-bottom: 4px;
}
.flexigrid div.hDiv th.sorted div {
border-bottom: 0px solid #ccc;
padding-bottom: 5px;
}
.flexigrid div.hDiv th.thMove {
background: #fff;
color: #fff;
}
.flexigrid div.hDiv th.sorted.thMove div {
border-bottom: 1px solid #fff;
padding-bottom: 4px
}
.flexigrid div.hDiv th.thMove div {
background: #fff !important;
}
.flexigrid div.hDiv th div.sdesc {
background: url(images/dn.png) no-repeat center top;
}
.flexigrid div.hDiv th div.sasc {
background: url(images/up.png) no-repeat center top;
}
.flexigrid div.bDiv td {
border-bottom: 1px solid #fff;
vertical-align: top;
white-space: nowrap;
}
.flexigrid div.hDiv th div {
}
.flexigrid span.cdropleft {
display: block;
background: url(images/prev.gif) no-repeat -4px center;
width: 24px;
height: 24px;
position: relative;
top: -24px;
margin-bottom: -24px;
z-index: 3;
}
.flexigrid div.hDiv span.cdropright {
display: block;
background: url(images/next.gif) no-repeat 12px center;
width: 24px;
height: 24px;
float: right;
position: relative;
top: -24px;
margin-bottom: -24px;
}
.flexigrid div.bDiv td div {
border-top: 0px solid #fff;
padding-bottom: 4px;
}
.flexigrid tr td.sorted {
background: #f3f3f3;
border-right: 1px solid #ddd;
border-bottom: 1px solid #f3f3f3;
}
.flexigrid tr td.sorted div {
}
.flexigrid tr.erow td {
background: #f7f7f7;
border-bottom: 1px solid #f7f7f7;
}
.flexigrid tr.erow td.sorted {
background: #e3e3e3;
border-bottom: 1px solid #e3e3e3;
}
.flexigrid tr.erow td.sorted div {
}
.flexigrid div.bDiv tr:hover td,.flexigrid div.bDiv tr:hover td.sorted,.flexigrid div.bDiv tr.trOver td.sorted,.flexigrid div.bDiv tr.trOver td
{
background: #d9ebf5;
border-left: 1px solid #eef8ff;
border-bottom: 1px dotted #a8d8eb;
}
.flexigrid div.bDiv tr.trSelected:hover td,.flexigrid div.bDiv tr.trSelected:hover td.sorted,.flexigrid div.bDiv tr.trOver.trSelected td.sorted,.flexigrid div.bDiv tr.trOver.trSelected td,.flexigrid tr.trSelected td.sorted,.flexigrid tr.trSelected td
{
background: #d5effc url(images/hl.png) repeat-x top;
border-right: 1px solid #d2e3ec;
border-left: 1px solid #eef8ff;
border-bottom: 1px solid #a8d8eb;
}
/* novstripe adjustments */
.flexigrid.novstripe .bDiv table {
border-bottom: 1px solid #ccc;
border-right: 1px solid #ccc;
}
.flexigrid.novstripe div.bDiv td {
border-right-color: #fff;
}
.flexigrid.novstripe div.bDiv tr.erow td.sorted {
border-right-color: #e3e3e3;
}
.flexigrid.novstripe div.bDiv tr td.sorted {
border-right-color: #f3f3f3;
}
.flexigrid.novstripe div.bDiv tr.erow td {
border-right-color: #f7f7f7;
border-left-color: #f7f7f7;
}
.flexigrid.novstripe div.bDiv tr.trSelected:hover td,.flexigrid.novstripe div.bDiv tr.trSelected:hover td.sorted,.flexigrid.novstripe div.bDiv tr.trOver.trSelected td.sorted,.flexigrid.novstripe div.bDiv tr.trOver.trSelected td,.flexigrid.novstripe tr.trSelected td.sorted,.flexigrid.novstripe tr.trSelected td
{
border-right: 1px solid #0066FF;
border-left: 1px solid #0066FF;
}
.flexigrid.novstripe div.bDiv tr.trOver td,.flexigrid.novstripe div.bDiv tr:hover td
{
border-left-color: #d9ebf5;
border-right-color: #d9ebf5;
}
/* end novstripe */
.flexigrid div.pDiv {
background: url(images/wbg.gif) repeat-x 0 -1px;
border: 1px solid #ccc;
border-top: 0px;
overflow: hidden;
white-space: nowrap;
position: relative;
}
.flexigrid div.pDiv div.pDiv2 {
margin: 3px;
margin-left: -2px;
float: left;
width: 1024px;
}
div.pGroup {
float: left;
background: none;
height: 24px;
margin: 0px 5px;
}
.flexigrid div.pDiv .pPageStat,.flexigrid div.pDiv .pcontrol {
position: relative;
top: 5px;
overflow: visible;
}
.flexigrid div.pDiv input {
vertical-align: text-top;
position: relative;
top: -5px;
margin: 3px;
}
.flexigrid div.pDiv select {
margin: 3px;
}
.flexigrid div.pDiv div.pButton {
float: left;
width: 22px;
height: 22px;
border: 0px;
cursor: pointer;
overflow: hidden;
}
.flexigrid div.pDiv div.pButton:hover,.flexigrid div.pDiv div.pButton.pBtnOver
{
width: 20px;
height: 20px;
border: 1px solid #ccc;
cursor: pointer;
}
.flexigrid div.pDiv div.pButton span {
width: 20px;
height: 20px;
display: block;
float: left;
}
.flexigrid div.pDiv div.pButton:hover span,.flexigrid div.pDiv div.pButton.pBtnOver span
{
width: 19px;
height: 19px;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
}
.flexigrid .pSearch {
background: url(images/magnifier.png) no-repeat center;
}
.flexigrid .pFirst {
background: url(images/first.gif) no-repeat center;
}
.flexigrid .pPrev {
background: url(images/prev.gif) no-repeat center;
}
.flexigrid .pNext {
background: url(images/next.gif) no-repeat center;
}
.flexigrid .pLast {
background: url(images/last.gif) no-repeat center;
}
.flexigrid .pReload {
background: url(images/load.png) no-repeat center;
}
.flexigrid .pReload.loading {
background: url(images/load.gif) no-repeat center;
}
/* ie adjustments */
.flexigrid.ie div.hDiv th div,.flexigrid.ie div.bDiv td div,div.colCopy.ie div
/* common inner cell properties*/ {
overflow: hidden;
}
web/media/css/flexigrid.less
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
@charset "UTF-8";
@basecolor: #fff;
@forecolor: #000;
@borderlight1: #fff;
@borderlight2: #eee;
@borderlight3: #ddd;
@borderlight4: #ccc;
@borderlight5: #bbb;
@borderlight6: #aaa;
@borderlight7: #f7f7f7;
@borderlight8: #f3f3f3;
@borderlight9: #eef8ff;
@borderlight10: #e3e3e3;
@borderlight11: #d9ebf5;
@borderlight12: #d2e3ec;
@borderlight13: #a8d8eb;
@borderlight14: #999;
@borderlight15: #316ac5;
@borderlight16: #0066FF;
@back1: #fafafa;
@back2: #f7f7f7;
@back3: #f3f3f3;
@back4: #eee;
@back5: #e3e3e3;
@back6: #d5effc;
.background-gradient (@start: #000) {
background: @start;
background: -moz-linear-gradient(top, @start 0%, darken(@start,10%) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,@start), color-stop(100%,darken(@start,10%)));
background: -webkit-linear-gradient(top, @start 0%,darken(@start,10%) 100%);
background: -o-linear-gradient(top, @start 0%,darken(@start,10%) 100%);
background: -ms-linear-gradient(top, @start 0%,darken(@start,10%) 100%);
background: linear-gradient(to bottom, @start 0%,darken(@start,10%) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=@start, endColorstr=darken(@start,10%),GradientType=0 );
}
/* CSS Document */
.flexigrid {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
line-height: normal;
position: relative;
border: 0px solid @borderlight2;
overflow: hidden;
color: @forecolor;
}
.flexigrid.hideBody {
height: 26px !important;
border-bottom: 1px solid @borderlight4;
}
.ie6fullwidthbug {
border-right: 0px solid @borderlight4;
padding-right: 2px;
}
.flexigrid div.nDiv {
background: @back4 url(images/line.gif) repeat-y -1px top;
border: 1px solid @borderlight4;
border-top: 0px;
overflow: auto;
left: 0px;
position: absolute;
z-index: 999;
float: left;
}
.flexigrid div.nDiv table {
margin: 2px;
}
.flexigrid div.hDivBox {
float: left;
padding-right: 40px;
}
.flexigrid div.bDiv table {
margin-bottom: 10px;
}
.flexigrid div.bDiv table.autoht {
border-bottom: 0px;
margin-bottom: 0px;
}
.flexigrid div.nDiv td {
padding: 2px 3px;
border: 1px solid @borderlight2;
cursor: default;
}
.flexigrid div.nDiv tr:hover td,.flexigrid div.nDiv tr.ndcolover td {
background: @back6 url(images/hl.png) repeat-x top;
border: 1px solid @borderlight13;
}
.flexigrid div.nDiv td.ndcol1 {
border-right: 1px solid @borderlight4;
}
.flexigrid div.nDiv td.ndcol2 {
border-left: 1px solid @borderlight1;
padding-right: 10px;
}
.flexigrid div.nDiv tr:hover td.ndcol1,.flexigrid div.nDiv tr.ndcolover td.ndcol1
{
border-right: 1px solid @borderlight12;
}
.flexigrid div.nDiv tr:hover td.ndcol2,.flexigrid div.nDiv tr.ndcolover td.ndcol2
{
border-left: 1px solid @borderlight9;
}
.flexigrid div.nBtn {
position: absolute;
height: 24px;
width: 14px;
z-index: 900;
background: @back1 url(images/fhbg.gif) repeat-x bottom;
/*.background-gradient(@back1);*/
border: 0px solid @borderlight4;
border-left: 1px solid @borderlight4;
top: 0px;
left: 0px;
margin-top: 1px;
cursor: pointer;
display: none;
}
.flexigrid div.nBtn div {
height: 24px;
width: 12px;
border-left: 1px solid @borderlight1;
float: left;
background: url(images/ddn.png) no-repeat center;
}
.flexigrid div.nBtn.srtd {
background: url(images/wbg.gif) repeat-x 0px -1px;
}
.flexigrid div.mDiv {
background: url(images/wbg.gif) repeat-x top;
border: 1px solid @borderlight4;
border-bottom: 0px;
border-top: 0px;
font-weight: bold;
display: block;
overflow: hidden;
white-space: nowrap;
position: relative;
}
.flexigrid div.mDiv div {
padding: 6px;
white-space: nowrap;
}
.flexigrid div.mDiv div.ptogtitle {
position: absolute;
top: 4px;
right: 3px;
padding: 0px;
height: 16px;
width: 16px;
overflow: hidden;
border: 1px solid @borderlight4;
cursor: pointer;
}
.flexigrid div.mDiv div.ptogtitle:hover {
background-position: left -2px;
border-color: @borderlight5;
}
.flexigrid div.mDiv div.ptogtitle span {
display: block;
border-left: 1px solid @borderlight2;
border-top: 1px solid @borderlight1;
border-bottom: 1px solid @borderlight3;
width: 14px;
height: 14px;
background: url(images/uup.png) no-repeat center;
}
.flexigrid div.mDiv div.ptogtitle.vsble span {
background: url(images/ddn.png) no-repeat center;
}
.flexigrid div.tDiv /*toolbar*/ {
background: @back1 url(images/bg.gif) repeat-x top;
position: relative;
border: 1px solid @borderlight4;
border-bottom: 0px;
overflow: hidden;
}
.flexigrid div.tDiv2 {
float: left;
clear: both;
padding: 1px;
}
.flexigrid div.sDiv /*toolbar*/ {
background: @back1 url(images/bg.gif) repeat-x top;
position: relative;
border: 1px solid @borderlight4;
border-top: 0px;
overflow: hidden;
display: none;
}
.flexigrid div.sDiv2 {
float: left;
clear: both;
padding: 5px;
padding-left: 5px;
width: 1024px;
}
.flexigrid div.sDiv2 input,.flexigrid div.sDiv2 select {
vertical-align: middle;
}
.flexigrid div.btnseparator {
float: left;
height: 22px;
border-left: 1px solid @borderlight4;
border-right: 1px solid @borderlight1;
margin: 1px;
}
.flexigrid div.fbutton {
float: left;
display: block;
cursor: pointer;
padding: 1px;
}
.flexigrid div.fbutton div {
float: left;
padding: 1px 3px;
}
.flexigrid div.fbutton span {
float: left;
display: block;
padding: 3px;
}
.flexigrid div.fbutton:hover,.flexigrid div.fbutton.fbOver {
padding: 0px;
border: 1px solid @borderlight4;
}
.flexigrid div.fbutton:hover div,.flexigrid div.fbutton.fbOver div {
padding: 0px 2px;
border-left: 1px solid @borderlight1;
border-top: 1px solid @borderlight1;
border-right: 1px solid @borderlight2;
border-bottom: 1px solid @borderlight2;
}
/* end toolbar*/
.flexigrid div.hDiv {
background: @back1 url(images/fhbg.gif) repeat-x bottom;
/*.background-gradient(@back1);*/
position: relative;
border: 1px solid @borderlight4;
border-bottom: 0px;
overflow: hidden;
}
.flexigrid div.hDiv table {
border-right: 1px solid @borderlight1;
}
.flexigrid div.cDrag {
float: left;
position: absolute;
z-index: 2;
overflow: visible;
}
.flexigrid div.cDrag div {
float: left;
background: none;
display: block;
position: absolute;
height: 24px;
width: 5px;
cursor: col-resize;
}
.flexigrid div.cDrag div:hover,.flexigrid div.cDrag div.dragging {
background: url(images/line.gif) repeat-y 2px center;
}
.flexigrid div.iDiv {
border: 1px solid @borderlight15;
position: absolute;
overflow: visible;
background: none;
}
.flexigrid div.iDiv input,.flexigrid div.iDiv select,.flexigrid div.iDiv textarea
{
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
}
.flexigrid div.iDiv input.tb {
border: 0px;
padding: 0px;
width: 100%;
height: 100%;
padding: 0px;
background: none;
}
.flexigrid div.bDiv {
border: 1px solid @borderlight4;
border-top: 0px;
background: @basecolor;
overflow: auto;
position: relative;
}
.flexigrid div.bDiv table {
border-bottom: 1px solid @borderlight4;
}
.flexigrid div.hGrip {
position: absolute;
top: 0px;
right: 0px;
height: 5px;
width: 5px;
background: url(images/line.gif) repeat-x center;
margin-right: 1px;
cursor: col-resize;
}
.flexigrid div.hGrip:hover,.flexigrid div.hGrip.hgOver {
border-right: 1px solid @borderlight14;
margin-right: 0px;
}
.flexigrid div.vGrip {
height: 5px;
overflow: hidden;
position: relative;
background: @back1 url(images/wbg.gif) repeat-x 0px -1px;
border: 1px solid @borderlight4;
border-top: 0px;
text-align: center;
cursor: row-resize;
}
.flexigrid div.vGrip span {
display: block;
margin: 1px auto;
width: 20px;
height: 1px;
overflow: hidden;
border-top: 1px solid @borderlight6;
border-bottom: 1px solid @borderlight6;
background: none;
}
.flexigrid div.hDiv th,.flexigrid div.bDiv td
/* common cell properties*/ {
text-align: left;
border-right: 1px solid @borderlight3;
border-left: 1px solid @borderlight1;
overflow: hidden;
vertical-align: top !important;
padding-left: 0;
padding-right: 0;
}
.flexigrid div.hDiv th div,.flexigrid div.bDiv td div,div.colCopy div
/* common inner cell properties*/ {
padding: 5px;
border-left: 0px solid @borderlight1;
}
.flexigrid div.hDiv th,div.colCopy {
font-weight: normal;
height: 24px;
cursor: default;
white-space: nowrap;
overflow: hidden;
}
div.colCopy {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
background: @back1 url(images/fhbg.gif) repeat-x bottom;
/*.background-gradient(@back1);*/
border: 1px solid @borderlight4;
border-bottom: 0px;
overflow: hidden;
}
.flexigrid div.hDiv th.sorted {
background: url(images/wbg.gif) repeat-x 0px -1px;
border-bottom: 0px solid @borderlight4;
}
.flexigrid div.hDiv th.thOver {
}
.flexigrid div.hDiv th.thOver div,.flexigrid div.hDiv th.sorted.thOver div
{
border-bottom: 1px solid orange;
padding-bottom: 4px;
}
.flexigrid div.hDiv th.sorted div {
border-bottom: 0px solid @borderlight4;
padding-bottom: 5px;
}
.flexigrid div.hDiv th.thMove {
background: @basecolor;
color: @basecolor;
}
.flexigrid div.hDiv th.sorted.thMove div {
border-bottom: 1px solid @borderlight1;
padding-bottom: 4px
}
.flexigrid div.hDiv th.thMove div {
background: @basecolor !important;
}
.flexigrid div.hDiv th div.sdesc {
background: url(images/dn.png) no-repeat center top;
}
.flexigrid div.hDiv th div.sasc {
background: url(images/up.png) no-repeat center top;
}
.flexigrid div.bDiv td {
border-bottom: 1px solid @borderlight1;
vertical-align: top;
white-space: nowrap;
}
.flexigrid div.hDiv th div {
}
.flexigrid span.cdropleft {
display: block;
background: url(images/prev.gif) no-repeat -4px center;
width: 24px;
height: 24px;
position: relative;
top: -24px;
margin-bottom: -24px;
z-index: 3;
}
.flexigrid div.hDiv span.cdropright {
display: block;
background: url(images/next.gif) no-repeat 12px center;
width: 24px;
height: 24px;
float: right;
position: relative;
top: -24px;
margin-bottom: -24px;
}
.flexigrid div.bDiv td div {
border-top: 0px solid @borderlight1;
padding-bottom: 4px;
}
.flexigrid tr td.sorted {
background: @back3;
border-right: 1px solid @borderlight3;
border-bottom: 1px solid @borderlight8;
}
.flexigrid tr td.sorted div {
}
.flexigrid tr.erow td {
background: @back2;
border-bottom: 1px solid @borderlight7;
}
.flexigrid tr.erow td.sorted {
background: @back5;
border-bottom: 1px solid @borderlight10;
}
.flexigrid tr.erow td.sorted div {
}
.flexigrid div.bDiv tr:hover td,.flexigrid div.bDiv tr:hover td.sorted,.flexigrid div.bDiv tr.trOver td.sorted,.flexigrid div.bDiv tr.trOver td
{
background: @borderlight11;
border-left: 1px solid @borderlight9;
border-bottom: 1px dotted @borderlight13;
}
.flexigrid div.bDiv tr.trSelected:hover td,.flexigrid div.bDiv tr.trSelected:hover td.sorted,.flexigrid div.bDiv tr.trOver.trSelected td.sorted,.flexigrid div.bDiv tr.trOver.trSelected td,.flexigrid tr.trSelected td.sorted,.flexigrid tr.trSelected td
{
background: @back6 url(images/hl.png) repeat-x top;
border-right: 1px solid @borderlight12;
border-left: 1px solid @borderlight9;
border-bottom: 1px solid @borderlight13;
}
/* novstripe adjustments */
.flexigrid.novstripe .bDiv table {
border-bottom: 1px solid @borderlight4;
border-right: 1px solid @borderlight4;
}
.flexigrid.novstripe div.bDiv td {
border-right-color: @borderlight1;
}
.flexigrid.novstripe div.bDiv tr.erow td.sorted {
border-right-color: @borderlight10;
}
.flexigrid.novstripe div.bDiv tr td.sorted {
border-right-color: @borderlight8;
}
.flexigrid.novstripe div.bDiv tr.erow td {
border-right-color: @borderlight7;
border-left-color: @borderlight7;
}
.flexigrid.novstripe div.bDiv tr.trSelected:hover td,.flexigrid.novstripe div.bDiv tr.trSelected:hover td.sorted,.flexigrid.novstripe div.bDiv tr.trOver.trSelected td.sorted,.flexigrid.novstripe div.bDiv tr.trOver.trSelected td,.flexigrid.novstripe tr.trSelected td.sorted,.flexigrid.novstripe tr.trSelected td
{
border-right: 1px solid @borderlight16;
border-left: 1px solid @borderlight16;
}
.flexigrid.novstripe div.bDiv tr.trOver td,.flexigrid.novstripe div.bDiv tr:hover td
{
border-left-color: @borderlight11;
border-right-color: @borderlight11;
}
/* end novstripe */
.flexigrid div.pDiv {
background: url(images/wbg.gif) repeat-x 0 -1px;
border: 1px solid @borderlight4;
border-top: 0px;
overflow: hidden;
white-space: nowrap;
position: relative;
}
.flexigrid div.pDiv div.pDiv2 {
margin: 3px;
margin-left: -2px;
float: left;
width: 1024px;
}
div.pGroup {
float: left;
background: none;
height: 24px;
margin: 0px 5px;
}
.flexigrid div.pDiv .pPageStat,.flexigrid div.pDiv .pcontrol {
position: relative;
top: 5px;
overflow: visible;
}
.flexigrid div.pDiv input {
vertical-align: text-top;
position: relative;
top: -5px;
margin: 3px;
}
.flexigrid div.pDiv select {
margin: 3px;
}
.flexigrid div.pDiv div.pButton {
float: left;
width: 22px;
height: 22px;
border: 0px;
cursor: pointer;
overflow: hidden;
}
.flexigrid div.pDiv div.pButton:hover,.flexigrid div.pDiv div.pButton.pBtnOver
{
width: 20px;
height: 20px;
border: 1px solid @borderlight4;
cursor: pointer;
}
.flexigrid div.pDiv div.pButton span {
width: 20px;
height: 20px;
display: block;
float: left;
}
.flexigrid div.pDiv div.pButton:hover span,.flexigrid div.pDiv div.pButton.pBtnOver span
{
width: 19px;
height: 19px;
border-top: 1px solid @borderlight1;
border-left: 1px solid @borderlight1;
}
.flexigrid .pSearch {
background: url(images/magnifier.png) no-repeat center;
}
.flexigrid .pFirst {
background: url(images/first.gif) no-repeat center;
}
.flexigrid .pPrev {
background: url(images/prev.gif) no-repeat center;
}
.flexigrid .pNext {
background: url(images/next.gif) no-repeat center;
}
.flexigrid .pLast {
background: url(images/last.gif) no-repeat center;
}
.flexigrid .pReload {
background: url(images/load.png) no-repeat center;
}
.flexigrid .pReload.loading {
background: url(images/load.gif) no-repeat center;
}
/* ie adjustments */
.flexigrid.ie div.hDiv th div,.flexigrid.ie div.bDiv td div,div.colCopy.ie div
/* common inner cell properties*/ {
overflow: hidden;
}
web/media/css/flexigrid.pack.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@charset UTF-8;
.flexigrid{font-family:Arial, Helvetica, sans-serif;font-size:11px;position:relative;border:0 solid #eee;overflow:hidden;color:#000}
.flexigrid.hideBody{height:26px!important;border-bottom:1px solid #ccc}
.ie6fullwidthbug{border-right:0 solid #ccc;padding-right:2px}
.flexigrid div.nDiv{background:#eee url(images/line.gif) repeat-y -1px top;border:1px solid #ccc;border-top:0;overflow:auto;left:0;position:absolute;z-index:999;float:left}
.flexigrid div.nDiv table{margin:2px}
.flexigrid div.hDivBox{float:left;padding-right:40px}
.flexigrid div.bDiv table{margin-bottom:10px;border-bottom:1px solid #ccc}
.flexigrid div.bDiv table.autoht{border-bottom:0;margin-bottom:0}
.flexigrid div.nDiv td{border:1px solid #eee;cursor:default;padding:2px 3px}
.flexigrid div.nDiv tr:hover td,.flexigrid div.nDiv tr.ndcolover td{background:#d5effc url(images/hl.png) repeat-x top;border:1px solid #a8d8eb}
.flexigrid div.nDiv td.ndcol1{border-right:1px solid #ccc}
.flexigrid div.nDiv td.ndcol2{border-left:1px solid #fff;padding-right:10px}
.flexigrid div.nDiv tr:hover td.ndcol1,.flexigrid div.nDiv tr.ndcolover td.ndcol1{border-right:1px solid #d2e3ec}
.flexigrid div.nDiv tr:hover td.ndcol2,.flexigrid div.nDiv tr.ndcolover td.ndcol2{border-left:1px solid #eef8ff}
.flexigrid div.nBtn{position:absolute;height:24px;width:14px;z-index:900;background:#fafafa url(images/fhbg.gif) repeat-x bottom;border:0 solid #ccc;border-left:1px solid #ccc;top:0;left:0;margin-top:1px;cursor:pointer;display:none}
.flexigrid div.nBtn div{height:24px;width:12px;border-left:1px solid #fff;float:left;background:url(images/ddn.png) no-repeat center}
.flexigrid div.nBtn.srtd{background:url(images/wbg.gif) repeat-x 0 -1px}
.flexigrid div.mDiv{background:url(images/wbg.gif) repeat-x top;border:1px solid #ccc;border-bottom:0;border-top:0;font-weight:700;display:block;overflow:hidden;white-space:nowrap;position:relative}
.flexigrid div.mDiv div{white-space:nowrap;padding:6px}
.flexigrid div.mDiv div.ptogtitle{position:absolute;top:4px;right:3px;height:16px;width:16px;overflow:hidden;border:1px solid #ccc;cursor:pointer;padding:0}
.flexigrid div.mDiv div.ptogtitle:hover{background-position:left -2px;border-color:#bbb}
.flexigrid div.mDiv div.ptogtitle span{display:block;border-left:1px solid #eee;border-top:1px solid #fff;border-bottom:1px solid #ddd;width:14px;height:14px;background:url(images/uup.png) no-repeat center}
.flexigrid div.mDiv div.ptogtitle.vsble span{background:url(images/ddn.png) no-repeat center}
.flexigrid div.tDiv /*toolbar*/{background:#fafafa url(images/bg.gif) repeat-x top;position:relative;border:1px solid #ccc;border-bottom:0;overflow:hidden}
.flexigrid div.tDiv2{float:left;clear:both;padding:1px}
.flexigrid div.sDiv /*toolbar*/{background:#fafafa url(images/bg.gif) repeat-x top;position:relative;border:1px solid #ccc;border-top:0;overflow:hidden;display:none}
.flexigrid div.sDiv2{float:left;clear:both;width:1024px;padding:5px}
.flexigrid div.sDiv2 input,.flexigrid div.sDiv2 select{vertical-align:middle}
.flexigrid div.btnseparator{float:left;height:22px;border-left:1px solid #ccc;border-right:1px solid #fff;margin:1px}
.flexigrid div.fbutton{float:left;display:block;cursor:pointer;padding:1px}
.flexigrid div.fbutton div{float:left;padding:1px 3px}
.flexigrid div.fbutton span{float:left;display:block;padding:3px}
.flexigrid div.fbutton:hover,.flexigrid div.fbutton.fbOver{border:1px solid #ccc;padding:0}
.flexigrid div.fbutton:hover div,.flexigrid div.fbutton.fbOver div{border-left:1px solid #fff;border-top:1px solid #fff;border-right:1px solid #eee;border-bottom:1px solid #eee;padding:0 2px}
.flexigrid div.hDiv{background:#fafafa url(images/fhbg.gif) repeat-x bottom;position:relative;border:1px solid #ccc;border-bottom:0;overflow:hidden}
.flexigrid div.hDiv table{border-right:1px solid #fff}
.flexigrid div.cDrag{float:left;position:absolute;z-index:2;overflow:visible}
.flexigrid div.cDrag div{float:left;background:none;display:block;position:absolute;height:24px;width:5px;cursor:col-resize}
.flexigrid div.cDrag div:hover,.flexigrid div.cDrag div.dragging{background:url(images/line.gif) repeat-y 2px center}
.flexigrid div.iDiv{border:1px solid #316ac5;position:absolute;overflow:visible;background:none}
.flexigrid div.iDiv input,.flexigrid div.iDiv select,.flexigrid div.iDiv textarea{font-family:Arial, Helvetica, sans-serif;font-size:11px}
.flexigrid div.iDiv input.tb{border:0;width:100%;height:100%;background:none;padding:0}
.flexigrid div.bDiv{border:1px solid #ccc;border-top:0;background:#fff;overflow:auto;position:relative}
.flexigrid div.hGrip{position:absolute;top:0;right:0;height:5px;width:5px;background:url(images/line.gif) repeat-x center;margin-right:1px;cursor:col-resize}
.flexigrid div.hGrip:hover,.flexigrid div.hGrip.hgOver{border-right:1px solid #999;margin-right:0}
.flexigrid div.vGrip{height:5px;overflow:hidden;position:relative;background:#fafafa url(images/wbg.gif) repeat-x 0 -1px;border:1px solid #ccc;border-top:0;text-align:center;cursor:row-resize}
.flexigrid div.vGrip span{display:block;width:20px;height:1px;overflow:hidden;border-top:1px solid #aaa;border-bottom:1px solid #aaa;background:none;margin:1px auto}
.flexigrid div.hDiv th,.flexigrid div.bDiv td
/* common cell properties*/{text-align:left;border-right:1px solid #ddd;border-left:1px solid #fff;overflow:hidden;vertical-align:top!important;padding-left:0;padding-right:0}
.flexigrid div.hDiv th div,.flexigrid div.bDiv td div,div.colCopy div
/* common inner cell properties*/{border-left:0 solid #fff;padding:5px}
.flexigrid div.hDiv th,div.colCopy{font-weight:400;height:24px;cursor:default;white-space:nowrap;overflow:hidden}
div.colCopy{font-family:Arial, Helvetica, sans-serif;font-size:11px;background:#fafafa url(images/fhbg.gif) repeat-x bottom;border:1px solid #ccc;border-bottom:0;overflow:hidden}
.flexigrid div.hDiv th.sorted{background:url(images/wbg.gif) repeat-x 0 -1px;border-bottom:0 solid #ccc}
.flexigrid div.hDiv th.thOver div,.flexigrid div.hDiv th.sorted.thOver div{border-bottom:1px solid orange;padding-bottom:4px}
.flexigrid div.hDiv th.sorted div{border-bottom:0 solid #ccc;padding-bottom:5px}
.flexigrid div.hDiv th.thMove{background:#fff;color:#fff}
.flexigrid div.hDiv th.sorted.thMove div{border-bottom:1px solid #fff;padding-bottom:4px}
.flexigrid div.hDiv th.thMove div{background:#fff!important}
.flexigrid div.hDiv th div.sdesc{background:url(images/dn.png) no-repeat center top}
.flexigrid div.hDiv th div.sasc{background:url(images/up.png) no-repeat center top}
.flexigrid div.bDiv td{border-bottom:1px solid #fff;vertical-align:top;white-space:nowrap}
.flexigrid span.cdropleft{display:block;background:url(images/prev.gif) no-repeat -4px center;width:24px;height:24px;position:relative;top:-24px;margin-bottom:-24px;z-index:3}
.flexigrid div.hDiv span.cdropright{display:block;background:url(images/next.gif) no-repeat 12px center;width:24px;height:24px;float:right;position:relative;top:-24px;margin-bottom:-24px}
.flexigrid div.bDiv td div{border-top:0 solid #fff;padding-bottom:4px}
.flexigrid tr td.sorted{background:#f3f3f3;border-right:1px solid #ddd;border-bottom:1px solid #f3f3f3}
.flexigrid tr.erow td{background:#f7f7f7;border-bottom:1px solid #f7f7f7}
.flexigrid tr.erow td.sorted{background:#e3e3e3;border-bottom:1px solid #e3e3e3}
.flexigrid div.bDiv tr:hover td,.flexigrid div.bDiv tr:hover td.sorted,.flexigrid div.bDiv tr.trOver td.sorted,.flexigrid div.bDiv tr.trOver td{background:#d9ebf5;border-left:1px solid #eef8ff;border-bottom:1px dotted #a8d8eb}
.flexigrid div.bDiv tr.trSelected:hover td,.flexigrid div.bDiv tr.trSelected:hover td.sorted,.flexigrid div.bDiv tr.trOver.trSelected td.sorted,.flexigrid div.bDiv tr.trOver.trSelected td,.flexigrid tr.trSelected td.sorted,.flexigrid tr.trSelected td{background:#d5effc url(images/hl.png) repeat-x top;border-right:1px solid #d2e3ec;border-left:1px solid #eef8ff;border-bottom:1px solid #a8d8eb}
.flexigrid.novstripe .bDiv table{border-bottom:1px solid #ccc;border-right:1px solid #ccc}
.flexigrid.novstripe div.bDiv td{border-right-color:#fff}
.flexigrid.novstripe div.bDiv tr.erow td.sorted{border-right-color:#e3e3e3}
.flexigrid.novstripe div.bDiv tr td.sorted{border-right-color:#f3f3f3}
.flexigrid.novstripe div.bDiv tr.erow td{border-right-color:#f7f7f7;border-left-color:#f7f7f7}
.flexigrid.novstripe div.bDiv tr.trSelected:hover td,.flexigrid.novstripe div.bDiv tr.trSelected:hover td.sorted,.flexigrid.novstripe div.bDiv tr.trOver.trSelected td.sorted,.flexigrid.novstripe div.bDiv tr.trOver.trSelected td,.flexigrid.novstripe tr.trSelected td.sorted,.flexigrid.novstripe tr.trSelected td{border-right:1px solid #06F;border-left:1px solid #06F}
.flexigrid.novstripe div.bDiv tr.trOver td,.flexigrid.novstripe div.bDiv tr:hover td{border-left-color:#d9ebf5;border-right-color:#d9ebf5}
.flexigrid div.pDiv{background:url(images/wbg.gif) repeat-x 0 -1px;border:1px solid #ccc;border-top:0;overflow:hidden;white-space:nowrap;position:relative}
.flexigrid div.pDiv div.pDiv2{float:left;width:1024px;margin:3px 3px 3px -2px}
div.pGroup{float:left;background:none;height:24px;margin:0 5px}
.flexigrid div.pDiv .pPageStat,.flexigrid div.pDiv .pcontrol{position:relative;top:5px;overflow:visible}
.flexigrid div.pDiv input{vertical-align:text-top;position:relative;top:-5px}
.flexigrid div.pDiv div.pButton{float:left;width:22px;height:22px;border:0;cursor:pointer;overflow:hidden}
.flexigrid div.pDiv div.pButton:hover,.flexigrid div.pDiv div.pButton.pBtnOver{width:20px;height:20px;border:1px solid #ccc;cursor:pointer}
.flexigrid div.pDiv div.pButton span{width:20px;height:20px;display:block;float:left}
.flexigrid div.pDiv div.pButton:hover span,.flexigrid div.pDiv div.pButton.pBtnOver span{width:19px;height:19px;border-top:1px solid #fff;border-left:1px solid #fff}
.flexigrid .pSearch{background:url(images/magnifier.png) no-repeat center}
.flexigrid .pFirst{background:url(images/first.gif) no-repeat center}
.flexigrid .pPrev{background:url(images/prev.gif) no-repeat center}
.flexigrid .pNext{background:url(images/next.gif) no-repeat center}
.flexigrid .pLast{background:url(images/last.gif) no-repeat center}
.flexigrid .pReload{background:url(images/load.png) no-repeat center}
.flexigrid .pReload.loading{background:url(images/load.gif) no-repeat center}
.flexigrid.ie div.hDiv th div,.flexigrid.ie div.bDiv td div,div.colCopy.ie div
/* common inner cell properties*/{overflow:hidden}
web/media/css/jquery.dynatable.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* jQuery Dynatable plugin 0.3.1
*
* Copyright (c) 2014 Steve Schwartz (JangoSteve)
*
* Dual licensed under the AGPL and Proprietary licenses:
* http://www.dynatable.com/license/
*
* Date: Tue Jan 02 2014
*/
th a {
/*color: #fff;*/
}
th a:hover {
/*color: #fff;*/
text-decoration: underline;
}
.dynatable-search {
float: right;
margin-bottom: 10px;
}
.dynatable-pagination-links {
float: right;
}
.dynatable-record-count {
display: block;
padding: 5px 0;
}
.dynatable-pagination-links span,
.dynatable-pagination-links li {
display: inline-block;
}
.dynatable-page-link,
.dynatable-page-break {
display: block;
padding: 5px 7px;
}
.dynatable-page-link {
cursor: pointer;
}
.dynatable-active-page,
.dynatable-disabled-page {
cursor: text;
}
.dynatable-active-page:hover,
.dynatable-disabled-page:hover {
text-decoration: none;
}
.dynatable-active-page {
background: #71AF5A;
border-radius: 5px;
color: #fff;
}
.dynatable-active-page:hover {
color: #fff;
}
.dynatable-disabled-page,
.dynatable-disabled-page:hover {
background: none;
color: #999;
}
web/media/js/flexigrid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
/*
* Flexigrid for jQuery - v1.1
*
* Copyright (c) 2008 Paulo P. Marinas (code.google.com/p/flexigrid/)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
*/
(function ($) {
/*
* jQuery 1.9 support. browser object has been removed in 1.9
*/
var browser = $.browser
if (!browser) {
function uaMatch( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
var matched = uaMatch( navigator.userAgent );
browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
}
/*!
* START code from jQuery UI
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI
*/
if(typeof $.support.selectstart != 'function') {
$.support.selectstart = "onselectstart" in document.createElement("div");
}
if(typeof $.fn.disableSelection != 'function') {
$.fn.disableSelection = function() {
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
".ui-disableSelection", function( event ) {
event.preventDefault();
});
};
}
/* END code from jQuery UI */
$.addFlex = function (t, p) {
if (t.grid) return false; //return if already exist
p = $.extend({ //apply default properties
height: 200, //default height
width: 'auto', //auto width
striped: true, //apply odd even stripes
novstripe: false,
minwidth: 30, //min width of columns
minheight: 80, //min height of columns
resizable: true, //allow table resizing
url: false, //URL if using data from AJAX
method: 'POST', //data sending method
dataType: 'xml', //type of data for AJAX, either xml or json
errormsg: 'Connection Error',
usepager: false,
nowrap: true,
page: 1, //current page
total: 1, //total pages
useRp: true, //use the results per page select box
rp: 15, //results per page
rpOptions: [10, 15, 20, 30, 50], //allowed per-page values
title: false,
idProperty: 'id',
pagestat: 'Displaying {from} to {to} of {total} items',
pagetext: 'Page',
outof: 'of',
findtext: 'Find',
params: [], //allow optional parameters to be passed around
procmsg: 'Processing, please wait ...',
query: '',
qtype: '',
nomsg: 'No items',
minColToggle: 1, //minimum allowed column to be hidden
showToggleBtn: true, //show or hide column toggle popup
hideOnSubmit: true,
autoload: true,
blockOpacity: 0.5,
preProcess: false,
addTitleToCell: false, // add a title attr to cells with truncated contents
dblClickResize: false, //auto resize column by double clicking
onDragCol: false,
onToggleCol: false,
onChangeSort: false,
onDoubleClick: false,
onSuccess: false,
onError: false,
onSubmit: false, //using a custom populate function
__mw: { //extendable middleware function holding object
datacol: function(p, col, val) { //middleware for formatting data columns
var _col = (typeof p.datacol[col] == 'function') ? p.datacol[col](val) : val; //format column using function
if(typeof p.datacol['*'] == 'function') { //if wildcard function exists
return p.datacol['*'](_col); //run wildcard function
} else {
return _col; //return column without wildcard
}
}
},
getGridClass: function(g) { //get the grid class, always returns g
return g;
},
datacol: {}, //datacol middleware object 'colkey': function(colval) {}
colResize: true, //from: http://stackoverflow.com/a/10615589
colMove: true
}, p);
$(t).show() //show if hidden
.attr({
cellPadding: 0,
cellSpacing: 0,
border: 0
}) //remove padding and spacing
.removeAttr('width'); //remove width properties
//create grid class
var g = {
hset: {},
rePosDrag: function () {
var cdleft = 0 - this.hDiv.scrollLeft;
if (this.hDiv.scrollLeft > 0) cdleft -= Math.floor(p.cgwidth / 2);
$(g.cDrag).css({
top: g.hDiv.offsetTop + 1
});
var cdpad = this.cdpad;
var cdcounter=0;
$('div', g.cDrag).hide();
$('thead tr:first th:visible', this.hDiv).each(function () {
var n = $('thead tr:first th:visible', g.hDiv).index(this);
var cdpos = parseInt($('div', this).width());
if (cdleft == 0) cdleft -= Math.floor(p.cgwidth / 2);
cdpos = cdpos + cdleft + cdpad;
if (isNaN(cdpos)) {
cdpos = 0;
}
$('div:eq(' + n + ')', g.cDrag).css({
'left': (!(browser.mozilla) ? cdpos - cdcounter : cdpos) + 'px'
}).show();
cdleft = cdpos;
cdcounter++;
});
},
fixHeight: function (newH) {
newH = false;
if (!newH) newH = $(g.bDiv).height();
var hdHeight = $(this.hDiv).height();
$('div', this.cDrag).each(
function () {
$(this).height(newH + hdHeight);
}
);
var nd = parseInt($(g.nDiv).height(), 10);
if (nd > newH) $(g.nDiv).height(newH).width(200);
else $(g.nDiv).height('auto').width('auto');
$(g.block).css({
height: newH,
marginBottom: (newH * -1)
});
var hrH = g.bDiv.offsetTop + newH;
if (p.height != 'auto' && p.resizable) hrH = g.vDiv.offsetTop;
$(g.rDiv).css({
height: hrH
});
},
dragStart: function (dragtype, e, obj) { //default drag function start
if (dragtype == 'colresize' && p.colResize === true) {//column resize
$(g.nDiv).hide();
$(g.nBtn).hide();
var n = $('div', this.cDrag).index(obj);
var ow = $('th:visible div:eq(' + n + ')', this.hDiv).width();
$(obj).addClass('dragging').siblings().hide();
$(obj).prev().addClass('dragging').show();
this.colresize = {
startX: e.pageX,
ol: parseInt(obj.style.left, 10),
ow: ow,
n: n
};
$('body').css('cursor', 'col-resize');
} else if (dragtype == 'vresize') {//table resize
var hgo = false;
$('body').css('cursor', 'row-resize');
if (obj) {
hgo = true;
$('body').css('cursor', 'col-resize');
}
this.vresize = {
h: p.height,
sy: e.pageY,
w: p.width,
sx: e.pageX,
hgo: hgo
};
} else if (dragtype == 'colMove') {//column header drag
$(e.target).disableSelection(); //disable selecting the column header
if((p.colMove === true)) {
$(g.nDiv).hide();
$(g.nBtn).hide();
this.hset = $(this.hDiv).offset();
this.hset.right = this.hset.left + $('table', this.hDiv).width();
this.hset.bottom = this.hset.top + $('table', this.hDiv).height();
this.dcol = obj;
this.dcoln = $('th', this.hDiv).index(obj);
this.colCopy = document.createElement("div");
this.colCopy.className = "colCopy";
this.colCopy.innerHTML = obj.innerHTML;
if (browser.msie) {
this.colCopy.className = "colCopy ie";
}
$(this.colCopy).css({
position: 'absolute',
'float': 'left',
display: 'none',
textAlign: obj.align
});
$('body').append(this.colCopy);
$(this.cDrag).hide();
}
}
$('body').noSelect();
},
dragMove: function (e) {
if (this.colresize) {//column resize
var n = this.colresize.n;
var diff = e.pageX - this.colresize.startX;
var nleft = this.colresize.ol + diff;
var nw = this.colresize.ow + diff;
if (nw > p.minwidth) {
$('div:eq(' + n + ')', this.cDrag).css('left', nleft);
this.colresize.nw = nw;
}
} else if (this.vresize) {//table resize
var v = this.vresize;
var y = e.pageY;
var diff = y - v.sy;
if (!p.defwidth) p.defwidth = p.width;
if (p.width != 'auto' && !p.nohresize && v.hgo) {
var x = e.pageX;
var xdiff = x - v.sx;
var newW = v.w + xdiff;
if (newW > p.defwidth) {
this.gDiv.style.width = newW + 'px';
p.width = newW;
}
}
var newH = v.h + diff;
if ((newH > p.minheight || p.height < p.minheight) && !v.hgo) {
this.bDiv.style.height = newH + 'px';
p.height = newH;
this.fixHeight(newH);
}
v = null;
} else if (this.colCopy) {
$(this.dcol).addClass('thMove').removeClass('thOver');
if (e.pageX > this.hset.right || e.pageX < this.hset.left || e.pageY > this.hset.bottom || e.pageY < this.hset.top) {
//this.dragEnd();
$('body').css('cursor', 'move');
} else {
$('body').css('cursor', 'pointer');
}
$(this.colCopy).css({
top: e.pageY + 10,
left: e.pageX + 20,
display: 'block'
});
}
},
dragEnd: function () {
if (this.colresize) {
var n = this.colresize.n;
var nw = this.colresize.nw;
$('th:visible div:eq(' + n + ')', this.hDiv).css('width', nw);
$('tr', this.bDiv).each(
function () {
var $tdDiv = $('td:visible div:eq(' + n + ')', this);
$tdDiv.css('width', nw);
g.addTitleToCell($tdDiv);
}
);
this.hDiv.scrollLeft = this.bDiv.scrollLeft;
$('div:eq(' + n + ')', this.cDrag).siblings().show();
$('.dragging', this.cDrag).removeClass('dragging');
this.rePosDrag();
this.fixHeight();
this.colresize = false;
if ($.cookies) {
var name = p.colModel[n].name;// Store the widths in the cookies
$.cookie('flexiwidths/'+name, nw);
}
} else if (this.vresize) {
this.vresize = false;
} else if (this.colCopy) {
$(this.colCopy).remove();
if (this.dcolt !== null) {
if (this.dcoln > this.dcolt) $('th:eq(' + this.dcolt + ')', this.hDiv).before(this.dcol);
else $('th:eq(' + this.dcolt + ')', this.hDiv).after(this.dcol);
this.switchCol(this.dcoln, this.dcolt);
$(this.cdropleft).remove();
$(this.cdropright).remove();
this.rePosDrag();
if (p.onDragCol) {
p.onDragCol(this.dcoln, this.dcolt);
}
}
this.dcol = null;
this.hset = null;
this.dcoln = null;
this.dcolt = null;
this.colCopy = null;
$('.thMove', this.hDiv).removeClass('thMove');
$(this.cDrag).show();
}
$('body').css('cursor', 'default');
$('body').noSelect(false);
},
toggleCol: function (cid, visible) {
var ncol = $("th[axis='col" + cid + "']", this.hDiv)[0];
var n = $('thead th', g.hDiv).index(ncol);
var cb = $('input[value=' + cid + ']', g.nDiv)[0];
if (visible == null) {
visible = ncol.hidden;
}
if ($('input:checked', g.nDiv).length < p.minColToggle && !visible) {
return false;
}
if (visible) {
ncol.hidden = false;
$(ncol).show();
cb.checked = true;
} else {
ncol.hidden = true;
$(ncol).hide();
cb.checked = false;
}
$('tbody tr', t).each(
function () {
if (visible) {
$('td:eq(' + n + ')', this).show();
} else {
$('td:eq(' + n + ')', this).hide();
}
}
);
this.rePosDrag();
if (p.onToggleCol) {
p.onToggleCol(cid, visible);
}
return visible;
},
switchCol: function (cdrag, cdrop) { //switch columns
$('tbody tr', t).each(
function () {
if (cdrag > cdrop) $('td:eq(' + cdrop + ')', this).before($('td:eq(' + cdrag + ')', this));
else $('td:eq(' + cdrop + ')', this).after($('td:eq(' + cdrag + ')', this));
}
);
//switch order in nDiv
if (cdrag > cdrop) {
$('tr:eq(' + cdrop + ')', this.nDiv).before($('tr:eq(' + cdrag + ')', this.nDiv));
} else {
$('tr:eq(' + cdrop + ')', this.nDiv).after($('tr:eq(' + cdrag + ')', this.nDiv));
}
if (browser.msie && browser.version < 7.0) {
$('tr:eq(' + cdrop + ') input', this.nDiv)[0].checked = true;
}
this.hDiv.scrollLeft = this.bDiv.scrollLeft;
},
scroll: function () {
this.hDiv.scrollLeft = this.bDiv.scrollLeft;
this.rePosDrag();
},
addData: function (data) { //parse data
if (p.dataType == 'json') {
data = $.extend({rows: [], page: 0, total: 0}, data);
}
if (p.preProcess) {
data = p.preProcess(data);
}
$('.pReload', this.pDiv).removeClass('loading');
this.loading = false;
if (!data) {
$('.pPageStat', this.pDiv).html(p.errormsg);
if (p.onSuccess) p.onSuccess(this);
return false;
}
if (p.dataType == 'xml') {
p.total = +$('rows total', data).text();
} else {
p.total = data.total;
}
if (p.total === 0) {
$('tr, a, td, div', t).unbind();
$(t).empty();
p.pages = 1;
p.page = 1;
this.buildpager();
$('.pPageStat', this.pDiv).html(p.nomsg);
if (p.onSuccess) p.onSuccess(this);
return false;
}
p.pages = Math.ceil(p.total / p.rp);
if (p.dataType == 'xml') {
p.page = +$('rows page', data).text();
} else {
p.page = data.page;
}
this.buildpager();
//build new body
var tbody = document.createElement('tbody');
if (p.dataType == 'json') {
$.each(data.rows, function (i, row) {
var tr = document.createElement('tr');
var jtr = $(tr);
if (row.name) tr.name = row.name;
if (row.color) {
jtr.css('background',row.color);
} else {
if (i % 2 && p.striped) tr.className = 'erow';
}
if (row[p.idProperty]) {
tr.id = 'row' + row[p.idProperty];
jtr.attr('data-id', row[p.idProperty]);
}
$('thead tr:first th', g.hDiv).each( //add cell
function () {
var td = document.createElement('td');
var idx = $(this).attr('axis').substr(3);
td.align = this.align;
// If each row is the object itself (no 'cell' key)
if (typeof row.cell == 'undefined') {
td.innerHTML = row[p.colModel[idx].name];
} else {
// If the json elements aren't named (which is typical), use numeric order
var iHTML = '';
if (typeof row.cell[idx] != "undefined") {
iHTML = (row.cell[idx] !== null) ? row.cell[idx] : ''; //null-check for Opera-browser
} else {
iHTML = row.cell[p.colModel[idx].name];
}
td.innerHTML = p.__mw.datacol(p, $(this).attr('abbr'), iHTML); //use middleware datacol to format cols
}
// If the content has a <BGCOLOR=nnnnnn> option, decode it.
var offs = td.innerHTML.indexOf( '<BGCOLOR=' );
if( offs >0 ) {
$(td).css('background', text.substr(offs+7,7) );
}
$(td).attr('abbr', $(this).attr('abbr'));
$(tr).append(td);
td = null;
}
);
if ($('thead', this.gDiv).length < 1) {//handle if grid has no headers
for (idx = 0; idx < row.cell.length; idx++) {
var td = document.createElement('td');
// If the json elements aren't named (which is typical), use numeric order
if (typeof row.cell[idx] != "undefined") {
td.innerHTML = (row.cell[idx] != null) ? row.cell[idx] : '';//null-check for Opera-browser
} else {
td.innerHTML = row.cell[p.colModel[idx].name];
}
$(tr).append(td);
td = null;
}
}
$(tbody).append(tr);
tr = null;
});
} else if (p.dataType == 'xml') {
var i = 1;
$("rows row", data).each(function () {
i++;
var tr = document.createElement('tr');
if ($(this).attr('name')) tr.name = $(this).attr('name');
if ($(this).attr('color')) {
$(tr).css('background',$(this).attr('id'));
} else {
if (i % 2 && p.striped) tr.className = 'erow';
}
var nid = $(this).attr('id');
if (nid) {
tr.id = 'row' + nid;
}
nid = null;
var robj = this;
$('thead tr:first th', g.hDiv).each(function () {
var td = document.createElement('td');
var idx = $(this).attr('axis').substr(3);
td.align = this.align;
var text = $("cell:eq(" + idx + ")", robj).text();
var offs = text.indexOf( '<BGCOLOR=' );
if( offs >0 ) {
$(td).css('background', text.substr(offs+7,7) );
}
td.innerHTML = p.__mw.datacol(p, $(this).attr('abbr'), text); //use middleware datacol to format cols
$(td).attr('abbr', $(this).attr('abbr'));
$(tr).append(td);
td = null;
});
if ($('thead', this.gDiv).length < 1) {//handle if grid has no headers
$('cell', this).each(function () {
var td = document.createElement('td');
td.innerHTML = $(this).text();
$(tr).append(td);
td = null;
});
}
$(tbody).append(tr);
tr = null;
robj = null;
});
}
$('tr', t).unbind();
$(t).empty();
$(t).append(tbody);
this.addCellProp();
this.addRowProp();
this.rePosDrag();
tbody = null;
data = null;
i = null;
if (p.onSuccess) {
p.onSuccess(this);
}
if (p.hideOnSubmit) {
$(g.block).remove();
}
this.hDiv.scrollLeft = this.bDiv.scrollLeft;
if (browser.opera) {
$(t).css('visibility', 'visible');
}
},
changeSort: function (th) { //change sortorder
if (this.loading) {
return true;
}
$(g.nDiv).hide();
$(g.nBtn).hide();
if (p.sortname == $(th).attr('abbr')) {
if (p.sortorder == 'asc') {
p.sortorder = 'desc';
} else {
p.sortorder = 'asc';
}
}
$(th).addClass('sorted').siblings().removeClass('sorted');
$('.sdesc', this.hDiv).removeClass('sdesc');
$('.sasc', this.hDiv).removeClass('sasc');
$('div', th).addClass('s' + p.sortorder);
p.sortname = $(th).attr('abbr');
if (p.onChangeSort) {
p.onChangeSort(p.sortname, p.sortorder);
} else {
this.populate();
}
},
buildpager: function () { //rebuild pager based on new properties
$('.pcontrol input', this.pDiv).val(p.page);
$('.pcontrol span', this.pDiv).html(p.pages);
var r1 = p.total == 0 ? 0 : (p.page - 1) * p.rp + 1;
var r2 = r1 + p.rp - 1;
if (p.total < r2) {
r2 = p.total;
}
var stat = p.pagestat;
stat = stat.replace(/{from}/, r1);
stat = stat.replace(/{to}/, r2);
stat = stat.replace(/{total}/, p.total);
$('.pPageStat', this.pDiv).html(stat);
},
populate: function () { //get latest data
if (this.loading) {
return true;
}
if (p.onSubmit) {
var gh = p.onSubmit();
if (!gh) {
return false;
}
}
this.loading = true;
if (!p.url) {
return false;
}
$('.pPageStat', this.pDiv).html(p.procmsg);
$('.pReload', this.pDiv).addClass('loading');
$(g.block).css({
top: g.bDiv.offsetTop
});
if (p.hideOnSubmit) {
$(this.gDiv).prepend(g.block);
}
if (browser.opera) {
$(t).css('visibility', 'hidden');
}
if (!p.newp) {
p.newp = 1;
}
if (p.page > p.pages) {
p.page = p.pages;
}
var param = [{
name: 'page',
value: p.newp
}, {
name: 'rp',
value: p.rp
}, {
name: 'sortname',
value: p.sortname
}, {
name: 'sortorder',
value: p.sortorder
}, {
name: 'query',
value: p.query
}, {
name: 'qtype',
value: p.qtype
}];
if (p.params.length) {
for (var pi = 0; pi < p.params.length; pi++) {
param[param.length] = p.params[pi];
}
}
$.ajax({
type: p.method,
url: p.url,
data: param,
dataType: p.dataType,
success: function (data) {
g.addData(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
try {
if (p.onError) p.onError(XMLHttpRequest, textStatus, errorThrown);
} catch (e) {}
}
});
},
doSearch: function () {
p.query = $('input[name=q]', g.sDiv).val();
p.qtype = $('select[name=qtype]', g.sDiv).val();
p.newp = 1;
this.populate();
},
changePage: function (ctype) { //change page
if (this.loading) {
return true;
}
switch (ctype) {
case 'first':
p.newp = 1;
break;
case 'prev':
if (p.page > 1) {
p.newp = parseInt(p.page, 10) - 1;
}
break;
case 'next':
if (p.page < p.pages) {
p.newp = parseInt(p.page, 10) + 1;
}
break;
case 'last':
p.newp = p.pages;
break;
case 'input':
var nv = parseInt($('.pcontrol input', this.pDiv).val(), 10);
if (isNaN(nv)) {
nv = 1;
}
if (nv < 1) {
nv = 1;
} else if (nv > p.pages) {
nv = p.pages;
}
$('.pcontrol input', this.pDiv).val(nv);
p.newp = nv;
break;
}
if (p.newp == p.page) {
return false;
}
if (p.onChangePage) {
p.onChangePage(p.newp);
} else {
this.populate();
}
},
addCellProp: function () {
$('tbody tr td', g.bDiv).each(function () {
var tdDiv = document.createElement('div');
var n = $('td', $(this).parent()).index(this);
var pth = $('th:eq(' + n + ')', g.hDiv).get(0);
if (pth != null) {
if (p.sortname == $(pth).attr('abbr') && p.sortname) {
this.className = 'sorted';
}
$(tdDiv).css({
textAlign: pth.align,
width: $('div:first', pth)[0].style.width
});
if (pth.hidden) {
$(this).css('display', 'none');
}
}
if (p.nowrap == false) {
$(tdDiv).css('white-space', 'normal');
}
if (this.innerHTML == '') {
this.innerHTML = '&nbsp;';
}
tdDiv.innerHTML = this.innerHTML;
var prnt = $(this).parent()[0];
var pid = false;
if (prnt.id) {
pid = prnt.id.substr(3);
}
if (pth != null) {
if (pth.process) pth.process(tdDiv, pid);
}
$(this).empty().append(tdDiv).removeAttr('width'); //wrap content
g.addTitleToCell(tdDiv);
});
},
getCellDim: function (obj) {// get cell prop for editable event
var ht = parseInt($(obj).height(), 10);
var pht = parseInt($(obj).parent().height(), 10);
var wt = parseInt(obj.style.width, 10);
var pwt = parseInt($(obj).parent().width(), 10);
var top = obj.offsetParent.offsetTop;
var left = obj.offsetParent.offsetLeft;
var pdl = parseInt($(obj).css('paddingLeft'), 10);
var pdt = parseInt($(obj).css('paddingTop'), 10);
return {
ht: ht,
wt: wt,
top: top,
left: left,
pdl: pdl,
pdt: pdt,
pht: pht,
pwt: pwt
};
},
addRowProp: function () {
$('tbody tr', g.bDiv).on('click', function (e) {
var obj = (e.target || e.srcElement);
if (obj.href || obj.type) return true;
if (e.ctrlKey || e.metaKey) {
// mousedown already took care of this case
return;
}
$(this).toggleClass('trSelected');
if (p.singleSelect && ! g.multisel) {
$(this).siblings().removeClass('trSelected');
}
}).on('mousedown', function (e) {
if (e.shiftKey) {
$(this).toggleClass('trSelected');
g.multisel = true;
this.focus();
$(g.gDiv).noSelect();
}
if (e.ctrlKey || e.metaKey) {
$(this).toggleClass('trSelected');
g.multisel = true;
this.focus();
}
}).on('mouseup', function (e) {
if (g.multisel && ! (e.ctrlKey || e.metaKey)) {
g.multisel = false;
$(g.gDiv).noSelect(false);
}
}).on('dblclick', function () {
if (p.onDoubleClick) {
p.onDoubleClick(this, g, p);
}
}).hover(function (e) {
if (g.multisel && e.shiftKey) {
$(this).toggleClass('trSelected');
}
}, function () {});
if (browser.msie && browser.version < 7.0) {
$(this).hover(function () {
$(this).addClass('trOver');
}, function () {
$(this).removeClass('trOver');
});
}
},
combo_flag: true,
combo_resetIndex: function(selObj)
{
if(this.combo_flag) {
selObj.selectedIndex = 0;
}
this.combo_flag = true;
},
combo_doSelectAction: function(selObj)
{
eval( selObj.options[selObj.selectedIndex].value );
selObj.selectedIndex = 0;
this.combo_flag = false;
},
//Add title attribute to div if cell contents is truncated
addTitleToCell: function(tdDiv) {
if(p.addTitleToCell) {
var $span = $('<span />').css('display', 'none'),
$div = (tdDiv instanceof jQuery) ? tdDiv : $(tdDiv),
div_w = $div.outerWidth(),
span_w = 0;
$('body').children(':first').before($span);
$span.html($div.html());
$span.css('font-size', '' + $div.css('font-size'));
$span.css('padding-left', '' + $div.css('padding-left'));
span_w = $span.innerWidth();
$span.remove();
if(span_w > div_w) {
$div.attr('title', $div.text());
} else {
$div.removeAttr('title');
}
}
},
autoResizeColumn: function (obj) {
if(!p.dblClickResize) {
return;
}
var n = $('div', this.cDrag).index(obj),
$th = $('th:visible div:eq(' + n + ')', this.hDiv),
ol = parseInt(obj.style.left, 10),
ow = $th.width(),
nw = 0,
nl = 0,
$span = $('<span />');
$('body').children(':first').before($span);
$span.html($th.html());
$span.css('font-size', '' + $th.css('font-size'));
$span.css('padding-left', '' + $th.css('padding-left'));
$span.css('padding-right', '' + $th.css('padding-right'));
nw = $span.width();
$('tr', this.bDiv).each(function () {
var $tdDiv = $('td:visible div:eq(' + n + ')', this),
spanW = 0;
$span.html($tdDiv.html());
$span.css('font-size', '' + $tdDiv.css('font-size'));
$span.css('padding-left', '' + $tdDiv.css('padding-left'));
$span.css('padding-right', '' + $tdDiv.css('padding-right'));
spanW = $span.width();
nw = (spanW > nw) ? spanW : nw;
});
$span.remove();
nw = (p.minWidth > nw) ? p.minWidth : nw;
nl = ol + (nw - ow);
$('div:eq(' + n + ')', this.cDrag).css('left', nl);
this.colresize = {
nw: nw,
n: n
};
g.dragEnd();
},
pager: 0
};
g = p.getGridClass(g); //get the grid class
if (p.colModel) { //create model if any
thead = document.createElement('thead');
var tr = document.createElement('tr');
for (var i = 0; i < p.colModel.length; i++) {
var cm = p.colModel[i];
var th = document.createElement('th');
$(th).attr('axis', 'col' + i);
if( cm ) {// only use cm if its defined
if ($.cookies) {
var cookie_width = 'flexiwidths/'+cm.name;// Re-Store the widths in the cookies
if( $.cookie(cookie_width) != undefined ) {
cm.width = $.cookie(cookie_width);
}
}
if( cm.display != undefined ) {
th.innerHTML = cm.display;
}
if (cm.name && cm.sortable) {
$(th).attr('abbr', cm.name);
}
if (cm.align) {
th.align = cm.align;
}
if (cm.width) {
$(th).attr('width', cm.width);
}
if ($(cm).attr('hide')) {
th.hidden = true;
}
if (cm.process) {
th.process = cm.process;
}
} else {
th.innerHTML = "";
$(th).attr('width',30);
}
$(tr).append(th);
}
$(thead).append(tr);
$(t).prepend(thead);
} // end if p.colmodel
//init divs
g.gDiv = document.createElement('div'); //create global container
g.mDiv = document.createElement('div'); //create title container
g.hDiv = document.createElement('div'); //create header container
g.bDiv = document.createElement('div'); //create body container
g.vDiv = document.createElement('div'); //create grip
g.rDiv = document.createElement('div'); //create horizontal resizer
g.cDrag = document.createElement('div'); //create column drag
g.block = document.createElement('div'); //creat blocker
g.nDiv = document.createElement('div'); //create column show/hide popup
g.nBtn = document.createElement('div'); //create column show/hide button
g.iDiv = document.createElement('div'); //create editable layer
g.tDiv = document.createElement('div'); //create toolbar
g.sDiv = document.createElement('div');
g.pDiv = document.createElement('div'); //create pager container
if(p.colResize === false) { //don't display column drag if we are not using it
$(g.cDrag).css('display', 'none');
}
if (!p.usepager) {
g.pDiv.style.display = 'none';
}
g.hTable = document.createElement('table');
g.gDiv.className = 'flexigrid';
if (p.width != 'auto') {
g.gDiv.style.width = p.width + (isNaN(p.width) ? '' : 'px');
}
//add conditional classes
if (browser.msie) {
$(g.gDiv).addClass('ie');
}
if (p.novstripe) {
$(g.gDiv).addClass('novstripe');
}
$(t).before(g.gDiv);
$(g.gDiv).append(t);
//set toolbar
if (p.buttons) {
g.tDiv.className = 'tDiv';
var tDiv2 = document.createElement('div');
tDiv2.className = 'tDiv2';
for (var i = 0; i < p.buttons.length; i++) {
var btn = p.buttons[i];
if (!btn.separator) {
var btnDiv = document.createElement('div');
btnDiv.className = 'fbutton';
btnDiv.innerHTML = ("<div><span>") + (btn.hidename ? "&nbsp;" : btn.name) + ("</span></div>");
if (btn.bclass) $('span', btnDiv).addClass(btn.bclass).css({
paddingLeft: 20
});
if (btn.bimage) // if bimage defined, use its string as an image url for this buttons style (RS)
$('span',btnDiv).css( 'background', 'url('+btn.bimage+') no-repeat center left' );
$('span',btnDiv).css( 'paddingLeft', 20 );
if (btn.tooltip) // add title if exists (RS)
$('span',btnDiv)[0].title = btn.tooltip;
btnDiv.onpress = btn.onpress;
btnDiv.name = btn.name;
if (btn.id) {
btnDiv.id = btn.id;
}
if (btn.onpress) {
$(btnDiv).click(function () {
this.onpress(this.id || this.name, g.gDiv);
});
}
$(tDiv2).append(btnDiv);
if (browser.msie && browser.version < 7.0) {
$(btnDiv).hover(function () {
$(this).addClass('fbOver');
}, function () {
$(this).removeClass('fbOver');
});
}
} else {
$(tDiv2).append("<div class='btnseparator'></div>");
}
}
$(g.tDiv).append(tDiv2);
$(g.tDiv).append("<div style='clear:both'></div>");
$(g.gDiv).prepend(g.tDiv);
}
g.hDiv.className = 'hDiv';
// Define a combo button set with custom action'ed calls when clicked.
if( p.combobuttons && $(g.tDiv2) )
{
var btnDiv = document.createElement('div');
btnDiv.className = 'fbutton';
var tSelect = document.createElement('select');
$(tSelect).change( function () { g.combo_doSelectAction( tSelect ) } );
$(tSelect).click( function () { g.combo_resetIndex( tSelect) } );
tSelect.className = 'cselect';
$(btnDiv).append(tSelect);
for (i=0;i<p.combobuttons.length;i++)
{
var btn = p.combobuttons[i];
if (!btn.separator)
{
var btnOpt = document.createElement('option');
btnOpt.innerHTML = btn.name;
if (btn.bclass)
$(btnOpt)
.addClass(btn.bclass)
.css({paddingLeft:20})
;
if (btn.bimage) // if bimage defined, use its string as an image url for this buttons style (RS)
$(btnOpt).css( 'background', 'url('+btn.bimage+') no-repeat center left' );
$(btnOpt).css( 'paddingLeft', 20 );
if (btn.tooltip) // add title if exists (RS)
$(btnOpt)[0].title = btn.tooltip;
if (btn.onpress)
{
btnOpt.value = btn.onpress;
}
$(tSelect).append(btnOpt);
}
}
$('.tDiv2').append(btnDiv);
}
$(t).before(g.hDiv);
g.hTable.cellPadding = 0;
g.hTable.cellSpacing = 0;
$(g.hDiv).append('<div class="hDivBox"></div>');
$('div', g.hDiv).append(g.hTable);
var thead = $("thead:first", t).get(0);
if (thead) $(g.hTable).append(thead);
thead = null;
if (!p.colmodel) var ci = 0;
$('thead tr:first th', g.hDiv).each(function () {
var thdiv = document.createElement('div');
if ($(this).attr('abbr')) {
$(this).click(function (e) {
if (!$(this).hasClass('thOver')) return false;
var obj = (e.target || e.srcElement);
if (obj.href || obj.type) return true;
g.changeSort(this);
});
if ($(this).attr('abbr') == p.sortname) {
this.className = 'sorted';
thdiv.className = 's' + p.sortorder;
}
}
if (this.hidden) {
$(this).hide();
}
if (!p.colmodel) {
$(this).attr('axis', 'col' + ci++);
}
// if there isn't a default width, then the column headers don't match
// i'm sure there is a better way, but this at least stops it failing
if (this.width == '') {
this.width = 100;
}
$(thdiv).css({
textAlign: this.align,
width: this.width + 'px'
});
thdiv.innerHTML = this.innerHTML;
$(this).empty().append(thdiv).removeAttr('width').mousedown(function (e) {
g.dragStart('colMove', e, this);
}).hover(function () {
if (!g.colresize && !$(this).hasClass('thMove') && !g.colCopy) {
$(this).addClass('thOver');
}
if ($(this).attr('abbr') != p.sortname && !g.colCopy && !g.colresize && $(this).attr('abbr')) {
$('div', this).addClass('s' + p.sortorder);
} else if ($(this).attr('abbr') == p.sortname && !g.colCopy && !g.colresize && $(this).attr('abbr')) {
var no = (p.sortorder == 'asc') ? 'desc' : 'asc';
$('div', this).removeClass('s' + p.sortorder).addClass('s' + no);
}
if (g.colCopy) {
var n = $('th', g.hDiv).index(this);
if (n == g.dcoln) {
return false;
}
if (n < g.dcoln) {
$(this).append(g.cdropleft);
} else {
$(this).append(g.cdropright);
}
g.dcolt = n;
} else if (!g.colresize) {
var nv = $('th:visible', g.hDiv).index(this);
var onl = parseInt($('div:eq(' + nv + ')', g.cDrag).css('left'), 10);
var nw = jQuery(g.nBtn).outerWidth();
var nl = onl - nw + Math.floor(p.cgwidth / 2);
$(g.nDiv).hide();
$(g.nBtn).hide();
$(g.nBtn).css({
'left': nl,
top: g.hDiv.offsetTop
}).show();
var ndw = parseInt($(g.nDiv).width(), 10);
$(g.nDiv).css({
top: g.bDiv.offsetTop
});
if ((nl + ndw) > $(g.gDiv).width()) {
$(g.nDiv).css('left', onl - ndw + 1);
} else {
$(g.nDiv).css('left', nl);
}
if ($(this).hasClass('sorted')) {
$(g.nBtn).addClass('srtd');
} else {
$(g.nBtn).removeClass('srtd');
}
}
}, function () {
$(this).removeClass('thOver');
if ($(this).attr('abbr') != p.sortname) {
$('div', this).removeClass('s' + p.sortorder);
} else if ($(this).attr('abbr') == p.sortname) {
var no = (p.sortorder == 'asc') ? 'desc' : 'asc';
$('div', this).addClass('s' + p.sortorder).removeClass('s' + no);
}
if (g.colCopy) {
$(g.cdropleft).remove();
$(g.cdropright).remove();
g.dcolt = null;
}
}); //wrap content
});
//set bDiv
g.bDiv.className = 'bDiv';
$(t).before(g.bDiv);
$(g.bDiv).css({
height: (p.height == 'auto') ? 'auto' : p.height + "px"
}).scroll(function (e) {
g.scroll()
}).append(t);
if (p.height == 'auto') {
$('table', g.bDiv).addClass('autoht');
}
//add td & row properties
g.addCellProp();
g.addRowProp();
//set cDrag only if we are using it
if (p.colResize === true) {
var cdcol = $('thead tr:first th:first', g.hDiv).get(0);
if(cdcol !== null) {
g.cDrag.className = 'cDrag';
g.cdpad = 0;
g.cdpad += (isNaN(parseInt($('div', cdcol).css('borderLeftWidth'), 10)) ? 0 : parseInt($('div', cdcol).css('borderLeftWidth'), 10));
g.cdpad += (isNaN(parseInt($('div', cdcol).css('borderRightWidth'), 10)) ? 0 : parseInt($('div', cdcol).css('borderRightWidth'), 10));
g.cdpad += (isNaN(parseInt($('div', cdcol).css('paddingLeft'), 10)) ? 0 : parseInt($('div', cdcol).css('paddingLeft'), 10));
g.cdpad += (isNaN(parseInt($('div', cdcol).css('paddingRight'), 10)) ? 0 : parseInt($('div', cdcol).css('paddingRight'), 10));
g.cdpad += (isNaN(parseInt($(cdcol).css('borderLeftWidth'), 10)) ? 0 : parseInt($(cdcol).css('borderLeftWidth'), 10));
g.cdpad += (isNaN(parseInt($(cdcol).css('borderRightWidth'), 10)) ? 0 : parseInt($(cdcol).css('borderRightWidth'), 10));
g.cdpad += (isNaN(parseInt($(cdcol).css('paddingLeft'), 10)) ? 0 : parseInt($(cdcol).css('paddingLeft'), 10));
g.cdpad += (isNaN(parseInt($(cdcol).css('paddingRight'), 10)) ? 0 : parseInt($(cdcol).css('paddingRight'), 10));
$(g.bDiv).before(g.cDrag);
var cdheight = $(g.bDiv).height();
var hdheight = $(g.hDiv).height();
$(g.cDrag).css({
top: -hdheight + 'px'
});
$('thead tr:first th', g.hDiv).each(function() {
var cgDiv = document.createElement('div');
$(g.cDrag).append(cgDiv);
if (!p.cgwidth) {
p.cgwidth = $(cgDiv).width();
}
$(cgDiv).css({
height: cdheight + hdheight
}).mousedown(function(e) {
g.dragStart('colresize', e, this);
}).dblclick(function(e) {
g.autoResizeColumn(this);
});
if (browser.msie && browser.version < 7.0) {
g.fixHeight($(g.gDiv).height());
$(cgDiv).hover(function() {
g.fixHeight();
$(this).addClass('dragging');
}, function() {
if(!g.colresize) {
$(this).removeClass('dragging');
}
});
}
});
}
}
//add strip
if (p.striped) {
$('tbody tr:odd', g.bDiv).addClass('erow');
}
if (p.resizable && p.height != 'auto') {
g.vDiv.className = 'vGrip';
$(g.vDiv).mousedown(function (e) {
g.dragStart('vresize', e);
}).html('<span></span>');
$(g.bDiv).after(g.vDiv);
}
if (p.resizable && p.width != 'auto' && !p.nohresize) {
g.rDiv.className = 'hGrip';
$(g.rDiv).mousedown(function (e) {
g.dragStart('vresize', e, true);
}).html('<span></span>').css('height', $(g.gDiv).height());
if (browser.msie && browser.version < 7.0) {
$(g.rDiv).hover(function () {
$(this).addClass('hgOver');
}, function () {
$(this).removeClass('hgOver');
});
}
$(g.gDiv).append(g.rDiv);
}
// add pager
if (p.usepager) {
g.pDiv.className = 'pDiv';
g.pDiv.innerHTML = '<div class="pDiv2"></div>';
$(g.bDiv).after(g.pDiv);
var html = ' <div class="pGroup"> <div class="pFirst pButton"><span></span></div><div class="pPrev pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pcontrol">' + p.pagetext + ' <input type="text" size="4" value="1" /> ' + p.outof + ' <span> 1 </span></span></div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pNext pButton"><span></span></div><div class="pLast pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pReload pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pPageStat"></span></div>';
$('div', g.pDiv).html(html);
$('.pReload', g.pDiv).click(function () {
g.populate();
});
$('.pFirst', g.pDiv).click(function () {
g.changePage('first');
});
$('.pPrev', g.pDiv).click(function () {
g.changePage('prev');
});
$('.pNext', g.pDiv).click(function () {
g.changePage('next');
});
$('.pLast', g.pDiv).click(function () {
g.changePage('last');
});
$('.pcontrol input', g.pDiv).keydown(function (e) {
if (e.keyCode == 13) {
g.changePage('input');
}
});
if (browser.msie && browser.version < 7) $('.pButton', g.pDiv).hover(function () {
$(this).addClass('pBtnOver');
}, function () {
$(this).removeClass('pBtnOver');
});
if (p.useRp) {
var opt = '',
sel = '';
for (var nx = 0; nx < p.rpOptions.length; nx++) {
if (p.rp == p.rpOptions[nx]) sel = 'selected="selected"';
else sel = '';
opt += "<option value='" + p.rpOptions[nx] + "' " + sel + " >" + p.rpOptions[nx] + "&nbsp;&nbsp;</option>";
}
$('.pDiv2', g.pDiv).prepend("<div class='pGroup'><select name='rp'>" + opt + "</select></div> <div class='btnseparator'></div>");
$('select', g.pDiv).change(function () {
if (p.onRpChange) {
p.onRpChange(+this.value);
} else {
p.newp = 1;
p.rp = +this.value;
g.populate();
}
});
}
//add search button
if (p.searchitems) {
$('.pDiv2', g.pDiv).prepend("<div class='pGroup'> <div class='pSearch pButton'><span></span></div> </div> <div class='btnseparator'></div>");
$('.pSearch', g.pDiv).click(function () {
$(g.sDiv).slideToggle('fast', function () {
$('.sDiv:visible input:first', g.gDiv).trigger('focus');
});
});
//add search box
g.sDiv.className = 'sDiv';
var sitems = p.searchitems;
var sopt = '', sel = '';
for (var s = 0; s < sitems.length; s++) {
if (p.qtype === '' && sitems[s].isdefault === true) {
p.qtype = sitems[s].name;
sel = 'selected="selected"';
} else {
sel = '';
}
sopt += "<option value='" + sitems[s].name + "' " + sel + " >" + sitems[s].display + "&nbsp;&nbsp;</option>";
}
if (p.qtype === '') {
p.qtype = sitems[0].name;
}
$(g.sDiv).append("<div class='sDiv2'>" + p.findtext +
" <input type='text' value='" + p.query +"' size='30' name='q' class='qsbox' /> "+
" <select name='qtype'>" + sopt + "</select></div>");
//Split into separate selectors because of bug in jQuery 1.3.2
$('input[name=q]', g.sDiv).keydown(function (e) {
if (e.keyCode == 13) {
g.doSearch();
}
});
$('select[name=qtype]', g.sDiv).keydown(function (e) {
if (e.keyCode == 13) {
g.doSearch();
}
});
$('input[value=Clear]', g.sDiv).click(function () {
$('input[name=q]', g.sDiv).val('');
p.query = '';
g.doSearch();
});
$(g.bDiv).after(g.sDiv);
}
}
$(g.pDiv, g.sDiv).append("<div style='clear:both'></div>");
// add title
if (p.title) {
g.mDiv.className = 'mDiv';
g.mDiv.innerHTML = '<div class="ftitle">' + p.title + '</div>';
$(g.gDiv).prepend(g.mDiv);
if (p.showTableToggleBtn) {
$(g.mDiv).append('<div class="ptogtitle" title="Minimize/Maximize Table"><span></span></div>');
$('div.ptogtitle', g.mDiv).click(function () {
$(g.gDiv).toggleClass('hideBody');
$(this).toggleClass('vsble');
});
}
}
//setup cdrops
g.cdropleft = document.createElement('span');
g.cdropleft.className = 'cdropleft';
g.cdropright = document.createElement('span');
g.cdropright.className = 'cdropright';
//add block
g.block.className = 'gBlock';
var gh = $(g.bDiv).height();
var gtop = g.bDiv.offsetTop;
$(g.block).css({
width: g.bDiv.style.width,
height: gh,
background: 'white',
position: 'relative',
marginBottom: (gh * -1),
zIndex: 1,
top: gtop,
left: '0px'
});
$(g.block).fadeTo(0, p.blockOpacity);
// add column control
if ($('th', g.hDiv).length) {
g.nDiv.className = 'nDiv';
g.nDiv.innerHTML = "<table cellpadding='0' cellspacing='0'><tbody></tbody></table>";
$(g.nDiv).css({
marginBottom: (gh * -1),
display: 'none',
top: gtop
}).noSelect();
var cn = 0;
$('th div', g.hDiv).each(function () {
var kcol = $("th[axis='col" + cn + "']", g.hDiv)[0];
var chk = 'checked="checked"';
if (kcol.style.display == 'none') {
chk = '';
}
$('tbody', g.nDiv).append('<tr><td class="ndcol1"><input type="checkbox" ' + chk + ' class="togCol" value="' + cn + '" /></td><td class="ndcol2">' + this.innerHTML + '</td></tr>');
cn++;
});
if (browser.msie && browser.version < 7.0) $('tr', g.nDiv).hover(function () {
$(this).addClass('ndcolover');
}, function () {
$(this).removeClass('ndcolover');
});
$('td.ndcol2', g.nDiv).click(function () {
if ($('input:checked', g.nDiv).length <= p.minColToggle && $(this).prev().find('input')[0].checked) return false;
return g.toggleCol($(this).prev().find('input').val());
});
$('input.togCol', g.nDiv).click(function () {
if ($('input:checked', g.nDiv).length < p.minColToggle && this.checked === false) return false;
$(this).parent().next().trigger('click');
});
$(g.gDiv).prepend(g.nDiv);
$(g.nBtn).addClass('nBtn')
.html('<div></div>')
.attr('title', 'Hide/Show Columns')
.click(function () {
$(g.nDiv).toggle();
return true;
}
);
if (p.showToggleBtn) {
$(g.gDiv).prepend(g.nBtn);
}
}
// add date edit layer
$(g.iDiv).addClass('iDiv').css({
display: 'none'
});
$(g.bDiv).append(g.iDiv);
// add flexigrid events
$(g.bDiv).hover(function () {
$(g.nDiv).hide();
$(g.nBtn).hide();
}, function () {
if (g.multisel) {
g.multisel = false;
}
});
$(g.gDiv).hover(function () {}, function () {
$(g.nDiv).hide();
$(g.nBtn).hide();
});
//add document events
$(document).mousemove(function (e) {
g.dragMove(e);
}).mouseup(function (e) {
g.dragEnd();
}).hover(function () {}, function () {
g.dragEnd();
});
//browser adjustments
if (browser.msie && browser.version < 7.0) {
$('.hDiv,.bDiv,.mDiv,.pDiv,.vGrip,.tDiv, .sDiv', g.gDiv).css({
width: '100%'
});
$(g.gDiv).addClass('ie6');
if (p.width != 'auto') {
$(g.gDiv).addClass('ie6fullwidthbug');
}
}
g.rePosDrag();
g.fixHeight();
//make grid functions accessible
t.p = p;
t.grid = g;
// load data
if (p.url && p.autoload) {
g.populate();
}
return t;
};
var docloaded = false;
$(document).ready(function () {
docloaded = true;
});
$.fn.flexigrid = function (p) {
return this.each(function () {
if (!docloaded) {
$(this).hide();
var t = this;
$(document).ready(function () {
$.addFlex(t, p);
});
} else {
$.addFlex(this, p);
}
});
}; //end flexigrid
$.fn.flexReload = function (p) { // function to reload grid
return this.each(function () {
if (this.grid && this.p.url) this.grid.populate();
});
}; //end flexReload
$.fn.flexOptions = function (p) { //function to update general options
return this.each(function () {
if (this.grid) $.extend(this.p, p);
});
}; //end flexOptions
$.fn.flexToggleCol = function (cid, visible) { // function to reload grid
return this.each(function () {
if (this.grid) this.grid.toggleCol(cid, visible);
});
}; //end flexToggleCol
$.fn.flexAddData = function (data) { // function to add data to grid
return this.each(function () {
if (this.grid) this.grid.addData(data);
});
};
$.fn.noSelect = function (p) { //no select plugin by me :-)
var prevent = (p === null) ? true : p;
if (prevent) {
return this.each(function () {
if (browser.msie || browser.safari) $(this).bind('selectstart', function () {
return false;
});
else if (browser.mozilla) {
$(this).css('MozUserSelect', 'none');
$('body').trigger('focus');
} else if (browser.opera) $(this).bind('mousedown', function () {
return false;
});
else $(this).attr('unselectable', 'on');
});
} else {
return this.each(function () {
if (browser.msie || browser.safari) $(this).unbind('selectstart');
else if (browser.mozilla) $(this).css('MozUserSelect', 'inherit');
else if (browser.opera) $(this).unbind('mousedown');
else $(this).removeAttr('unselectable', 'on');
});
}
}; //end noSelect
$.fn.flexSearch = function(p) { // function to search grid
return this.each( function() { if (this.grid&&this.p.searchitems) this.grid.doSearch(); });
}; //end flexSearch
$.fn.selectedRows = function (p) { // Returns the selected rows as an array, taken and adapted from http://stackoverflow.com/questions/11868404/flexigrid-get-selected-row-columns-values
var arReturn = [];
var arRow = [];
var selector = $(this.selector + ' .trSelected');
$(selector).each(function (i, row) {
arRow = [];
var idr = $(row).data('id');
$.each(row.cells, function (c, cell) {
var col = cell.abbr;
var val = cell.firstChild.innerHTML;
if (val == '&nbsp;') val = ''; // Trim the content
var idx = cell.cellIndex;
arRow.push({
Column: col, // Column identifier
Value: val, // Column value
CellIndex: idx, // Cell index
RowIdentifier: idr // Identifier of this row element
});
});
arReturn.push(arRow);
});
return arReturn;
};
})(jQuery);
web/media/js/flexigrid.pack.js
1
(function($){var browser=$.browser;if(!browser){function uaMatch(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}}var matched=uaMatch(navigator.userAgent);browser={};if(matched.browser){browser[matched.browser]=true;browser.version=matched.version}if(browser.chrome){browser.webkit=true}else if(browser.webkit){browser.safari=true}}if(typeof $.support.selectstart!="function"){$.support.selectstart="onselectstart"in document.createElement("div")}if(typeof $.fn.disableSelection!="function"){$.fn.disableSelection=function(){return this.bind(($.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})}}$.addFlex=function(t,p){if(t.grid)return false;p=$.extend({height:200,width:"auto",striped:true,novstripe:false,minwidth:30,minheight:80,resizable:true,url:false,method:"POST",dataType:"xml",errormsg:"Connection Error",usepager:false,nowrap:true,page:1,total:1,useRp:true,rp:15,rpOptions:[10,20,30,50,100],title:false,idProperty:"id",pagestat:"Displaying {from} to {to} of {total} items",pagetext:"Page",outof:"of",findtext:"Find",params:[],procmsg:"Processing, please wait ...",query:"",qtype:"",nomsg:"No items",minColToggle:1,showToggleBtn:true,hideOnSubmit:true,autoload:true,blockOpacity:.5,preProcess:false,addTitleToCell:false,dblClickResize:false,onDragCol:false,onToggleCol:false,onChangeSort:false,onDoubleClick:false,onSuccess:false,onError:false,onSubmit:false,__mw:{datacol:function(e,t,n){var r=typeof e.datacol[t]=="function"?e.datacol[t](n):n;if(typeof e.datacol["*"]=="function"){return e.datacol["*"](r)}else{return r}}},getGridClass:function(e){return e},datacol:{},colResize:true,colMove:true},p);$(t).show().attr({cellPadding:0,cellSpacing:0,border:0}).removeAttr("width");var g={hset:{},rePosDrag:function(){var e=0-this.hDiv.scrollLeft;if(this.hDiv.scrollLeft>0)e-=Math.floor(p.cgwidth/2);$(g.cDrag).css({top:g.hDiv.offsetTop+1});var t=this.cdpad;var n=0;$("div",g.cDrag).hide();$("thead tr:first th:visible",this.hDiv).each(function(){var r=$("thead tr:first th:visible",g.hDiv).index(this);var i=parseInt($("div",this).width());if(e==0)e-=Math.floor(p.cgwidth/2);i=i+e+t;if(isNaN(i)){i=0}$("div:eq("+r+")",g.cDrag).css({left:(!browser.mozilla?i-n:i)+"px"}).show();e=i;n++})},fixHeight:function(e){e=false;if(!e)e=$(g.bDiv).height();var t=$(this.hDiv).height();$("div",this.cDrag).each(function(){$(this).height(e+t)});var n=parseInt($(g.nDiv).height(),10);if(n>e)$(g.nDiv).height(e).width(200);else $(g.nDiv).height("auto").width("auto");$(g.block).css({height:e,marginBottom:e*-1});var r=g.bDiv.offsetTop+e;if(p.height!="auto"&&p.resizable)r=g.vDiv.offsetTop;$(g.rDiv).css({height:r})},dragStart:function(e,t,n){if(e=="colresize"&&p.colResize===true){$(g.nDiv).hide();$(g.nBtn).hide();var r=$("div",this.cDrag).index(n);var i=$("th:visible div:eq("+r+")",this.hDiv).width();$(n).addClass("dragging").siblings().hide();$(n).prev().addClass("dragging").show();this.colresize={startX:t.pageX,ol:parseInt(n.style.left,10),ow:i,n:r};$("body").css("cursor","col-resize")}else if(e=="vresize"){var s=false;$("body").css("cursor","row-resize");if(n){s=true;$("body").css("cursor","col-resize")}this.vresize={h:p.height,sy:t.pageY,w:p.width,sx:t.pageX,hgo:s}}else if(e=="colMove"){$(t.target).disableSelection();if(p.colMove===true){$(g.nDiv).hide();$(g.nBtn).hide();this.hset=$(this.hDiv).offset();this.hset.right=this.hset.left+$("table",this.hDiv).width();this.hset.bottom=this.hset.top+$("table",this.hDiv).height();this.dcol=n;this.dcoln=$("th",this.hDiv).index(n);this.colCopy=document.createElement("div");this.colCopy.className="colCopy";this.colCopy.innerHTML=n.innerHTML;if(browser.msie){this.colCopy.className="colCopy ie"}$(this.colCopy).css({position:"absolute","float":"left",display:"none",textAlign:n.align});$("body").append(this.colCopy);$(this.cDrag).hide()}}$("body").noSelect()},dragMove:function(e){if(this.colresize){var t=this.colresize.n;var n=e.pageX-this.colresize.startX;var r=this.colresize.ol+n;var i=this.colresize.ow+n;if(i>p.minwidth){$("div:eq("+t+")",this.cDrag).css("left",r);this.colresize.nw=i}}else if(this.vresize){var s=this.vresize;var o=e.pageY;var n=o-s.sy;if(!p.defwidth)p.defwidth=p.width;if(p.width!="auto"&&!p.nohresize&&s.hgo){var u=e.pageX;var a=u-s.sx;var f=s.w+a;if(f>p.defwidth){this.gDiv.style.width=f+"px";p.width=f}}var l=s.h+n;if((l>p.minheight||p.height<p.minheight)&&!s.hgo){this.bDiv.style.height=l+"px";p.height=l;this.fixHeight(l)}s=null}else if(this.colCopy){$(this.dcol).addClass("thMove").removeClass("thOver");if(e.pageX>this.hset.right||e.pageX<this.hset.left||e.pageY>this.hset.bottom||e.pageY<this.hset.top){$("body").css("cursor","move")}else{$("body").css("cursor","pointer")}$(this.colCopy).css({top:e.pageY+10,left:e.pageX+20,display:"block"})}},dragEnd:function(){if(this.colresize){var e=this.colresize.n;var t=this.colresize.nw;$("th:visible div:eq("+e+")",this.hDiv).css("width",t);$("tr",this.bDiv).each(function(){var n=$("td:visible div:eq("+e+")",this);n.css("width",t);g.addTitleToCell(n)});this.hDiv.scrollLeft=this.bDiv.scrollLeft;$("div:eq("+e+")",this.cDrag).siblings().show();$(".dragging",this.cDrag).removeClass("dragging");this.rePosDrag();this.fixHeight();this.colresize=false;if($.cookies){var n=p.colModel[e].name;$.cookie("flexiwidths/"+n,t)}}else if(this.vresize){this.vresize=false}else if(this.colCopy){$(this.colCopy).remove();if(this.dcolt!==null){if(this.dcoln>this.dcolt)$("th:eq("+this.dcolt+")",this.hDiv).before(this.dcol);else $("th:eq("+this.dcolt+")",this.hDiv).after(this.dcol);this.switchCol(this.dcoln,this.dcolt);$(this.cdropleft).remove();$(this.cdropright).remove();this.rePosDrag();if(p.onDragCol){p.onDragCol(this.dcoln,this.dcolt)}}this.dcol=null;this.hset=null;this.dcoln=null;this.dcolt=null;this.colCopy=null;$(".thMove",this.hDiv).removeClass("thMove");$(this.cDrag).show()}$("body").css("cursor","default");$("body").noSelect(false)},toggleCol:function(e,n){var r=$("th[axis='col"+e+"']",this.hDiv)[0];var i=$("thead th",g.hDiv).index(r);var s=$("input[value="+e+"]",g.nDiv)[0];if(n==null){n=r.hidden}if($("input:checked",g.nDiv).length<p.minColToggle&&!n){return false}if(n){r.hidden=false;$(r).show();s.checked=true}else{r.hidden=true;$(r).hide();s.checked=false}$("tbody tr",t).each(function(){if(n){$("td:eq("+i+")",this).show()}else{$("td:eq("+i+")",this).hide()}});this.rePosDrag();if(p.onToggleCol){p.onToggleCol(e,n)}return n},switchCol:function(e,n){$("tbody tr",t).each(function(){if(e>n)$("td:eq("+n+")",this).before($("td:eq("+e+")",this));else $("td:eq("+n+")",this).after($("td:eq("+e+")",this))});if(e>n){$("tr:eq("+n+")",this.nDiv).before($("tr:eq("+e+")",this.nDiv))}else{$("tr:eq("+n+")",this.nDiv).after($("tr:eq("+e+")",this.nDiv))}if(browser.msie&&browser.version<7){$("tr:eq("+n+") input",this.nDiv)[0].checked=true}this.hDiv.scrollLeft=this.bDiv.scrollLeft},scroll:function(){this.hDiv.scrollLeft=this.bDiv.scrollLeft;this.rePosDrag()},addData:function(e){if(p.dataType=="json"){e=$.extend({rows:[],page:0,total:0},e)}if(p.preProcess){e=p.preProcess(e)}$(".pReload",this.pDiv).removeClass("loading");this.loading=false;if(!e){$(".pPageStat",this.pDiv).html(p.errormsg);if(p.onSuccess)p.onSuccess(this);return false}if(p.dataType=="xml"){p.total=+$("rows total",e).text()}else{p.total=e.total}if(p.total===0){$("tr, a, td, div",t).unbind();$(t).empty();p.pages=1;p.page=1;this.buildpager();$(".pPageStat",this.pDiv).html(p.nomsg);if(p.onSuccess)p.onSuccess(this);return false}p.pages=Math.ceil(p.total/p.rp);if(p.dataType=="xml"){p.page=+$("rows page",e).text()}else{p.page=e.page}this.buildpager();var n=document.createElement("tbody");if(p.dataType=="json"){$.each(e.rows,function(e,t){var r=document.createElement("tr");var i=$(r);if(t.name)r.name=t.name;if(t.color){i.css("background",t.color)}else{if(e%2&&p.striped)r.className="erow"}if(t[p.idProperty]){r.id="row"+t[p.idProperty];i.attr("data-id",t[p.idProperty])}$("thead tr:first th",g.hDiv).each(function(){var e=document.createElement("td");var n=$(this).attr("axis").substr(3);e.align=this.align;if(typeof t.cell=="undefined"){e.innerHTML=t[p.colModel[n].name]}else{var i="";if(typeof t.cell[n]!="undefined"){i=t.cell[n]!==null?t.cell[n]:""}else{i=t.cell[p.colModel[n].name]}e.innerHTML=p.__mw.datacol(p,$(this).attr("abbr"),i)}var s=e.innerHTML.indexOf("<BGCOLOR=");if(s>0){$(e).css("background",text.substr(s+7,7))}$(e).attr("abbr",$(this).attr("abbr"));$(r).append(e);e=null});if($("thead",this.gDiv).length<1){for(idx=0;idx<t.cell.length;idx++){var s=document.createElement("td");if(typeof t.cell[idx]!="undefined"){s.innerHTML=t.cell[idx]!=null?t.cell[idx]:""}else{s.innerHTML=t.cell[p.colModel[idx].name]}$(r).append(s);s=null}}$(n).append(r);r=null})}else if(p.dataType=="xml"){var r=1;$("rows row",e).each(function(){r++;var e=document.createElement("tr");if($(this).attr("name"))e.name=$(this).attr("name");if($(this).attr("color")){$(e).css("background",$(this).attr("id"))}else{if(r%2&&p.striped)e.className="erow"}var t=$(this).attr("id");if(t){e.id="row"+t}t=null;var s=this;$("thead tr:first th",g.hDiv).each(function(){var t=document.createElement("td");var n=$(this).attr("axis").substr(3);t.align=this.align;var r=$("cell:eq("+n+")",s).text();var i=r.indexOf("<BGCOLOR=");if(i>0){$(t).css("background",r.substr(i+7,7))}t.innerHTML=p.__mw.datacol(p,$(this).attr("abbr"),r);$(t).attr("abbr",$(this).attr("abbr"));$(e).append(t);t=null});if($("thead",this.gDiv).length<1){$("cell",this).each(function(){var t=document.createElement("td");t.innerHTML=$(this).text();$(e).append(t);t=null})}$(n).append(e);e=null;s=null})}$("tr",t).unbind();$(t).empty();$(t).append(n);this.addCellProp();this.addRowProp();this.rePosDrag();n=null;e=null;r=null;if(p.onSuccess){p.onSuccess(this)}if(p.hideOnSubmit){$(g.block).remove()}this.hDiv.scrollLeft=this.bDiv.scrollLeft;if(browser.opera){$(t).css("visibility","visible")}},changeSort:function(e){if(this.loading){return true}$(g.nDiv).hide();$(g.nBtn).hide();if(p.sortname==$(e).attr("abbr")){if(p.sortorder=="asc"){p.sortorder="desc"}else{p.sortorder="asc"}}$(e).addClass("sorted").siblings().removeClass("sorted");$(".sdesc",this.hDiv).removeClass("sdesc");$(".sasc",this.hDiv).removeClass("sasc");$("div",e).addClass("s"+p.sortorder);p.sortname=$(e).attr("abbr");if(p.onChangeSort){p.onChangeSort(p.sortname,p.sortorder)}else{this.populate()}},buildpager:function(){$(".pcontrol input",this.pDiv).val(p.page);$(".pcontrol span",this.pDiv).html(p.pages);var e=(p.page-1)*p.rp+1;var t=e+p.rp-1;if(p.total<t){t=p.total}var n=p.pagestat;n=n.replace(/{from}/,e);n=n.replace(/{to}/,t);n=n.replace(/{total}/,p.total);$(".pPageStat",this.pDiv).html(n)},populate:function(){if(this.loading){return true}if(p.onSubmit){var e=p.onSubmit();if(!e){return false}}this.loading=true;if(!p.url){return false}$(".pPageStat",this.pDiv).html(p.procmsg);$(".pReload",this.pDiv).addClass("loading");$(g.block).css({top:g.bDiv.offsetTop});if(p.hideOnSubmit){$(this.gDiv).prepend(g.block)}if(browser.opera){$(t).css("visibility","hidden")}if(!p.newp){p.newp=1}if(p.page>p.pages){p.page=p.pages}var n=[{name:"page",value:p.newp},{name:"rp",value:p.rp},{name:"sortname",value:p.sortname},{name:"sortorder",value:p.sortorder},{name:"query",value:p.query},{name:"qtype",value:p.qtype}];if(p.params.length){for(var r=0;r<p.params.length;r++){n[n.length]=p.params[r]}}$.ajax({type:p.method,url:p.url,data:n,dataType:p.dataType,success:function(e){g.addData(e)},error:function(e,t,n){try{if(p.onError)p.onError(e,t,n)}catch(r){}}})},doSearch:function(){p.query=$("input[name=q]",g.sDiv).val();p.qtype=$("select[name=qtype]",g.sDiv).val();p.newp=1;this.populate()},changePage:function(e){if(this.loading){return true}switch(e){case"first":p.newp=1;break;case"prev":if(p.page>1){p.newp=parseInt(p.page,10)-1}break;case"next":if(p.page<p.pages){p.newp=parseInt(p.page,10)+1}break;case"last":p.newp=p.pages;break;case"input":var t=parseInt($(".pcontrol input",this.pDiv).val(),10);if(isNaN(t)){t=1}if(t<1){t=1}else if(t>p.pages){t=p.pages}$(".pcontrol input",this.pDiv).val(t);p.newp=t;break}if(p.newp==p.page){return false}if(p.onChangePage){p.onChangePage(p.newp)}else{this.populate()}},addCellProp:function(){$("tbody tr td",g.bDiv).each(function(){var e=document.createElement("div");var t=$("td",$(this).parent()).index(this);var n=$("th:eq("+t+")",g.hDiv).get(0);if(n!=null){if(p.sortname==$(n).attr("abbr")&&p.sortname){this.className="sorted"}$(e).css({textAlign:n.align,width:$("div:first",n)[0].style.width});if(n.hidden){$(this).css("display","none")}}if(p.nowrap==false){$(e).css("white-space","normal")}if(this.innerHTML==""){this.innerHTML=" "}e.innerHTML=this.innerHTML;var r=$(this).parent()[0];var i=false;if(r.id){i=r.id.substr(3)}if(n!=null){if(n.process)n.process(e,i)}$(this).empty().append(e).removeAttr("width");g.addTitleToCell(e)})},getCellDim:function(e){var t=parseInt($(e).height(),10);var n=parseInt($(e).parent().height(),10);var r=parseInt(e.style.width,10);var i=parseInt($(e).parent().width(),10);var s=e.offsetParent.offsetTop;var o=e.offsetParent.offsetLeft;var u=parseInt($(e).css("paddingLeft"),10);var a=parseInt($(e).css("paddingTop"),10);return{ht:t,wt:r,top:s,left:o,pdl:u,pdt:a,pht:n,pwt:i}},addRowProp:function(){$("tbody tr",g.bDiv).on("click",function(e){var t=e.target||e.srcElement;if(t.href||t.type)return true;if(e.ctrlKey||e.metaKey){return}$(this).toggleClass("trSelected");if(p.singleSelect&&!g.multisel){$(this).siblings().removeClass("trSelected")}}).on("mousedown",function(e){if(e.shiftKey){$(this).toggleClass("trSelected");g.multisel=true;this.focus();$(g.gDiv).noSelect()}if(e.ctrlKey||e.metaKey){$(this).toggleClass("trSelected");g.multisel=true;this.focus()}}).on("mouseup",function(e){if(g.multisel&&!(e.ctrlKey||e.metaKey)){g.multisel=false;$(g.gDiv).noSelect(false)}}).on("dblclick",function(){$(this).addClass("trSelected");if(p.onDoubleClick){p.onDoubleClick(this,g,p)}}).hover(function(e){if(g.multisel&&e.shiftKey){$(this).toggleClass("trSelected")}},function(){});if(browser.msie&&browser.version<7){$(this).hover(function(){$(this).addClass("trOver")},function(){$(this).removeClass("trOver")})}},combo_flag:true,combo_resetIndex:function(e){if(this.combo_flag){e.selectedIndex=0}this.combo_flag=true},combo_doSelectAction:function(selObj){eval(selObj.options[selObj.selectedIndex].value);selObj.selectedIndex=0;this.combo_flag=false},addTitleToCell:function(e){if(p.addTitleToCell){var t=$("<span />").css("display","none"),n=e instanceof jQuery?e:$(e),r=n.outerWidth(),i=0;$("body").children(":first").before(t);t.html(n.html());t.css("font-size",""+n.css("font-size"));t.css("padding-left",""+n.css("padding-left"));i=t.innerWidth();t.remove();if(i>r){n.attr("title",n.text())}else{n.removeAttr("title")}}},autoResizeColumn:function(e){if(!p.dblClickResize){return}var t=$("div",this.cDrag).index(e),n=$("th:visible div:eq("+t+")",this.hDiv),r=parseInt(e.style.left,10),i=n.width(),s=0,o=0,u=$("<span />");$("body").children(":first").before(u);u.html(n.html());u.css("font-size",""+n.css("font-size"));u.css("padding-left",""+n.css("padding-left"));u.css("padding-right",""+n.css("padding-right"));s=u.width();$("tr",this.bDiv).each(function(){var e=$("td:visible div:eq("+t+")",this),n=0;u.html(e.html());u.css("font-size",""+e.css("font-size"));u.css("padding-left",""+e.css("padding-left"));u.css("padding-right",""+e.css("padding-right"));n=u.width();s=n>s?n:s});u.remove();s=p.minWidth>s?p.minWidth:s;o=r+(s-i);$("div:eq("+t+")",this.cDrag).css("left",o);this.colresize={nw:s,n:t};g.dragEnd()},pager:0};g=p.getGridClass(g);if(p.colModel){thead=document.createElement("thead");var tr=document.createElement("tr");for(var i=0;i<p.colModel.length;i++){var cm=p.colModel[i];var th=document.createElement("th");$(th).attr("axis","col"+i);if(cm){if($.cookies){var cookie_width="flexiwidths/"+cm.name;if($.cookie(cookie_width)!=undefined){cm.width=$.cookie(cookie_width)}}if(cm.display!=undefined){th.innerHTML=cm.display}if(cm.name&&cm.sortable){$(th).attr("abbr",cm.name)}if(cm.align){th.align=cm.align}if(cm.width){$(th).attr("width",cm.width)}if($(cm).attr("hide")){th.hidden=true}if(cm.process){th.process=cm.process}}else{th.innerHTML="";$(th).attr("width",30)}$(tr).append(th)}$(thead).append(tr);$(t).prepend(thead)}g.gDiv=document.createElement("div");g.mDiv=document.createElement("div");g.hDiv=document.createElement("div");g.bDiv=document.createElement("div");g.vDiv=document.createElement("div");g.rDiv=document.createElement("div");g.cDrag=document.createElement("div");g.block=document.createElement("div");g.nDiv=document.createElement("div");g.nBtn=document.createElement("div");g.iDiv=document.createElement("div");g.tDiv=document.createElement("div");g.sDiv=document.createElement("div");g.pDiv=document.createElement("div");if(p.colResize===false){$(g.cDrag).css("display","none")}if(!p.usepager){g.pDiv.style.display="none"}g.hTable=document.createElement("table");g.gDiv.className="flexigrid";if(p.width!="auto"){g.gDiv.style.width=p.width+(isNaN(p.width)?"":"px")}if(browser.msie){$(g.gDiv).addClass("ie")}if(p.novstripe){$(g.gDiv).addClass("novstripe")}$(t).before(g.gDiv);$(g.gDiv).append(t);if(p.buttons){g.tDiv.className="tDiv";var tDiv2=document.createElement("div");tDiv2.className="tDiv2";for(var i=0;i<p.buttons.length;i++){var btn=p.buttons[i];if(!btn.separator){var btnDiv=document.createElement("div");btnDiv.className="fbutton";btnDiv.innerHTML="<div><span>"+(btn.hidename?" ":btn.name)+"</span></div>";if(btn.bclass)$("span",btnDiv).addClass(btn.bclass).css({paddingLeft:20});if(btn.bimage)$("span",btnDiv).css("background","url("+btn.bimage+") no-repeat center left");$("span",btnDiv).css("paddingLeft",20);if(btn.tooltip)$("span",btnDiv)[0].title=btn.tooltip;btnDiv.onpress=btn.onpress;btnDiv.name=btn.name;if(btn.id){btnDiv.id=btn.id}if(btn.onpress){$(btnDiv).click(function(){this.onpress(this.id||this.name,g.gDiv)})}$(tDiv2).append(btnDiv);if(browser.msie&&browser.version<7){$(btnDiv).hover(function(){$(this).addClass("fbOver")},function(){$(this).removeClass("fbOver")})}}else{$(tDiv2).append("<div class='btnseparator'></div>")}}$(g.tDiv).append(tDiv2);$(g.tDiv).append("<div style='clear:both'></div>");$(g.gDiv).prepend(g.tDiv)}g.hDiv.className="hDiv";if(p.combobuttons&&$(g.tDiv2)){var btnDiv=document.createElement("div");btnDiv.className="fbutton";var tSelect=document.createElement("select");$(tSelect).change(function(){g.combo_doSelectAction(tSelect)});$(tSelect).click(function(){g.combo_resetIndex(tSelect)});tSelect.className="cselect";$(btnDiv).append(tSelect);for(i=0;i<p.combobuttons.length;i++){var btn=p.combobuttons[i];if(!btn.separator){var btnOpt=document.createElement("option");btnOpt.innerHTML=btn.name;if(btn.bclass)$(btnOpt).addClass(btn.bclass).css({paddingLeft:20});if(btn.bimage)$(btnOpt).css("background","url("+btn.bimage+") no-repeat center left");$(btnOpt).css("paddingLeft",20);if(btn.tooltip)$(btnOpt)[0].title=btn.tooltip;if(btn.onpress){btnOpt.value=btn.onpress}$(tSelect).append(btnOpt)}}$(".tDiv2").append(btnDiv)}$(t).before(g.hDiv);g.hTable.cellPadding=0;g.hTable.cellSpacing=0;$(g.hDiv).append('<div class="hDivBox"></div>');$("div",g.hDiv).append(g.hTable);var thead=$("thead:first",t).get(0);if(thead)$(g.hTable).append(thead);thead=null;if(!p.colmodel)var ci=0;$("thead tr:first th",g.hDiv).each(function(){var e=document.createElement("div");if($(this).attr("abbr")){$(this).click(function(e){if(!$(this).hasClass("thOver"))return false;var t=e.target||e.srcElement;if(t.href||t.type)return true;g.changeSort(this)});if($(this).attr("abbr")==p.sortname){this.className="sorted";e.className="s"+p.sortorder}}if(this.hidden){$(this).hide()}if(!p.colmodel){$(this).attr("axis","col"+ci++)}if(this.width==""){this.width=100}$(e).css({textAlign:this.align,width:this.width+"px"});e.innerHTML=this.innerHTML;$(this).empty().append(e).removeAttr("width").mousedown(function(e){g.dragStart("colMove",e,this)}).hover(function(){if(!g.colresize&&!$(this).hasClass("thMove")&&!g.colCopy){$(this).addClass("thOver")}if($(this).attr("abbr")!=p.sortname&&!g.colCopy&&!g.colresize&&$(this).attr("abbr")){$("div",this).addClass("s"+p.sortorder)}else if($(this).attr("abbr")==p.sortname&&!g.colCopy&&!g.colresize&&$(this).attr("abbr")){var e=p.sortorder=="asc"?"desc":"asc";$("div",this).removeClass("s"+p.sortorder).addClass("s"+e)}if(g.colCopy){var t=$("th",g.hDiv).index(this);if(t==g.dcoln){return false}if(t<g.dcoln){$(this).append(g.cdropleft)}else{$(this).append(g.cdropright)}g.dcolt=t}else if(!g.colresize){var n=$("th:visible",g.hDiv).index(this);var r=parseInt($("div:eq("+n+")",g.cDrag).css("left"),10);var i=jQuery(g.nBtn).outerWidth();var s=r-i+Math.floor(p.cgwidth/2);$(g.nDiv).hide();$(g.nBtn).hide();$(g.nBtn).css({left:s,top:g.hDiv.offsetTop}).show();var o=parseInt($(g.nDiv).width(),10);$(g.nDiv).css({top:g.bDiv.offsetTop});if(s+o>$(g.gDiv).width()){$(g.nDiv).css("left",r-o+1)}else{$(g.nDiv).css("left",s)}if($(this).hasClass("sorted")){$(g.nBtn).addClass("srtd")}else{$(g.nBtn).removeClass("srtd")}}},function(){$(this).removeClass("thOver");if($(this).attr("abbr")!=p.sortname){$("div",this).removeClass("s"+p.sortorder)}else if($(this).attr("abbr")==p.sortname){var e=p.sortorder=="asc"?"desc":"asc";$("div",this).addClass("s"+p.sortorder).removeClass("s"+e)}if(g.colCopy){$(g.cdropleft).remove();$(g.cdropright).remove();g.dcolt=null}})});g.bDiv.className="bDiv";$(t).before(g.bDiv);$(g.bDiv).css({height:p.height=="auto"?"auto":p.height+"px"}).scroll(function(e){g.scroll()}).append(t);if(p.height=="auto"){$("table",g.bDiv).addClass("autoht")}g.addCellProp();g.addRowProp();if(p.colResize===true){var cdcol=$("thead tr:first th:first",g.hDiv).get(0);if(cdcol!==null){g.cDrag.className="cDrag";g.cdpad=0;g.cdpad+=isNaN(parseInt($("div",cdcol).css("borderLeftWidth"),10))?0:parseInt($("div",cdcol).css("borderLeftWidth"),10);g.cdpad+=isNaN(parseInt($("div",cdcol).css("borderRightWidth"),10))?0:parseInt($("div",cdcol).css("borderRightWidth"),10);g.cdpad+=isNaN(parseInt($("div",cdcol).css("paddingLeft"),10))?0:parseInt($("div",cdcol).css("paddingLeft"),10);g.cdpad+=isNaN(parseInt($("div",cdcol).css("paddingRight"),10))?0:parseInt($("div",cdcol).css("paddingRight"),10);g.cdpad+=isNaN(parseInt($(cdcol).css("borderLeftWidth"),10))?0:parseInt($(cdcol).css("borderLeftWidth"),10);g.cdpad+=isNaN(parseInt($(cdcol).css("borderRightWidth"),10))?0:parseInt($(cdcol).css("borderRightWidth"),10);g.cdpad+=isNaN(parseInt($(cdcol).css("paddingLeft"),10))?0:parseInt($(cdcol).css("paddingLeft"),10);g.cdpad+=isNaN(parseInt($(cdcol).css("paddingRight"),10))?0:parseInt($(cdcol).css("paddingRight"),10);$(g.bDiv).before(g.cDrag);var cdheight=$(g.bDiv).height();var hdheight=$(g.hDiv).height();$(g.cDrag).css({top:-hdheight+"px"});$("thead tr:first th",g.hDiv).each(function(){var e=document.createElement("div");$(g.cDrag).append(e);if(!p.cgwidth){p.cgwidth=$(e).width()}$(e).css({height:cdheight+hdheight}).mousedown(function(e){g.dragStart("colresize",e,this)}).dblclick(function(e){g.autoResizeColumn(this)});if(browser.msie&&browser.version<7){g.fixHeight($(g.gDiv).height());$(e).hover(function(){g.fixHeight();$(this).addClass("dragging")},function(){if(!g.colresize){$(this).removeClass("dragging")}})}})}}if(p.striped){$("tbody tr:odd",g.bDiv).addClass("erow")}if(p.resizable&&p.height!="auto"){g.vDiv.className="vGrip";$(g.vDiv).mousedown(function(e){g.dragStart("vresize",e)}).html("<span></span>");$(g.bDiv).after(g.vDiv)}if(p.resizable&&p.width!="auto"&&!p.nohresize){g.rDiv.className="hGrip";$(g.rDiv).mousedown(function(e){g.dragStart("vresize",e,true)}).html("<span></span>").css("height",$(g.gDiv).height());if(browser.msie&&browser.version<7){$(g.rDiv).hover(function(){$(this).addClass("hgOver")},function(){$(this).removeClass("hgOver")})}$(g.gDiv).append(g.rDiv)}if(p.usepager){g.pDiv.className="pDiv";g.pDiv.innerHTML='<div class="pDiv2"></div>';$(g.bDiv).after(g.pDiv);var html=' <div class="pGroup"> <div class="pFirst pButton"><span></span></div><div class="pPrev pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pcontrol">'+p.pagetext+' <input type="text" size="4" value="1" /> '+p.outof+' <span> 1 </span></span></div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pNext pButton"><span></span></div><div class="pLast pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pReload pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pPageStat"></span></div>';$("div",g.pDiv).html(html);$(".pReload",g.pDiv).click(function(){g.populate()});$(".pFirst",g.pDiv).click(function(){g.changePage("first")});$(".pPrev",g.pDiv).click(function(){g.changePage("prev")});$(".pNext",g.pDiv).click(function(){g.changePage("next")});$(".pLast",g.pDiv).click(function(){g.changePage("last")});$(".pcontrol input",g.pDiv).keydown(function(e){if(e.keyCode==13){g.changePage("input")}});if(browser.msie&&browser.version<7)$(".pButton",g.pDiv).hover(function(){$(this).addClass("pBtnOver")},function(){$(this).removeClass("pBtnOver")});if(p.useRp){var opt="",sel="";for(var nx=0;nx<p.rpOptions.length;nx++){if(p.rp==p.rpOptions[nx])sel='selected="selected"';else sel="";opt+="<option value='"+p.rpOptions[nx]+"' "+sel+" >"+p.rpOptions[nx]+"  </option>"}$(".pDiv2",g.pDiv).prepend("<div class='pGroup'><select name='rp'>"+opt+"</select></div> <div class='btnseparator'></div>");$("select",g.pDiv).change(function(){if(p.onRpChange){p.onRpChange(+this.value)}else{p.newp=1;p.rp=+this.value;g.populate()}})}if(p.searchitems){$(".pDiv2",g.pDiv).prepend("<div class='pGroup'> <div class='pSearch pButton'><span></span></div> </div> <div class='btnseparator'></div>");$(".pSearch",g.pDiv).click(function(){$(g.sDiv).slideToggle("fast",function(){$(".sDiv:visible input:first",g.gDiv).trigger("focus")})});g.sDiv.className="sDiv";var sitems=p.searchitems;var sopt="",sel="";for(var s=0;s<sitems.length;s++){if(p.qtype===""&&sitems[s].isdefault===true){p.qtype=sitems[s].name;sel='selected="selected"'}else{sel=""}sopt+="<option value='"+sitems[s].name+"' "+sel+" >"+sitems[s].display+"  </option>"}if(p.qtype===""){p.qtype=sitems[0].name}$(g.sDiv).append("<div class='sDiv2'>"+p.findtext+" <input type='text' value='"+p.query+"' size='30' name='q' class='qsbox' /> "+" <select name='qtype'>"+sopt+"</select></div>");$("input[name=q]",g.sDiv).keydown(function(e){if(e.keyCode==13){g.doSearch()}});$("select[name=qtype]",g.sDiv).keydown(function(e){if(e.keyCode==13){g.doSearch()}});$("input[value=Clear]",g.sDiv).click(function(){$("input[name=q]",g.sDiv).val("");p.query="";g.doSearch()});$(g.bDiv).after(g.sDiv)}}$(g.pDiv,g.sDiv).append("<div style='clear:both'></div>");if(p.title){g.mDiv.className="mDiv";g.mDiv.innerHTML='<div class="ftitle">'+p.title+"</div>";$(g.gDiv).prepend(g.mDiv);if(p.showTableToggleBtn){$(g.mDiv).append('<div class="ptogtitle" title="Minimize/Maximize Table"><span></span></div>');$("div.ptogtitle",g.mDiv).click(function(){$(g.gDiv).toggleClass("hideBody");$(this).toggleClass("vsble")})}}g.cdropleft=document.createElement("span");g.cdropleft.className="cdropleft";g.cdropright=document.createElement("span");g.cdropright.className="cdropright";g.block.className="gBlock";var gh=$(g.bDiv).height();var gtop=g.bDiv.offsetTop;$(g.block).css({width:g.bDiv.style.width,height:gh,background:"white",position:"relative",marginBottom:gh*-1,zIndex:1,top:gtop,left:"0px"});$(g.block).fadeTo(0,p.blockOpacity);if($("th",g.hDiv).length){g.nDiv.className="nDiv";g.nDiv.innerHTML="<table cellpadding='0' cellspacing='0'><tbody></tbody></table>";$(g.nDiv).css({marginBottom:gh*-1,display:"none",top:gtop}).noSelect();var cn=0;$("th div",g.hDiv).each(function(){var e=$("th[axis='col"+cn+"']",g.hDiv)[0];var t='checked="checked"';if(e.style.display=="none"){t=""}$("tbody",g.nDiv).append('<tr><td class="ndcol1"><input type="checkbox" '+t+' class="togCol" value="'+cn+'" /></td><td class="ndcol2">'+this.innerHTML+"</td></tr>");cn++});if(browser.msie&&browser.version<7)$("tr",g.nDiv).hover(function(){$(this).addClass("ndcolover")},function(){$(this).removeClass("ndcolover")});$("td.ndcol2",g.nDiv).click(function(){if($("input:checked",g.nDiv).length<=p.minColToggle&&$(this).prev().find("input")[0].checked)return false;return g.toggleCol($(this).prev().find("input").val())});$("input.togCol",g.nDiv).click(function(){if($("input:checked",g.nDiv).length<p.minColToggle&&this.checked===false)return false;$(this).parent().next().trigger("click")});$(g.gDiv).prepend(g.nDiv);$(g.nBtn).addClass("nBtn").html("<div></div>").attr("title","Hide/Show Columns").click(function(){$(g.nDiv).toggle();return true});if(p.showToggleBtn){$(g.gDiv).prepend(g.nBtn)}}$(g.iDiv).addClass("iDiv").css({display:"none"});$(g.bDiv).append(g.iDiv);$(g.bDiv).hover(function(){$(g.nDiv).hide();$(g.nBtn).hide()},function(){if(g.multisel){g.multisel=false}});$(g.gDiv).hover(function(){},function(){$(g.nDiv).hide();$(g.nBtn).hide()});$(document).mousemove(function(e){g.dragMove(e)}).mouseup(function(e){g.dragEnd()}).hover(function(){},function(){g.dragEnd()});if(browser.msie&&browser.version<7){$(".hDiv,.bDiv,.mDiv,.pDiv,.vGrip,.tDiv, .sDiv",g.gDiv).css({width:"100%"});$(g.gDiv).addClass("ie6");if(p.width!="auto"){$(g.gDiv).addClass("ie6fullwidthbug")}}g.rePosDrag();g.fixHeight();t.p=p;t.grid=g;if(p.url&&p.autoload){g.populate()}return t};var docloaded=false;$(document).ready(function(){docloaded=true});$.fn.flexigrid=function(e){return this.each(function(){if(!docloaded){$(this).hide();var t=this;$(document).ready(function(){$.addFlex(t,e)})}else{$.addFlex(this,e)}})};$.fn.flexReload=function(e){return this.each(function(){if(this.grid&&this.p.url)this.grid.populate()})};$.fn.flexOptions=function(e){return this.each(function(){if(this.grid)$.extend(this.p,e)})};$.fn.flexToggleCol=function(e,t){return this.each(function(){if(this.grid)this.grid.toggleCol(e,t)})};$.fn.flexAddData=function(e){return this.each(function(){if(this.grid)this.grid.addData(e)})};$.fn.noSelect=function(e){var t=e===null?true:e;if(t){return this.each(function(){if(browser.msie||browser.safari)$(this).bind("selectstart",function(){return false});else if(browser.mozilla){$(this).css("MozUserSelect","none");$("body").trigger("focus")}else if(browser.opera)$(this).bind("mousedown",function(){return false});else $(this).attr("unselectable","on")})}else{return this.each(function(){if(browser.msie||browser.safari)$(this).unbind("selectstart");else if(browser.mozilla)$(this).css("MozUserSelect","inherit");else if(browser.opera)$(this).unbind("mousedown");else $(this).removeAttr("unselectable","on")})}};$.fn.flexSearch=function(e){return this.each(function(){if(this.grid&&this.p.searchitems)this.grid.doSearch()})};$.fn.selectedRows=function(e){var t=[];var n=[];var r=$(this.selector+" .trSelected");$(r).each(function(e,r){n=[];var i=$(r).data("id");$.each(r.cells,function(e,t){var r=t.abbr;var s=t.firstChild.innerHTML;if(s==" ")s="";var o=t.cellIndex;n.push({Column:r,Value:s,CellIndex:o,RowIdentifier:i})});t.push(n)});return t}})(jQuery)
web/media/js/jquery.dynatable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
/*
* jQuery Dynatable plugin 0.3.1
*
* Copyright (c) 2014 Steve Schwartz (JangoSteve)
*
* Dual licensed under the AGPL and Proprietary licenses:
* http://www.dynatable.com/license/
*
* Date: Tue Jan 02 2014
*/
//
(function($) {
var defaults,
mergeSettings,
dt,
Model,
modelPrototypes = {
dom: Dom,
domColumns: DomColumns,
records: Records,
recordsCount: RecordsCount,
processingIndicator: ProcessingIndicator,
state: State,
sorts: Sorts,
sortsHeaders: SortsHeaders,
queries: Queries,
inputsSearch: InputsSearch,
paginationPage: PaginationPage,
paginationPerPage: PaginationPerPage,
paginationLinks: PaginationLinks
},
utility,
build,
processAll,
initModel,
defaultRowWriter,
defaultCellWriter,
defaultAttributeWriter,
defaultAttributeReader;
//-----------------------------------------------------------------
// Cached plugin global defaults
//-----------------------------------------------------------------
defaults = {
features: {
paginate: true,
sort: true,
pushState: true,
search: true,
recordCount: true,
perPageSelect: true
},
table: {
defaultColumnIdStyle: 'camelCase',
columns: null,
headRowSelector: 'thead tr', // or e.g. tr:first-child
bodyRowSelector: 'tbody tr',
headRowClass: null
},
inputs: {
queries: null,
sorts: null,
multisort: ['ctrlKey', 'shiftKey', 'metaKey'],
page: null,
queryEvent: 'blur change',
recordCountTarget: null,
recordCountPlacement: 'after',
paginationLinkTarget: null,
paginationLinkPlacement: 'after',
paginationClass: 'dynatable-pagination-links',
paginationLinkClass: 'dynatable-page-link',
paginationPrevClass: 'dynatable-page-prev',
paginationNextClass: 'dynatable-page-next',
paginationActiveClass: 'dynatable-active-page',
paginationDisabledClass: 'dynatable-disabled-page',
paginationPrev: 'Previous',
paginationNext: 'Next',
paginationGap: [1,2,2,1],
searchTarget: null,
searchPlacement: 'before',
perPageTarget: null,
perPagePlacement: 'before',
perPageText: 'Show: ',
recordCountText: 'Showing ',
processingText: 'Processing...'
},
dataset: {
ajax: false,
ajaxUrl: null,
ajaxCache: null,
ajaxOnLoad: false,
ajaxMethod: 'GET',
ajaxDataType: 'json',
totalRecordCount: null,
queries: {},
queryRecordCount: null,
page: null,
perPageDefault: 10,
perPageOptions: [10,20,50,100],
sorts: {},
sortsKeys: null,
sortTypes: {},
records: null
},
writers: {
_rowWriter: defaultRowWriter,
_cellWriter: defaultCellWriter,
_attributeWriter: defaultAttributeWriter
},
readers: {
_rowReader: null,
_attributeReader: defaultAttributeReader
},
params: {
dynatable: 'dynatable',
queries: 'queries',
sorts: 'sorts',
page: 'page',
perPage: 'perPage',
offset: 'offset',
records: 'records',
record: null,
queryRecordCount: 'queryRecordCount',
totalRecordCount: 'totalRecordCount'
}
};
//-----------------------------------------------------------------
// Each dynatable instance inherits from this,
// set properties specific to instance
//-----------------------------------------------------------------
dt = {
init: function(element, options) {
this.settings = mergeSettings(options);
this.element = element;
this.$element = $(element);
// All the setup that doesn't require element or options
build.call(this);
return this;
},
process: function(skipPushState) {
processAll.call(this, skipPushState);
}
};
//-----------------------------------------------------------------
// Cached plugin global functions
//-----------------------------------------------------------------
mergeSettings = function(options) {
var newOptions = $.extend(true, {}, defaults, options);
// TODO: figure out a better way to do this.
// Doing `extend(true)` causes any elements that are arrays
// to merge the default and options arrays instead of overriding the defaults.
if (options) {
if (options.inputs) {
if (options.inputs.multisort) {
newOptions.inputs.multisort = options.inputs.multisort;
}
if (options.inputs.paginationGap) {
newOptions.inputs.paginationGap = options.inputs.paginationGap;
}
}
if (options.dataset && options.dataset.perPageOptions) {
newOptions.dataset.perPageOptions = options.dataset.perPageOptions;
}
}
return newOptions;
};
build = function() {
this.$element.trigger('dynatable:preinit', this);
for (model in modelPrototypes) {
if (modelPrototypes.hasOwnProperty(model)) {
var modelInstance = this[model] = new modelPrototypes[model](this, this.settings);
if (modelInstance.initOnLoad()) {
modelInstance.init();
}
}
}
this.$element.trigger('dynatable:init', this);
if (!this.settings.dataset.ajax || (this.settings.dataset.ajax && this.settings.dataset.ajaxOnLoad) || this.settings.features.paginate) {
this.process();
}
};
processAll = function(skipPushState) {
var data = {};
this.$element.trigger('dynatable:beforeProcess', data);
if (!$.isEmptyObject(this.settings.dataset.queries)) { data[this.settings.params.queries] = this.settings.dataset.queries; }
// TODO: Wrap this in a try/rescue block to hide the processing indicator and indicate something went wrong if error
this.processingIndicator.show();
if (this.settings.features.sort && !$.isEmptyObject(this.settings.dataset.sorts)) { data[this.settings.params.sorts] = this.settings.dataset.sorts; }
if (this.settings.features.paginate && this.settings.dataset.page) {
var page = this.settings.dataset.page,
perPage = this.settings.dataset.perPage;
data[this.settings.params.page] = page;
data[this.settings.params.perPage] = perPage;
data[this.settings.params.offset] = (page - 1) * perPage;
}
if (this.settings.dataset.ajaxData) { $.extend(data, this.settings.dataset.ajaxData); }
// If ajax, sends query to ajaxUrl with queries and sorts serialized and appended in ajax data
// otherwise, executes queries and sorts on in-page data
if (this.settings.dataset.ajax) {
var _this = this;
var options = {
type: _this.settings.dataset.ajaxMethod,
dataType: _this.settings.dataset.ajaxDataType,
data: data,
error: function(xhr, error) {
},
success: function(response) {
_this.$element.trigger('dynatable:ajax:success', response);
// Merge ajax results and meta-data into dynatables cached data
_this.records.updateFromJson(response);
// update table with new records
_this.dom.update();
if (!skipPushState && _this.state.initOnLoad()) {
_this.state.push(data);
}
},
complete: function() {
_this.processingIndicator.hide();
}
};
// Do not pass url to `ajax` options if blank
if (this.settings.dataset.ajaxUrl) {
options.url = this.settings.dataset.ajaxUrl;
// If ajaxUrl is blank, then we're using the current page URL,
// we need to strip out any query, sort, or page data controlled by dynatable
// that may have been in URL when page loaded, so that it doesn't conflict with
// what's passed in with the data ajax parameter
} else {
options.url = utility.refreshQueryString(window.location.href, {}, this.settings);
}
if (this.settings.dataset.ajaxCache !== null) { options.cache = this.settings.dataset.ajaxCache; }
$.ajax(options);
} else {
this.records.resetOriginal();
this.queries.run();
if (this.settings.features.sort) {
this.records.sort();
}
if (this.settings.features.paginate) {
this.records.paginate();
}
this.dom.update();
this.processingIndicator.hide();
if (!skipPushState && this.state.initOnLoad()) {
this.state.push(data);
}
}
this.$element.trigger('dynatable:afterProcess', data);
};
function defaultRowWriter(rowIndex, record, columns, cellWriter) {
var tr = '';
// grab the record's attribute for each column
for (var i = 0, len = columns.length; i < len; i++) {
tr += cellWriter(columns[i], record);
}
return '<tr class="' + record.originalTR[0].className + '">' + tr + '</tr>';
};
function defaultCellWriter(column, record) {
var html = column.attributeWriter(record),
td = '<td';
if (column.hidden || column.textAlign) {
td += ' style="';
// keep cells for hidden column headers hidden
if (column.hidden) {
td += 'display: none;';
}
// keep cells aligned as their column headers are aligned
if (column.textAlign) {
td += 'text-align: ' + column.textAlign + ';';
}
td += '"';
}
return td + '>' + html + '</td>';
};
function defaultAttributeWriter(record) {
// `this` is the column object in settings.columns
// TODO: automatically convert common types, such as arrays and objects, to string
return record[this.id];
};
function defaultAttributeReader(cell, record) {
return $(cell).html();
};
//-----------------------------------------------------------------
// Dynatable object model prototype
// (all object models get these default functions)
//-----------------------------------------------------------------
Model = {
initOnLoad: function() {
return true;
},
init: function() {}
};
for (model in modelPrototypes) {
if (modelPrototypes.hasOwnProperty(model)) {
var modelPrototype = modelPrototypes[model];
modelPrototype.prototype = Model;
}
}
//-----------------------------------------------------------------
// Dynatable object models
//-----------------------------------------------------------------
function Dom(obj, settings) {
var _this = this;
// update table contents with new records array
// from query (whether ajax or not)
this.update = function() {
var rows = '',
columns = settings.table.columns,
rowWriter = settings.writers._rowWriter,
cellWriter = settings.writers._cellWriter;
obj.$element.trigger('dynatable:beforeUpdate', rows);
// loop through records
for (var i = 0, len = settings.dataset.records.length; i < len; i++) {
var record = settings.dataset.records[i],
tr = rowWriter(i, record, columns, cellWriter);
rows += tr;
}
// Appended dynatable interactive elements
if (settings.features.recordCount) {
$('#dynatable-record-count-' + obj.element.id).replaceWith(obj.recordsCount.create());
}
if (settings.features.paginate) {
$('#dynatable-pagination-links-' + obj.element.id).replaceWith(obj.paginationLinks.create());
if (settings.features.perPageSelect) {
$('#dynatable-per-page-' + obj.element.id).val(parseInt(settings.dataset.perPage));
}
}
// Sort headers functionality
if (settings.features.sort && columns) {
obj.sortsHeaders.removeAllArrows();
for (var i = 0, len = columns.length; i < len; i++) {
var column = columns[i],
sortedByColumn = utility.allMatch(settings.dataset.sorts, column.sorts, function(sorts, sort) { return sort in sorts; }),
value = settings.dataset.sorts[column.sorts[0]];
if (sortedByColumn) {
obj.$element.find('[data-dynatable-column="' + column.id + '"]').find('.dynatable-sort-header').each(function(){
if (value == 1) {
obj.sortsHeaders.appendArrowUp($(this));
} else {
obj.sortsHeaders.appendArrowDown($(this));
}
});
}
}
}
// Query search functionality
if (settings.inputs.queries || settings.features.search) {
var allQueries = settings.inputs.queries || $();
if (settings.features.search) {
allQueries = allQueries.add('#dynatable-query-search-' + obj.element.id);
}
allQueries.each(function() {
var $this = $(this),
q = settings.dataset.queries[$this.data('dynatable-query')];
$this.val(q || '');
});
}
obj.$element.find(settings.table.bodyRowSelector).remove();
obj.$element.append(rows);
obj.$element.trigger('dynatable:afterUpdate', rows);
};
};
function DomColumns(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return obj.$element.is('table');
};
this.init = function() {
settings.table.columns = [];
this.getFromTable();
};
// initialize table[columns] array
this.getFromTable = function() {
var $columns = obj.$element.find(settings.table.headRowSelector).children('th,td');
if ($columns.length) {
$columns.each(function(index){
_this.add($(this), index, true);
});
} else {
return $.error("Couldn't find any columns headers in '" + settings.table.headRowSelector + " th,td'. If your header row is different, specify the selector in the table: headRowSelector option.");
}
};
this.add = function($column, position, skipAppend, skipUpdate) {
var columns = settings.table.columns,
label = $column.text(),
id = $column.data('dynatable-column') || utility.normalizeText(label, settings.table.defaultColumnIdStyle),
dataSorts = $column.data('dynatable-sorts'),
sorts = dataSorts ? $.map(dataSorts.split(','), function(text) { return $.trim(text); }) : [id];
// If the column id is blank, generate an id for it
if ( !id ) {
this.generate($column);
id = $column.data('dynatable-column');
}
// Add column data to plugin instance
columns.splice(position, 0, {
index: position,
label: label,
id: id,
attributeWriter: settings.writers[id] || settings.writers._attributeWriter,
attributeReader: settings.readers[id] || settings.readers._attributeReader,
sorts: sorts,
hidden: $column.css('display') === 'none',
textAlign: $column.css('text-align')
});
// Modify header cell
$column
.attr('data-dynatable-column', id)
.addClass('dynatable-head');
if (settings.table.headRowClass) { $column.addClass(settings.table.headRowClass); }
// Append column header to table
if (!skipAppend) {
var domPosition = position + 1,
$sibling = obj.$element.find(settings.table.headRowSelector)
.children('th:nth-child(' + domPosition + '),td:nth-child(' + domPosition + ')').first(),
columnsAfter = columns.slice(position + 1, columns.length);
if ($sibling.length) {
$sibling.before($column);
// sibling column doesn't yet exist (maybe this is the last column in the header row)
} else {
obj.$element.find(settings.table.headRowSelector).append($column);
}
obj.sortsHeaders.attachOne($column.get());
// increment the index of all columns after this one that was just inserted
if (columnsAfter.length) {
for (var i = 0, len = columnsAfter.length; i < len; i++) {
columnsAfter[i].index += 1;
}
}
if (!skipUpdate) {
obj.dom.update();
}
}
return dt;
};
this.remove = function(columnIndexOrId) {
var columns = settings.table.columns,
length = columns.length;
if (typeof(columnIndexOrId) === "number") {
var column = columns[columnIndexOrId];
this.removeFromTable(column.id);
this.removeFromArray(columnIndexOrId);
} else {
// Traverse columns array in reverse order so that subsequent indices
// don't get messed up when we delete an item from the array in an iteration
for (var i = columns.length - 1; i >= 0; i--) {
var column = columns[i];
if (column.id === columnIndexOrId) {
this.removeFromTable(columnIndexOrId);
this.removeFromArray(i);
}
}
}
obj.dom.update();
};
this.removeFromTable = function(columnId) {
obj.$element.find(settings.table.headRowSelector).children('[data-dynatable-column="' + columnId + '"]').first()
.remove();
};
this.removeFromArray = function(index) {
var columns = settings.table.columns,
adjustColumns;
columns.splice(index, 1);
adjustColumns = columns.slice(index, columns.length);
for (var i = 0, len = adjustColumns.length; i < len; i++) {
adjustColumns[i].index -= 1;
}
};
this.generate = function($cell) {
var cell = $cell === undefined ? $('<th></th>') : $cell;
return this.attachGeneratedAttributes(cell);
};
this.attachGeneratedAttributes = function($cell) {
// Use increment to create unique column name that is the same each time the page is reloaded,
// in order to avoid errors with mismatched attribute names when loading cached `dataset.records` array
var increment = obj.$element.find(settings.table.headRowSelector).children('th[data-dynatable-generated]').length;
return $cell
.attr('data-dynatable-column', 'dynatable-generated-' + increment) //+ utility.randomHash(),
.attr('data-dynatable-no-sort', 'true')
.attr('data-dynatable-generated', increment);
};
};
function Records(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return !settings.dataset.ajax;
};
this.init = function() {
if (settings.dataset.records === null) {
settings.dataset.records = this.getFromTable();
if (!settings.dataset.queryRecordCount) {
settings.dataset.queryRecordCount = this.count();
}
if (!settings.dataset.totalRecordCount){
settings.dataset.totalRecordCount = settings.dataset.queryRecordCount;
}
}
// Create cache of original full recordset (unpaginated and unqueried)
settings.dataset.originalRecords = $.extend(true, [], settings.dataset.records);
};
// merge ajax response json with cached data including
// meta-data and records
this.updateFromJson = function(data) {
var records;
if (settings.params.records === "_root") {
records = data;
} else if (settings.params.records in data) {
records = data[settings.params.records];
}
if (settings.params.record) {
var len = records.length - 1;
for (var i = 0; i < len; i++) {
records[i] = records[i][settings.params.record];
}
}
if (settings.params.queryRecordCount in data) {
settings.dataset.queryRecordCount = data[settings.params.queryRecordCount];
}
if (settings.params.totalRecordCount in data) {
settings.dataset.totalRecordCount = data[settings.params.totalRecordCount];
}
settings.dataset.records = records;
};
// For really advanced sorting,
// see http://james.padolsey.com/javascript/sorting-elements-with-jquery/
this.sort = function() {
var sort = [].sort,
sorts = settings.dataset.sorts,
sortsKeys = settings.dataset.sortsKeys,
sortTypes = settings.dataset.sortTypes;
var sortFunction = function(a, b) {
var comparison;
if ($.isEmptyObject(sorts)) {
comparison = obj.sorts.functions['originalPlacement'](a, b);
} else {
for (var i = 0, len = sortsKeys.length; i < len; i++) {
var attr = sortsKeys[i],
direction = sorts[attr],
sortType = sortTypes[attr] || obj.sorts.guessType(a, b, attr);
comparison = obj.sorts.functions[sortType](a, b, attr, direction);
// Don't need to sort any further unless this sort is a tie between a and b,
// so break the for loop unless tied
if (comparison !== 0) { break; }
}
}
return comparison;
}
return sort.call(settings.dataset.records, sortFunction);
};
this.paginate = function() {
var bounds = this.pageBounds(),
first = bounds[0], last = bounds[1];
settings.dataset.records = settings.dataset.records.slice(first, last);
};
this.resetOriginal = function() {
settings.dataset.records = settings.dataset.originalRecords || [];
};
this.pageBounds = function() {
var page = settings.dataset.page || 1,
first = (page - 1) * settings.dataset.perPage,
last = Math.min(first + settings.dataset.perPage, settings.dataset.queryRecordCount);
return [first,last];
};
// get initial recordset to populate table
// if ajax, call ajaxUrl
// otherwise, initialize from in-table records
this.getFromTable = function() {
var records = [],
columns = settings.table.columns,
tableRecords = obj.$element.find(settings.table.bodyRowSelector);
tableRecords.each(function(index){
var record = {};
record['dynatable-original-index'] = index;
record["originalTR"] = $(this);
$(this).find('th,td').each(function(index) {
if (columns[index] === undefined) {
// Header cell didn't exist for this column, so let's generate and append
// a new header cell with a randomly generated name (so we can store and
// retrieve the contents of this column for each record)
obj.domColumns.add(obj.domColumns.generate(), columns.length, false, true); // don't skipAppend, do skipUpdate
}
var value = columns[index].attributeReader(this, record),
attr = columns[index].id;
// If value from table is HTML, let's get and cache the text equivalent for
// the default string sorting, since it rarely makes sense for sort headers
// to sort based on HTML tags.
if (typeof(value) === "string" && value.match(/\s*\<.+\>/)) {
if (! record['dynatable-sortable-text']) {
record['dynatable-sortable-text'] = {};
}
record['dynatable-sortable-text'][attr] = $.trim($('<div></div>').html(value).text());
}
record[attr] = value;
});
// Allow configuration function which alters record based on attributes of
// table row (e.g. from html5 data- attributes)
if (typeof(settings.readers._rowReader) === "function") {
settings.readers._rowReader(index, this, record);
}
records.push(record);
});
return records; // 1st row is header
};
// count records from table
this.count = function() {
return settings.dataset.records.length;
};
};
function RecordsCount(obj, settings) {
this.initOnLoad = function() {
return settings.features.recordCount;
};
this.init = function() {
this.attach();
};
this.create = function() {
var recordsShown = obj.records.count(),
recordsQueryCount = settings.dataset.queryRecordCount,
recordsTotal = settings.dataset.totalRecordCount,
text = settings.inputs.recordCountText,
collection_name = settings.params.records;
if (recordsShown < recordsQueryCount && settings.features.paginate) {
var bounds = obj.records.pageBounds();
text += "<span class='dynatable-record-bounds'>" + (bounds[0] + 1) + " to " + bounds[1] + "</span> of ";
} else if (recordsShown === recordsQueryCount && settings.features.paginate) {
text += recordsShown + " of ";
}
text += recordsQueryCount + " " + collection_name;
if (recordsQueryCount < recordsTotal) {
text += " (filtered from " + recordsTotal + " total records)";
}
return $('<span></span>', {
id: 'dynatable-record-count-' + obj.element.id,
'class': 'dynatable-record-count',
html: text
});
};
this.attach = function() {
var $target = settings.inputs.recordCountTarget ? $(settings.inputs.recordCountTarget) : obj.$element;
$target[settings.inputs.recordCountPlacement](this.create());
};
};
function ProcessingIndicator(obj, settings) {
this.init = function() {
this.attach();
};
this.create = function() {
var $processing = $('<div></div>', {
html: '<span>' + settings.inputs.processingText + '</span>',
id: 'dynatable-processing-' + obj.element.id,
'class': 'dynatable-processing',
style: 'position: absolute; display: none;'
});
return $processing;
};
this.position = function() {
var $processing = $('#dynatable-processing-' + obj.element.id),
$span = $processing.children('span'),
spanHeight = $span.outerHeight(),
spanWidth = $span.outerWidth(),
$covered = obj.$element,
offset = $covered.offset(),
height = $covered.outerHeight(), width = $covered.outerWidth();
$processing
.offset({left: offset.left, top: offset.top})
.width(width)
.height(height)
$span
.offset({left: offset.left + ( (width - spanWidth) / 2 ), top: offset.top + ( (height - spanHeight) / 2 )});
return $processing;
};
this.attach = function() {
obj.$element.before(this.create());
};
this.show = function() {
$('#dynatable-processing-' + obj.element.id).show();
this.position();
};
this.hide = function() {
$('#dynatable-processing-' + obj.element.id).hide();
};
};
function State(obj, settings) {
this.initOnLoad = function() {
// Check if pushState option is true, and if browser supports it
return settings.features.pushState && history.pushState;
};
this.init = function() {
window.onpopstate = function(event) {
if (event.state && event.state.dynatable) {
obj.state.pop(event);
}
}
};
this.push = function(data) {
var urlString = window.location.search,
urlOptions,
path,
params,
hash,
newParams,
cacheStr,
cache,
// replaceState on initial load, then pushState after that
firstPush = !(window.history.state && window.history.state.dynatable),
pushFunction = firstPush ? 'replaceState' : 'pushState';
if (urlString && /^\?/.test(urlString)) { urlString = urlString.substring(1); }
$.extend(urlOptions, data);
params = utility.refreshQueryString(urlString, data, settings);
if (params) { params = '?' + params; }
hash = window.location.hash;
path = window.location.pathname;
obj.$element.trigger('dynatable:push', data);
cache = { dynatable: { dataset: settings.dataset } };
if (!firstPush) { cache.dynatable.scrollTop = $(window).scrollTop(); }
cacheStr = JSON.stringify(cache);
// Mozilla has a 640k char limit on what can be stored in pushState.
// See "limit" in https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#The_pushState().C2.A0method
// and "dataStr.length" in http://wine.git.sourceforge.net/git/gitweb.cgi?p=wine/wine-gecko;a=patch;h=43a11bdddc5fc1ff102278a120be66a7b90afe28
//
// Likewise, other browsers may have varying (undocumented) limits.
// Also, Firefox's limit can be changed in about:config as browser.history.maxStateObjectSize
// Since we don't know what the actual limit will be in any given situation, we'll just try caching and rescue
// any exceptions by retrying pushState without caching the records.
//
// I have absolutely no idea why perPageOptions suddenly becomes an array-like object instead of an array,
// but just recently, this started throwing an error if I don't convert it:
// 'Uncaught Error: DATA_CLONE_ERR: DOM Exception 25'
cache.dynatable.dataset.perPageOptions = $.makeArray(cache.dynatable.dataset.perPageOptions);
try {
window.history[pushFunction](cache, "Dynatable state", path + params + hash);
} catch(error) {
// Make cached records = null, so that `pop` will rerun process to retrieve records
cache.dynatable.dataset.records = null;
window.history[pushFunction](cache, "Dynatable state", path + params + hash);
}
};
this.pop = function(event) {
var data = event.state.dynatable;
settings.dataset = data.dataset;
if (data.scrollTop) { $(window).scrollTop(data.scrollTop); }
// If dataset.records is cached from pushState
if ( data.dataset.records ) {
obj.dom.update();
} else {
obj.process(true);
}
};
};
function Sorts(obj, settings) {
this.initOnLoad = function() {
return settings.features.sort;
};
this.init = function() {
var sortsUrl = window.location.search.match(new RegExp(settings.params.sorts + '[^&=]*=[^&]*', 'g'));
settings.dataset.sorts = sortsUrl ? utility.deserialize(sortsUrl)[settings.params.sorts] : {};
settings.dataset.sortsKeys = sortsUrl ? utility.keysFromObject(settings.dataset.sorts) : [];
};
this.add = function(attr, direction) {
var sortsKeys = settings.dataset.sortsKeys,
index = $.inArray(attr, sortsKeys);
settings.dataset.sorts[attr] = direction;
if (index === -1) { sortsKeys.push(attr); }
return dt;
};
this.remove = function(attr) {
var sortsKeys = settings.dataset.sortsKeys,
index = $.inArray(attr, sortsKeys);
delete settings.dataset.sorts[attr];
if (index !== -1) { sortsKeys.splice(index, 1); }
return dt;
};
this.clear = function() {
settings.dataset.sorts = {};
settings.dataset.sortsKeys.length = 0;
};
// Try to intelligently guess which sort function to use
// based on the type of attribute values.
// Consider using something more robust than `typeof` (http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/)
this.guessType = function(a, b, attr) {
var types = {
string: 'string',
number: 'number',
'boolean': 'number',
object: 'number' // dates and null values are also objects, this works...
},
attrType = a[attr] ? typeof(a[attr]) : typeof(b[attr]),
type = types[attrType] || 'number';
return type;
};
// Built-in sort functions
// (the most common use-cases I could think of)
this.functions = {
number: function(a, b, attr, direction) {
return a[attr] === b[attr] ? 0 : (direction > 0 ? a[attr] - b[attr] : b[attr] - a[attr]);
},
string: function(a, b, attr, direction) {
var aAttr = (a['dynatable-sortable-text'] && a['dynatable-sortable-text'][attr]) ? a['dynatable-sortable-text'][attr] : a[attr],
bAttr = (b['dynatable-sortable-text'] && b['dynatable-sortable-text'][attr]) ? b['dynatable-sortable-text'][attr] : b[attr],
comparison;
aAttr = aAttr.toLowerCase();
bAttr = bAttr.toLowerCase();
comparison = aAttr === bAttr ? 0 : (direction > 0 ? aAttr > bAttr : bAttr > aAttr);
// force false boolean value to -1, true to 1, and tie to 0
return comparison === false ? -1 : (comparison - 0);
},
originalPlacement: function(a, b) {
return a['dynatable-original-index'] - b['dynatable-original-index'];
}
};
};
// turn table headers into links which add sort to sorts array
function SortsHeaders(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return settings.features.sort;
};
this.init = function() {
this.attach();
};
this.create = function(cell) {
var $cell = $(cell),
$link = $('<a></a>', {
'class': 'dynatable-sort-header',
href: '#',
html: $cell.html()
}),
id = $cell.data('dynatable-column'),
column = utility.findObjectInArray(settings.table.columns, {id: id});
$link.bind('click', function(e) {
_this.toggleSort(e, $link, column);
obj.process();
e.preventDefault();
});
if (this.sortedByColumn($link, column)) {
if (this.sortedByColumnValue(column) == 1) {
this.appendArrowUp($link);
} else {
this.appendArrowDown($link);
}
}
return $link;
};
this.removeAll = function() {
obj.$element.find(settings.table.headRowSelector).children('th,td').each(function(){
_this.removeAllArrows();
_this.removeOne(this);
});
};
this.removeOne = function(cell) {
var $cell = $(cell),
$link = $cell.find('.dynatable-sort-header');
if ($link.length) {
var html = $link.html();
$link.remove();
$cell.html($cell.html() + html);
}
};
this.attach = function() {
obj.$element.find(settings.table.headRowSelector).children('th,td').each(function(){
_this.attachOne(this);
});
};
this.attachOne = function(cell) {
var $cell = $(cell);
if (!$cell.data('dynatable-no-sort')) {
$cell.html(this.create(cell));
}
};
this.appendArrowUp = function($link) {
this.removeArrow($link);
$link.append("<span class='dynatable-arrow'> &#9650;</span>");
};
this.appendArrowDown = function($link) {
this.removeArrow($link);
$link.append("<span class='dynatable-arrow'> &#9660;</span>");
};
this.removeArrow = function($link) {
// Not sure why `parent()` is needed, the arrow should be inside the link from `append()` above
$link.find('.dynatable-arrow').remove();
};
this.removeAllArrows = function() {
obj.$element.find('.dynatable-arrow').remove();
};
this.toggleSort = function(e, $link, column) {
var sortedByColumn = this.sortedByColumn($link, column),
value = this.sortedByColumnValue(column);
// Clear existing sorts unless this is a multisort event
if (!settings.inputs.multisort || !utility.anyMatch(e, settings.inputs.multisort, function(evt, key) { return e[key]; })) {
this.removeAllArrows();
obj.sorts.clear();
}
// If sorts for this column are already set
if (sortedByColumn) {
// If ascending, then make descending
if (value == 1) {
for (var i = 0, len = column.sorts.length; i < len; i++) {
obj.sorts.add(column.sorts[i], -1);
}
this.appendArrowDown($link);
// If descending, remove sort
} else {
for (var i = 0, len = column.sorts.length; i < len; i++) {
obj.sorts.remove(column.sorts[i]);
}
this.removeArrow($link);
}
// Otherwise, if not already set, set to ascending
} else {
for (var i = 0, len = column.sorts.length; i < len; i++) {
obj.sorts.add(column.sorts[i], 1);
}
this.appendArrowUp($link);
}
};
this.sortedByColumn = function($link, column) {
return utility.allMatch(settings.dataset.sorts, column.sorts, function(sorts, sort) { return sort in sorts; });
};
this.sortedByColumnValue = function(column) {
return settings.dataset.sorts[column.sorts[0]];
};
};
function Queries(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return settings.inputs.queries || settings.features.search;
};
this.init = function() {
var queriesUrl = window.location.search.match(new RegExp(settings.params.queries + '[^&=]*=[^&]*', 'g'));
settings.dataset.queries = queriesUrl ? utility.deserialize(queriesUrl)[settings.params.queries] : {};
if (settings.dataset.queries === "") { settings.dataset.queries = {}; }
if (settings.inputs.queries) {
this.setupInputs();
}
};
this.add = function(name, value) {
// reset to first page since query will change records
if (settings.features.paginate) {
settings.dataset.page = 1;
}
settings.dataset.queries[name] = value;
return dt;
};
this.remove = function(name) {
delete settings.dataset.queries[name];
return dt;
};
this.run = function() {
for (query in settings.dataset.queries) {
if (settings.dataset.queries.hasOwnProperty(query)) {
var value = settings.dataset.queries[query];
if (_this.functions[query] === undefined) {
// Try to lazily evaluate query from column names if not explicitly defined
var queryColumn = utility.findObjectInArray(settings.table.columns, {id: query});
if (queryColumn) {
_this.functions[query] = function(record, queryValue) {
return record[query] == queryValue;
};
} else {
$.error("Query named '" + query + "' called, but not defined in queries.functions");
continue; // to skip to next query
}
}
// collect all records that return true for query
settings.dataset.records = $.map(settings.dataset.records, function(record) {
return _this.functions[query](record, value) ? record : null;
});
}
}
settings.dataset.queryRecordCount = obj.records.count();
};
// Shortcut for performing simple query from built-in search
this.runSearch = function(q) {
var origQueries = $.extend({}, settings.dataset.queries);
if (q) {
this.add('search', q);
} else {
this.remove('search');
}
if (!utility.objectsEqual(settings.dataset.queries, origQueries)) {
obj.process();
}
};
this.setupInputs = function() {
settings.inputs.queries.each(function() {
var $this = $(this),
event = $this.data('dynatable-query-event') || settings.inputs.queryEvent,
query = $this.data('dynatable-query') || $this.attr('name') || this.id,
queryFunction = function(e) {
var q = $(this).val();
if (q === "") { q = undefined; }
if (q === settings.dataset.queries[query]) { return false; }
if (q) {
_this.add(query, q);
} else {
_this.remove(query);
}
obj.process();
e.preventDefault();
};
$this
.attr('data-dynatable-query', query)
.bind(event, queryFunction)
.bind('keypress', function(e) {
if (e.which == 13) {
queryFunction.call(this, e);
}
});
if (settings.dataset.queries[query]) { $this.val(decodeURIComponent(settings.dataset.queries[query])); }
});
};
// Query functions for in-page querying
// each function should take a record and a value as input
// and output true of false as to whether the record is a match or not
this.functions = {
search: function(record, queryValue) {
var contains = false;
// Loop through each attribute of record
for (attr in record) {
if (record.hasOwnProperty(attr)) {
var attrValue = record[attr];
if (typeof(attrValue) === "string" && attrValue.toLowerCase().indexOf(queryValue.toLowerCase()) !== -1) {
contains = true;
// Don't need to keep searching attributes once found
break;
} else {
continue;
}
}
}
return contains;
}
};
};
function InputsSearch(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return settings.features.search;
};
this.init = function() {
this.attach();
};
this.create = function() {
var $search = $('<input />', {
type: 'search',
id: 'dynatable-query-search-' + obj.element.id,
'data-dynatable-query': 'search',
value: settings.dataset.queries.search
}),
$searchSpan = $('<span></span>', {
id: 'dynatable-search-' + obj.element.id,
'class': 'dynatable-search',
text: 'Search: '
}).append($search);
$search
.bind(settings.inputs.queryEvent, function() {
obj.queries.runSearch($(this).val());
})
.bind('keypress', function(e) {
if (e.which == 13) {
obj.queries.runSearch($(this).val());
e.preventDefault();
}
});
return $searchSpan;
};
this.attach = function() {
var $target = settings.inputs.searchTarget ? $(settings.inputs.searchTarget) : obj.$element;
$target[settings.inputs.searchPlacement](this.create());
};
};
// provide a public function for selecting page
function PaginationPage(obj, settings) {
this.initOnLoad = function() {
return settings.features.paginate;
};
this.init = function() {
var pageUrl = window.location.search.match(new RegExp(settings.params.page + '=([^&]*)'));
// If page is present in URL parameters and pushState is enabled
// (meaning that it'd be possible for dynatable to have put the
// page parameter in the URL)
if (pageUrl && settings.features.pushState) {
this.set(pageUrl[1]);
} else {
this.set(1);
}
};
this.set = function(page) {
settings.dataset.page = parseInt(page, 10);
}
};
function PaginationPerPage(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return settings.features.paginate;
};
this.init = function() {
var perPageUrl = window.location.search.match(new RegExp(settings.params.perPage + '=([^&]*)'));
// If perPage is present in URL parameters and pushState is enabled
// (meaning that it'd be possible for dynatable to have put the
// perPage parameter in the URL)
if (perPageUrl && settings.features.pushState) {
// Don't reset page to 1 on init, since it might override page
// set on init from URL
this.set(perPageUrl[1], true);
} else {
this.set(settings.dataset.perPageDefault, true);
}
if (settings.features.perPageSelect) {
this.attach();
}
};
this.create = function() {
var $select = $('<select>', {
id: 'dynatable-per-page-' + obj.element.id,
'class': 'dynatable-per-page-select'
});
for (var i = 0, len = settings.dataset.perPageOptions.length; i < len; i++) {
var number = settings.dataset.perPageOptions[i],
selected = settings.dataset.perPage == number ? 'selected="selected"' : '';
$select.append('<option value="' + number + '" ' + selected + '>' + number + '</option>');
}
$select.bind('change', function(e) {
_this.set($(this).val());
obj.process();
});
return $('<span />', {
'class': 'dynatable-per-page'
}).append("<span class='dynatable-per-page-label'>" + settings.inputs.perPageText + "</span>").append($select);
};
this.attach = function() {
var $target = settings.inputs.perPageTarget ? $(settings.inputs.perPageTarget) : obj.$element;
$target[settings.inputs.perPagePlacement](this.create());
};
this.set = function(number, skipResetPage) {
if (!skipResetPage) { obj.paginationPage.set(1); }
settings.dataset.perPage = parseInt(number);
};
};
// pagination links which update dataset.page attribute
function PaginationLinks(obj, settings) {
var _this = this;
this.initOnLoad = function() {
return settings.features.paginate;
};
this.init = function() {
this.attach();
};
this.create = function() {
var pageLinks = '<ul id="' + 'dynatable-pagination-links-' + obj.element.id + '" class="' + settings.inputs.paginationClass + '">',
pageLinkClass = settings.inputs.paginationLinkClass,
activePageClass = settings.inputs.paginationActiveClass,
disabledPageClass = settings.inputs.paginationDisabledClass,
pages = Math.ceil(settings.dataset.queryRecordCount / settings.dataset.perPage),
page = settings.dataset.page,
breaks = [
settings.inputs.paginationGap[0],
settings.dataset.page - settings.inputs.paginationGap[1],
settings.dataset.page + settings.inputs.paginationGap[2],
(pages + 1) - settings.inputs.paginationGap[3]
];
pageLinks += '<li><span>Pages: </span></li>';
for (var i = 1; i <= pages; i++) {
if ( (i > breaks[0] && i < breaks[1]) || (i > breaks[2] && i < breaks[3])) {
// skip to next iteration in loop
continue;
} else {
var li = obj.paginationLinks.buildLink(i, i, pageLinkClass, page == i, activePageClass),
breakIndex,
nextBreak;
// If i is not between one of the following
// (1 + (settings.paginationGap[0]))
// (page - settings.paginationGap[1])
// (page + settings.paginationGap[2])
// (pages - settings.paginationGap[3])
breakIndex = $.inArray(i, breaks);
nextBreak = breaks[breakIndex + 1];
if (breakIndex > 0 && i !== 1 && nextBreak && nextBreak > (i + 1)) {
var ellip = '<li><span class="dynatable-page-break">&hellip;</span></li>';
li = breakIndex < 2 ? ellip + li : li + ellip;
}
if (settings.inputs.paginationPrev && i === 1) {
var prevLi = obj.paginationLinks.buildLink(page - 1, settings.inputs.paginationPrev, pageLinkClass + ' ' + settings.inputs.paginationPrevClass, page === 1, disabledPageClass);
li = prevLi + li;
}
if (settings.inputs.paginationNext && i === pages) {
var nextLi = obj.paginationLinks.buildLink(page + 1, settings.inputs.paginationNext, pageLinkClass + ' ' + settings.inputs.paginationNextClass, page === pages, disabledPageClass);
li += nextLi;
}
pageLinks += li;
}
}
pageLinks += '</ul>';
// only bind page handler to non-active and non-disabled page links
var selector = '#dynatable-pagination-links-' + obj.element.id + ' a.' + pageLinkClass + ':not(.' + activePageClass + ',.' + disabledPageClass + ')';
// kill any existing delegated-bindings so they don't stack up
$(document).undelegate(selector, 'click.dynatable');
$(document).delegate(selector, 'click.dynatable', function(e) {
$this = $(this);
$this.closest(settings.inputs.paginationClass).find('.' + activePageClass).removeClass(activePageClass);
$this.addClass(activePageClass);
obj.paginationPage.set($this.data('dynatable-page'));
obj.process();
e.preventDefault();
});
return pageLinks;
};
this.buildLink = function(page, label, linkClass, conditional, conditionalClass) {
var link = '<a data-dynatable-page=' + page + ' class="' + linkClass,
li = '<li';
if (conditional) {
link += ' ' + conditionalClass;
li += ' class="' + conditionalClass + '"';
}
link += '">' + label + '</a>';
li += '>' + link + '</li>';
return li;
};
this.attach = function() {
// append page links *after* delegate-event-binding so it doesn't need to
// find and select all page links to bind event
var $target = settings.inputs.paginationLinkTarget ? $(settings.inputs.paginationLinkTarget) : obj.$element;
$target[settings.inputs.paginationLinkPlacement](obj.paginationLinks.create());
};
};
utility = dt.utility = {
normalizeText: function(text, style) {
text = this.textTransform[style](text);
return text;
},
textTransform: {
trimDash: function(text) {
return text.replace(/^\s+|\s+$/g, "").replace(/\s+/g, "-");
},
camelCase: function(text) {
text = this.trimDash(text);
return text
.replace(/(\-[a-zA-Z])/g, function($1){return $1.toUpperCase().replace('-','');})
.replace(/([A-Z])([A-Z]+)/g, function($1,$2,$3){return $2 + $3.toLowerCase();})
.replace(/^[A-Z]/, function($1){return $1.toLowerCase();});
},
dashed: function(text) {
text = this.trimDash(text);
return this.lowercase(text);
},
underscore: function(text) {
text = this.trimDash(text);
return this.lowercase(text.replace(/(-)/g, '_'));
},
lowercase: function(text) {
return text.replace(/([A-Z])/g, function($1){return $1.toLowerCase();});
}
},
// Deserialize params in URL to object
// see http://stackoverflow.com/questions/1131630/javascript-jquery-param-inverse-function/3401265#3401265
deserialize: function(query) {
if (!query) return {};
// modified to accept an array of partial URL strings
if (typeof(query) === "object") { query = query.join('&'); }
var hash = {},
vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("="),
k = decodeURIComponent(pair[0]),
v, m;
if (!pair[1]) { continue };
v = decodeURIComponent(pair[1].replace(/\+/g, ' '));
// modified to parse multi-level parameters (e.g. "hi[there][dude]=whatsup" => hi: {there: {dude: "whatsup"}})
while (m = k.match(/([^&=]+)\[([^&=]+)\]$/)) {
var origV = v;
k = m[1];
v = {};
// If nested param ends in '][', then the regex above erroneously included half of a trailing '[]',
// which indicates the end-value is part of an array
if (m[2].substr(m[2].length-2) == '][') { // must use substr for IE to understand it
v[m[2].substr(0,m[2].length-2)] = [origV];
} else {
v[m[2]] = origV;
}
}
// If it is the first entry with this name
if (typeof hash[k] === "undefined") {
if (k.substr(k.length-2) != '[]') { // not end with []. cannot use negative index as IE doesn't understand it
hash[k] = v;
} else {
hash[k] = [v];
}
// If subsequent entry with this name and not array
} else if (typeof hash[k] === "string") {
hash[k] = v; // replace it
// modified to add support for objects
} else if (typeof hash[k] === "object") {
hash[k] = $.extend({}, hash[k], v);
// If subsequent entry with this name and is array
} else {
hash[k].push(v);
}
}
return hash;
},
refreshQueryString: function(urlString, data, settings) {
var _this = this,
queryString = urlString.split('?'),
path = queryString.shift(),
urlOptions;
urlOptions = this.deserialize(urlString);
// Loop through each dynatable param and update the URL with it
for (attr in settings.params) {
if (settings.params.hasOwnProperty(attr)) {
var label = settings.params[attr];
// Skip over parameters matching attributes for disabled features (i.e. leave them untouched),
// because if the feature is turned off, then parameter name is a coincidence and it's unrelated to dynatable.
if (
(!settings.features.sort && attr == "sorts") ||
(!settings.features.paginate && _this.anyMatch(attr, ["page", "perPage", "offset"], function(attr, param) { return attr == param; }))
) {
continue;
}
// Delete page and offset from url params if on page 1 (default)
if ((attr === "page" || attr === "offset") && data["page"] === 1) {
if (urlOptions[label]) {
delete urlOptions[label];
}
continue;
}
// Delete perPage from url params if default perPage value
if (attr === "perPage" && data[label] == settings.dataset.perPageDefault) {
if (urlOptions[label]) {
delete urlOptions[label];
}
continue;
}
// For queries, we're going to handle each possible query parameter individually here instead of
// handling the entire queries object below, since we need to make sure that this is a query controlled by dynatable.
if (attr == "queries" && data[label]) {
var queries = settings.inputs.queries || [],
inputQueries = $.makeArray(queries.map(function() { return $(this).attr('name') }));
if (settings.features.search) { inputQueries.push('search'); }
for (var i = 0, len = inputQueries.length; i < len; i++) {
var attr = inputQueries[i];
if (data[label][attr]) {
if (typeof urlOptions[label] === 'undefined') { urlOptions[label] = {}; }
urlOptions[label][attr] = data[label][attr];
} else {
delete urlOptions[label][attr];
}
}
continue;
}
// If we haven't returned true by now, then we actually want to update the parameter in the URL
if (data[label]) {
urlOptions[label] = data[label];
} else {
delete urlOptions[label];
}
}
}
return decodeURI($.param(urlOptions));
},
// Get array of keys from object
// see http://stackoverflow.com/questions/208016/how-to-list-the-properties-of-a-javascript-object/208020#208020
keysFromObject: function(obj){
var keys = [];
for (var key in obj){
keys.push(key);
}
return keys;
},
// Find an object in an array of objects by attributes.
// E.g. find object with {id: 'hi', name: 'there'} in an array of objects
findObjectInArray: function(array, objectAttr) {
var _this = this,
foundObject;
for (var i = 0, len = array.length; i < len; i++) {
var item = array[i];
// For each object in array, test to make sure all attributes in objectAttr match
if (_this.allMatch(item, objectAttr, function(item, key, value) { return item[key] == value; })) {
foundObject = item;
break;
}
}
return foundObject;
},
// Return true if supplied test function passes for ALL items in an array
allMatch: function(item, arrayOrObject, test) {
// start off with true result by default
var match = true,
isArray = $.isArray(arrayOrObject);
// Loop through all items in array
$.each(arrayOrObject, function(key, value) {
var result = isArray ? test(item, value) : test(item, key, value);
// If a single item tests false, go ahead and break the array by returning false
// and return false as result,
// otherwise, continue with next iteration in loop
// (if we make it through all iterations without overriding match with false,
// then we can return the true result we started with by default)
if (!result) { return match = false; }
});
return match;
},
// Return true if supplied test function passes for ANY items in an array
anyMatch: function(item, arrayOrObject, test) {
var match = false,
isArray = $.isArray(arrayOrObject);
$.each(arrayOrObject, function(key, value) {
var result = isArray ? test(item, value) : test(item, key, value);
if (result) {
// As soon as a match is found, set match to true, and return false to stop the `$.each` loop
match = true;
return false;
}
});
return match;
},
// Return true if two objects are equal
// (i.e. have the same attributes and attribute values)
objectsEqual: function(a, b) {
for (attr in a) {
if (a.hasOwnProperty(attr)) {
if (!b.hasOwnProperty(attr) || a[attr] !== b[attr]) {
return false;
}
}
}
for (attr in b) {
if (b.hasOwnProperty(attr) && !a.hasOwnProperty(attr)) {
return false;
}
}
return true;
},
// Taken from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/105074#105074
randomHash: function() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
};
//-----------------------------------------------------------------
// Build the dynatable plugin
//-----------------------------------------------------------------
// Object.create support test, and fallback for browsers without it
if ( typeof Object.create !== "function" ) {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
//-----------------------------------------------------------------
// Global dynatable plugin setting defaults
//-----------------------------------------------------------------
$.dynatableSetup = function(options) {
defaults = mergeSettings(options);
};
// Create dynatable plugin based on a defined object
$.dynatable = function( object ) {
$.fn['dynatable'] = function( options ) {
return this.each(function() {
if ( ! $.data( this, 'dynatable' ) ) {
$.data( this, 'dynatable', Object.create(object).init(this, options) );
}
});
};
};
$.dynatable(dt);
})(jQuery);

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.27143s using 14 queries.