Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager - Version 2.6

Version Description

Gallery related bugs and items-counter issues were fixed

Download this release

Release Info

Developer galdub
Plugin Icon wp plugin Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager
Version 2.6
Comparing to
See all releases

Code changes from version 2.5.9 to 2.6

assets/css/jstree.css CHANGED
@@ -1,1113 +1,1113 @@
1
- /* jsTree default theme */
2
- .jstree-node,
3
- .jstree-children,
4
- .jstree-container-ul {
5
- display: block;
6
- margin: 0;
7
- padding: 0;
8
- list-style-type: none;
9
- list-style-image: none;
10
- }
11
- .jstree-node {
12
- white-space: nowrap;
13
- }
14
- .jstree-anchor {
15
- display: inline-block;
16
- color: black;
17
- white-space: nowrap;
18
- padding: 0 4px 0 1px;
19
- margin: 0;
20
- vertical-align: top;
21
- }
22
- .jstree-anchor:focus {
23
- outline: 0;
24
- }
25
- .jstree-anchor,
26
- .jstree-anchor:link,
27
- .jstree-anchor:visited,
28
- .jstree-anchor:hover,
29
- .jstree-anchor:active {
30
- text-decoration: none;
31
- }
32
- .jstree-icon {
33
- display: inline-block;
34
- text-decoration: none;
35
- margin: 0;
36
- padding: 0;
37
- vertical-align: top;
38
- text-align: center;
39
- }
40
- .jstree-icon:empty {
41
- display: inline-block;
42
- text-decoration: none;
43
- margin: 0;
44
- padding: 0;
45
- vertical-align: top;
46
- text-align: center;
47
- }
48
- .jstree-ocl {
49
- cursor: pointer;
50
- }
51
- .jstree-leaf > .jstree-ocl {
52
- cursor: default;
53
- }
54
- .jstree .jstree-open > .jstree-children {
55
- display: block;
56
- }
57
- .jstree .jstree-closed > .jstree-children,
58
- .jstree .jstree-leaf > .jstree-children {
59
- display: none;
60
- }
61
- .jstree-anchor > .jstree-themeicon {
62
- margin-right: 2px;
63
- }
64
- .jstree-no-icons .jstree-themeicon,
65
- .jstree-anchor > .jstree-themeicon-hidden {
66
- display: none;
67
- }
68
- .jstree-hidden,
69
- .jstree-node.jstree-hidden {
70
- display: none;
71
- }
72
- .jstree-rtl .jstree-anchor {
73
- padding: 0 1px 0 4px;
74
- }
75
- .jstree-rtl .jstree-anchor > .jstree-themeicon {
76
- margin-left: 2px;
77
- margin-right: 0;
78
- }
79
- .jstree-rtl .jstree-node {
80
- margin-left: 0;
81
- }
82
- .jstree-rtl .jstree-container-ul > .jstree-node {
83
- margin-right: 0;
84
- }
85
- .jstree-wholerow-ul {
86
- position: relative;
87
- display: inline-block;
88
- min-width: 100%;
89
- }
90
- .jstree-wholerow-ul .jstree-leaf > .jstree-ocl {
91
- cursor: pointer;
92
- }
93
- .jstree-wholerow-ul .jstree-anchor,
94
- .jstree-wholerow-ul .jstree-icon {
95
- position: relative;
96
- }
97
- .jstree-wholerow-ul .jstree-wholerow {
98
- width: 100%;
99
- cursor: pointer;
100
- position: absolute;
101
- left: 0;
102
- -webkit-user-select: none;
103
- -moz-user-select: none;
104
- -ms-user-select: none;
105
- user-select: none;
106
- }
107
- .jstree-contextmenu .jstree-anchor {
108
- -webkit-user-select: none;
109
- /* disable selection/Copy of UIWebView */
110
- -webkit-touch-callout: none;
111
- /* disable the IOS popup when long-press on a link */
112
- }
113
- .vakata-context {
114
- display: none;
115
- }
116
- .vakata-context,
117
- .vakata-context ul {
118
- margin: 0;
119
- padding: 2px;
120
- position: absolute;
121
- background: #f5f5f5;
122
- border: 1px solid #979797;
123
- box-shadow: 2px 2px 2px #999999;
124
- }
125
- .vakata-context ul {
126
- list-style: none;
127
- left: 100%;
128
- margin-top: -2.7em;
129
- margin-left: -4px;
130
- }
131
- .vakata-context .vakata-context-right ul {
132
- left: auto;
133
- right: 100%;
134
- margin-left: auto;
135
- margin-right: -4px;
136
- }
137
- .vakata-context li {
138
- list-style: none;
139
- }
140
- .vakata-context li > a {
141
- display: block;
142
- padding: 0 2em 0 2em;
143
- text-decoration: none;
144
- width: auto;
145
- color: black;
146
- white-space: nowrap;
147
- line-height: 2.4em;
148
- text-shadow: 1px 1px 0 white;
149
- border-radius: 1px;
150
- }
151
- .vakata-context li > a:hover {
152
- position: relative;
153
- background-color: #e8eff7;
154
- box-shadow: 0 0 2px #0a6aa1;
155
- }
156
- .vakata-context li > a.vakata-context-parent {
157
- background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw==");
158
- background-position: right center;
159
- background-repeat: no-repeat;
160
- }
161
- .vakata-context li > a:focus {
162
- outline: 0;
163
- }
164
- .vakata-context .vakata-context-hover > a {
165
- position: relative;
166
- background-color: #e8eff7;
167
- box-shadow: 0 0 2px #0a6aa1;
168
- }
169
- .vakata-context .vakata-context-separator > a,
170
- .vakata-context .vakata-context-separator > a:hover {
171
- background: white;
172
- border: 0;
173
- border-top: 1px solid #e2e3e3;
174
- height: 1px;
175
- min-height: 1px;
176
- max-height: 1px;
177
- padding: 0;
178
- margin: 0 0 0 2.4em;
179
- border-left: 1px solid #e0e0e0;
180
- text-shadow: 0 0 0 transparent;
181
- box-shadow: 0 0 0 transparent;
182
- border-radius: 0;
183
- }
184
- .vakata-context .vakata-contextmenu-disabled a,
185
- .vakata-context .vakata-contextmenu-disabled a:hover {
186
- color: silver;
187
- background-color: transparent;
188
- border: 0;
189
- box-shadow: 0 0 0;
190
- }
191
- .vakata-context .vakata-contextmenu-disabled > a > i {
192
- filter: grayscale(100%);
193
- }
194
- .vakata-context li > a > i {
195
- text-decoration: none;
196
- display: inline-block;
197
- width: 2.4em;
198
- height: 2.4em;
199
- background: transparent;
200
- margin: 0 0 0 -2em;
201
- vertical-align: top;
202
- text-align: center;
203
- line-height: 2.4em;
204
- }
205
- .vakata-context li > a > i:empty {
206
- width: 2.4em;
207
- line-height: 2.4em;
208
- }
209
- .vakata-context li > a .vakata-contextmenu-sep {
210
- display: inline-block;
211
- width: 1px;
212
- height: 2.4em;
213
- background: white;
214
- margin: 0 0.5em 0 0;
215
- border-left: 1px solid #e2e3e3;
216
- }
217
- .vakata-context .vakata-contextmenu-shortcut {
218
- font-size: 0.8em;
219
- color: silver;
220
- opacity: 0.5;
221
- display: none;
222
- }
223
- .vakata-context-rtl ul {
224
- left: auto;
225
- right: 100%;
226
- margin-left: auto;
227
- margin-right: -4px;
228
- }
229
- .vakata-context-rtl li > a.vakata-context-parent {
230
- background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7");
231
- background-position: left center;
232
- background-repeat: no-repeat;
233
- }
234
- .vakata-context-rtl .vakata-context-separator > a {
235
- margin: 0 2.4em 0 0;
236
- border-left: 0;
237
- border-right: 1px solid #e2e3e3;
238
- }
239
- .vakata-context-rtl .vakata-context-left ul {
240
- right: auto;
241
- left: 100%;
242
- margin-left: -4px;
243
- margin-right: auto;
244
- }
245
- .vakata-context-rtl li > a > i {
246
- margin: 0 -2em 0 0;
247
- }
248
- .vakata-context-rtl li > a .vakata-contextmenu-sep {
249
- margin: 0 0 0 0.5em;
250
- border-left-color: white;
251
- background: #e2e3e3;
252
- }
253
- #jstree-marker {
254
- position: absolute;
255
- top: 0;
256
- left: 0;
257
- margin: -5px 0 0 0;
258
- padding: 0;
259
- border-right: 0;
260
- border-top: 5px solid transparent;
261
- border-bottom: 5px solid transparent;
262
- border-left: 5px solid;
263
- width: 0;
264
- height: 0;
265
- font-size: 0;
266
- line-height: 0;
267
- }
268
- {
269
- line-height: 16px;
270
- margin: 0;
271
- padding: 4px;
272
- }
273
- .jstree-icon,
274
- .jstree-copy {
275
- display: inline-block;
276
- text-decoration: none;
277
- margin: 0 2px 0 0;
278
- padding: 0;
279
- width: 16px;
280
- height: 16px;
281
- }
282
- .jstree-ok {
283
- background: green;
284
- }
285
- .jstree-er {
286
- background: red;
287
- }
288
- .jstree-copy {
289
- margin: 0 2px 0 2px;
290
- }
291
- .jstree-default .jstree-node,
292
- .jstree-default .jstree-icon {
293
- background-repeat: no-repeat;
294
- background-color: transparent;
295
- }
296
- .jstree-default .jstree-anchor,
297
- .jstree-default .jstree-animated,
298
- .jstree-default .jstree-wholerow {
299
- transition: background-color 0.15s, box-shadow 0.15s;
300
- }
301
- .jstree-default .jstree-hovered {
302
- box-shadow: inset 0 0 1px #cccccc;
303
- }
304
- .jstree-default .jstree-context {
305
- background: #e7f4f9;
306
- border-radius: 2px;
307
- box-shadow: inset 0 0 1px #cccccc;
308
- }
309
- .jstree-default .jstree-clicked {
310
- background: #beebff;
311
- border-radius: 2px;
312
- box-shadow: inset 0 0 1px #999999;
313
- }
314
- .jstree-default .jstree-no-icons .jstree-anchor > .jstree-themeicon {
315
- display: none;
316
- }
317
- .jstree-default .jstree-disabled {
318
- background: transparent;
319
- color: #666666;
320
- }
321
- .jstree-default .jstree-disabled.jstree-hovered {
322
- background: transparent;
323
- box-shadow: none;
324
- }
325
- .jstree-default .jstree-disabled.jstree-clicked {
326
- background: #efefef;
327
- }
328
- .jstree-default .jstree-disabled > .jstree-icon {
329
- opacity: 0.8;
330
- filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
331
- /* Firefox 10+ */
332
- filter: gray;
333
- /* IE6-9 */
334
- -webkit-filter: grayscale(100%);
335
- /* Chrome 19+ & Safari 6+ */
336
- }
337
- .jstree-default .jstree-search {
338
- font-style: italic;
339
- color: #8b0000;
340
- font-weight: bold;
341
- }
342
- .jstree-default .jstree-no-checkboxes .jstree-checkbox {
343
- display: none !important;
344
- }
345
- .jstree-default.jstree-checkbox-no-clicked .jstree-clicked {
346
- background: transparent;
347
- box-shadow: none;
348
- }
349
- .jstree-default.jstree-checkbox-no-clicked .jstree-clicked.jstree-hovered {
350
- background: #e7f4f9;
351
- }
352
- .jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked {
353
- background: transparent;
354
- }
355
- .jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked.jstree-wholerow-hovered {
356
- background: #e7f4f9;
357
- }
358
- .jstree-default > .jstree-striped {
359
- min-width: 100%;
360
- display: inline-block;
361
- background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==") left top repeat;
362
- }
363
- .jstree-default > .jstree-wholerow-ul .jstree-hovered,
364
- .jstree-default > .jstree-wholerow-ul .jstree-clicked {
365
- background: transparent;
366
- box-shadow: none;
367
- border-radius: 0;
368
- }
369
- .jstree-default .jstree-wholerow {
370
- -moz-box-sizing: border-box;
371
- -webkit-box-sizing: border-box;
372
- box-sizing: border-box;
373
- }
374
- .jstree-default .jstree-wholerow-hovered {
375
- background: #e7f4f9;
376
- }
377
- .jstree-default .jstree-wholerow-clicked {
378
- background: #beebff;
379
- background: -webkit-linear-gradient(top, #beebff 0%, #a8e4ff 100%);
380
- background: linear-gradient(to bottom, #beebff 0%, #a8e4ff 100%);
381
- }
382
- .jstree-default .jstree-node {
383
- min-height: 30px;
384
- line-height: 30px;
385
- margin-left: 24px;
386
- min-width: 30px;
387
- }
388
- .jstree-default .jstree-anchor {
389
- line-height: 30px;
390
- height: 30px;
391
- width: calc(100% - 30px);
392
- overflow: hidden;
393
- padding: 0 30px 0 6px;
394
- box-sizing: border-box;
395
- position: relative;
396
- margin: 0 0 0 4px;
397
- border-radius: 4px;
398
- display: inline-block;
399
- white-space: nowrap;
400
- text-overflow: ellipsis;
401
- }
402
- .jstree-default .jstree-icon {
403
- width: 30px;
404
- height: 30px;
405
- line-height: 30px;
406
- }
407
- .jstree-default .jstree-icon:empty {
408
- width: 24px;
409
- height: 30px;
410
- line-height: 30px;
411
- }
412
- .jstree-default.jstree-rtl .jstree-node {
413
- margin-right: 30px;
414
- }
415
- .jstree-default .jstree-wholerow {
416
- height: 30px;
417
- }
418
- .jstree-default .jstree-node,
419
- .jstree-default .jstree-icon {
420
- background-image: url("../images/32px.png");
421
- }
422
- .jstree-default .jstree-node {
423
- background-position: -292px -4px;
424
- background-repeat: repeat-y;
425
- position: relative;
426
- }
427
- .jstree-default .jstree-last {
428
- background: transparent;
429
- }
430
- .jstree-default .jstree-open > .jstree-ocl {
431
- background-position: -132px -2px;
432
- }
433
- .jstree-default .jstree-closed > .jstree-ocl {
434
- background-position: -100px -2px;
435
- }
436
- .jstree-default .jstree-leaf > .jstree-ocl {
437
- background-position: -68px -2px;
438
- }
439
- .jstree-default .jstree-themeicon {
440
- background-position: -260px -2px;
441
- background: none;
442
- }
443
- .jstree-default > .jstree-no-dots .jstree-node,
444
- .jstree-default > .jstree-no-dots .jstree-leaf > .jstree-ocl {
445
- background: transparent;
446
- }
447
- .jstree-default > .jstree-no-dots .jstree-open > .jstree-ocl {
448
- background-position: -36px -2px;
449
- }
450
- .jstree-default > .jstree-no-dots .jstree-closed > .jstree-ocl {
451
- background-position: -4px -2px;
452
- }
453
- .jstree-default .jstree-disabled {
454
- background: transparent;
455
- }
456
- .jstree-default .jstree-disabled.jstree-hovered {
457
- background: transparent;
458
- }
459
- .jstree-default .jstree-disabled.jstree-clicked {
460
- background: #efefef;
461
- }
462
- .jstree-default .jstree-checkbox {
463
- background-position: -164px -4px;
464
- }
465
- .jstree-default .jstree-checkbox:hover {
466
- background-position: -164px -36px;
467
- }
468
- .jstree-default.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
469
- .jstree-default .jstree-checked > .jstree-checkbox {
470
- background-position: -228px -4px;
471
- }
472
- .jstree-default.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
473
- .jstree-default .jstree-checked > .jstree-checkbox:hover {
474
- background-position: -228px -36px;
475
- }
476
- .jstree-default .jstree-anchor > .jstree-undetermined {
477
- background-position: -196px -4px;
478
- }
479
- .jstree-default .jstree-anchor > .jstree-undetermined:hover {
480
- background-position: -196px -36px;
481
- }
482
- .jstree-default .jstree-checkbox-disabled {
483
- opacity: 0.8;
484
- filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
485
- /* Firefox 10+ */
486
- filter: gray;
487
- /* IE6-9 */
488
- -webkit-filter: grayscale(100%);
489
- /* Chrome 19+ & Safari 6+ */
490
- }
491
- .jstree-default > .jstree-striped {
492
- background-size: auto 48px;
493
- }
494
- .jstree-default.jstree-rtl .jstree-node {
495
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
496
- background-position: 100% 1px;
497
- background-repeat: repeat-y;
498
- }
499
- .jstree-default.jstree-rtl .jstree-last {
500
- background: transparent;
501
- }
502
- .jstree-default.jstree-rtl .jstree-open > .jstree-ocl {
503
- background-position: -132px -36px;
504
- }
505
- .jstree-default.jstree-rtl .jstree-closed > .jstree-ocl {
506
- background-position: -100px -36px;
507
- }
508
- .jstree-default.jstree-rtl .jstree-leaf > .jstree-ocl {
509
- background-position: -68px -36px;
510
- }
511
- .jstree-default.jstree-rtl > .jstree-no-dots .jstree-node,
512
- .jstree-default.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl {
513
- background: transparent;
514
- }
515
- .jstree-default.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl {
516
- background-position: -36px -36px;
517
- }
518
- .jstree-default.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl {
519
- background-position: -4px -36px;
520
- }
521
- .jstree-default .jstree-themeicon-custom {
522
- background-color: transparent;
523
- background-image: none;
524
- background-position: 0 0;
525
- }
526
- .jstree-default > .jstree-container-ul .jstree-loading > .jstree-ocl {
527
- background: url("throbber.gif") center center no-repeat;
528
- }
529
- .jstree-default .jstree-file {
530
- background: url("../images/32px.png") -100px -68px no-repeat;
531
- }
532
- .jstree-default .jstree-folder {
533
- background: url("../images/32px.png") -260px -4px no-repeat;
534
- }
535
- .jstree-default > .jstree-container-ul > .jstree-node {
536
- margin-left: 0;
537
- margin-right: 0;
538
- }
539
- .jstree-default {
540
- line-height: 30px;
541
- padding: 0 4px;
542
- }
543
- .jstree-default .jstree-ok,
544
- .jstree-default .jstree-er {
545
- background-image: url("../images/32px.png");
546
- background-repeat: no-repeat;
547
- background-color: transparent;
548
- }
549
- .jstree-default i {
550
- background: transparent;
551
- width: 20px;
552
- height: 30px;
553
- line-height: 30px;
554
- display: inline-block;
555
- vertical-align: top;
556
- }
557
- .jstree-default .jstree-ok {
558
- background-position: -4px -68px;
559
- }
560
- .jstree-default .jstree-er {
561
- background-position: -36px -68px;
562
- }
563
- .jstree-default .jstree-ellipsis {
564
- overflow: hidden;
565
- }
566
- .jstree-default .jstree-ellipsis .jstree-anchor {
567
- width: calc(100% - 29px);
568
- text-overflow: ellipsis;
569
- overflow: hidden;
570
- }
571
- .jstree-default.jstree-rtl .jstree-node {
572
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
573
- }
574
- .jstree-default.jstree-rtl .jstree-last {
575
- background: transparent;
576
- }
577
- .jstree-default-small .jstree-node {
578
- min-height: 18px;
579
- line-height: 18px;
580
- margin-left: 18px;
581
- min-width: 18px;
582
- }
583
- .jstree-default-small .jstree-anchor {
584
- line-height: 18px;
585
- height: 18px;
586
- }
587
- .jstree-default-small .jstree-icon {
588
- width: 18px;
589
- height: 18px;
590
- line-height: 18px;
591
- }
592
- .jstree-default-small .jstree-icon:empty {
593
- width: 18px;
594
- height: 18px;
595
- line-height: 18px;
596
- }
597
- .jstree-default-small.jstree-rtl .jstree-node {
598
- margin-right: 18px;
599
- }
600
- .jstree-default-small .jstree-wholerow {
601
- height: 18px;
602
- }
603
- .jstree-default-small .jstree-node,
604
- .jstree-default-small .jstree-icon {
605
- background-image: url("../images/32px.png");
606
- }
607
- .jstree-default-small .jstree-node {
608
- background-position: -295px -7px;
609
- background-repeat: repeat-y;
610
- }
611
- .jstree-default-small .jstree-last {
612
- background: transparent;
613
- }
614
- .jstree-default-small .jstree-open > .jstree-ocl {
615
- background-position: -135px -7px;
616
- }
617
- .jstree-default-small .jstree-closed > .jstree-ocl {
618
- background-position: -103px -7px;
619
- }
620
- .jstree-default-small .jstree-leaf > .jstree-ocl {
621
- background-position: -71px -7px;
622
- }
623
- .jstree-default-small .jstree-themeicon {
624
- background-position: -263px -7px;
625
- }
626
- .jstree-default-small > .jstree-no-dots .jstree-node,
627
- .jstree-default-small > .jstree-no-dots .jstree-leaf > .jstree-ocl {
628
- background: transparent;
629
- }
630
- .jstree-default-small > .jstree-no-dots .jstree-open > .jstree-ocl {
631
- background-position: -39px -7px;
632
- }
633
- .jstree-default-small > .jstree-no-dots .jstree-closed > .jstree-ocl {
634
- background-position: -7px -7px;
635
- }
636
- .jstree-default-small .jstree-disabled {
637
- background: transparent;
638
- }
639
- .jstree-default-small .jstree-disabled.jstree-hovered {
640
- background: transparent;
641
- }
642
- .jstree-default-small .jstree-disabled.jstree-clicked {
643
- background: #efefef;
644
- }
645
- .jstree-default-small .jstree-checkbox {
646
- background-position: -167px -7px;
647
- }
648
- .jstree-default-small .jstree-checkbox:hover {
649
- background-position: -167px -39px;
650
- }
651
- .jstree-default-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
652
- .jstree-default-small .jstree-checked > .jstree-checkbox {
653
- background-position: -231px -7px;
654
- }
655
- .jstree-default-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
656
- .jstree-default-small .jstree-checked > .jstree-checkbox:hover {
657
- background-position: -231px -39px;
658
- }
659
- .jstree-default-small .jstree-anchor > .jstree-undetermined {
660
- background-position: -199px -7px;
661
- }
662
- .jstree-default-small .jstree-anchor > .jstree-undetermined:hover {
663
- background-position: -199px -39px;
664
- }
665
- .jstree-default-small .jstree-checkbox-disabled {
666
- opacity: 0.8;
667
- filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
668
- /* Firefox 10+ */
669
- filter: gray;
670
- /* IE6-9 */
671
- -webkit-filter: grayscale(100%);
672
- /* Chrome 19+ & Safari 6+ */
673
- }
674
- .jstree-default-small > .jstree-striped {
675
- background-size: auto 36px;
676
- }
677
- .jstree-default-small.jstree-rtl .jstree-node {
678
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
679
- background-position: 100% 1px;
680
- background-repeat: repeat-y;
681
- }
682
- .jstree-default-small.jstree-rtl .jstree-last {
683
- background: transparent;
684
- }
685
- .jstree-default-small.jstree-rtl .jstree-open > .jstree-ocl {
686
- background-position: -135px -39px;
687
- }
688
- .jstree-default-small.jstree-rtl .jstree-closed > .jstree-ocl {
689
- background-position: -103px -39px;
690
- }
691
- .jstree-default-small.jstree-rtl .jstree-leaf > .jstree-ocl {
692
- background-position: -71px -39px;
693
- }
694
- .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-node,
695
- .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl {
696
- background: transparent;
697
- }
698
- .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl {
699
- background-position: -39px -39px;
700
- }
701
- .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl {
702
- background-position: -7px -39px;
703
- }
704
- .jstree-default-small .jstree-themeicon-custom {
705
- background-color: transparent;
706
- background-image: none;
707
- background-position: 0 0;
708
- }
709
- .jstree-default-small > .jstree-container-ul .jstree-loading > .jstree-ocl {
710
- background: url("throbber.gif") center center no-repeat;
711
- }
712
- .jstree-default-small .jstree-file {
713
- background: url("../images/32px.png") -103px -71px no-repeat;
714
- }
715
- .jstree-default-small .jstree-folder {
716
- background: url("../images/32px.png") -263px -7px no-repeat;
717
- }
718
- .jstree-default-small > .jstree-container-ul > .jstree-node {
719
- margin-left: 0;
720
- margin-right: 0;
721
- }
722
- .jstree-default-small {
723
- line-height: 18px;
724
- padding: 0 4px;
725
- }
726
- .jstree-default-small .jstree-ok,
727
- .jstree-default-small .jstree-er {
728
- background-image: url("../images/32px.png");
729
- background-repeat: no-repeat;
730
- background-color: transparent;
731
- }
732
- .jstree-default-small i {
733
- background: transparent;
734
- width: 18px;
735
- height: 18px;
736
- line-height: 18px;
737
- }
738
- .jstree-default-small .jstree-ok {
739
- background-position: -7px -71px;
740
- }
741
- .jstree-default-small .jstree-er {
742
- background-position: -39px -71px;
743
- }
744
- .jstree-default-small .jstree-ellipsis {
745
- overflow: hidden;
746
- }
747
- .jstree-default-small .jstree-ellipsis .jstree-anchor {
748
- width: calc(100% - 23px);
749
- text-overflow: ellipsis;
750
- overflow: hidden;
751
- }
752
- .jstree-default-small.jstree-rtl .jstree-node {
753
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg==");
754
- }
755
- .jstree-default-small.jstree-rtl .jstree-last {
756
- background: transparent;
757
- }
758
- .jstree-default-large .jstree-node {
759
- min-height: 32px;
760
- line-height: 32px;
761
- margin-left: 32px;
762
- min-width: 32px;
763
- }
764
- .jstree-default-large .jstree-anchor {
765
- line-height: 32px;
766
- height: 32px;
767
- }
768
- .jstree-default-large .jstree-icon {
769
- width: 32px;
770
- height: 32px;
771
- line-height: 32px;
772
- }
773
- .jstree-default-large .jstree-icon:empty {
774
- width: 32px;
775
- height: 32px;
776
- line-height: 32px;
777
- }
778
- .jstree-default-large.jstree-rtl .jstree-node {
779
- margin-right: 32px;
780
- }
781
- .jstree-default-large .jstree-wholerow {
782
- height: 32px;
783
- }
784
- .jstree-default-large .jstree-node,
785
- .jstree-default-large .jstree-icon {
786
- background-image: url("../images/32px.png");
787
- }
788
- .jstree-default-large .jstree-node {
789
- background-position: -288px 0px;
790
- background-repeat: repeat-y;
791
- }
792
- .jstree-default-large .jstree-last {
793
- background: transparent;
794
- }
795
- .jstree-default-large .jstree-open > .jstree-ocl {
796
- background-position: -128px 0px;
797
- }
798
- .jstree-default-large .jstree-closed > .jstree-ocl {
799
- background-position: -96px 0px;
800
- }
801
- .jstree-default-large .jstree-leaf > .jstree-ocl {
802
- background-position: -64px 0px;
803
- }
804
- .jstree-default-large .jstree-themeicon {
805
- background-position: -256px 0px;
806
- }
807
- .jstree-default-large > .jstree-no-dots .jstree-node,
808
- .jstree-default-large > .jstree-no-dots .jstree-leaf > .jstree-ocl {
809
- background: transparent;
810
- }
811
- .jstree-default-large > .jstree-no-dots .jstree-open > .jstree-ocl {
812
- background-position: -32px 0px;
813
- }
814
- .jstree-default-large > .jstree-no-dots .jstree-closed > .jstree-ocl {
815
- background-position: 0px 0px;
816
- }
817
- .jstree-default-large .jstree-disabled {
818
- background: transparent;
819
- }
820
- .jstree-default-large .jstree-disabled.jstree-hovered {
821
- background: transparent;
822
- }
823
- .jstree-default-large .jstree-disabled.jstree-clicked {
824
- background: #efefef;
825
- }
826
- .jstree-default-large .jstree-checkbox {
827
- background-position: -160px 0px;
828
- }
829
- .jstree-default-large .jstree-checkbox:hover {
830
- background-position: -160px -32px;
831
- }
832
- .jstree-default-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
833
- .jstree-default-large .jstree-checked > .jstree-checkbox {
834
- background-position: -224px 0px;
835
- }
836
- .jstree-default-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
837
- .jstree-default-large .jstree-checked > .jstree-checkbox:hover {
838
- background-position: -224px -32px;
839
- }
840
- .jstree-default-large .jstree-anchor > .jstree-undetermined {
841
- background-position: -192px 0px;
842
- }
843
- .jstree-default-large .jstree-anchor > .jstree-undetermined:hover {
844
- background-position: -192px -32px;
845
- }
846
- .jstree-default-large .jstree-checkbox-disabled {
847
- opacity: 0.8;
848
- filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
849
- /* Firefox 10+ */
850
- filter: gray;
851
- /* IE6-9 */
852
- -webkit-filter: grayscale(100%);
853
- /* Chrome 19+ & Safari 6+ */
854
- }
855
- .jstree-default-large > .jstree-striped {
856
- background-size: auto 64px;
857
- }
858
- .jstree-default-large.jstree-rtl .jstree-node {
859
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
860
- background-position: 100% 1px;
861
- background-repeat: repeat-y;
862
- }
863
- .jstree-default-large.jstree-rtl .jstree-last {
864
- background: transparent;
865
- }
866
- .jstree-default-large.jstree-rtl .jstree-open > .jstree-ocl {
867
- background-position: -128px -32px;
868
- }
869
- .jstree-default-large.jstree-rtl .jstree-closed > .jstree-ocl {
870
- background-position: -96px -32px;
871
- }
872
- .jstree-default-large.jstree-rtl .jstree-leaf > .jstree-ocl {
873
- background-position: -64px -32px;
874
- }
875
- .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-node,
876
- .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl {
877
- background: transparent;
878
- }
879
- .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl {
880
- background-position: -32px -32px;
881
- }
882
- .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl {
883
- background-position: 0px -32px;
884
- }
885
- .jstree-default-large .jstree-themeicon-custom {
886
- background-color: transparent;
887
- background-image: none;
888
- background-position: 0 0;
889
- }
890
- .jstree-default-large > .jstree-container-ul .jstree-loading > .jstree-ocl {
891
- background: url("throbber.gif") center center no-repeat;
892
- }
893
- .jstree-default-large .jstree-file {
894
- background: url("../images/32px.png") -96px -64px no-repeat;
895
- }
896
- .jstree-default-large .jstree-folder {
897
- background: url("../images/32px.png") -256px 0px no-repeat;
898
- }
899
- .jstree-default-large > .jstree-container-ul > .jstree-node {
900
- margin-left: 0;
901
- margin-right: 0;
902
- }
903
- .jstree-default-large {
904
- line-height: 32px;
905
- padding: 0 4px;
906
- }
907
- .jstree-default-large .jstree-ok,
908
- .jstree-default-large .jstree-er {
909
- background-image: url("../images/32px.png");
910
- background-repeat: no-repeat;
911
- background-color: transparent;
912
- }
913
- .jstree-default-large i {
914
- background: transparent;
915
- width: 32px;
916
- height: 32px;
917
- line-height: 32px;
918
- }
919
- .jstree-default-large .jstree-ok {
920
- background-position: 0px -64px;
921
- }
922
- .jstree-default-large .jstree-er {
923
- background-position: -32px -64px;
924
- }
925
- .jstree-default-large .jstree-ellipsis {
926
- overflow: hidden;
927
- }
928
- .jstree-default-large .jstree-ellipsis .jstree-anchor {
929
- width: calc(100% - 37px);
930
- text-overflow: ellipsis;
931
- overflow: hidden;
932
- }
933
- .jstree-default-large.jstree-rtl .jstree-node {
934
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==");
935
- }
936
- .jstree-default-large.jstree-rtl .jstree-last {
937
- background: transparent;
938
- }
939
- @media (max-width: 768px) {
940
- .jstree-dnd-responsive {
941
- line-height: 40px;
942
- font-weight: bold;
943
- font-size: 1.1em;
944
- text-shadow: 1px 1px white;
945
- }
946
- .jstree-dnd-responsive > i {
947
- background: transparent;
948
- width: 40px;
949
- height: 40px;
950
- }
951
- .jstree-dnd-responsive > .jstree-ok {
952
- background-image: url("../images/40px.png");
953
- background-position: 0 -200px;
954
- background-size: 120px 240px;
955
- }
956
- .jstree-dnd-responsive > .jstree-er {
957
- background-image: url("../images/40px.png");
958
- background-position: -40px -200px;
959
- background-size: 120px 240px;
960
- }
961
- #jstree-marker.jstree-dnd-responsive {
962
- border-left-width: 10px;
963
- border-top-width: 10px;
964
- border-bottom-width: 10px;
965
- margin-top: -10px;
966
- }
967
- }
968
- @media (max-width: 768px) {
969
- .jstree-default-responsive {
970
- /*
971
- .jstree-open > .jstree-ocl,
972
- .jstree-closed > .jstree-ocl { border-radius:20px; background-color:white; }
973
- */
974
- }
975
- .jstree-default-responsive .jstree-icon {
976
- background-image: url("../images/40px.png");
977
- }
978
- .jstree-default-responsive .jstree-node,
979
- .jstree-default-responsive .jstree-leaf > .jstree-ocl {
980
- background: transparent;
981
- }
982
- .jstree-default-responsive .jstree-node {
983
- min-height: 40px;
984
- line-height: 40px;
985
- margin-left: 40px;
986
- min-width: 40px;
987
- white-space: nowrap;
988
- }
989
- .jstree-default-responsive .jstree-anchor {
990
- line-height: 40px;
991
- height: 40px;
992
- }
993
- .jstree-default-responsive .jstree-icon,
994
- .jstree-default-responsive .jstree-icon:empty {
995
- width: 40px;
996
- height: 40px;
997
- line-height: 40px;
998
- }
999
- .jstree-default-responsive > .jstree-container-ul > .jstree-node {
1000
- margin-left: 0;
1001
- }
1002
- .jstree-default-responsive.jstree-rtl .jstree-node {
1003
- margin-left: 0;
1004
- margin-right: 40px;
1005
- background: transparent;
1006
- }
1007
- .jstree-default-responsive.jstree-rtl .jstree-container-ul > .jstree-node {
1008
- margin-right: 0;
1009
- }
1010
- .jstree-default-responsive .jstree-ocl,
1011
- .jstree-default-responsive .jstree-themeicon,
1012
- .jstree-default-responsive .jstree-checkbox {
1013
- background-size: 120px 240px;
1014
- }
1015
- .jstree-default-responsive .jstree-leaf > .jstree-ocl,
1016
- .jstree-default-responsive.jstree-rtl .jstree-leaf > .jstree-ocl {
1017
- background: transparent;
1018
- }
1019
- .jstree-default-responsive .jstree-open > .jstree-ocl {
1020
- background-position: 0 0 !important;
1021
- }
1022
- .jstree-default-responsive .jstree-closed > .jstree-ocl {
1023
- background-position: 0 -40px !important;
1024
- }
1025
- .jstree-default-responsive.jstree-rtl .jstree-closed > .jstree-ocl {
1026
- background-position: -40px 0 !important;
1027
- }
1028
- .jstree-default-responsive .jstree-themeicon {
1029
- background-position: -40px -40px;
1030
- }
1031
- .jstree-default-responsive .jstree-checkbox,
1032
- .jstree-default-responsive .jstree-checkbox:hover {
1033
- background-position: -40px -80px;
1034
- }
1035
- .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
1036
- .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
1037
- .jstree-default-responsive .jstree-checked > .jstree-checkbox,
1038
- .jstree-default-responsive .jstree-checked > .jstree-checkbox:hover {
1039
- background-position: 0 -80px;
1040
- }
1041
- .jstree-default-responsive .jstree-anchor > .jstree-undetermined,
1042
- .jstree-default-responsive .jstree-anchor > .jstree-undetermined:hover {
1043
- background-position: 0 -120px;
1044
- }
1045
- .jstree-default-responsive .jstree-anchor {
1046
- font-weight: bold;
1047
- font-size: 1.1em;
1048
- text-shadow: 1px 1px white;
1049
- }
1050
- .jstree-default-responsive > .jstree-striped {
1051
- background: transparent;
1052
- }
1053
- .jstree-default-responsive .jstree-wholerow {
1054
- border-top: 1px solid rgba(255, 255, 255, 0.7);
1055
- border-bottom: 1px solid rgba(64, 64, 64, 0.2);
1056
- background: #ebebeb;
1057
- height: 40px;
1058
- }
1059
- .jstree-default-responsive .jstree-wholerow-hovered {
1060
- background: #e7f4f9;
1061
- }
1062
- .jstree-default-responsive .jstree-wholerow-clicked {
1063
- background: #beebff;
1064
- }
1065
- .jstree-default-responsive .jstree-children .jstree-last > .jstree-wholerow {
1066
- box-shadow: inset 0 -6px 3px -5px #666666;
1067
- }
1068
- .jstree-default-responsive .jstree-children .jstree-open > .jstree-wholerow {
1069
- box-shadow: inset 0 6px 3px -5px #666666;
1070
- border-top: 0;
1071
- }
1072
- .jstree-default-responsive .jstree-children .jstree-open + .jstree-open {
1073
- box-shadow: none;
1074
- }
1075
- .jstree-default-responsive .jstree-node,
1076
- .jstree-default-responsive .jstree-icon,
1077
- .jstree-default-responsive .jstree-node > .jstree-ocl,
1078
- .jstree-default-responsive .jstree-themeicon,
1079
- .jstree-default-responsive .jstree-checkbox {
1080
- background-image: url("../images/40px.png");
1081
- background-size: 120px 240px;
1082
- }
1083
- .jstree-default-responsive .jstree-node {
1084
- background-position: -80px 0;
1085
- background-repeat: repeat-y;
1086
- }
1087
- .jstree-default-responsive .jstree-last {
1088
- background: transparent;
1089
- }
1090
- .jstree-default-responsive .jstree-leaf > .jstree-ocl {
1091
- background-position: -40px -120px;
1092
- }
1093
- .jstree-default-responsive .jstree-last > .jstree-ocl {
1094
- background-position: -40px -160px;
1095
- }
1096
- .jstree-default-responsive .jstree-themeicon-custom {
1097
- background-color: transparent;
1098
- background-image: none;
1099
- background-position: 0 0;
1100
- }
1101
- .jstree-default-responsive .jstree-file {
1102
- background: url("../images/40px.png") 0 -160px no-repeat;
1103
- background-size: 120px 240px;
1104
- }
1105
- .jstree-default-responsive .jstree-folder {
1106
- background: url("../images/40px.png") -40px -40px no-repeat;
1107
- background-size: 120px 240px;
1108
- }
1109
- .jstree-default-responsive > .jstree-container-ul > .jstree-node {
1110
- margin-left: 0;
1111
- margin-right: 0;
1112
- }
1113
- }
1
+ /* jsTree default theme */
2
+ .jstree-node,
3
+ .jstree-children,
4
+ .jstree-container-ul {
5
+ display: block;
6
+ margin: 0;
7
+ padding: 0;
8
+ list-style-type: none;
9
+ list-style-image: none;
10
+ }
11
+ .jstree-node {
12
+ white-space: nowrap;
13
+ }
14
+ .jstree-anchor {
15
+ display: inline-block;
16
+ color: black;
17
+ white-space: nowrap;
18
+ padding: 0 4px 0 1px;
19
+ margin: 0;
20
+ vertical-align: top;
21
+ }
22
+ .jstree-anchor:focus {
23
+ outline: 0;
24
+ }
25
+ .jstree-anchor,
26
+ .jstree-anchor:link,
27
+ .jstree-anchor:visited,
28
+ .jstree-anchor:hover,
29
+ .jstree-anchor:active {
30
+ text-decoration: none;
31
+ }
32
+ .jstree-icon {
33
+ display: inline-block;
34
+ text-decoration: none;
35
+ margin: 0;
36
+ padding: 0;
37
+ vertical-align: top;
38
+ text-align: center;
39
+ }
40
+ .jstree-icon:empty {
41
+ display: inline-block;
42
+ text-decoration: none;
43
+ margin: 0;
44
+ padding: 0;
45
+ vertical-align: top;
46
+ text-align: center;
47
+ }
48
+ .jstree-ocl {
49
+ cursor: pointer;
50
+ }
51
+ .jstree-leaf > .jstree-ocl {
52
+ cursor: default;
53
+ }
54
+ .jstree .jstree-open > .jstree-children {
55
+ display: block;
56
+ }
57
+ .jstree .jstree-closed > .jstree-children,
58
+ .jstree .jstree-leaf > .jstree-children {
59
+ display: none;
60
+ }
61
+ .jstree-anchor > .jstree-themeicon {
62
+ margin-right: 2px;
63
+ }
64
+ .jstree-no-icons .jstree-themeicon,
65
+ .jstree-anchor > .jstree-themeicon-hidden {
66
+ display: none;
67
+ }
68
+ .jstree-hidden,
69
+ .jstree-node.jstree-hidden {
70
+ display: none;
71
+ }
72
+ .jstree-rtl .jstree-anchor {
73
+ padding: 0 1px 0 4px;
74
+ }
75
+ .jstree-rtl .jstree-anchor > .jstree-themeicon {
76
+ margin-left: 2px;
77
+ margin-right: 0;
78
+ }
79
+ .jstree-rtl .jstree-node {
80
+ margin-left: 0;
81
+ }
82
+ .jstree-rtl .jstree-container-ul > .jstree-node {
83
+ margin-right: 0;
84
+ }
85
+ .jstree-wholerow-ul {
86
+ position: relative;
87
+ display: inline-block;
88
+ min-width: 100%;
89
+ }
90
+ .jstree-wholerow-ul .jstree-leaf > .jstree-ocl {
91
+ cursor: pointer;
92
+ }
93
+ .jstree-wholerow-ul .jstree-anchor,
94
+ .jstree-wholerow-ul .jstree-icon {
95
+ position: relative;
96
+ }
97
+ .jstree-wholerow-ul .jstree-wholerow {
98
+ width: 100%;
99
+ cursor: pointer;
100
+ position: absolute;
101
+ left: 0;
102
+ -webkit-user-select: none;
103
+ -moz-user-select: none;
104
+ -ms-user-select: none;
105
+ user-select: none;
106
+ }
107
+ .jstree-contextmenu .jstree-anchor {
108
+ -webkit-user-select: none;
109
+ /* disable selection/Copy of UIWebView */
110
+ -webkit-touch-callout: none;
111
+ /* disable the IOS popup when long-press on a link */
112
+ }
113
+ .vakata-context {
114
+ display: none;
115
+ }
116
+ .vakata-context,
117
+ .vakata-context ul {
118
+ margin: 0;
119
+ padding: 2px;
120
+ position: absolute;
121
+ background: #f5f5f5;
122
+ border: 1px solid #979797;
123
+ box-shadow: 2px 2px 2px #999999;
124
+ }
125
+ .vakata-context ul {
126
+ list-style: none;
127
+ left: 100%;
128
+ margin-top: -2.7em;
129
+ margin-left: -4px;
130
+ }
131
+ .vakata-context .vakata-context-right ul {
132
+ left: auto;
133
+ right: 100%;
134
+ margin-left: auto;
135
+ margin-right: -4px;
136
+ }
137
+ .vakata-context li {
138
+ list-style: none;
139
+ }
140
+ .vakata-context li > a {
141
+ display: block;
142
+ padding: 0 2em 0 2em;
143
+ text-decoration: none;
144
+ width: auto;
145
+ color: black;
146
+ white-space: nowrap;
147
+ line-height: 2.4em;
148
+ text-shadow: 1px 1px 0 white;
149
+ border-radius: 1px;
150
+ }
151
+ .vakata-context li > a:hover {
152
+ position: relative;
153
+ background-color: #e8eff7;
154
+ box-shadow: 0 0 2px #0a6aa1;
155
+ }
156
+ .vakata-context li > a.vakata-context-parent {
157
+ background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw==");
158
+ background-position: right center;
159
+ background-repeat: no-repeat;
160
+ }
161
+ .vakata-context li > a:focus {
162
+ outline: 0;
163
+ }
164
+ .vakata-context .vakata-context-hover > a {
165
+ position: relative;
166
+ background-color: #e8eff7;
167
+ box-shadow: 0 0 2px #0a6aa1;
168
+ }
169
+ .vakata-context .vakata-context-separator > a,
170
+ .vakata-context .vakata-context-separator > a:hover {
171
+ background: white;
172
+ border: 0;
173
+ border-top: 1px solid #e2e3e3;
174
+ height: 1px;
175
+ min-height: 1px;
176
+ max-height: 1px;
177
+ padding: 0;
178
+ margin: 0 0 0 2.4em;
179
+ border-left: 1px solid #e0e0e0;
180
+ text-shadow: 0 0 0 transparent;
181
+ box-shadow: 0 0 0 transparent;
182
+ border-radius: 0;
183
+ }
184
+ .vakata-context .vakata-contextmenu-disabled a,
185
+ .vakata-context .vakata-contextmenu-disabled a:hover {
186
+ color: silver;
187
+ background-color: transparent;
188
+ border: 0;
189
+ box-shadow: 0 0 0;
190
+ }
191
+ .vakata-context .vakata-contextmenu-disabled > a > i {
192
+ filter: grayscale(100%);
193
+ }
194
+ .vakata-context li > a > i {
195
+ text-decoration: none;
196
+ display: inline-block;
197
+ width: 2.4em;
198
+ height: 2.4em;
199
+ background: transparent;
200
+ margin: 0 0 0 -2em;
201
+ vertical-align: top;
202
+ text-align: center;
203
+ line-height: 2.4em;
204
+ }
205
+ .vakata-context li > a > i:empty {
206
+ width: 2.4em;
207
+ line-height: 2.4em;
208
+ }
209
+ .vakata-context li > a .vakata-contextmenu-sep {
210
+ display: inline-block;
211
+ width: 1px;
212
+ height: 2.4em;
213
+ background: white;
214
+ margin: 0 0.5em 0 0;
215
+ border-left: 1px solid #e2e3e3;
216
+ }
217
+ .vakata-context .vakata-contextmenu-shortcut {
218
+ font-size: 0.8em;
219
+ color: silver;
220
+ opacity: 0.5;
221
+ display: none;
222
+ }
223
+ .vakata-context-rtl ul {
224
+ left: auto;
225
+ right: 100%;
226
+ margin-left: auto;
227
+ margin-right: -4px;
228
+ }
229
+ .vakata-context-rtl li > a.vakata-context-parent {
230
+ background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7");
231
+ background-position: left center;
232
+ background-repeat: no-repeat;
233
+ }
234
+ .vakata-context-rtl .vakata-context-separator > a {
235
+ margin: 0 2.4em 0 0;
236
+ border-left: 0;
237
+ border-right: 1px solid #e2e3e3;
238
+ }
239
+ .vakata-context-rtl .vakata-context-left ul {
240
+ right: auto;
241
+ left: 100%;
242
+ margin-left: -4px;
243
+ margin-right: auto;
244
+ }
245
+ .vakata-context-rtl li > a > i {
246
+ margin: 0 -2em 0 0;
247
+ }
248
+ .vakata-context-rtl li > a .vakata-contextmenu-sep {
249
+ margin: 0 0 0 0.5em;
250
+ border-left-color: white;
251
+ background: #e2e3e3;
252
+ }
253
+ #jstree-marker {
254
+ position: absolute;
255
+ top: 0;
256
+ left: 0;
257
+ margin: -5px 0 0 0;
258
+ padding: 0;
259
+ border-right: 0;
260
+ border-top: 5px solid transparent;
261
+ border-bottom: 5px solid transparent;
262
+ border-left: 5px solid;
263
+ width: 0;
264
+ height: 0;
265
+ font-size: 0;
266
+ line-height: 0;
267
+ }
268
+ {
269
+ line-height: 16px;
270
+ margin: 0;
271
+ padding: 4px;
272
+ }
273
+ .jstree-icon,
274
+ .jstree-copy {
275
+ display: inline-block;
276
+ text-decoration: none;
277
+ margin: 0 2px 0 0;
278
+ padding: 0;
279
+ width: 16px;
280
+ height: 16px;
281
+ }
282
+ .jstree-ok {
283
+ background: green;
284
+ }
285
+ .jstree-er {
286
+ background: red;
287
+ }
288
+ .jstree-copy {
289
+ margin: 0 2px 0 2px;
290
+ }
291
+ .jstree-default .jstree-node,
292
+ .jstree-default .jstree-icon {
293
+ background-repeat: no-repeat;
294
+ background-color: transparent;
295
+ }
296
+ .jstree-default .jstree-anchor,
297
+ .jstree-default .jstree-animated,
298
+ .jstree-default .jstree-wholerow {
299
+ transition: background-color 0.15s, box-shadow 0.15s;
300
+ }
301
+ .jstree-default .jstree-hovered {
302
+ box-shadow: inset 0 0 1px #cccccc;
303
+ }
304
+ .jstree-default .jstree-context {
305
+ background: #e7f4f9;
306
+ border-radius: 2px;
307
+ box-shadow: inset 0 0 1px #cccccc;
308
+ }
309
+ .jstree-default .jstree-clicked {
310
+ background: #beebff;
311
+ border-radius: 2px;
312
+ box-shadow: inset 0 0 1px #999999;
313
+ }
314
+ .jstree-default .jstree-no-icons .jstree-anchor > .jstree-themeicon {
315
+ display: none;
316
+ }
317
+ .jstree-default .jstree-disabled {
318
+ background: transparent;
319
+ color: #666666;
320
+ }
321
+ .jstree-default .jstree-disabled.jstree-hovered {
322
+ background: transparent;
323
+ box-shadow: none;
324
+ }
325
+ .jstree-default .jstree-disabled.jstree-clicked {
326
+ background: #efefef;
327
+ }
328
+ .jstree-default .jstree-disabled > .jstree-icon {
329
+ opacity: 0.8;
330
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
331
+ /* Firefox 10+ */
332
+ filter: gray;
333
+ /* IE6-9 */
334
+ -webkit-filter: grayscale(100%);
335
+ /* Chrome 19+ & Safari 6+ */
336
+ }
337
+ .jstree-default .jstree-search {
338
+ font-style: italic;
339
+ color: #8b0000;
340
+ font-weight: bold;
341
+ }
342
+ .jstree-default .jstree-no-checkboxes .jstree-checkbox {
343
+ display: none !important;
344
+ }
345
+ .jstree-default.jstree-checkbox-no-clicked .jstree-clicked {
346
+ background: transparent;
347
+ box-shadow: none;
348
+ }
349
+ .jstree-default.jstree-checkbox-no-clicked .jstree-clicked.jstree-hovered {
350
+ background: #e7f4f9;
351
+ }
352
+ .jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked {
353
+ background: transparent;
354
+ }
355
+ .jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked.jstree-wholerow-hovered {
356
+ background: #e7f4f9;
357
+ }
358
+ .jstree-default > .jstree-striped {
359
+ min-width: 100%;
360
+ display: inline-block;
361
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==") left top repeat;
362
+ }
363
+ .jstree-default > .jstree-wholerow-ul .jstree-hovered,
364
+ .jstree-default > .jstree-wholerow-ul .jstree-clicked {
365
+ background: transparent;
366
+ box-shadow: none;
367
+ border-radius: 0;
368
+ }
369
+ .jstree-default .jstree-wholerow {
370
+ -moz-box-sizing: border-box;
371
+ -webkit-box-sizing: border-box;
372
+ box-sizing: border-box;
373
+ }
374
+ .jstree-default .jstree-wholerow-hovered {
375
+ background: #e7f4f9;
376
+ }
377
+ .jstree-default .jstree-wholerow-clicked {
378
+ background: #beebff;
379
+ background: -webkit-linear-gradient(top, #beebff 0%, #a8e4ff 100%);
380
+ background: linear-gradient(to bottom, #beebff 0%, #a8e4ff 100%);
381
+ }
382
+ .jstree-default .jstree-node {
383
+ min-height: 30px;
384
+ line-height: 30px;
385
+ margin-left: 24px;
386
+ min-width: 30px;
387
+ }
388
+ .jstree-default .jstree-anchor {
389
+ line-height: 30px;
390
+ height: 30px;
391
+ width: calc(100% - 30px);
392
+ overflow: hidden;
393
+ padding: 0 30px 0 6px;
394
+ box-sizing: border-box;
395
+ position: relative;
396
+ margin: 0 0 0 4px;
397
+ border-radius: 4px;
398
+ display: inline-block;
399
+ white-space: nowrap;
400
+ text-overflow: ellipsis;
401
+ }
402
+ .jstree-default .jstree-icon {
403
+ width: 30px;
404
+ height: 30px;
405
+ line-height: 30px;
406
+ }
407
+ .jstree-default .jstree-icon:empty {
408
+ width: 24px;
409
+ height: 30px;
410
+ line-height: 30px;
411
+ }
412
+ .jstree-default.jstree-rtl .jstree-node {
413
+ margin-right: 30px;
414
+ }
415
+ .jstree-default .jstree-wholerow {
416
+ height: 30px;
417
+ }
418
+ .jstree-default .jstree-node,
419
+ .jstree-default .jstree-icon {
420
+ background-image: url("../images/32px.png");
421
+ }
422
+ .jstree-default .jstree-node {
423
+ background-position: -292px -4px;
424
+ background-repeat: repeat-y;
425
+ position: relative;
426
+ }
427
+ .jstree-default .jstree-last {
428
+ background: transparent;
429
+ }
430
+ .jstree-default .jstree-open > .jstree-ocl {
431
+ background-position: -132px -2px;
432
+ }
433
+ .jstree-default .jstree-closed > .jstree-ocl {
434
+ background-position: -100px -2px;
435
+ }
436
+ .jstree-default .jstree-leaf > .jstree-ocl {
437
+ background-position: -68px -2px;
438
+ }
439
+ .jstree-default .jstree-themeicon {
440
+ background-position: -260px -2px;
441
+ background: none;
442
+ }
443
+ .jstree-default > .jstree-no-dots .jstree-node,
444
+ .jstree-default > .jstree-no-dots .jstree-leaf > .jstree-ocl {
445
+ background: transparent;
446
+ }
447
+ .jstree-default > .jstree-no-dots .jstree-open > .jstree-ocl {
448
+ background-position: -36px -2px;
449
+ }
450
+ .jstree-default > .jstree-no-dots .jstree-closed > .jstree-ocl {
451
+ background-position: -4px -2px;
452
+ }
453
+ .jstree-default .jstree-disabled {
454
+ background: transparent;
455
+ }
456
+ .jstree-default .jstree-disabled.jstree-hovered {
457
+ background: transparent;
458
+ }
459
+ .jstree-default .jstree-disabled.jstree-clicked {
460
+ background: #efefef;
461
+ }
462
+ .jstree-default .jstree-checkbox {
463
+ background-position: -164px -4px;
464
+ }
465
+ .jstree-default .jstree-checkbox:hover {
466
+ background-position: -164px -36px;
467
+ }
468
+ .jstree-default.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
469
+ .jstree-default .jstree-checked > .jstree-checkbox {
470
+ background-position: -228px -4px;
471
+ }
472
+ .jstree-default.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
473
+ .jstree-default .jstree-checked > .jstree-checkbox:hover {
474
+ background-position: -228px -36px;
475
+ }
476
+ .jstree-default .jstree-anchor > .jstree-undetermined {
477
+ background-position: -196px -4px;
478
+ }
479
+ .jstree-default .jstree-anchor > .jstree-undetermined:hover {
480
+ background-position: -196px -36px;
481
+ }
482
+ .jstree-default .jstree-checkbox-disabled {
483
+ opacity: 0.8;
484
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
485
+ /* Firefox 10+ */
486
+ filter: gray;
487
+ /* IE6-9 */
488
+ -webkit-filter: grayscale(100%);
489
+ /* Chrome 19+ & Safari 6+ */
490
+ }
491
+ .jstree-default > .jstree-striped {
492
+ background-size: auto 48px;
493
+ }
494
+ .jstree-default.jstree-rtl .jstree-node {
495
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
496
+ background-position: 100% 1px;
497
+ background-repeat: repeat-y;
498
+ }
499
+ .jstree-default.jstree-rtl .jstree-last {
500
+ background: transparent;
501
+ }
502
+ .jstree-default.jstree-rtl .jstree-open > .jstree-ocl {
503
+ background-position: -132px -36px;
504
+ }
505
+ .jstree-default.jstree-rtl .jstree-closed > .jstree-ocl {
506
+ background-position: -100px -36px;
507
+ }
508
+ .jstree-default.jstree-rtl .jstree-leaf > .jstree-ocl {
509
+ background-position: -68px -36px;
510
+ }
511
+ .jstree-default.jstree-rtl > .jstree-no-dots .jstree-node,
512
+ .jstree-default.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl {
513
+ background: transparent;
514
+ }
515
+ .jstree-default.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl {
516
+ background-position: -36px -36px;
517
+ }
518
+ .jstree-default.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl {
519
+ background-position: -4px -36px;
520
+ }
521
+ .jstree-default .jstree-themeicon-custom {
522
+ background-color: transparent;
523
+ background-image: none;
524
+ background-position: 0 0;
525
+ }
526
+ .jstree-default > .jstree-container-ul .jstree-loading > .jstree-ocl {
527
+ background: url("throbber.gif") center center no-repeat;
528
+ }
529
+ .jstree-default .jstree-file {
530
+ background: url("../images/32px.png") -100px -68px no-repeat;
531
+ }
532
+ .jstree-default .jstree-folder {
533
+ background: url("../images/32px.png") -260px -4px no-repeat;
534
+ }
535
+ .jstree-default > .jstree-container-ul > .jstree-node {
536
+ margin-left: 0;
537
+ margin-right: 0;
538
+ }
539
+ .jstree-default {
540
+ line-height: 30px;
541
+ padding: 0 4px;
542
+ }
543
+ .jstree-default .jstree-ok,
544
+ .jstree-default .jstree-er {
545
+ background-image: url("../images/32px.png");
546
+ background-repeat: no-repeat;
547
+ background-color: transparent;
548
+ }
549
+ .jstree-default i {
550
+ background: transparent;
551
+ width: 20px;
552
+ height: 30px;
553
+ line-height: 30px;
554
+ display: inline-block;
555
+ vertical-align: top;
556
+ }
557
+ .jstree-default .jstree-ok {
558
+ background-position: -4px -68px;
559
+ }
560
+ .jstree-default .jstree-er {
561
+ background-position: -36px -68px;
562
+ }
563
+ .jstree-default .jstree-ellipsis {
564
+ overflow: hidden;
565
+ }
566
+ .jstree-default .jstree-ellipsis .jstree-anchor {
567
+ width: calc(100% - 29px);
568
+ text-overflow: ellipsis;
569
+ overflow: hidden;
570
+ }
571
+ .jstree-default.jstree-rtl .jstree-node {
572
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
573
+ }
574
+ .jstree-default.jstree-rtl .jstree-last {
575
+ background: transparent;
576
+ }
577
+ .jstree-default-small .jstree-node {
578
+ min-height: 18px;
579
+ line-height: 18px;
580
+ margin-left: 18px;
581
+ min-width: 18px;
582
+ }
583
+ .jstree-default-small .jstree-anchor {
584
+ line-height: 18px;
585
+ height: 18px;
586
+ }
587
+ .jstree-default-small .jstree-icon {
588
+ width: 18px;
589
+ height: 18px;
590
+ line-height: 18px;
591
+ }
592
+ .jstree-default-small .jstree-icon:empty {
593
+ width: 18px;
594
+ height: 18px;
595
+ line-height: 18px;
596
+ }
597
+ .jstree-default-small.jstree-rtl .jstree-node {
598
+ margin-right: 18px;
599
+ }
600
+ .jstree-default-small .jstree-wholerow {
601
+ height: 18px;
602
+ }
603
+ .jstree-default-small .jstree-node,
604
+ .jstree-default-small .jstree-icon {
605
+ background-image: url("../images/32px.png");
606
+ }
607
+ .jstree-default-small .jstree-node {
608
+ background-position: -295px -7px;
609
+ background-repeat: repeat-y;
610
+ }
611
+ .jstree-default-small .jstree-last {
612
+ background: transparent;
613
+ }
614
+ .jstree-default-small .jstree-open > .jstree-ocl {
615
+ background-position: -135px -7px;
616
+ }
617
+ .jstree-default-small .jstree-closed > .jstree-ocl {
618
+ background-position: -103px -7px;
619
+ }
620
+ .jstree-default-small .jstree-leaf > .jstree-ocl {
621
+ background-position: -71px -7px;
622
+ }
623
+ .jstree-default-small .jstree-themeicon {
624
+ background-position: -263px -7px;
625
+ }
626
+ .jstree-default-small > .jstree-no-dots .jstree-node,
627
+ .jstree-default-small > .jstree-no-dots .jstree-leaf > .jstree-ocl {
628
+ background: transparent;
629
+ }
630
+ .jstree-default-small > .jstree-no-dots .jstree-open > .jstree-ocl {
631
+ background-position: -39px -7px;
632
+ }
633
+ .jstree-default-small > .jstree-no-dots .jstree-closed > .jstree-ocl {
634
+ background-position: -7px -7px;
635
+ }
636
+ .jstree-default-small .jstree-disabled {
637
+ background: transparent;
638
+ }
639
+ .jstree-default-small .jstree-disabled.jstree-hovered {
640
+ background: transparent;
641
+ }
642
+ .jstree-default-small .jstree-disabled.jstree-clicked {
643
+ background: #efefef;
644
+ }
645
+ .jstree-default-small .jstree-checkbox {
646
+ background-position: -167px -7px;
647
+ }
648
+ .jstree-default-small .jstree-checkbox:hover {
649
+ background-position: -167px -39px;
650
+ }
651
+ .jstree-default-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
652
+ .jstree-default-small .jstree-checked > .jstree-checkbox {
653
+ background-position: -231px -7px;
654
+ }
655
+ .jstree-default-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
656
+ .jstree-default-small .jstree-checked > .jstree-checkbox:hover {
657
+ background-position: -231px -39px;
658
+ }
659
+ .jstree-default-small .jstree-anchor > .jstree-undetermined {
660
+ background-position: -199px -7px;
661
+ }
662
+ .jstree-default-small .jstree-anchor > .jstree-undetermined:hover {
663
+ background-position: -199px -39px;
664
+ }
665
+ .jstree-default-small .jstree-checkbox-disabled {
666
+ opacity: 0.8;
667
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
668
+ /* Firefox 10+ */
669
+ filter: gray;
670
+ /* IE6-9 */
671
+ -webkit-filter: grayscale(100%);
672
+ /* Chrome 19+ & Safari 6+ */
673
+ }
674
+ .jstree-default-small > .jstree-striped {
675
+ background-size: auto 36px;
676
+ }
677
+ .jstree-default-small.jstree-rtl .jstree-node {
678
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
679
+ background-position: 100% 1px;
680
+ background-repeat: repeat-y;
681
+ }
682
+ .jstree-default-small.jstree-rtl .jstree-last {
683
+ background: transparent;
684
+ }
685
+ .jstree-default-small.jstree-rtl .jstree-open > .jstree-ocl {
686
+ background-position: -135px -39px;
687
+ }
688
+ .jstree-default-small.jstree-rtl .jstree-closed > .jstree-ocl {
689
+ background-position: -103px -39px;
690
+ }
691
+ .jstree-default-small.jstree-rtl .jstree-leaf > .jstree-ocl {
692
+ background-position: -71px -39px;
693
+ }
694
+ .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-node,
695
+ .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl {
696
+ background: transparent;
697
+ }
698
+ .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl {
699
+ background-position: -39px -39px;
700
+ }
701
+ .jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl {
702
+ background-position: -7px -39px;
703
+ }
704
+ .jstree-default-small .jstree-themeicon-custom {
705
+ background-color: transparent;
706
+ background-image: none;
707
+ background-position: 0 0;
708
+ }
709
+ .jstree-default-small > .jstree-container-ul .jstree-loading > .jstree-ocl {
710
+ background: url("throbber.gif") center center no-repeat;
711
+ }
712
+ .jstree-default-small .jstree-file {
713
+ background: url("../images/32px.png") -103px -71px no-repeat;
714
+ }
715
+ .jstree-default-small .jstree-folder {
716
+ background: url("../images/32px.png") -263px -7px no-repeat;
717
+ }
718
+ .jstree-default-small > .jstree-container-ul > .jstree-node {
719
+ margin-left: 0;
720
+ margin-right: 0;
721
+ }
722
+ .jstree-default-small {
723
+ line-height: 18px;
724
+ padding: 0 4px;
725
+ }
726
+ .jstree-default-small .jstree-ok,
727
+ .jstree-default-small .jstree-er {
728
+ background-image: url("../images/32px.png");
729
+ background-repeat: no-repeat;
730
+ background-color: transparent;
731
+ }
732
+ .jstree-default-small i {
733
+ background: transparent;
734
+ width: 18px;
735
+ height: 18px;
736
+ line-height: 18px;
737
+ }
738
+ .jstree-default-small .jstree-ok {
739
+ background-position: -7px -71px;
740
+ }
741
+ .jstree-default-small .jstree-er {
742
+ background-position: -39px -71px;
743
+ }
744
+ .jstree-default-small .jstree-ellipsis {
745
+ overflow: hidden;
746
+ }
747
+ .jstree-default-small .jstree-ellipsis .jstree-anchor {
748
+ width: calc(100% - 23px);
749
+ text-overflow: ellipsis;
750
+ overflow: hidden;
751
+ }
752
+ .jstree-default-small.jstree-rtl .jstree-node {
753
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg==");
754
+ }
755
+ .jstree-default-small.jstree-rtl .jstree-last {
756
+ background: transparent;
757
+ }
758
+ .jstree-default-large .jstree-node {
759
+ min-height: 32px;
760
+ line-height: 32px;
761
+ margin-left: 32px;
762
+ min-width: 32px;
763
+ }
764
+ .jstree-default-large .jstree-anchor {
765
+ line-height: 32px;
766
+ height: 32px;
767
+ }
768
+ .jstree-default-large .jstree-icon {
769
+ width: 32px;
770
+ height: 32px;
771
+ line-height: 32px;
772
+ }
773
+ .jstree-default-large .jstree-icon:empty {
774
+ width: 32px;
775
+ height: 32px;
776
+ line-height: 32px;
777
+ }
778
+ .jstree-default-large.jstree-rtl .jstree-node {
779
+ margin-right: 32px;
780
+ }
781
+ .jstree-default-large .jstree-wholerow {
782
+ height: 32px;
783
+ }
784
+ .jstree-default-large .jstree-node,
785
+ .jstree-default-large .jstree-icon {
786
+ background-image: url("../images/32px.png");
787
+ }
788
+ .jstree-default-large .jstree-node {
789
+ background-position: -288px 0px;
790
+ background-repeat: repeat-y;
791
+ }
792
+ .jstree-default-large .jstree-last {
793
+ background: transparent;
794
+ }
795
+ .jstree-default-large .jstree-open > .jstree-ocl {
796
+ background-position: -128px 0px;
797
+ }
798
+ .jstree-default-large .jstree-closed > .jstree-ocl {
799
+ background-position: -96px 0px;
800
+ }
801
+ .jstree-default-large .jstree-leaf > .jstree-ocl {
802
+ background-position: -64px 0px;
803
+ }
804
+ .jstree-default-large .jstree-themeicon {
805
+ background-position: -256px 0px;
806
+ }
807
+ .jstree-default-large > .jstree-no-dots .jstree-node,
808
+ .jstree-default-large > .jstree-no-dots .jstree-leaf > .jstree-ocl {
809
+ background: transparent;
810
+ }
811
+ .jstree-default-large > .jstree-no-dots .jstree-open > .jstree-ocl {
812
+ background-position: -32px 0px;
813
+ }
814
+ .jstree-default-large > .jstree-no-dots .jstree-closed > .jstree-ocl {
815
+ background-position: 0px 0px;
816
+ }
817
+ .jstree-default-large .jstree-disabled {
818
+ background: transparent;
819
+ }
820
+ .jstree-default-large .jstree-disabled.jstree-hovered {
821
+ background: transparent;
822
+ }
823
+ .jstree-default-large .jstree-disabled.jstree-clicked {
824
+ background: #efefef;
825
+ }
826
+ .jstree-default-large .jstree-checkbox {
827
+ background-position: -160px 0px;
828
+ }
829
+ .jstree-default-large .jstree-checkbox:hover {
830
+ background-position: -160px -32px;
831
+ }
832
+ .jstree-default-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
833
+ .jstree-default-large .jstree-checked > .jstree-checkbox {
834
+ background-position: -224px 0px;
835
+ }
836
+ .jstree-default-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
837
+ .jstree-default-large .jstree-checked > .jstree-checkbox:hover {
838
+ background-position: -224px -32px;
839
+ }
840
+ .jstree-default-large .jstree-anchor > .jstree-undetermined {
841
+ background-position: -192px 0px;
842
+ }
843
+ .jstree-default-large .jstree-anchor > .jstree-undetermined:hover {
844
+ background-position: -192px -32px;
845
+ }
846
+ .jstree-default-large .jstree-checkbox-disabled {
847
+ opacity: 0.8;
848
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'jstree-grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#jstree-grayscale");
849
+ /* Firefox 10+ */
850
+ filter: gray;
851
+ /* IE6-9 */
852
+ -webkit-filter: grayscale(100%);
853
+ /* Chrome 19+ & Safari 6+ */
854
+ }
855
+ .jstree-default-large > .jstree-striped {
856
+ background-size: auto 64px;
857
+ }
858
+ .jstree-default-large.jstree-rtl .jstree-node {
859
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
860
+ background-position: 100% 1px;
861
+ background-repeat: repeat-y;
862
+ }
863
+ .jstree-default-large.jstree-rtl .jstree-last {
864
+ background: transparent;
865
+ }
866
+ .jstree-default-large.jstree-rtl .jstree-open > .jstree-ocl {
867
+ background-position: -128px -32px;
868
+ }
869
+ .jstree-default-large.jstree-rtl .jstree-closed > .jstree-ocl {
870
+ background-position: -96px -32px;
871
+ }
872
+ .jstree-default-large.jstree-rtl .jstree-leaf > .jstree-ocl {
873
+ background-position: -64px -32px;
874
+ }
875
+ .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-node,
876
+ .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl {
877
+ background: transparent;
878
+ }
879
+ .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl {
880
+ background-position: -32px -32px;
881
+ }
882
+ .jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl {
883
+ background-position: 0px -32px;
884
+ }
885
+ .jstree-default-large .jstree-themeicon-custom {
886
+ background-color: transparent;
887
+ background-image: none;
888
+ background-position: 0 0;
889
+ }
890
+ .jstree-default-large > .jstree-container-ul .jstree-loading > .jstree-ocl {
891
+ background: url("throbber.gif") center center no-repeat;
892
+ }
893
+ .jstree-default-large .jstree-file {
894
+ background: url("../images/32px.png") -96px -64px no-repeat;
895
+ }
896
+ .jstree-default-large .jstree-folder {
897
+ background: url("../images/32px.png") -256px 0px no-repeat;
898
+ }
899
+ .jstree-default-large > .jstree-container-ul > .jstree-node {
900
+ margin-left: 0;
901
+ margin-right: 0;
902
+ }
903
+ .jstree-default-large {
904
+ line-height: 32px;
905
+ padding: 0 4px;
906
+ }
907
+ .jstree-default-large .jstree-ok,
908
+ .jstree-default-large .jstree-er {
909
+ background-image: url("../images/32px.png");
910
+ background-repeat: no-repeat;
911
+ background-color: transparent;
912
+ }
913
+ .jstree-default-large i {
914
+ background: transparent;
915
+ width: 32px;
916
+ height: 32px;
917
+ line-height: 32px;
918
+ }
919
+ .jstree-default-large .jstree-ok {
920
+ background-position: 0px -64px;
921
+ }
922
+ .jstree-default-large .jstree-er {
923
+ background-position: -32px -64px;
924
+ }
925
+ .jstree-default-large .jstree-ellipsis {
926
+ overflow: hidden;
927
+ }
928
+ .jstree-default-large .jstree-ellipsis .jstree-anchor {
929
+ width: calc(100% - 37px);
930
+ text-overflow: ellipsis;
931
+ overflow: hidden;
932
+ }
933
+ .jstree-default-large.jstree-rtl .jstree-node {
934
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==");
935
+ }
936
+ .jstree-default-large.jstree-rtl .jstree-last {
937
+ background: transparent;
938
+ }
939
+ @media (max-width: 768px) {
940
+ .jstree-dnd-responsive {
941
+ line-height: 40px;
942
+ font-weight: bold;
943
+ font-size: 1.1em;
944
+ text-shadow: 1px 1px white;
945
+ }
946
+ .jstree-dnd-responsive > i {
947
+ background: transparent;
948
+ width: 40px;
949
+ height: 40px;
950
+ }
951
+ .jstree-dnd-responsive > .jstree-ok {
952
+ background-image: url("../images/40px.png");
953
+ background-position: 0 -200px;
954
+ background-size: 120px 240px;
955
+ }
956
+ .jstree-dnd-responsive > .jstree-er {
957
+ background-image: url("../images/40px.png");
958
+ background-position: -40px -200px;
959
+ background-size: 120px 240px;
960
+ }
961
+ #jstree-marker.jstree-dnd-responsive {
962
+ border-left-width: 10px;
963
+ border-top-width: 10px;
964
+ border-bottom-width: 10px;
965
+ margin-top: -10px;
966
+ }
967
+ }
968
+ @media (max-width: 768px) {
969
+ .jstree-default-responsive {
970
+ /*
971
+ .jstree-open > .jstree-ocl,
972
+ .jstree-closed > .jstree-ocl { border-radius:20px; background-color:white; }
973
+ */
974
+ }
975
+ .jstree-default-responsive .jstree-icon {
976
+ background-image: url("../images/40px.png");
977
+ }
978
+ .jstree-default-responsive .jstree-node,
979
+ .jstree-default-responsive .jstree-leaf > .jstree-ocl {
980
+ background: transparent;
981
+ }
982
+ .jstree-default-responsive .jstree-node {
983
+ min-height: 40px;
984
+ line-height: 40px;
985
+ margin-left: 40px;
986
+ min-width: 40px;
987
+ white-space: nowrap;
988
+ }
989
+ .jstree-default-responsive .jstree-anchor {
990
+ line-height: 40px;
991
+ height: 40px;
992
+ }
993
+ .jstree-default-responsive .jstree-icon,
994
+ .jstree-default-responsive .jstree-icon:empty {
995
+ width: 40px;
996
+ height: 40px;
997
+ line-height: 40px;
998
+ }
999
+ .jstree-default-responsive > .jstree-container-ul > .jstree-node {
1000
+ margin-left: 0;
1001
+ }
1002
+ .jstree-default-responsive.jstree-rtl .jstree-node {
1003
+ margin-left: 0;
1004
+ margin-right: 40px;
1005
+ background: transparent;
1006
+ }
1007
+ .jstree-default-responsive.jstree-rtl .jstree-container-ul > .jstree-node {
1008
+ margin-right: 0;
1009
+ }
1010
+ .jstree-default-responsive .jstree-ocl,
1011
+ .jstree-default-responsive .jstree-themeicon,
1012
+ .jstree-default-responsive .jstree-checkbox {
1013
+ background-size: 120px 240px;
1014
+ }
1015
+ .jstree-default-responsive .jstree-leaf > .jstree-ocl,
1016
+ .jstree-default-responsive.jstree-rtl .jstree-leaf > .jstree-ocl {
1017
+ background: transparent;
1018
+ }
1019
+ .jstree-default-responsive .jstree-open > .jstree-ocl {
1020
+ background-position: 0 0 !important;
1021
+ }
1022
+ .jstree-default-responsive .jstree-closed > .jstree-ocl {
1023
+ background-position: 0 -40px !important;
1024
+ }
1025
+ .jstree-default-responsive.jstree-rtl .jstree-closed > .jstree-ocl {
1026
+ background-position: -40px 0 !important;
1027
+ }
1028
+ .jstree-default-responsive .jstree-themeicon {
1029
+ background-position: -40px -40px;
1030
+ }
1031
+ .jstree-default-responsive .jstree-checkbox,
1032
+ .jstree-default-responsive .jstree-checkbox:hover {
1033
+ background-position: -40px -80px;
1034
+ }
1035
+ .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox,
1036
+ .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover,
1037
+ .jstree-default-responsive .jstree-checked > .jstree-checkbox,
1038
+ .jstree-default-responsive .jstree-checked > .jstree-checkbox:hover {
1039
+ background-position: 0 -80px;
1040
+ }
1041
+ .jstree-default-responsive .jstree-anchor > .jstree-undetermined,
1042
+ .jstree-default-responsive .jstree-anchor > .jstree-undetermined:hover {
1043
+ background-position: 0 -120px;
1044
+ }
1045
+ .jstree-default-responsive .jstree-anchor {
1046
+ font-weight: bold;
1047
+ font-size: 1.1em;
1048
+ text-shadow: 1px 1px white;
1049
+ }
1050
+ .jstree-default-responsive > .jstree-striped {
1051
+ background: transparent;
1052
+ }
1053
+ .jstree-default-responsive .jstree-wholerow {
1054
+ border-top: 1px solid rgba(255, 255, 255, 0.7);
1055
+ border-bottom: 1px solid rgba(64, 64, 64, 0.2);
1056
+ background: #ebebeb;
1057
+ height: 40px;
1058
+ }
1059
+ .jstree-default-responsive .jstree-wholerow-hovered {
1060
+ background: #e7f4f9;
1061
+ }
1062
+ .jstree-default-responsive .jstree-wholerow-clicked {
1063
+ background: #beebff;
1064
+ }
1065
+ .jstree-default-responsive .jstree-children .jstree-last > .jstree-wholerow {
1066
+ box-shadow: inset 0 -6px 3px -5px #666666;
1067
+ }
1068
+ .jstree-default-responsive .jstree-children .jstree-open > .jstree-wholerow {
1069
+ box-shadow: inset 0 6px 3px -5px #666666;
1070
+ border-top: 0;
1071
+ }
1072
+ .jstree-default-responsive .jstree-children .jstree-open + .jstree-open {
1073
+ box-shadow: none;
1074
+ }
1075
+ .jstree-default-responsive .jstree-node,
1076
+ .jstree-default-responsive .jstree-icon,
1077
+ .jstree-default-responsive .jstree-node > .jstree-ocl,
1078
+ .jstree-default-responsive .jstree-themeicon,
1079
+ .jstree-default-responsive .jstree-checkbox {
1080
+ background-image: url("../images/40px.png");
1081
+ background-size: 120px 240px;
1082
+ }
1083
+ .jstree-default-responsive .jstree-node {
1084
+ background-position: -80px 0;
1085
+ background-repeat: repeat-y;
1086
+ }
1087
+ .jstree-default-responsive .jstree-last {
1088
+ background: transparent;
1089
+ }
1090
+ .jstree-default-responsive .jstree-leaf > .jstree-ocl {
1091
+ background-position: -40px -120px;
1092
+ }
1093
+ .jstree-default-responsive .jstree-last > .jstree-ocl {
1094
+ background-position: -40px -160px;
1095
+ }
1096
+ .jstree-default-responsive .jstree-themeicon-custom {
1097
+ background-color: transparent;
1098
+ background-image: none;
1099
+ background-position: 0 0;
1100
+ }
1101
+ .jstree-default-responsive .jstree-file {
1102
+ background: url("../images/40px.png") 0 -160px no-repeat;
1103
+ background-size: 120px 240px;
1104
+ }
1105
+ .jstree-default-responsive .jstree-folder {
1106
+ background: url("../images/40px.png") -40px -40px no-repeat;
1107
+ background-size: 120px 240px;
1108
+ }
1109
+ .jstree-default-responsive > .jstree-container-ul > .jstree-node {
1110
+ margin-left: 0;
1111
+ margin-right: 0;
1112
+ }
1113
+ }
assets/css/page-post-media.css CHANGED
@@ -7,11 +7,9 @@
7
  background: #f1f1f1;
8
  direction: ltr;
9
  }
10
-
11
- .media-frame.hide-menu .media-frame-content, .media-frame.hide-menu .media-frame-router, .media-frame.hide-menu .media-frame-title, .media-frame.hide-menu .media-frame-toolbar {
12
  left: 275px
13
  }
14
-
15
  .wcp-container {
16
  padding: 20px 20px 20px 16px
17
  }
@@ -1084,6 +1082,10 @@ html[dir=rtl] .media-frame.hide-menu .media-frame-content, html[dir=rtl] .media-
1084
  left: 0;
1085
  right: 275px;
1086
  }
 
 
 
 
1087
  .sticky-folders > ul > li {
1088
  position: relative;
1089
  }
7
  background: #f1f1f1;
8
  direction: ltr;
9
  }
10
+ .folder-modal .media-frame .media-frame-content, .folder-modal .media-frame .media-frame-router, .folder-modal .media-frame .media-frame-title, .folder-modal .media-frame .media-frame-toolbar {
 
11
  left: 275px
12
  }
 
13
  .wcp-container {
14
  padding: 20px 20px 20px 16px
15
  }
1082
  left: 0;
1083
  right: 275px;
1084
  }
1085
+ html[dir=rtl] .media-frame .folder-modal .media-frame-content, html[dir=rtl] .folder-modal .media-frame .media-frame-router, html[dir=rtl] .folder-modal .media-frame .media-frame-title, html[dir=rtl] .folder-modal .media-frame .media-frame-toolbar {
1086
+ left: 0;
1087
+ right: 275px;
1088
+ }
1089
  .sticky-folders > ul > li {
1090
  position: relative;
1091
  }
assets/css/page-post-media.min.css CHANGED
@@ -1 +1 @@
1
- .folder-custom-menu{width:275px;z-index:10001;position:absolute;height:100%;border-right:solid 1px #ddd;background:#f1f1f1;direction:ltr}.media-frame.hide-menu .media-frame-content,.media-frame.hide-menu .media-frame-router,.media-frame.hide-menu .media-frame-title,.media-frame.hide-menu .media-frame-toolbar{left:275px}.wcp-container{padding:20px 20px 20px 16px}.form-title{font-size:23px;font-weight:400;margin:0;padding:0 0 10px 0;line-height:29px;min-height:36px}.media-frame a.add-new-folder{text-decoration:none;display:block;float:right;font-size:14px;padding:4px 10px 4px 4px;background:#f51366;color:#fff;border:solid 1px #f51366;border-radius:4px;line-height:24px;position:relative}.add-new-folder span{display:block;float:left;line-height:24px;font-size:14px;margin-right:5px}span.create_new_folder{width:26px;height:26px;line-height:26px;font-size:14px;background:rgba(255,255,255,.4);backdrop-filter:blur(16px);border-radius:4px;text-align:center;margin:0 15px 0 0}span.folder-loader-ajax{float:right;margin:0;line-height:30px;display:none}.folder-loader-ajax.active{display:inline-block}@-webkit-keyframes scaleAnimation{0%{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes scaleAnimation{0%{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes drawCircle{0%{stroke-dashoffset:151px}100%{stroke-dashoffset:0}}@keyframes drawCircle{0%{stroke-dashoffset:151px}100%{stroke-dashoffset:0}}@-webkit-keyframes drawCheck{0%{stroke-dashoffset:36px}100%{stroke-dashoffset:0}}@keyframes drawCheck{0%{stroke-dashoffset:36px}100%{stroke-dashoffset:0}}@-webkit-keyframes fadeOut{0%{opacity:1}100%{opacity:0}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}#successAnimationCircle{stroke-dasharray:151px 151px;stroke:#2ce0a7}#successAnimationCheck{stroke-dasharray:36px 36px;stroke:#2ce0a7}#successAnimationResult{fill:#2ce0a7;opacity:0}svg#successAnimation{width:30px;height:34px;padding:0;display:none;float:left}#successAnimation.active{display:inline-block}.folder-loader-ajax img{display:none}#successAnimation.animated{-webkit-animation:1s ease-out 0s 1 both scaleAnimation;animation:1s ease-out 0s 1 both scaleAnimation}#successAnimation.animated #successAnimationCircle{-webkit-animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCircle,.3s linear .9s 1 both fadeOut;animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCircle,.3s linear .9s 1 both fadeOut}#successAnimation.animated #successAnimationCheck{-webkit-animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCheck,.3s linear .9s 1 both fadeOut;animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCheck,.3s linear .9s 1 both fadeOut}#successAnimation.animated #successAnimationResult{-webkit-animation:.3s linear .9s both fadeIn;animation:.3s linear .9s both fadeIn}.form-options{background:#fff;padding:5px;margin:0 0;border-radius:4px;box-shadow:0 4px 21px rgba(7,16,28,.1)}.wcp-container ul{list-style:none}.form-options ul{margin:0;padding:0}.form-options>ul>li{display:inline-block;margin:0 2px 0 0;vertical-align:top}.form-options>ul>li.last{margin:0}.form-options>ul>li.last.folder-checkbox{padding:5px 0 0}.form-options>ul>li>a{display:inline-block;text-decoration:none;padding:5px 5px;color:#000;vertical-align:middle;margin:0 0 5px 0;background:#f1f1f1;border-radius:4px}.form-options span.icon{font-size:12px;display:inline-block;vertical-align:baseline;color:#a4c0d2}.wcp-hide-show-buttons{display:none}.folder-order{position:relative}.form-options>ul>li.last>a.sort-folder-order{width:28px;padding:5px;text-align:center;display:inline-block;box-sizing:border-box}.folder-sort-menu{position:absolute;right:0;width:120px;z-index:101;background:#fff;-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,.25);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,.25);box-shadow:0 0 5px 0 rgba(0,0,0,.25);display:none}.folder-sort-menu li{display:block;margin:0;padding:0;background:0 0}.folder-sort-menu li a{display:block;margin:0;padding:3px 5px;background:0 0;color:#848484;text-decoration:none;font-size:14px}span.upgrade-message{padding:0;background:#fff;display:inline-block;font-size:12px;color:#000}span.upgrade-message a.pink,span.upgrade-message span.pink{color:#ff5983;text-decoration:none;font-weight:700}.form-loader{width:100%;height:5px;margin:0 0 10px}.form-loader-count{width:0;height:5px;background:url(../images/form-loader.png);transition:all 2.5s linear;-webkit-transition:all 2s linear;-moz-transition:all 2.5s linear}.top-settings{background:#fff;padding:10px 10px 5px;-webkit-border-top-left-radius:4px;-webkit-border-top-right-radius:4px;-moz-border-radius-topleft:4px;-moz-border-radius-topright:4px;border-top-left-radius:4px;border-top-right-radius:4px;box-shadow:0 4px 21px rgba(7,16,28,.1)}.header-posts a,.un-categorised-items a{color:#444;padding:7px;display:block;text-decoration:none;font-size:14px;border-radius:4px;line-height:18px}.header-posts a.active-item,.orange-bg>span,.un-categorised-items.active-item,.wcp-container .route.active-item>h3.title{background-color:#fa166b!important;color:#fff}.header-posts a.active-item span.total-count,.un-categorised-items.active-item span.total-count,.wcp-container .route.active-item>h3.title span.total-count{color:#fff!important}.wcp-icon{display:inline-block;font-size:16px;vertical-align:top;margin-right:3px}span.total-count{float:right;font-size:12px;line-height:16px}.header-posts a.active-item span.total-count,.un-categorised-items.active-item a span{color:#fff!important}.header-posts a:hover,.un-categorised-items.active-item,.un-categorised-items:hover{background:rgba(250,22,107,.08);border-radius:4px;color:#444}.un-categorised-items.active-item a,.un-categorised-items.active-item a:hover{color:#fff}.un-categorised-items a:hover,.un-categorised-items:hover a{color:#444}.media-frame .folder-custom-menu a:focus{outline:0;box-shadow:none}.sticky-title{font-size:16px;font-weight:700;padding:7px}div#custom-menu{padding:10px;background:#fff;box-shadow:0 4px 21px rgba(7,16,28,.1)}.wcp-container .space{position:relative;list-style-type:none;border:0;margin:0 0 0 20px;padding:0 0 30px 0;width:40px;top:30px;height:100%;z-index:1}.wcp-container .first-space{margin-left:0;top:0;padding:0}.wcp-container .route{position:relative;list-style-type:none;border:0;margin:0;padding:0;top:0;max-height:100%!important;width:100%;border-radius:2px;z-index:-1;background:0 0}.wcp-container .route .title{position:absolute;border:0;margin:0;padding:0;height:30px;width:200px;text-indent:28px;background:0 0;box-shadow:none;font-size:13px;line-height:26px;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;overflow:hidden;font-weight:400}.wcp-container .route span{position:absolute;top:2px;left:0;z-index:10;width:20px;height:18px;text-indent:0;font-size:20px;background:no-repeat;text-align:center}.wcp-container .route span.ui-icon{line-height:24px;font-size:18px;cursor:move;left:5px;top:2px;height:26px}#custom-menu .wcp-icon{font-size:16px!important;line-height:24px}#custom-menu input.checkbox{display:none}.wcp-container .route span.title-text{position:relative;top:auto;left:auto;display:inline-block;font-size:16px;line-height:30px;height:30px;width:calc(100% - 100px);overflow:hidden;white-space:nowrap;text-align:left}#custom-menu [class*=" pfolder-"],#custom-menu [class^=pfolder-]{font-size:12px}.wcp-container .route .title .folder-sticky-icon,.wcp-container .route .title .move-folder-icon{float:right;position:relative;top:0;left:auto;width:20px;height:30px;line-height:26px;display:none}.wcp-container .route.is-sticky>h3.title .folder-sticky-icon,.wcp-container .route.is-sticky>h3.title .move-folder-icon{display:block}.nav-icon{display:none;left:-10px!important;cursor:pointer}#custom-menu .route .nav-icon .wcp-icon{font-size:9px!important;color:#fa166b;font-weight:700;transform:rotate(-90deg);transition:all .25s linear}.header-posts a,.un-categorised-items a,.wcp-container .route span.title-text{font-size:12px}.wcp-container .route span.total-count{position:relative;font-size:10px;float:right;text-align:center;width:auto;display:block;margin:4px 8px 3px 3px;color:#23282d!important;line-height:16px;height:16px}.has-sub-tree>.nav-icon{display:block}.has-sub-tree>ul.ui-sortable li{display:none}.has-sub-tree.active>ul.ui-sortable>li{display:block}body:not(.no-hover-css) .wcp-container .route .title:hover{background:rgba(250,22,107,.08);cursor:pointer}body:not(.no-hover-css) .wcp-container .route .title.wcp-drop-hover .move-folder-icon,body:not(.no-hover-css) .wcp-container .route .title:hover .move-folder-icon{display:block}body:not(.no-hover-css) .wcp-container .route .title:hover>.folder-sticky-icon,body:not(.no-hover-css) .wcp-container .route .title:hover>.star-icon{display:none!important}body:not(.no-hover-css) .sticky-folders li a:hover span.update-inline-record,body:not(.no-hover-css) .wcp-container .route h3:hover>span.update-inline-record{width:18px}body:not(.no-hover-css) .wcp-container .route .title.wcp-drop-hover .ui-icon .pfolder-folder-close:before,body:not(.no-hover-css) .wcp-container .route .title:hover .ui-icon .pfolder-folder-close:before{content:"\e901"!important}.sticky-folders li.is-high a span.star-icon,.wcp-container .route.is-high>h3>span.star-icon{display:block}.dynamic-menu{position:absolute;left:50px;background:#fff;width:170px;padding:0;z-index:101;-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,.25);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,.25);box-shadow:0 0 5px 0 rgba(0,0,0,.25)}.dynamic-menu li{position:relative;width:100%;display:block!important;padding:2px 0;margin:0}.dynamic-menu li.new-folder{border-bottom:solid 1px #d8d8d8}.dynamic-menu a{text-decoration:none;color:#848484;position:relative;display:block;padding:5px 10px;line-height:18px;white-space:nowrap}.dynamic-menu ul>li>a>span,.dynamic-menu ul>li>a>span span{position:relative!important;display:inline-block;vertical-align:middle;margin-right:5px;top:auto!important;width:20px!important;height:20px!important;line-height:14px}#custom-menu .dynamic-menu ul>li>a .sticky-pin{line-height:20px}#custom-menu .dynamic-menu ul>li>a .sticky-pin i{font-size:16px!important}li.active-menu{z-index:2!important}.dynamic-menu a.active,.dynamic-menu a:hover{background:#efefef;color:#000}.folder-popup-form{position:fixed;width:100%;height:100%;background:rgba(0,0,0,.5);top:0;left:0;z-index:10001;display:none}.popup-form-content{background:#fff;min-height:100px;width:400px;text-align:center;margin:0 auto;position:absolute;left:0;right:0;top:50%;transform:translate(0,-50%);-webkit-transform:translate(0,-50%);-moz-transform:translate(0,-50%);-o-transform:translate(0,-50%);-ms-transform:translate(0,-50%);padding:20px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;color:#484848}.add-update-folder-title{display:block;position:relative;max-width:100%;margin:0 0 .4em;padding:0;color:#595959;text-align:center;text-transform:none;word-wrap:break-word;font-weight:700;font-size:22px;line-height:26px}.folder-group{position:relative;margin:45px auto 15px;padding:0 2px}.folder-group input,.folder-group textarea{background:0 0;font-size:14px;padding:0 0 0 15px;display:block;width:100%;border-radius:4px;border:1px solid #484848;height:34px;line-height:34px;color:#484848;outline:0}.highlight{background-color:#e4f2fd;color:#000}.folder-group .folder-bar{position:relative;display:block;width:320px}.folder-group label{font-size:14px;font-weight:500;position:absolute;pointer-events:none;left:20px;top:10px;-webkit-transition:.3s ease all;transition:.3s ease all;color:#484848}.folder-form-errors{margin:0 0 10px 0;padding:8px 0;background:#ffe4e4;color:#a20000;display:none}.folder-form-buttons{display:flex}.folder-form-buttons a,.folder-form-buttons button{display:inline-flex;padding:0;text-decoration:none;margin:10px 3px;border-radius:4px;border:solid 1px #1da1f4;line-height:34px;font-weight:700;font-size:14px;box-sizing:border-box;height:36px;cursor:pointer;flex:1;justify-content:center;outline:0;color:#fff}.folder-form-buttons .form-cancel-btn,.folder-form-buttons a.form-cancel-btn:hover{background-color:#fff;color:#3085d6;outline:0}.form-submit-btn,.form-submit-btn:hover{background-color:#3085d6;color:#fff!important;outline:0}.folder-group input:focus~label,.folder-group input:valid~label,.folder-group textarea:focus~label,.folder-group textarea:valid~label{top:-9px;background:#fff;padding:0 5px;font-weight:400;font-size:12px;line-height:14px;color:#aeaeae}#no-more-folder-credit .folder-form-message{margin:20px 80px;font-size:14px}.folder-form-message{margin:25px auto;font-size:15px;line-height:18px;color:#484848;width:310px}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.folder-form-buttons a span,.folder-form-buttons button span{-webkit-animation:fa-spin .75s infinite linear;animation:fa-spin .75s infinite linear;padding:7px}.wcp-container .folder-tooltip{position:relative}.wcp-container .folder-tooltip::after,.wcp-container .folder-tooltip::before{text-transform:none;font-size:.9em;line-height:1;user-select:none;pointer-events:none;position:absolute;display:none;opacity:0}.wcp-container .folder-tooltip::before{content:'';border:5px solid transparent;z-index:1001}.wcp-container .folder-tooltip::after{content:attr(data-folder-tooltip);font-family:Helvetica,sans-serif;text-align:center;min-width:3em;max-width:21em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:1ch 1.5ch;border-radius:.3ch;box-shadow:0 1em 2em -.5em rgba(0,0,0,.35);background:#333;color:#fff;z-index:1000}.wcp-container .folder-tooltip:hover::after,.wcp-container .folder-tooltip:hover::before{display:block;opacity:1}.wcp-container .folder-tooltip:not([flow])::before,.wcp-container .folder-tooltip[flow^=up]::before{bottom:100%;border-bottom-width:0;border-top-color:#333}.wcp-container .folder-tooltip:not([flow])::after,.wcp-container .folder-tooltip[flow^=up]::after{bottom:calc(100% + 5px)}.wcp-container .folder-tooltip:not([flow])::after,.wcp-container .folder-tooltip:not([flow])::before,.wcp-container .folder-tooltip[flow^=up]::after,.wcp-container .folder-tooltip[flow^=up]::before{left:50%;transform:translate(-50%,-.5em)}.folder-order.active .folder-sort-menu{display:block}.folder-sort-menu li a.active,.folder-sort-menu li a:hover{background:#efefef;color:#000}.media-toolbar-secondary select{width:30%!important;width:calc(30% - 10px)!important;margin:32px 10px 0 0!important}.media-frame .uploader-inline{z-index:1}.wcp-drop-hover{background:#fa166b!important;z-index:2!important;color:#fff!important}.wcp-drop-hover i{color:#fff!important}.selected-items{background:#0073aa;color:#fff;padding:10px 20px;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;margin-top:0;cursor:none;font-size:12px;z-index:10001!important}.media-frame,.media-frame .attachments-browser,.media-frame-content{overflow:inherit}#custom-menu .route.active .nav-icon .wcp-icon{transform:rotate(0);-webkit-transform:rotate(0)}.expand-collapse.all-open span.icon{transform:rotate(180deg);-webkit-transform:rotate(180deg)}.folder-search-form{padding:0 0 10px 0;position:relative}.folder-search-form input{background:#fff;border:1px solid #dbdbdb!important;box-sizing:border-box;border-radius:4px;height:32px;line-height:32px;box-sizing:border-box;padding:0 5px!important;width:100%!important;box-shadow:none!important;outline:0}.folder-search-form span{position:absolute;color:#aeaeae;right:0;top:0;height:32px;line-height:32px;width:32px;text-align:center}.folder-separator{padding:0 10px;height:1px;background:#e9e5e5;margin:0 0 10px 0}.wcp-drop-hover i{color:#fff!important}.ui-draggable-dragging{z-index:10051!important}.attachments.ui-sortable.ui-draggable-dragging{z-index:10001!important}#custom-menu.has-filter li.route{display:none!important}#custom-menu.has-filter li.route.has-search{display:block!important}#custom-menu.has-filter h3 span.title-text.has-search-text{font-weight:700}.form-options>ul>li>a:hover{background:#404040;color:#fff}#custom-menu.show-folder-checkbox input.checkbox{display:block;margin:5px 0 0 0}#custom-menu.show-folder-checkbox h3.title>.ui-icon>i,#custom-menu.show-folder-checkbox h3.title>.ui-icon>img{display:none!important}.plugin-button{float:right}.plugin-button.d-block{float:none}.plugin-title{display:inline-block}.form-options .form-options{background:0 0;padding:0;box-shadow:none}.attachments-browser .media-toolbar-secondary{width:78%;max-width:inherit}.media-toolbar-primary.search-form{width:20%;max-width:inherit}body .media-frame.hide-menu .media-frame-menu{display:block}.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-content,.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-router,.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-title,.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-toolbar{left:275px}.media-frame-menu.has-folder-menu{width:275px}.media-frame-menu.has-folder-menu .folder-custom-menu{position:relative;border:none;width:100%}.media-frame.mode-select.hide-router .media-frame-content,.media-frame.mode-select.hide-router .media-frame-router,.media-frame.mode-select.hide-router .media-frame-title,.media-frame.mode-select.hide-router .media-frame-toolbar{left:275px}.media-frame.mode-select.hide-router select#media-attachment-taxonomy-filter{display:none}.media-frame.mode-select.hide-router .folder-custom-menu{display:none}html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-content,html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-router,html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-title,html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-toolbar{left:0;right:275px}html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-content,html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-router,html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-title,html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-toolbar{left:0;right:275px}html[dir=rtl] .media-frame.hide-menu .media-frame-content,html[dir=rtl] .media-frame.hide-menu .media-frame-router,html[dir=rtl] .media-frame.hide-menu .media-frame-title,html[dir=rtl] .media-frame.hide-menu .media-frame-toolbar{left:0;right:275px}.sticky-folders>ul>li{position:relative}#vakata-dnd{z-index:10000000!important}
1
+ .folder-custom-menu{width:275px;z-index:10001;position:absolute;height:100%;border-right:solid 1px #ddd;background:#f1f1f1;direction:ltr}.folder-modal .media-frame .media-frame-content,.folder-modal .media-frame .media-frame-router,.folder-modal .media-frame .media-frame-title,.folder-modal .media-frame .media-frame-toolbar{left:275px}.wcp-container{padding:20px 20px 20px 16px}.form-title{font-size:23px;font-weight:400;margin:0;padding:0 0 10px 0;line-height:29px;min-height:36px}.media-frame a.add-new-folder{text-decoration:none;display:block;float:right;font-size:14px;padding:4px 10px 4px 4px;background:#f51366;color:#fff;border:solid 1px #f51366;border-radius:4px;line-height:24px;position:relative}.add-new-folder span{display:block;float:left;line-height:24px;font-size:14px;margin-right:5px}span.create_new_folder{width:26px;height:26px;line-height:26px;font-size:14px;background:rgba(255,255,255,.4);backdrop-filter:blur(16px);border-radius:4px;text-align:center;margin:0 15px 0 0}span.folder-loader-ajax{float:right;margin:0;line-height:30px;display:none}.folder-loader-ajax.active{display:inline-block}@-webkit-keyframes scaleAnimation{0%{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes scaleAnimation{0%{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes drawCircle{0%{stroke-dashoffset:151px}100%{stroke-dashoffset:0}}@keyframes drawCircle{0%{stroke-dashoffset:151px}100%{stroke-dashoffset:0}}@-webkit-keyframes drawCheck{0%{stroke-dashoffset:36px}100%{stroke-dashoffset:0}}@keyframes drawCheck{0%{stroke-dashoffset:36px}100%{stroke-dashoffset:0}}@-webkit-keyframes fadeOut{0%{opacity:1}100%{opacity:0}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}#successAnimationCircle{stroke-dasharray:151px 151px;stroke:#2ce0a7}#successAnimationCheck{stroke-dasharray:36px 36px;stroke:#2ce0a7}#successAnimationResult{fill:#2ce0a7;opacity:0}svg#successAnimation{width:30px;height:34px;padding:0;display:none;float:left}#successAnimation.active{display:inline-block}.folder-loader-ajax img{display:none}#successAnimation.animated{-webkit-animation:1s ease-out 0s 1 both scaleAnimation;animation:1s ease-out 0s 1 both scaleAnimation}#successAnimation.animated #successAnimationCircle{-webkit-animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCircle,.3s linear .9s 1 both fadeOut;animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCircle,.3s linear .9s 1 both fadeOut}#successAnimation.animated #successAnimationCheck{-webkit-animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCheck,.3s linear .9s 1 both fadeOut;animation:1s cubic-bezier(.77,0,.175,1) 0s 1 both drawCheck,.3s linear .9s 1 both fadeOut}#successAnimation.animated #successAnimationResult{-webkit-animation:.3s linear .9s both fadeIn;animation:.3s linear .9s both fadeIn}.form-options{background:#fff;padding:5px;margin:0;border-radius:4px;box-shadow:0 4px 21px rgba(7,16,28,.1)}.wcp-container ul{list-style:none}.form-options ul{margin:0;padding:0}.form-options>ul>li{display:inline-block;margin:0 2px 0 0;vertical-align:top}.form-options>ul>li.last{margin:0}.form-options>ul>li.last.folder-checkbox{padding:5px 0 0}.form-options>ul>li>a{display:inline-block;text-decoration:none;padding:5px 5px;color:#000;vertical-align:middle;margin:0 0 5px 0;background:#f1f1f1;border-radius:4px}.form-options span.icon{font-size:12px;display:inline-block;vertical-align:baseline;color:#a4c0d2}.wcp-hide-show-buttons{display:none}.folder-order{position:relative}.form-options>ul>li.last>a.sort-folder-order{width:28px;padding:5px;text-align:center;display:inline-block;box-sizing:border-box}.folder-sort-menu{position:absolute;right:0;width:120px;z-index:101;background:#fff;-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,.25);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,.25);box-shadow:0 0 5px 0 rgba(0,0,0,.25);display:none}.folder-sort-menu li{display:block;margin:0;padding:0;background:0}.folder-sort-menu li a{display:block;margin:0;padding:3px 5px;background:0;color:#848484;text-decoration:none;font-size:14px}span.upgrade-message{padding:0;background:#fff;display:inline-block;font-size:12px;color:#000}span.upgrade-message a.pink,span.upgrade-message span.pink{color:#ff5983;text-decoration:none;font-weight:700}.form-loader{width:100%;height:5px;margin:0 0 10px}.form-loader-count{width:0;height:5px;background:url(../images/form-loader.png);transition:all 2.5s linear;-webkit-transition:all 2s linear;-moz-transition:all 2.5s linear}.top-settings{background:#fff;padding:10px 10px 5px;-webkit-border-top-left-radius:4px;-webkit-border-top-right-radius:4px;-moz-border-radius-topleft:4px;-moz-border-radius-topright:4px;border-top-left-radius:4px;border-top-right-radius:4px;box-shadow:0 4px 21px rgba(7,16,28,.1)}.header-posts a,.un-categorised-items a{color:#444;padding:7px;display:block;text-decoration:none;font-size:14px;border-radius:4px;line-height:18px}.header-posts a.active-item,.orange-bg>span,.un-categorised-items.active-item,.wcp-container .route.active-item>h3.title{background-color:#fa166b!important;color:#fff}.header-posts a.active-item span.total-count,.un-categorised-items.active-item span.total-count,.wcp-container .route.active-item>h3.title span.total-count{color:#fff!important}.wcp-icon{display:inline-block;font-size:16px;vertical-align:top;margin-right:3px}span.total-count{float:right;font-size:12px;line-height:16px}.header-posts a.active-item span.total-count,.un-categorised-items.active-item a span{color:#fff!important}.header-posts a:hover,.un-categorised-items.active-item,.un-categorised-items:hover{background:rgba(250,22,107,.08);border-radius:4px;color:#444}.un-categorised-items.active-item a,.un-categorised-items.active-item a:hover{color:#fff}.un-categorised-items a:hover,.un-categorised-items:hover a{color:#444}.media-frame .folder-custom-menu a:focus{outline:0;box-shadow:none}.sticky-title{font-size:16px;font-weight:700;padding:7px}div#custom-menu{padding:10px;background:#fff;box-shadow:0 4px 21px rgba(7,16,28,.1)}.wcp-container .space{position:relative;list-style-type:none;border:0;margin:0 0 0 20px;padding:0 0 30px 0;width:40px;top:30px;height:100%;z-index:1}.wcp-container .first-space{margin-left:0;top:0;padding:0}.wcp-container .route{position:relative;list-style-type:none;border:0;margin:0;padding:0;top:0;max-height:100%!important;width:100%;border-radius:2px;z-index:-1;background:0}.wcp-container .route .title{position:absolute;border:0;margin:0;padding:0;height:30px;width:200px;text-indent:28px;background:0;box-shadow:none;font-size:13px;line-height:26px;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;overflow:hidden;font-weight:400}.wcp-container .route span{position:absolute;top:2px;left:0;z-index:10;width:20px;height:18px;text-indent:0;font-size:20px;background:no-repeat;text-align:center}.wcp-container .route span.ui-icon{line-height:24px;font-size:18px;cursor:move;left:5px;top:2px;height:26px}#custom-menu .wcp-icon{font-size:16px!important;line-height:24px}#custom-menu input.checkbox{display:none}.wcp-container .route span.title-text{position:relative;top:auto;left:auto;display:inline-block;font-size:16px;line-height:30px;height:30px;width:calc(100% - 100px);overflow:hidden;white-space:nowrap;text-align:left}#custom-menu [class*=" pfolder-"],#custom-menu [class^=pfolder-]{font-size:12px}.wcp-container .route .title .folder-sticky-icon,.wcp-container .route .title .move-folder-icon{float:right;position:relative;top:0;left:auto;width:20px;height:30px;line-height:26px;display:none}.wcp-container .route.is-sticky>h3.title .folder-sticky-icon,.wcp-container .route.is-sticky>h3.title .move-folder-icon{display:block}.nav-icon{display:none;left:-10px!important;cursor:pointer}#custom-menu .route .nav-icon .wcp-icon{font-size:9px!important;color:#fa166b;font-weight:700;transform:rotate(-90deg);transition:all .25s linear}.header-posts a,.un-categorised-items a,.wcp-container .route span.title-text{font-size:12px}.wcp-container .route span.total-count{position:relative;font-size:10px;float:right;text-align:center;width:auto;display:block;margin:4px 8px 3px 3px;color:#23282d!important;line-height:16px;height:16px}.has-sub-tree>.nav-icon{display:block}.has-sub-tree>ul.ui-sortable li{display:none}.has-sub-tree.active>ul.ui-sortable>li{display:block}body:not(.no-hover-css) .wcp-container .route .title:hover{background:rgba(250,22,107,.08);cursor:pointer}body:not(.no-hover-css) .wcp-container .route .title.wcp-drop-hover .move-folder-icon,body:not(.no-hover-css) .wcp-container .route .title:hover .move-folder-icon{display:block}body:not(.no-hover-css) .wcp-container .route .title:hover>.folder-sticky-icon,body:not(.no-hover-css) .wcp-container .route .title:hover>.star-icon{display:none!important}body:not(.no-hover-css) .sticky-folders li a:hover span.update-inline-record,body:not(.no-hover-css) .wcp-container .route h3:hover>span.update-inline-record{width:18px}body:not(.no-hover-css) .wcp-container .route .title:hover .ui-icon .pfolder-folder-close:before,body:not(.no-hover-css) .wcp-container .route .title.wcp-drop-hover .ui-icon .pfolder-folder-close:before{content:"\e901"!important}.sticky-folders li.is-high a span.star-icon,.wcp-container .route.is-high>h3>span.star-icon{display:block}.dynamic-menu{position:absolute;left:50px;background:#fff;width:170px;padding:0;z-index:101;-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,.25);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,.25);box-shadow:0 0 5px 0 rgba(0,0,0,.25)}.dynamic-menu li{position:relative;width:100%;display:block!important;padding:2px 0;margin:0}.dynamic-menu li.new-folder{border-bottom:solid 1px #d8d8d8}.dynamic-menu a{text-decoration:none;color:#848484;position:relative;display:block;padding:5px 10px;line-height:18px;white-space:nowrap}.dynamic-menu ul>li>a>span,.dynamic-menu ul>li>a>span span{position:relative!important;display:inline-block;vertical-align:middle;margin-right:5px;top:auto!important;width:20px!important;height:20px!important;line-height:14px}#custom-menu .dynamic-menu ul>li>a .sticky-pin{line-height:20px}#custom-menu .dynamic-menu ul>li>a .sticky-pin i{font-size:16px!important}li.active-menu{z-index:2!important}.dynamic-menu a.active,.dynamic-menu a:hover{background:#efefef;color:#000}.folder-popup-form{position:fixed;width:100%;height:100%;background:rgba(0,0,0,.5);top:0;left:0;z-index:10001;display:none}.popup-form-content{background:#fff;min-height:100px;width:400px;text-align:center;margin:0 auto;position:absolute;left:0;right:0;top:50%;transform:translate(0,-50%);-webkit-transform:translate(0,-50%);-moz-transform:translate(0,-50%);-o-transform:translate(0,-50%);-ms-transform:translate(0,-50%);padding:20px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;color:#484848}.add-update-folder-title{display:block;position:relative;max-width:100%;margin:0 0 .4em;padding:0;color:#595959;text-align:center;text-transform:none;word-wrap:break-word;font-weight:700;font-size:22px;line-height:26px}.folder-group{position:relative;margin:45px auto 15px;padding:0 2px}.folder-group input,.folder-group textarea{background:0;font-size:14px;padding:0 0 0 15px;display:block;width:100%;border-radius:4px;border:1px solid #484848;height:34px;line-height:34px;color:#484848;outline:0}.highlight{background-color:#e4f2fd;color:#000}.folder-group .folder-bar{position:relative;display:block;width:320px}.folder-group label{font-size:14px;font-weight:500;position:absolute;pointer-events:none;left:20px;top:10px;-webkit-transition:.3s ease all;transition:.3s ease all;color:#484848}.folder-form-errors{margin:0 0 10px 0;padding:8px 0;background:#ffe4e4;color:#a20000;display:none}.folder-form-buttons{display:flex}.folder-form-buttons a,.folder-form-buttons button{display:inline-flex;padding:0;text-decoration:none;margin:10px 3px;border-radius:4px;border:solid 1px #1da1f4;line-height:34px;font-weight:700;font-size:14px;box-sizing:border-box;height:36px;cursor:pointer;flex:1;justify-content:center;outline:0;color:#fff}.folder-form-buttons .form-cancel-btn,.folder-form-buttons a.form-cancel-btn:hover{background-color:#fff;color:#3085d6;outline:0}.form-submit-btn,.form-submit-btn:hover{background-color:#3085d6;color:#fff!important;outline:0}.folder-group input:focus ~ label,.folder-group input:valid ~ label,.folder-group textarea:focus ~ label,.folder-group textarea:valid ~ label{top:-9px;background:#fff;padding:0 5px;font-weight:400;font-size:12px;line-height:14px;color:#aeaeae}#no-more-folder-credit .folder-form-message{margin:20px 80px;font-size:14px}.folder-form-message{margin:25px auto;font-size:15px;line-height:18px;color:#484848;width:310px}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.folder-form-buttons a span,.folder-form-buttons button span{-webkit-animation:fa-spin .75s infinite linear;animation:fa-spin .75s infinite linear;padding:7px}.wcp-container .folder-tooltip{position:relative}.wcp-container .folder-tooltip::after,.wcp-container .folder-tooltip::before{text-transform:none;font-size:.9em;line-height:1;user-select:none;pointer-events:none;position:absolute;display:none;opacity:0}.wcp-container .folder-tooltip::before{content:'';border:5px solid transparent;z-index:1001}.wcp-container .folder-tooltip::after{content:attr(data-folder-tooltip);font-family:Helvetica,sans-serif;text-align:center;min-width:3em;max-width:21em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:1ch 1.5ch;border-radius:.3ch;box-shadow:0 1em 2em -.5em rgba(0,0,0,.35);background:#333;color:#fff;z-index:1000}.wcp-container .folder-tooltip:hover::after,.wcp-container .folder-tooltip:hover::before{display:block;opacity:1}.wcp-container .folder-tooltip:not([flow])::before,.wcp-container .folder-tooltip[flow^=up]::before{bottom:100%;border-bottom-width:0;border-top-color:#333}.wcp-container .folder-tooltip:not([flow])::after,.wcp-container .folder-tooltip[flow^=up]::after{bottom:calc(100%+5px)}.wcp-container .folder-tooltip:not([flow])::after,.wcp-container .folder-tooltip:not([flow])::before,.wcp-container .folder-tooltip[flow^=up]::after,.wcp-container .folder-tooltip[flow^=up]::before{left:50%;transform:translate(-50%,-.5em)}.folder-order.active .folder-sort-menu{display:block}.folder-sort-menu li a.active,.folder-sort-menu li a:hover{background:#efefef;color:#000}.media-toolbar-secondary select{width:30%!important;width:calc(30% - 10px)!important;margin:32px 10px 0 0!important}.media-frame .uploader-inline{z-index:1}.wcp-drop-hover{background:#fa166b!important;z-index:2!important;color:#fff!important}.wcp-drop-hover i{color:#fff!important}.selected-items{background:#0073aa;color:#fff;padding:10px 20px;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;margin-top:0;cursor:none;font-size:12px;z-index:10001!important}.media-frame,.media-frame .attachments-browser,.media-frame-content{overflow:inherit}#custom-menu .route.active .nav-icon .wcp-icon{transform:rotate(0);-webkit-transform:rotate(0)}.expand-collapse.all-open span.icon{transform:rotate(180deg);-webkit-transform:rotate(180deg)}.folder-search-form{padding:0 0 10px 0;position:relative}.folder-search-form input{background:#fff;border:1px solid #dbdbdb!important;box-sizing:border-box;border-radius:4px;height:32px;line-height:32px;box-sizing:border-box;padding:0 5px!important;width:100%!important;box-shadow:none!important;outline:0}.folder-search-form span{position:absolute;color:#aeaeae;right:0;top:0;height:32px;line-height:32px;width:32px;text-align:center}.folder-separator{padding:0 10px;height:1px;background:#e9e5e5;margin:0 0 10px 0}.wcp-drop-hover i{color:#fff!important}.ui-draggable-dragging{z-index:10051!important}.attachments.ui-sortable.ui-draggable-dragging{z-index:10001!important}#custom-menu.has-filter li.route{display:none!important}#custom-menu.has-filter li.route.has-search{display:block!important}#custom-menu.has-filter h3 span.title-text.has-search-text{font-weight:700}.form-options>ul>li>a:hover{background:#404040;color:#fff}#custom-menu.show-folder-checkbox input.checkbox{display:block;margin:5px 0 0 0}#custom-menu.show-folder-checkbox h3.title>.ui-icon>i,#custom-menu.show-folder-checkbox h3.title>.ui-icon>img{display:none!important}.plugin-button{float:right}.plugin-button.d-block{float:none}.plugin-title{display:inline-block}.form-options .form-options{background:transparent;padding:0;box-shadow:none}.attachments-browser .media-toolbar-secondary{width:78%;max-width:inherit}.media-toolbar-primary.search-form{width:20%;max-width:inherit}body *.media-frame.hide-menu .media-frame-menu{display:block}.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-content,.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-router,.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-title,.folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-toolbar{left:275px}.media-frame-menu.has-folder-menu{width:275px}.media-frame-menu.has-folder-menu .folder-custom-menu{position:relative;border:0;width:100%}.media-frame.mode-select.hide-router .media-frame-title,.media-frame.mode-select.hide-router .media-frame-router,.media-frame.mode-select.hide-router .media-frame-content,.media-frame.mode-select.hide-router .media-frame-toolbar{left:275px}.media-frame.mode-select.hide-router select#media-attachment-taxonomy-filter{display:none}.media-frame.mode-select.hide-router .folder-custom-menu{display:none}html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-content,html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-router,html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-title,html[dir=rtl] .folder-modal .media-frame:not(.hide-menu):not(.hide-router) .media-frame-toolbar{left:0;right:275px}html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-title,html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-router,html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-content,html[dir=rtl] .media-frame.mode-select.hide-router .media-frame-toolbar{left:0;right:275px}html[dir=rtl] .media-frame.hide-menu .media-frame-content,html[dir=rtl] .media-frame.hide-menu .media-frame-router,html[dir=rtl] .media-frame.hide-menu .media-frame-title,html[dir=rtl] .media-frame.hide-menu .media-frame-toolbar{left:0;right:275px}html[dir=rtl] .media-frame .folder-modal .media-frame-content,html[dir=rtl] .folder-modal .media-frame .media-frame-router,html[dir=rtl] .folder-modal .media-frame .media-frame-title,html[dir=rtl] .folder-modal .media-frame .media-frame-toolbar{left:0;right:275px}.sticky-folders>ul>li{position:relative}#vakata-dnd{z-index:10000000!important}
assets/fonts/premio-folder.svg CHANGED
@@ -1,24 +1,24 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Generated by IcoMoon</metadata>
5
- <defs>
6
- <font id="premio-folder" horiz-adv-x="1024">
7
- <font-face units-per-em="1024" ascent="960" descent="-64" />
8
- <missing-glyph horiz-adv-x="1024" />
9
- <glyph unicode="&#x20;" horiz-adv-x="512" d="" />
10
- <glyph unicode="&#xe900;" glyph-name="star" d="M1021.295 592.423c-6.605 19.354-24.064 33.025-44.442 34.612l-291.903 23.194-126.315 279.612c-8.244 18.381-26.522 30.158-46.645 30.158s-38.401-11.776-46.645-30.107l-126.315-279.664-291.9-23.194c-20.020-1.587-37.275-14.746-44.085-33.639s-1.997-40.040 12.391-54.069l215.712-210.285-76.291-330.356c-4.71-20.429 3.534-41.677 20.788-53.606 8.807-6.042 18.945-9.114 29.134-9.114 9.882 0 19.815 2.867 28.417 8.602l278.793 185.863 278.793-185.863c17.818-11.878 41.217-11.418 58.626 1.229 17.304 12.646 24.933 34.816 19.045 55.398l-93.646 327.694 232.253 209.005c15.206 13.722 20.787 35.124 14.234 54.53z" />
11
- <glyph unicode="&#xe901;" glyph-name="move" d="M1014.704 469.51l-167.38 157.538c-8.58 8.078-21.138 10.282-31.963 5.606-10.818-4.675-17.818-15.33-17.818-27.116v-68.924h-196.926v196.924h68.924c11.784 0 22.442 7.004 27.116 17.822s2.472 23.38-5.606 31.96l-157.54 167.386c-5.582 5.93-13.366 9.294-21.51 9.294s-15.928-3.364-21.51-9.294l-157.538-167.386c-8.078-8.58-10.28-21.142-5.606-31.96s15.33-17.822 27.116-17.822h68.924v-196.924h-196.924v68.924c0 11.784-7.004 22.442-17.822 27.116-10.82 4.674-23.38 2.471-31.96-5.606l-167.386-157.538c-5.93-5.582-9.294-13.366-9.294-21.51s3.364-15.928 9.294-21.51l167.384-157.538c8.58-8.078 21.14-10.282 31.96-5.606 10.819 4.675 17.822 15.33 17.822 27.116v68.924h196.924v-196.921h-68.924c-11.784 0-22.442-7.007-27.116-17.825s-2.472-23.376 5.606-31.963l157.538-167.38c5.58-5.932 13.366-9.296 21.51-9.296s15.928 3.365 21.51 9.296l157.539 167.38c8.078 8.587 10.279 21.146 5.606 31.963s-15.33 17.825-27.116 17.825h-68.924v196.921h196.923v-68.924c0-11.784 7.007-22.442 17.825-27.116s23.376-2.471 31.956 5.606l167.387 157.538c5.932 5.58 9.289 13.366 9.289 21.51s-3.357 15.928-9.289 21.51z" />
12
- <glyph unicode="&#xe902;" glyph-name="folder-open" d="M8.448 61.399c9.523-14.336 25.549-22.992 42.752-22.992h767.994c20.48 0 39.014 12.186 47.049 31.027l153.6 358.398c6.806 15.82 5.168 33.945-4.301 48.332-9.523 14.387-25.552 23.039-42.749 23.039h-51.2v153.599c0 56.473-45.93 102.399-102.4 102.399h-340.734l-130.866 102.399h-245.195c-56.473 0-102.399-45.926-102.399-102.399v-665.595h0.358c0-9.83 2.509-19.709 8.090-28.208zM819.193 652.802v-153.599h-614.395c-20.48 0-39.014-12.185-47.052-31.027l-55.347-129.176v313.801h716.795z" />
13
- <glyph unicode="&#xe903;" glyph-name="edit-folder" d="M372.090 132.805l-214.445 214.448 518.671 518.671 214.445-214.445-518.672-518.675zM137.6 309.479l196.715-196.713-294.931-98.217 98.216 294.93zM956.715 717.154l-37.195-37.196-214.726 214.728 37.196 37.196c37.468 37.491 98.225 37.491 135.696 0l79.029-79.033c37.203-37.593 37.203-98.113 0-135.695z" />
14
- <glyph unicode="&#xe904;" glyph-name="pin" d="M588.646 348.696l166.548 166.544 59.627-59.63 59.633 59.63c32.913 32.916 32.913 86.344 0 119.26l-178.893 178.89c-32.913 32.916-86.341 32.916-119.258 0l-59.63-59.63 59.63-59.63-166.546-166.546-131.603 29.815c-11.181 0.030-21.884-4.413-29.815-12.343l-59.63-59.63c-16.488-16.488-16.457-43.172 0-59.63l119.26-119.258-89.445-89.449-29.815-89.443 89.445 29.816 89.445 89.443 119.26-119.26c16.488-16.486 43.142-16.486 59.63 0l59.63 59.633c7.933 7.927 12.372 18.631 12.342 29.81l-29.814 131.608z" />
15
- <glyph unicode="&#xe905;" glyph-name="search" d="M437.911 84.18c101.048 0 193.94 34.757 268.056 92.394l201.934-201.925c21.372-21.38 56.027-21.38 77.4 0 21.372 21.372 21.372 56.027 0 77.4l-201.933 201.93c57.695 74.171 92.453 167.063 92.453 268.111 0 241.453-196.456 437.911-437.909 437.911s-437.911-196.458-437.911-437.911c0-241.453 196.458-437.909 437.911-437.909zM437.911 850.522c181.131 0 328.436-147.302 328.436-328.433s-147.305-328.436-328.436-328.436c-181.131 0-328.433 147.305-328.433 328.436s147.302 328.433 328.433 328.433z" />
16
- <glyph unicode="&#xe906;" glyph-name="folder-close" d="M921.6 818.215h-490.803l-87.398 87.398c-9.574 9.626-22.63 15.002-36.198 15.002h-204.8c-56.474 0-102.4-45.926-102.4-102.4v-716.8c0-56.47 45.926-102.4 102.4-102.4h819.2c56.47 0 102.4 45.93 102.4 102.4v614.4c0 56.474-45.93 102.4-102.4 102.4z" />
17
- <glyph unicode="&#xe907;" glyph-name="arrow-sort" horiz-adv-x="783" d="M246.971 919.211l166.793-225.886c13.697-18.512 0.676-45.166-22.235-45.166h-83.766v-536.477c0-15.607-12.063-28.232-27.428-28.232h-111.194c-15.365 0-27.799 12.625-27.799 28.232v536.477h-83.397c-22.891 0-35.945 26.635-22.233 45.166l166.793 225.886c10.478 14.229 33.988 14.229 44.466 0zM641.349 248.459h83.769c22.914 0 35.93-26.654 22.233-45.164l-166.792-225.882c-11.082-15.047-33.367-15.071-44.466 0l-166.795 225.888c-13.712 18.528-0.66 45.164 22.233 45.164h83.398v536.474c0 15.607 12.433 28.235 27.799 28.235h111.196c15.366 0 27.425-12.628 27.425-28.235v-536.48z" />
18
- <glyph unicode="&#xe908;" glyph-name="arrow-down" d="M512.003 310.272l-405.237 398.966c-24.424 24.046-64.024 24.046-88.448 0s-24.424-63.033 0-87.079l442.24-435.397c14.052-13.834 33.127-19.709 51.445-17.625 18.318-2.084 37.394 3.791 51.446 17.625l442.24 435.397c24.427 24.046 24.427 63.033 0 87.079s-64.028 24.046-88.448 0l-405.238-398.966z" />
19
- <glyph unicode="&#xe909;" glyph-name="add-folder" d="M512 960c42.415 0 76.8-34.385 76.8-76.8v-870.4c0-42.415-34.385-76.8-76.8-76.8s-76.8 34.385-76.8 76.8v870.4c0 42.415 34.385 76.8 76.8 76.8zM1024 448c0-42.415-34.385-76.8-76.8-76.8h-870.4c-42.415 0-76.8 34.385-76.8 76.8s34.385 76.8 76.8 76.8h870.4c42.415 0 76.8-34.385 76.8-76.8z" />
20
- <glyph unicode="&#xe90a;" glyph-name="remove" d="M612.572 960v-64h319.999v-127.999h-896v127.999h320v64h256.001zM228.571-64c-70.594 0-127.999 57.439-127.999 128v639.999h768v-639.999c0-70.561-57.403-128-128-128h-512.001z" />
21
- <glyph unicode="&#xe90b;" glyph-name="edit" d="M360.346 64.088l-232.261 232.259 561.763 561.762 232.264-232.26-561.766-561.761zM106.375 255.434l213.059-213.055-319.434-106.379 106.375 319.434zM993.543 696.978l-40.28-40.286-232.571 232.568 40.286 40.286c40.58 40.605 106.386 40.605 146.966 0l85.599-85.6c40.287-40.716 40.287-106.265 0-146.968z" />
22
- <glyph unicode="&#xe90c;" glyph-name="zip-file" horiz-adv-x="768" d="M754 750l-195.8 196c-9 9-21.2 14-34 14h-12.2v-256h256v12.2c0 12.6-5 24.8-14 33.8zM256.8 288c-35.8 0-64.8-24.2-64.8-54 0-30 29.2-54 65-54s64.8 24.2 64.8 54-29.2 54-65 54zM448 688v272h-127.2v-64h-64v64h-208.8c-26.6 0-48-21.4-48-48v-928c0-26.6 21.4-48 48-48h672c26.6 0 48 21.4 48 48v656h-272c-26.4 0-48 21.6-48 48zM191.8 896h64v-64h-64zM256.4 128c-66.4 0-116 60.8-102.8 125.8l39.2 194.2v64h64v64h-64v64h64v64h-64v64h64v64h64v-64h-64v-64h64v-64h-64v-64h64v-64h-64v-64h44.2c11.4 0 21.4-8.2 23.6-19.4l34.6-175.4c12.8-64.8-36.8-125.2-102.8-125.2z" />
23
- <glyph unicode="&#xe90d;" glyph-name="clone" horiz-adv-x="896" d="M640 64v-80c0-26.51-21.49-48-48-48h-544c-26.51 0-48 21.49-48 48v736c0 26.51 21.49 48 48 48h144v-592c0-61.758 50.242-112 112-112h336zM640 752v208h-336c-26.51 0-48-21.49-48-48v-736c0-26.51 21.49-48 48-48h544c26.51 0 48 21.49 48 48v528h-208c-26.4 0-48 21.6-48 48zM881.942 814.058l-131.884 131.884c-8.686 8.686-20.686 14.058-33.94 14.058h-12.118v-192h192v12.118c0 13.254-5.372 25.254-14.058 33.94v0z" />
24
  </font></defs></svg>
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by IcoMoon</metadata>
5
+ <defs>
6
+ <font id="premio-folder" horiz-adv-x="1024">
7
+ <font-face units-per-em="1024" ascent="960" descent="-64" />
8
+ <missing-glyph horiz-adv-x="1024" />
9
+ <glyph unicode="&#x20;" horiz-adv-x="512" d="" />
10
+ <glyph unicode="&#xe900;" glyph-name="star" d="M1021.295 592.423c-6.605 19.354-24.064 33.025-44.442 34.612l-291.903 23.194-126.315 279.612c-8.244 18.381-26.522 30.158-46.645 30.158s-38.401-11.776-46.645-30.107l-126.315-279.664-291.9-23.194c-20.020-1.587-37.275-14.746-44.085-33.639s-1.997-40.040 12.391-54.069l215.712-210.285-76.291-330.356c-4.71-20.429 3.534-41.677 20.788-53.606 8.807-6.042 18.945-9.114 29.134-9.114 9.882 0 19.815 2.867 28.417 8.602l278.793 185.863 278.793-185.863c17.818-11.878 41.217-11.418 58.626 1.229 17.304 12.646 24.933 34.816 19.045 55.398l-93.646 327.694 232.253 209.005c15.206 13.722 20.787 35.124 14.234 54.53z" />
11
+ <glyph unicode="&#xe901;" glyph-name="move" d="M1014.704 469.51l-167.38 157.538c-8.58 8.078-21.138 10.282-31.963 5.606-10.818-4.675-17.818-15.33-17.818-27.116v-68.924h-196.926v196.924h68.924c11.784 0 22.442 7.004 27.116 17.822s2.472 23.38-5.606 31.96l-157.54 167.386c-5.582 5.93-13.366 9.294-21.51 9.294s-15.928-3.364-21.51-9.294l-157.538-167.386c-8.078-8.58-10.28-21.142-5.606-31.96s15.33-17.822 27.116-17.822h68.924v-196.924h-196.924v68.924c0 11.784-7.004 22.442-17.822 27.116-10.82 4.674-23.38 2.471-31.96-5.606l-167.386-157.538c-5.93-5.582-9.294-13.366-9.294-21.51s3.364-15.928 9.294-21.51l167.384-157.538c8.58-8.078 21.14-10.282 31.96-5.606 10.819 4.675 17.822 15.33 17.822 27.116v68.924h196.924v-196.921h-68.924c-11.784 0-22.442-7.007-27.116-17.825s-2.472-23.376 5.606-31.963l157.538-167.38c5.58-5.932 13.366-9.296 21.51-9.296s15.928 3.365 21.51 9.296l157.539 167.38c8.078 8.587 10.279 21.146 5.606 31.963s-15.33 17.825-27.116 17.825h-68.924v196.921h196.923v-68.924c0-11.784 7.007-22.442 17.825-27.116s23.376-2.471 31.956 5.606l167.387 157.538c5.932 5.58 9.289 13.366 9.289 21.51s-3.357 15.928-9.289 21.51z" />
12
+ <glyph unicode="&#xe902;" glyph-name="folder-open" d="M8.448 61.399c9.523-14.336 25.549-22.992 42.752-22.992h767.994c20.48 0 39.014 12.186 47.049 31.027l153.6 358.398c6.806 15.82 5.168 33.945-4.301 48.332-9.523 14.387-25.552 23.039-42.749 23.039h-51.2v153.599c0 56.473-45.93 102.399-102.4 102.399h-340.734l-130.866 102.399h-245.195c-56.473 0-102.399-45.926-102.399-102.399v-665.595h0.358c0-9.83 2.509-19.709 8.090-28.208zM819.193 652.802v-153.599h-614.395c-20.48 0-39.014-12.185-47.052-31.027l-55.347-129.176v313.801h716.795z" />
13
+ <glyph unicode="&#xe903;" glyph-name="edit-folder" d="M372.090 132.805l-214.445 214.448 518.671 518.671 214.445-214.445-518.672-518.675zM137.6 309.479l196.715-196.713-294.931-98.217 98.216 294.93zM956.715 717.154l-37.195-37.196-214.726 214.728 37.196 37.196c37.468 37.491 98.225 37.491 135.696 0l79.029-79.033c37.203-37.593 37.203-98.113 0-135.695z" />
14
+ <glyph unicode="&#xe904;" glyph-name="pin" d="M588.646 348.696l166.548 166.544 59.627-59.63 59.633 59.63c32.913 32.916 32.913 86.344 0 119.26l-178.893 178.89c-32.913 32.916-86.341 32.916-119.258 0l-59.63-59.63 59.63-59.63-166.546-166.546-131.603 29.815c-11.181 0.030-21.884-4.413-29.815-12.343l-59.63-59.63c-16.488-16.488-16.457-43.172 0-59.63l119.26-119.258-89.445-89.449-29.815-89.443 89.445 29.816 89.445 89.443 119.26-119.26c16.488-16.486 43.142-16.486 59.63 0l59.63 59.633c7.933 7.927 12.372 18.631 12.342 29.81l-29.814 131.608z" />
15
+ <glyph unicode="&#xe905;" glyph-name="search" d="M437.911 84.18c101.048 0 193.94 34.757 268.056 92.394l201.934-201.925c21.372-21.38 56.027-21.38 77.4 0 21.372 21.372 21.372 56.027 0 77.4l-201.933 201.93c57.695 74.171 92.453 167.063 92.453 268.111 0 241.453-196.456 437.911-437.909 437.911s-437.911-196.458-437.911-437.911c0-241.453 196.458-437.909 437.911-437.909zM437.911 850.522c181.131 0 328.436-147.302 328.436-328.433s-147.305-328.436-328.436-328.436c-181.131 0-328.433 147.305-328.433 328.436s147.302 328.433 328.433 328.433z" />
16
+ <glyph unicode="&#xe906;" glyph-name="folder-close" d="M921.6 818.215h-490.803l-87.398 87.398c-9.574 9.626-22.63 15.002-36.198 15.002h-204.8c-56.474 0-102.4-45.926-102.4-102.4v-716.8c0-56.47 45.926-102.4 102.4-102.4h819.2c56.47 0 102.4 45.93 102.4 102.4v614.4c0 56.474-45.93 102.4-102.4 102.4z" />
17
+ <glyph unicode="&#xe907;" glyph-name="arrow-sort" horiz-adv-x="783" d="M246.971 919.211l166.793-225.886c13.697-18.512 0.676-45.166-22.235-45.166h-83.766v-536.477c0-15.607-12.063-28.232-27.428-28.232h-111.194c-15.365 0-27.799 12.625-27.799 28.232v536.477h-83.397c-22.891 0-35.945 26.635-22.233 45.166l166.793 225.886c10.478 14.229 33.988 14.229 44.466 0zM641.349 248.459h83.769c22.914 0 35.93-26.654 22.233-45.164l-166.792-225.882c-11.082-15.047-33.367-15.071-44.466 0l-166.795 225.888c-13.712 18.528-0.66 45.164 22.233 45.164h83.398v536.474c0 15.607 12.433 28.235 27.799 28.235h111.196c15.366 0 27.425-12.628 27.425-28.235v-536.48z" />
18
+ <glyph unicode="&#xe908;" glyph-name="arrow-down" d="M512.003 310.272l-405.237 398.966c-24.424 24.046-64.024 24.046-88.448 0s-24.424-63.033 0-87.079l442.24-435.397c14.052-13.834 33.127-19.709 51.445-17.625 18.318-2.084 37.394 3.791 51.446 17.625l442.24 435.397c24.427 24.046 24.427 63.033 0 87.079s-64.028 24.046-88.448 0l-405.238-398.966z" />
19
+ <glyph unicode="&#xe909;" glyph-name="add-folder" d="M512 960c42.415 0 76.8-34.385 76.8-76.8v-870.4c0-42.415-34.385-76.8-76.8-76.8s-76.8 34.385-76.8 76.8v870.4c0 42.415 34.385 76.8 76.8 76.8zM1024 448c0-42.415-34.385-76.8-76.8-76.8h-870.4c-42.415 0-76.8 34.385-76.8 76.8s34.385 76.8 76.8 76.8h870.4c42.415 0 76.8-34.385 76.8-76.8z" />
20
+ <glyph unicode="&#xe90a;" glyph-name="remove" d="M612.572 960v-64h319.999v-127.999h-896v127.999h320v64h256.001zM228.571-64c-70.594 0-127.999 57.439-127.999 128v639.999h768v-639.999c0-70.561-57.403-128-128-128h-512.001z" />
21
+ <glyph unicode="&#xe90b;" glyph-name="edit" d="M360.346 64.088l-232.261 232.259 561.763 561.762 232.264-232.26-561.766-561.761zM106.375 255.434l213.059-213.055-319.434-106.379 106.375 319.434zM993.543 696.978l-40.28-40.286-232.571 232.568 40.286 40.286c40.58 40.605 106.386 40.605 146.966 0l85.599-85.6c40.287-40.716 40.287-106.265 0-146.968z" />
22
+ <glyph unicode="&#xe90c;" glyph-name="zip-file" horiz-adv-x="768" d="M754 750l-195.8 196c-9 9-21.2 14-34 14h-12.2v-256h256v12.2c0 12.6-5 24.8-14 33.8zM256.8 288c-35.8 0-64.8-24.2-64.8-54 0-30 29.2-54 65-54s64.8 24.2 64.8 54-29.2 54-65 54zM448 688v272h-127.2v-64h-64v64h-208.8c-26.6 0-48-21.4-48-48v-928c0-26.6 21.4-48 48-48h672c26.6 0 48 21.4 48 48v656h-272c-26.4 0-48 21.6-48 48zM191.8 896h64v-64h-64zM256.4 128c-66.4 0-116 60.8-102.8 125.8l39.2 194.2v64h64v64h-64v64h64v64h-64v64h64v64h64v-64h-64v-64h64v-64h-64v-64h64v-64h-64v-64h44.2c11.4 0 21.4-8.2 23.6-19.4l34.6-175.4c12.8-64.8-36.8-125.2-102.8-125.2z" />
23
+ <glyph unicode="&#xe90d;" glyph-name="clone" horiz-adv-x="896" d="M640 64v-80c0-26.51-21.49-48-48-48h-544c-26.51 0-48 21.49-48 48v736c0 26.51 21.49 48 48 48h144v-592c0-61.758 50.242-112 112-112h336zM640 752v208h-336c-26.51 0-48-21.49-48-48v-736c0-26.51 21.49-48 48-48h544c26.51 0 48 21.49 48 48v528h-208c-26.4 0-48 21.6-48 48zM881.942 814.058l-131.884 131.884c-8.686 8.686-20.686 14.058-33.94 14.058h-12.118v-192h192v12.118c0 13.254-5.372 25.254-14.058 33.94v0z" />
24
  </font></defs></svg>
assets/js/folders.js CHANGED
@@ -24,6 +24,7 @@
24
  var folderIDs = "";
25
  var folderPropertyArray = [];
26
  var folderCurrentURL = wcp_settings.page_url;
 
27
  var listFolderString = "<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'>" +
28
  "<div class='folder-item is-folder' data-id='__folder_id__'>" +
29
  "<a title='__folder_name__' id='folder_view___folder_id__'" +
@@ -36,6 +37,8 @@
36
  "</li>";
37
  $(document).ready(function(){
38
 
 
 
39
  isKeyActive = parseInt(wcp_settings.is_key_active);
40
  n_o_file = parseInt(wcp_settings.folders);
41
  activeRecordID = parseInt(wcp_settings.selected_taxonomy);
@@ -574,12 +577,12 @@
574
  chkStr += $(this).val()+",";
575
  });
576
  nonce = getSettingForPost(folderID, 'nonce');
577
- jQuery.ajax({
578
  url: wcp_settings.ajax_url,
579
  data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
580
  method: 'post',
581
  success: function (res) {
582
- res = jQuery.parseJSON(res);
583
  if(res.status == "1") {
584
  resetMediaAndPosts();
585
  ajaxAnimation();
@@ -601,12 +604,12 @@
601
  chkStr += $(this).val() + ",";
602
  }
603
  });
604
- jQuery.ajax({
605
  url: wcp_settings.ajax_url,
606
  data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
607
  method: 'post',
608
  success: function (res) {
609
- res = jQuery.parseJSON(res);
610
  if(res.status == "1") {
611
  // window.location.reload();
612
  resetMediaAndPosts();
@@ -629,7 +632,7 @@
629
  });
630
  }
631
  folderIDs = chkStr;
632
- jQuery.ajax({
633
  url: wcp_settings.ajax_url,
634
  data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
635
  method: 'post',
@@ -1431,13 +1434,13 @@
1431
  $(".form-loader-count").css("width","100%");
1432
  nonce = getSettingForPost(folderID, 'nonce');
1433
  checkForExpandCollapse();
1434
- jQuery.ajax({
1435
  url: wcp_settings.ajax_url,
1436
  data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1437
  method: 'post',
1438
  success: function (res) {
1439
  $(".form-loader-count").css("width","0");
1440
- res = jQuery.parseJSON(res);
1441
  if(res.status == "0") {
1442
  // $(".folder-popup-form").hide();
1443
  // $(".folder-popup-form").removeClass("disabled");
@@ -1620,13 +1623,13 @@
1620
  if(folderIDs != "") {
1621
  $(".form-loader-count").css("width","100%");
1622
  nonce = wcp_settings.nonce;
1623
- jQuery.ajax({
1624
  url: wcp_settings.ajax_url,
1625
  data: "type=" + wcp_settings.post_type + "&action=wcp_change_all_status&status=" + statusType + "&folders="+folderIDs+"&nonce="+nonce,
1626
  method: 'post',
1627
  success: function (res) {
1628
  $(".form-loader-count").css("width","0");
1629
- res = jQuery.parseJSON(res);
1630
  if(res.status == "0") {
1631
  $(".folder-popup-form").hide();
1632
  $(".folder-popup-form").removeClass("disabled");
@@ -1708,18 +1711,18 @@
1708
  }
1709
  if(orderString != "") {
1710
  $(".form-loader-count").css("width","100%");
1711
- jQuery.ajax({
1712
  url: wcp_settings.ajax_url,
1713
  data: "term_ids=" + orderString + "&action=wcp_save_folder_order&type=" + wcp_settings.post_type+"&nonce="+wcp_settings.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,
1714
  method: 'post',
1715
  success: function (res) {
1716
- res = jQuery.parseJSON(res);
1717
  if (res.status == '1') {
1718
  $("#wcp_folder_parent").html(res.options);
1719
  $(".form-loader-count").css("width", "0");
1720
- add_menu_to_list();
1721
  resetMediaAndPosts();
1722
  ajaxAnimation();
 
1723
  } else {
1724
  $(".folder-popup-form").hide();
1725
  $(".folder-popup-form").removeClass("disabled");
@@ -1750,17 +1753,19 @@
1750
  $(".form-loader-count").css("width", "100%");
1751
  $(".folder-order").removeClass("active");
1752
  lastOrderStatus = $(this).attr("data-sort");
1753
- jQuery.ajax({
1754
  url: wcp_settings.ajax_url,
1755
  data: "type=" + wcp_settings.post_type + "&action=wcp_folders_by_order&nonce=" + wcp_settings.nonce+"&order="+$(this).attr("data-sort"),
1756
  method: 'post',
1757
  success: function (res) {
1758
- res = jQuery.parseJSON(res);
1759
  if(res.status == 1) {
1760
  $("#js-tree-menu").jstree().destroy();
1761
  $("#js-tree-menu").append("<ul></ul>");
1762
  $("#js-tree-menu ul").html(res.data);
1763
  initJSTree();
 
 
1764
  }
1765
  $(".form-loader-count").css("width", "0");
1766
  add_active_item_to_list();
@@ -1847,10 +1852,37 @@
1847
  }
1848
  });
1849
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1850
  });
1851
 
1852
  function set_default_folders(post_id) {
1853
- jQuery.ajax({
1854
  url: wcp_settings.ajax_url,
1855
  type: 'post',
1856
  data: 'action=save_folder_last_status&post_type='+wcp_settings.post_type+"&post_id="+post_id+"&nonce="+wcp_settings.nonce,
@@ -1952,6 +1984,49 @@
1952
  setCustomScrollForFolder();
1953
  }
1954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1955
  if(wcp_settings.post_type == "attachment") {
1956
 
1957
  $(document).ready(function(){
@@ -2022,7 +2097,7 @@
2022
  checkStr += $(this).attr("data-id")+",";
2023
  });
2024
  if($(this).val() == "-1") {
2025
- jQuery.ajax({
2026
  url: wcp_settings.ajax_url,
2027
  data: "post_id=" + checkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + $(this).val() + "&nonce=" + wcp_settings.nonce +"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
2028
  method: 'post',
@@ -2032,13 +2107,13 @@
2032
  }
2033
  });
2034
  } else {
2035
- nonce = jQuery.trim($("#wcp_folder_" + $(this).val()).data("nonce"));
2036
- jQuery.ajax({
2037
  url: wcp_settings.ajax_url,
2038
  data: "post_ids=" + checkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + $(this).val() + "&nonce=" + nonce + "&status=" + wcp_settings.taxonomy_status + "&taxonomy=" + activeRecordID,
2039
  method: 'post',
2040
  success: function (res) {
2041
- res = jQuery.parseJSON(res);
2042
  $("#bulk-move-folder").hide();
2043
  if (res.status == "1") {
2044
  resetMediaAndPosts();
@@ -2086,40 +2161,8 @@
2086
  }
2087
  }
2088
  }
2089
- if(res.taxonomies.length) {
2090
- if($("#media-attachment-taxonomy-filter").length) {
2091
- folders_media_options.terms = res.taxonomies;
2092
- var selectedDD = $("#media-attachment-taxonomy-filter");
2093
- selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
2094
- $(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>");
2095
- for (i = 0; i < res.taxonomies.length; i++) {
2096
- selectedDD.append("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name + " (" + res.taxonomies[i].trash_count + ")</option>");
2097
- $(".media-select-folder").append("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name + " (" + res.taxonomies[i].trash_count + ")</option>");
2098
-
2099
- $("#title_"+res.taxonomies[i].term_id).attr("title", res.taxonomies[i].term_name);
2100
- $("#title_"+res.taxonomies[i].term_id+" .title-text").html(res.taxonomies[i].term_name);
2101
- }
2102
- selectedDD.val(selectedVal);
2103
- $(".media-select-folder").val("");
2104
- }
2105
- if($("select.folder_for_media").length) {
2106
- selectedVal = $("select.folder_for_media").val();
2107
- $("select.folder_for_media option:not(:first-child):not(:last-child)").remove();
2108
- for (i = 0; i < res.taxonomies.length; i++) {
2109
- $("select.folder_for_media option:last-child").before("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name +"</option>");
2110
- }
2111
- if(selectedVal != "") {
2112
- $(".folder_for_media").val(selectedVal);
2113
- }
2114
- }
2115
- $("span.premio-folder-count").text("");
2116
- for (i = 0; i < res.taxonomies.length; i++) {
2117
- if(parseInt(res.taxonomies[i].trash_count) != 0) {
2118
- $(".jstree-node[id='" + res.taxonomies[i].term_id + "'] > a.jstree-anchor span.premio-folder-count").text(res.taxonomies[i].trash_count);
2119
- $(".sticky-folder-"+res.taxonomies[i].term_id+" .premio-folder-count").text(res.taxonomies[i].trash_count);
2120
- }
2121
- }
2122
- }
2123
 
2124
  if(activeRecordID != "") {
2125
  $("#wcp_folder_"+activeRecordID).addClass("active-item");
24
  var folderIDs = "";
25
  var folderPropertyArray = [];
26
  var folderCurrentURL = wcp_settings.page_url;
27
+ var foldersArray = [];
28
  var listFolderString = "<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'>" +
29
  "<div class='folder-item is-folder' data-id='__folder_id__'>" +
30
  "<a title='__folder_name__' id='folder_view___folder_id__'" +
37
  "</li>";
38
  $(document).ready(function(){
39
 
40
+ foldersArray = wcp_settings.taxonomies;
41
+
42
  isKeyActive = parseInt(wcp_settings.is_key_active);
43
  n_o_file = parseInt(wcp_settings.folders);
44
  activeRecordID = parseInt(wcp_settings.selected_taxonomy);
577
  chkStr += $(this).val()+",";
578
  });
579
  nonce = getSettingForPost(folderID, 'nonce');
580
+ $.ajax({
581
  url: wcp_settings.ajax_url,
582
  data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
583
  method: 'post',
584
  success: function (res) {
585
+ res = $.parseJSON(res);
586
  if(res.status == "1") {
587
  resetMediaAndPosts();
588
  ajaxAnimation();
604
  chkStr += $(this).val() + ",";
605
  }
606
  });
607
+ $.ajax({
608
  url: wcp_settings.ajax_url,
609
  data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
610
  method: 'post',
611
  success: function (res) {
612
+ res = $.parseJSON(res);
613
  if(res.status == "1") {
614
  // window.location.reload();
615
  resetMediaAndPosts();
632
  });
633
  }
634
  folderIDs = chkStr;
635
+ $.ajax({
636
  url: wcp_settings.ajax_url,
637
  data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
638
  method: 'post',
1434
  $(".form-loader-count").css("width","100%");
1435
  nonce = getSettingForPost(folderID, 'nonce');
1436
  checkForExpandCollapse();
1437
+ $.ajax({
1438
  url: wcp_settings.ajax_url,
1439
  data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1440
  method: 'post',
1441
  success: function (res) {
1442
  $(".form-loader-count").css("width","0");
1443
+ res = $.parseJSON(res);
1444
  if(res.status == "0") {
1445
  // $(".folder-popup-form").hide();
1446
  // $(".folder-popup-form").removeClass("disabled");
1623
  if(folderIDs != "") {
1624
  $(".form-loader-count").css("width","100%");
1625
  nonce = wcp_settings.nonce;
1626
+ $.ajax({
1627
  url: wcp_settings.ajax_url,
1628
  data: "type=" + wcp_settings.post_type + "&action=wcp_change_all_status&status=" + statusType + "&folders="+folderIDs+"&nonce="+nonce,
1629
  method: 'post',
1630
  success: function (res) {
1631
  $(".form-loader-count").css("width","0");
1632
+ res = $.parseJSON(res);
1633
  if(res.status == "0") {
1634
  $(".folder-popup-form").hide();
1635
  $(".folder-popup-form").removeClass("disabled");
1711
  }
1712
  if(orderString != "") {
1713
  $(".form-loader-count").css("width","100%");
1714
+ $.ajax({
1715
  url: wcp_settings.ajax_url,
1716
  data: "term_ids=" + orderString + "&action=wcp_save_folder_order&type=" + wcp_settings.post_type+"&nonce="+wcp_settings.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,
1717
  method: 'post',
1718
  success: function (res) {
1719
+ res = $.parseJSON(res);
1720
  if (res.status == '1') {
1721
  $("#wcp_folder_parent").html(res.options);
1722
  $(".form-loader-count").css("width", "0");
 
1723
  resetMediaAndPosts();
1724
  ajaxAnimation();
1725
+ setFolderCountAndDD();
1726
  } else {
1727
  $(".folder-popup-form").hide();
1728
  $(".folder-popup-form").removeClass("disabled");
1753
  $(".form-loader-count").css("width", "100%");
1754
  $(".folder-order").removeClass("active");
1755
  lastOrderStatus = $(this).attr("data-sort");
1756
+ $.ajax({
1757
  url: wcp_settings.ajax_url,
1758
  data: "type=" + wcp_settings.post_type + "&action=wcp_folders_by_order&nonce=" + wcp_settings.nonce+"&order="+$(this).attr("data-sort"),
1759
  method: 'post',
1760
  success: function (res) {
1761
+ res = $.parseJSON(res);
1762
  if(res.status == 1) {
1763
  $("#js-tree-menu").jstree().destroy();
1764
  $("#js-tree-menu").append("<ul></ul>");
1765
  $("#js-tree-menu ul").html(res.data);
1766
  initJSTree();
1767
+ foldersArray = res.terms;
1768
+ setFolderCountAndDD();
1769
  }
1770
  $(".form-loader-count").css("width", "0");
1771
  add_active_item_to_list();
1852
  }
1853
  });
1854
  });
1855
+
1856
+ $(document).on("click", ".folders-toggle-button", function(){
1857
+ dbStatus = 'show';
1858
+ if($(".tree-structure-content").hasClass("active")) {
1859
+ $(".tree-structure-content .tree-structure").animate({
1860
+ height: '40px'
1861
+ }, 100, function(){
1862
+ $(".tree-structure-content").removeClass("active");
1863
+ });
1864
+ dbStatus = 'hide';
1865
+ } else {
1866
+ newHeight = parseInt($(".tree-structure-content .tree-structure").attr("data-height"));
1867
+ $(".tree-structure-content .tree-structure").animate({
1868
+ height: newHeight
1869
+ }, 100, function(){
1870
+ $(".tree-structure-content").addClass("active");
1871
+ });
1872
+ }
1873
+ $.ajax({
1874
+ url: wcp_settings.ajax_url,
1875
+ data: "type=" + wcp_settings.post_type + "&action=wcp_hide_folders&status=" + dbStatus +"&nonce="+wcp_settings.nonce,
1876
+ method: 'post',
1877
+ success: function (res) {
1878
+ setStickyHeaderForMedia();
1879
+ }
1880
+ });
1881
+ });
1882
  });
1883
 
1884
  function set_default_folders(post_id) {
1885
+ $.ajax({
1886
  url: wcp_settings.ajax_url,
1887
  type: 'post',
1888
  data: 'action=save_folder_last_status&post_type='+wcp_settings.post_type+"&post_id="+post_id+"&nonce="+wcp_settings.nonce,
1984
  setCustomScrollForFolder();
1985
  }
1986
 
1987
+ function setFolderCountAndDD() {
1988
+ if($("#media-attachment-taxonomy-filter").length) {
1989
+ $("#media-attachment-taxonomy-filter").each(function(){
1990
+ folders_media_options.terms = foldersArray;
1991
+ var selectedDD = $(this);
1992
+ currentDDVal = $(this).val();
1993
+ selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
1994
+ lastFolderData = foldersArray;
1995
+ for (var i = 0; i < foldersArray.length; i++) {
1996
+ selectedDD.append("<option value='" + foldersArray[i].term_id + "'>" + foldersArray[i].name + " (" + foldersArray[i].trash_count + ")</option>");
1997
+ }
1998
+ selectedDD.val(currentDDVal).trigger("change");
1999
+ });
2000
+ if($("select.folder_for_media").length) {
2001
+ var selectedVal = $("select.folder_for_media").val();
2002
+ $("select.folder_for_media option:not(:first-child):not(:last-child)").remove();
2003
+ for (var i = 0; i < foldersArray.length; i++) {
2004
+ $("select.folder_for_media option:last-child").before("<option value='" + foldersArray[i].term_id + "'>" + foldersArray[i].name +"</option>");
2005
+ }
2006
+ if(selectedVal != "") {
2007
+ $(".folder_for_media").val(selectedVal);
2008
+ }
2009
+ }
2010
+ }
2011
+ $("span.premio-folder-count").text("");
2012
+ $(".folder-count").text("");
2013
+ for (i = 0; i < foldersArray.length; i++) {
2014
+ if(parseInt(foldersArray[i].trash_count) != 0) {
2015
+ $(".jstree-node[id='" + foldersArray[i].term_id + "'] > a.jstree-anchor span.premio-folder-count").text(foldersArray[i].trash_count);
2016
+ $(".sticky-folder-"+foldersArray[i].term_id+" .premio-folder-count").text(foldersArray[i].trash_count);
2017
+ }
2018
+ }
2019
+
2020
+ if(activeRecordID != "") {
2021
+ $("#wcp_folder_"+activeRecordID).addClass("active-item");
2022
+ }
2023
+
2024
+ if(isItFromMedia) {
2025
+ $("#title_"+fileFolderID).trigger("click");
2026
+ isItFromMedia = false;
2027
+ }
2028
+ }
2029
+
2030
  if(wcp_settings.post_type == "attachment") {
2031
 
2032
  $(document).ready(function(){
2097
  checkStr += $(this).attr("data-id")+",";
2098
  });
2099
  if($(this).val() == "-1") {
2100
+ $.ajax({
2101
  url: wcp_settings.ajax_url,
2102
  data: "post_id=" + checkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + $(this).val() + "&nonce=" + wcp_settings.nonce +"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
2103
  method: 'post',
2107
  }
2108
  });
2109
  } else {
2110
+ nonce = $.trim($("#wcp_folder_" + $(this).val()).data("nonce"));
2111
+ $.ajax({
2112
  url: wcp_settings.ajax_url,
2113
  data: "post_ids=" + checkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + $(this).val() + "&nonce=" + nonce + "&status=" + wcp_settings.taxonomy_status + "&taxonomy=" + activeRecordID,
2114
  method: 'post',
2115
  success: function (res) {
2116
+ res = $.parseJSON(res);
2117
  $("#bulk-move-folder").hide();
2118
  if (res.status == "1") {
2119
  resetMediaAndPosts();
2161
  }
2162
  }
2163
  }
2164
+ foldersArray = res.taxonomies;
2165
+ setFolderCountAndDD();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2166
 
2167
  if(activeRecordID != "") {
2168
  $("#wcp_folder_"+activeRecordID).addClass("active-item");
assets/js/folders.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e,t){var s,o,a,r="#js-tree-menu",l="",n=!1,d=!1,c=0,p=0,u=0,m=!1,f="",h=[],_=wcp_settings.page_url,g="<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'><div class='folder-item is-folder' data-id='__folder_id__'><a title='__folder_name__' id='folder_view___folder_id__'class='folder-view __append_class__ has-new-folder'data-id='__folder_id__'><span class='folder item-name'><span id='wcp_folder_text___folder_id__'class='folder-title'>__folder_name__</span></span></a></div></li>";function v(e,t){if(h.length>0)for(i=0;i<h.length;i++)if(parseInt(h[i].folder_id)==parseInt(e))return h[i][t];return""}function w(e){if(h.length>0)for(i=0;i<h.length;i++)if(parseInt(h[i].folder_id)==parseInt(e))return i;return null}function y(){if(e(".media-toolbar").hasClass("media-toolbar-mode-select")&&e("ul.attachments li.selected").length&&(e("ul.attachments li.selected").trigger("click"),e(".select-mode-toggle-button").trigger("click")),""!=f&&(e("#js-tree-menu a.jstree-clicked").length>0||"-1"==l)){if(e("#media-attachment-taxonomy-filter").length){f=f.split(",");for(var t=0;t<f.length;t++)""!=f[t]&&e(".attachments-browser li[data-id='"+f[t]+"']").remove()}f=""}e("#media-attachment-taxonomy-filter").length?z(0):(e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=get_folders_default_list",method:"post",success:function(s){for(s=e.parseJSON(s),e(".header-posts .total-count").text(s.total_items),e(".un-categorised-items .total-count").text(s.empty_items),t=0;t<s.taxonomies.length;t++)e("#title_"+s.taxonomies[t].term_id+" .total-count").length||e("#title_"+s.taxonomies[t].term_id+" .star-icon").before("<span class='total-count'></span>"),e("#title_"+s.taxonomies[t].term_id+" .total-count").text(parseInt(s.taxonomies[t].trash_count));for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),t=0;t<s.taxonomies.length;t++)0!=parseInt(s.taxonomies[t].trash_count)&&(e(".jstree-node[id='"+s.taxonomies[t].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(s.taxonomies[t].trash_count),e(".sticky-folder-"+s.taxonomies[t].term_id+" .premio-folder-count").text(s.taxonomies[t].trash_count))}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(_+" #posts-filter",function(){var t={Title:"",Url:_};history.pushState(t,t.Title,t.Url),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),x(),j()}):e("#wpbody").load(_+" #wpbody-content",!1,function(t){var s={Title:"",Url:_};history.pushState(s,s.Title,s.Url),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),x()}))}function j(){x(),e(".form-loader-count").css("width","0"),"object"==typeof inlineEditPost&&(inlineEditPost.init(),e("#the-list").on("click",".editinline",function(){e(this).attr("aria-expanded","true"),inlineEditPost.edit(this)}),e(document).on("click",".inline-edit-save .save",function(){var t=e(this).closest("tr").attr("id");t=(t=t.replace("edit-","")).replace("post-",""),inlineEditPost.save(t)}),e(document).on("click",".inline-edit-save .cancel",function(){var t=e(this).closest("tr").attr("id");t=(t=t.replace("edit-","")).replace("post-",""),inlineEditPost.revert(t)})),"attachment"==wcp_settings.post_type&&(e(".move-to-folder-top").length||e("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>"),e(".move-to-folder-bottom").length||e("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>"))}function x(){if(h.length&&e("li.jstree-node").each(function(){folderPostId=w(e(this).attr("id")),null!=folderPostId&&(1==h[folderPostId].is_high?e(this).addClass("is-high"):e(this).removeClass("is-high"),1==h[folderPostId].is_sticky?e(this).addClass("is-sticky"):e(this).removeClass("is-sticky"))}),folderId=0,e(".tree-structure ul").html(""),folderStatus=!0,e(".jstree-clicked").length&&(folderID=e(".jstree-clicked").closest(".jstree-node").attr("id"),e(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").length?(folderStatus=!1,e(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").each(function(){fID=e(this).attr("id"),fName=e.trim(e("#js-tree-menu").jstree(!0).get_node(fID).text),liHtml=g.replace(/__folder_id__/g,fID),liHtml=liHtml.replace(/__folder_name__/g,fName),selectedClass=e(this).hasClass("is-high")?"is-high":"",liHtml=liHtml.replace(/__append_class__/g,selectedClass),e(".tree-structure ul").append(liHtml)})):e(".jstree-node[id='"+folderID+"']").closest("ul").hasClass("jstree-container-ul")||(folderStatus=!1)),folderStatus&&e("#js-tree-menu > ul > li.jstree-node").each(function(){fID=e(this).attr("id"),fName=e.trim(e("#js-tree-menu").jstree(!0).get_node(fID).text),liHtml=g.replace(/__folder_id__/g,fID),liHtml=liHtml.replace(/__folder_name__/g,fName),selectedClass=e(this).hasClass("is-high")?"is-high":"",liHtml=liHtml.replace(/__append_class__/g,selectedClass),e(".tree-structure ul").append(liHtml)}),N(),"attachment"==wcp_settings.post_type&&(e(".move-to-folder-top").length||e("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>"),e(".move-to-folder-bottom").length||e("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>")),e(".sticky-folders .active-item").removeClass("active-item"),e("#js-tree-menu li.jstree-node.active-item").length){var t=e("#js-tree-menu li.jstree-node.active-item").data("folder-id");e(".sticky-folders .sticky-folder-"+t+" a").addClass("active-item")}}function b(){x()}function k(){if(0==o&&a>=10)return e("#folder-limitation-message").html("You've reached the 10 folder limitation!"),e("#no-more-folder-credit").show(),!1;e("#add-update-folder-title").text("Add new folder"),e("#save-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#add-update-folder-name").val(""),d&&(c=p,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(p).text)+" #2"),p=e("#"+p+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+p+"_anchor").closest(".jstree-node").parent().parent().attr("id"):0),e("#add-update-folder").removeClass("disabled"),e("#add-update-folder").show(),e("#add-update-folder-name").focus(),e(".dynamic-menu").remove()}function C(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(p).text),parentID=e("#wcp_folder_"+p).closest("li.jstree-node").data("folder-id"),parentID==t&&(parentID=0),e("#update-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#update-folder-item-name").val(folderName),e("#update-folder-item").removeClass("disabled"),e("#update-folder-item").show(),e("#update-folder-item-name").focus(),e(".dynamic-menu").remove()}function I(t){var s="Are you sure you want to delete the selected folder?",o="Items in the folder will not be deleted.";if(m=!1,1==t&&e("#folder-hide-show-checkbox").is(":checked")){if(m=!0,0==e("#js-tree-menu input.checkbox:checked").length)return e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html("Please select at least one folder to delete"),void e("#error-folder-popup").show();e("#js-tree-menu input.checkbox:checked").length>1&&(s="Are you sure you want to delete the selected folders?",o="Items in the selected folders will not be deleted.")}e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#remove-folder-item").text("Yes, Delete it!"),e("#remove-folder-message").text(s),e("#remove-folder-notice").text(o),e("#confirm-remove-folder").show(),e("#remove-folder-item").focus()}function S(){e(r).jstree({core:{cache:!1,animation:0,check_callback:function(t,s,o,a,i){if(e("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up"),("move_node"===t||"copy_node"===t)&&i&&i.dnd)switch(i.pos){case"a":i.origin.get_node(i.ref,!0).addClass("drag-bot"),nodeId=e(".drag-bot").attr("id"),e("#jstree-dnd").text("Below "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"i":i.origin.get_node(i.ref,!0).addClass("drag-in"),nodeId=e(".drag-in").attr("id"),e("#jstree-dnd").text("Inside "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"b":i.origin.get_node(i.ref,!0).addClass("drag-up"),nodeId=e(".drag-up").attr("id"),e("#jstree-dnd").text("Above "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;default:e("#jstree-dnd").text(e("#jstree-dnd").data("txt"))}return!0}},data:{cache:!1},select_node:!1,search:{show_only_matches:!0,case_sensitive:!1,fuzzy:!1},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",function(){e("#js-tree-menu .jstree-node").each(function(){var t=parseInt(e(this).data("count"));t>0&&e(".jstree-node[id='"+e(this).attr("id")+"'] > a span.premio-folder-count").text(t);var s={folder_id:e(this).attr("id"),folder_count:t,is_sticky:e(this).hasClass("is-sticky")?1:0,is_high:e(this).hasClass("is-high")?1:0,nonce:e(this).data("nonce"),slug:e(this).data("slug"),is_deleted:0};h.push(s)}),""!=l&&0!=l&&e(".jstree-node[id='"+l+"']").length&&(e("#js-tree-menu").jstree("select_node",l),e(".sticky-folders .sticky-folder-"+l+" a").length&&e(".sticky-folders .sticky-folder-"+l+" a").addClass("active-item")),e(".ajax-preloader").hide(),e(".js-tree-data").show(),U(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active"),x()}).bind("move_node.jstree",function(t,s){folderMoveId=s.node.id,orderString="",e(".jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?parentID=e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id"):parentID=0,""!=orderString&&(e(".form-loader-count").css("width","100%"),jQuery.ajax({url:wcp_settings.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+wcp_settings.post_type+"&nonce="+wcp_settings.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(t){"1"==(t=jQuery.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),b(),y(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))})}function D(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function P(e){jQuery.ajax({url:wcp_settings.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+wcp_settings.post_type+"&post_id="+e+"&nonce="+wcp_settings.nonce,cache:!1,async:!1,success:function(){}})}function T(){setTimeout(function(){if(currentStatus=!0,e("#js-tree-menu .jstree-node.jstree-leaf").length==e("#js-tree-menu .jstree-node").length)e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand");else{var t=e("#js-tree-menu .jstree-node.jstree-closed").length+e("#js-tree-menu .jstree-node.jstree-open").length;e("#js-tree-menu .jstree-node.jstree-closed").length==t?(e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand")):(e("#expand-collapse-list").addClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Collapse"))}},500)}function N(){0==e(".tree-structure-content .tree-structure li").length?e(".tree-structure-content").hide():(e(".tree-structure-content").show(),oldHeight=e(".tree-structure-content .tree-structure").height(),e(".tree-structure-content .tree-structure").height("auto"),e(".tree-structure-content .tree-structure").height()>56?e(".folders-toggle-button").show():e(".folders-toggle-button").hide(),newHeight=e(".tree-structure-content .tree-structure").height(),e(".tree-structure-content .tree-structure").attr("data-height",newHeight),e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").height(newHeight),e(".tree-structure-content .tree-structure").attr("data-height",newHeight)):e(".tree-structure-content .tree-structure").height(oldHeight))}function H(){e(".folder-loader-ajax").addClass("active"),e(".folder-loader-ajax img").removeClass("active"),e(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated"),setTimeout(function(){e(".folder-loader-ajax").removeClass("active"),e(".folder-loader-ajax img").addClass("active"),e(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2e3)}function U(){e(".sticky-folders > ul").html("");var t="";if(e("#js-tree-menu li.jstree-node.is-sticky").each(function(){var s=e(this).attr("id"),o=e.trim(e("#js-tree-menu").jstree(!0).get_node(s).text),a=e("li.jstree-node[id='"+s+"'] > a span.premio-folder-count").text(),i=e("li.jstree-node[id='"+s+"']").hasClass("is-high")?" is-high ":"";t+="<li data-folder-id='"+s+"' class='sticky-fldr "+i+" sticky-folder-"+s+"'><a href='javascript:;'><span class='folder-title'>"+o+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'>"+a+"</span></span></a></li>"}),e(".sticky-folders > ul").html(t),e(".jstree-anchor.jstree-clicked").length){var s=e(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item")}e(".sticky-folders > ul > li").length>0?e(".sticky-folders").addClass("active"):e(".sticky-folders").removeClass("active")}if(e(document).ready(function(){o=parseInt(wcp_settings.is_key_active),a=parseInt(wcp_settings.folders),l=parseInt(wcp_settings.selected_taxonomy),S();var t="1"==wcp_settings.isRTL||1==wcp_settings.isRTL?"w":"e";e(".wcp-content").resizable({resizeHeight:!1,handles:t,minWidth:100,maxWidth:500,resize:function(t,s){var o=s.size.width;for(o<=275?e(".plugin-button").addClass("d-block"):e(".plugin-button").removeClass("d-block"),o<=225&&(o=225),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",o+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",o+20+"px"),newWidth=o-40,cssString="",classString="",i=0;i<=15;i++)classString+=" .space > .jstree-node >",currentWidth=newWidth-(13+20*i),cssString+="#js-tree-menu > "+classString+" .title { width: "+currentWidth+"px !important; } ",cssString+="#js-tree-menu > "+classString+" .dynamic-menu { left: "+(currentWidth-190)+"px !important; } ";e("#wcp-custom-style").html("<style>"+cssString+"</style>"),s.size.width<=185?(folderStatus="hide",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active"),e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px")):e("#wcp-content").hasClass("hide-folders-area")&&(folderStatus="show",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active"),e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",wcp_settings.folder_width+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",wcp_settings.folder_width+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250))},stop:function(t,o){var a=o.size.width;o.size.width<=275?e(".plugin-button").addClass("d-block"):e(".plugin-button").removeClass("d-block"),a<=225&&(a=225),o.size.width<=185?(folderStatus="hide",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active"),e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+folderStatus+"&nonce="+s,method:"post",success:function(e){}})):e("#wcp-content").hasClass("hide-folders-area")&&(folderStatus="show",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active"),e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",wcp_settings.folder_width+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",wcp_settings.folder_width+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250)),s=wcp_settings.nonce,wcp_settings.folder_width=o.size.width,e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_post_width&width="+a+"&nonce="+s,method:"post",success:function(e){}}),o.size.width<=225&&(e(".wcp-content").width(225),wcp_settings.folder_width=225)}}),e(document).on("contextmenu",".jstree-anchor",function(t){return e(this).find("span.folder-inline-edit").trigger("click"),!1}),e(document).on("click",".folder-actions span.folder-inline-edit",function(t){t.stopImmediatePropagation(),t.stopPropagation(),0!=wcp_settings.can_manage_folder&&(isHigh=e(this).closest("li.jstree-node").hasClass("is-high"),isSticky=e(this).closest("li.jstree-node").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span> Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>",hasPosts=parseInt(e(this).closest("a.jstree-anchor").find(".premio-folder-count").text()),"attachment"==wcp_settings.post_type&&hasPosts&&(menuHtml+="<li target='_blank' class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>",e(this).closest("a.jstree-anchor").after(menuHtml),e(this).parents("li.jstree-node").addClass("active-menu"),e(this).offset().top+e(".dynamic-menu").height()>e(window).height()-20&&(e(".dynamic-menu").addClass("bottom-fix"),e(".dynamic-menu.bottom-fix").offset().top<e("#custom-scroll-menu").offset().top&&e(".dynamic-menu").removeClass("bottom-fix")))}),e(document).on("click",".sticky-folders .sticky-fldr > a",function(t){t.stopPropagation();var s=e(this).closest("li").data("folder-id");e(".jstree-node[id='"+s+"']").length&&(e(".jstree-clicked").removeClass("jstree-clicked"),e(".active-item").removeClass("active-item"),e("#js-tree-menu").jstree("select_node",l),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").trigger("click"),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").addClass("jstree-clicked"),e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item"))}),e(document).on("contextmenu",".sticky-folders li .sticky-fldr > a",function(t){return e(this).find("span.update-inline-record").trigger("click"),!1}),e(document).on("click",".update-inline-record",function(t){t.stopImmediatePropagation(),t.stopPropagation(),0!=wcp_settings.can_manage_folder&&(isHigh=e(this).closest("li.sticky-fldr").hasClass("is-high"),isSticky=e(this).closest("li.sticky-fldr").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>",hasPosts=parseInt(e(this).closest("li.jstree-node").find("h3.title:first > .total-count").text()),"attachment"==wcp_settings.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>",e(this).closest("li").append(menuHtml),e(this).offset().top+e(".dynamic-menu").height()>e(window).height()-20&&(e(".dynamic-menu").addClass("bottom-fix"),e(".dynamic-menu.bottom-fix").offset().top<e("#custom-scroll-menu").offset().top&&e(".dynamic-menu").removeClass("bottom-fix")))}),e(document).on("click",".dynamic-menu",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","body, html",function(){e(".dynamic-menu").remove()}),e(".wcp-hide-show-buttons .toggle-buttons").click(function(){var t="show";e(this).hasClass("hide-folders")&&(t="hide"),e(".wcp-hide-show-buttons .toggle-buttons").toggleClass("active"),s=wcp_settings.nonce,"show"==t?(e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",wcp_settings.folder_width+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",wcp_settings.folder_width+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250)):(e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px")),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+t+"&nonce="+s,method:"post",success:function(e){}})}),e(".jstree-anchor").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=e(this).closest("li.jstree-node").attr("id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),s=v(folderID,"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?y():(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=v(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?y():(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=v(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),f=chkStr,e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y()}}))}})}),e(".un-categorised-items").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=-1,s=wcp_settings.nonce,o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y()}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,chkStr=postID+",",e(".wp-list-table input:checked").each(function(){postID!=e(this).val()&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),f=chkStr,e.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y()}}))}})}),e(".attachments-browser li.attachment").livequery(function(){e(this).draggable({revert:"invalid",containment:"document",helper:function(t,s){return e(".selected-items").remove(),selectedItems=e(".attachments-browser li.attachment.selected").length,selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")},start:function(t,s){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,s){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}})}),e(".tree-structure .folder-item").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){e("body").removeClass("no-hover-css"),folderID=e(this).data("id"),o.draggable.hasClass("wcp-move-multiple")?(s=v(folderID,"nonce"),e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y(),H()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=v(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y(),H()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=v(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y(),H()}}))}})}),e(".sticky-folders li a").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=e(this).closest("li").data("folder-id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),s=v(folderID,"nonce"),jQuery.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(t){"1"==(t=jQuery.parseJSON(t)).status?(y(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=v(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),jQuery.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(t){"1"==(t=jQuery.parseJSON(t)).status?(y(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=v(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),f=chkStr,jQuery.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y(),H()}}))}})})}),e(window).on("resize",function(){}),e(window).scroll(function(){}),e(document).ready(function(){e("#add-new-folder").livequery(function(){e(this).click(function(){p=e("#js-tree-menu a.jstree-clicked").length?e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"):0,n=!1,k()})}),e(".new-folder").livequery(function(){e(this).click(function(){p=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),n=!1,k()})}),e(".duplicate-folder").livequery(function(){e(this).click(function(t){t.stopPropagation(),p=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),e(".dynamic-menu").remove(),n=!1,d=!0,k(),b()})}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),folderNameDynamic=e.trim(e("#add-update-folder-name").val()),""==e.trim(folderNameDynamic))e(".folder-form-errors").addClass("active"),e("#add-update-folder-name").focus();else{e("#save-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#add-update-folder").addClass("disabled");var s=p;n&&(s=0),u=0==s?e("#js-tree-menu > ul > li.jstree-node").length:e("#js-tree-menu > ul > li.jstree-node[id='"+s+"'] > ul.jstree-children > li").length+1,e.ajax({url:wcp_settings.ajax_url,data:{parent_id:s,type:wcp_settings.post_type,action:"wcp_add_new_folder",nonce:wcp_settings.nonce,term_id:s,order:u,name:folderNameDynamic,is_duplicate:d,duplicate_from:c},method:"post",success:function(t){if(result=e.parseJSON(t),"1"==result.status){o=parseInt(result.is_key_active),a=parseInt(result.folders),e("#current-folder").text(a),e("#ttl-fldr").text(10),T(),b(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled");var s={folder_id:result.term_id,folder_count:0,is_sticky:0,is_high:0,nonce:result.nonce,slug:result.slug,is_deleted:0};h.push(s),H(),U(),e("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.term_id,text:" "+result.title},"last",function(){e(".jstree-node[id='"+result.term_id+"']").attr("data-nonce",result.nonce),e(".jstree-node[id='"+result.term_id+"']").attr("data-slug",result.slug)}),e("#media-attachment-taxonomy-filter").length&&(p=result.term_id,z(0))}else e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show()}})}return!1})}),e(document).ready(function(){e("#inline-update").click(function(){e("#js-tree-menu a.jstree-clicked").length&&(p=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),C())}),e(".rename-folder").livequery(function(){e(this).click(function(t){t.stopPropagation(),p=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),C(),e(".dynamic-menu").remove()})}),e(document).on("click",".form-cancel-btn",function(){e(".folder-popup-form").hide()}),e(document).on("click",".folder-popup-form",function(t){e(".folder-popup-form").hide()}),e(document).on("click",".popup-form-content",function(e){e.stopPropagation()}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),folderNameDynamic=e("#update-folder-item-name").val(),""==e.trim(folderNameDynamic)?(e(".folder-form-errors").addClass("active"),e("#update-folder-item-name").focus()):(e("#update-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#update-folder-item").addClass("disabled"),s=v(p,"nonce"),parentID=e(".jstree-node[id='"+p+"']").closest("li.jstree-node").attr("id"),parentID==t&&(parentID=0),e.ajax({url:wcp_settings.ajax_url,data:{parent_id:parentID,type:wcp_settings.post_type,action:"wcp_update_folder",nonce:s,term_id:p,order:u,name:folderNameDynamic},method:"post",success:function(t){result=e.parseJSON(t),"1"==result.status?(e("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title),folderPostId=w(result.id),null!=folderPostId&&(h[folderPostId].nonce=result.nonce,h[folderPostId].slug=result.slug),b(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),e("#media-attachment-taxonomy-filter").length&&z(0)):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show())}})),!1})}),e(document).ready(function(){e("#inline-remove").click(function(){e("#js-tree-menu a.jstree-clicked").length?(p=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),I(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#folder-hide-show-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),I(1))}),e(document).on("click","#folder-hide-show-checkbox",function(){e(this).is(":checked")?e("#js-tree-menu").addClass("show-folder-checkbox"):(e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"))}),e(document).on("click",".folder-checkbox, .input-checkbox",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(".remove-folder").livequery(function(){e(this).click(function(){folderID=e(this).closest("li.jstree-node").data("id"),p=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),I(0),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")})}),e(document).on("click","#remove-folder-item",function(t){t.stopPropagation(),e(".folder-popup-form").addClass("disabled"),e("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>'),s=v(p,"nonce"),m?function(){if(e("#folder-hide-show-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0){var t="";e("#js-tree-menu input.checkbox:checked").each(function(){t+=e(this).closest("li.jstree-node").attr("id")+",",e(this).closest("li.jstree-node").hasClass("jstree-clicked")&&!0}),e(".form-loader-count").css("width","100%"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_muliple_folder&term_id="+t+"&nonce="+wcp_settings.nonce,method:"post",success:function(t){if(t=e.parseJSON(t),e(".form-loader-count").css("width","0px"),"1"==t.status){for(o=parseInt(t.is_key_active),a=parseInt(t.folders),e("#current-folder").text(a),i=0;i<t.term_ids.length;i++)e("#js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),H(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),y(),U(),H(),e("#js-tree-menu li.jstree-node").removeClass("has-sub-tree"),e("#js-tree-menu li.jstree-node").each(function(){e(this).find("ul.ui-sortable li").length?e(this).addClass("has-sub-tree"):e(this).removeClass("active")}),e("#wcp_folder_"+l).length||(e(".header-posts a").trigger("click"),l=0)}else window.location.reload();e("#folder-hide-show-checkbox").attr("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox")}})}}():e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_folder&term_id="+p+"&nonce="+s,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(p),o=parseInt(t.is_key_active),a=parseInt(t.folders),e("#current-folder").text(a),e("#ttl-fldr").text(10),e(".sticky-folders .sticky-folder-"+p).remove(),b(),H(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),y(),U(),l==p&&e(".header-posts").trigger("click")):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})}),e(document).ready(function(){e(".mark-folder").livequery(function(){e(this).click(function(t){t.stopPropagation(),e(this).closest("li.jstree-node").length?folderID=e(this).closest("li.jstree-node").attr("id"):folderID=e(this).closest("li.sticky-fldr").data("folder-id"),s=v(folderID,"nonce"),e(".form-loader-count").css("width","100%"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e.ajax({url:wcp_settings.ajax_url,data:"term_id="+folderID+"&type="+wcp_settings.post_type+"&action=wcp_mark_un_mark_folder&nonce="+s,method:"post",cache:!1,success:function(t){t=e.parseJSON(t),e(".form-loader-count").css("width","0%"),"1"==t.status?(folderPostId=w(t.id),"1"==t.marked?(e("li.jstree-node[id='"+t.id+"']").addClass("is-high"),e(".sticky-folder-"+t.id).addClass("is-high"),null!=folderPostId&&(h[folderPostId].is_high=1)):(e("li.jstree-node[id='"+t.id+"']").removeClass("is-high"),e(".sticky-folder-"+t.id).removeClass("is-high"),null!=folderPostId&&(h[folderPostId].is_high=0)),b(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})})}),e(document).ready(function(){e(".jstree-node .jstree-icon").livequery(function(){e(this).click(function(){folderID=e(this).closest("li.jstree-node").attr("id"),e("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")?folderStatus=0:folderStatus=1,e(".form-loader-count").css("width","100%"),s=v(folderID,"nonce"),T(),jQuery.ajax({url:wcp_settings.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+folderID+"&nonce="+s,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=jQuery.parseJSON(t)).status||(e("#wcp_folder_"+folderID).hasClass("active")?(e("#wcp_folder_"+folderID).removeClass("active"),e("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp(),folderStatus=0):(e("#wcp_folder_"+folderID).addClass("active"),e("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown(),folderStatus=1),H())}})})})}),e(document).ready(function(){e(document).on("click","a.jstree-anchor",function(t){if(t.stopPropagation(),e(".un-categorised-items").removeClass("active-item"),e(".header-posts a").removeClass("active-item"),e("active-item").removeClass("active-item"),l=e(this).closest("li.jstree-node").attr("id"),p=e(this).closest("li.jstree-node").attr("id"),e(".sticky-folders .sticky-folder-"+l+" a").addClass("active-item"),e("#media-attachment-taxonomy-filter").length){var s=e(this).closest("li.jstree-node").attr("id");e("#media-attachment-taxonomy-filter").val(s),e("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=v(s,"slug"),_=wcp_settings.page_url+thisSlug;var o={Title:thisSlug,Url:_};history.pushState(o,o.Title,o.Url),P(thisSlug),e(".custom-media-select").removeClass("active")}else{var a=v(l,"slug");_=wcp_settings.page_url+a,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(_+" #posts-filter",function(){var t={Title:a,Url:_};history.pushState(t,t.Title,t.Url),P(a),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>'),j()}):e("#wpbody").load(_+" #wpbody-content",function(){var t={Title:a,Url:_};history.pushState(t,t.Title,t.Url),P(a),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>'),j()})}x(),e(".sticky-folders .sticky-folder-"+l+" a").addClass("active-item")}),e(".header-posts").click(function(){if(l="",e(".wcp-container .route").removeClass("active-item"),e(".un-categorised-items").removeClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".header-posts a").addClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e("#media-attachment-taxonomy-filter").length){l="",e("#media-attachment-taxonomy-filter").val("all"),e("#media-attachment-taxonomy-filter").trigger("change");var t={Title:"",Url:wcp_settings.page_url};history.pushState(t,t.Title,t.Url),P("all"),x()}else _=wcp_settings.page_url,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(_+" #posts-filter",function(){var t={Title:"",Url:_};history.pushState(t,t.Title,t.Url),P("all"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>'),x(),j()}):e("#wpbody").load(_+" #wpbody-content",function(){var t={Title:"",Url:_};history.pushState(t,t.Title,t.Url),P("all"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>'),x(),j()})}),e(".un-categorised-items").click(function(){if(l="-1",e(".wcp-container .route").removeClass("active-item"),e(".header-posts a").removeClass("active-item"),e(".un-categorised-items").addClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e("#media-attachment-taxonomy-filter").length){e("#media-attachment-taxonomy-filter").val("unassigned"),e("#media-attachment-taxonomy-filter").trigger("change");var t={Title:"",Url:wcp_settings.page_url+"-1"};history.pushState(t,t.Title,t.Url),P("-1"),x()}else _=wcp_settings.page_url+"-1",e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(_+" #posts-filter",function(){var t={Title:"",Url:_};history.pushState(t,t.Title,t.Url),P("-1"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>'),x(),j()}):e("#wpbody").load(_+" #wpbody-content",function(){var t={Title:"",Url:_};history.pushState(t,t.Title,t.Url),P("-1"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>'),x(),j()})}),e("#expand-collapse-list").click(function(t){t.stopPropagation(),statusType=0,e(this).hasClass("all-open")?(e(this).removeClass("all-open"),statusType=0,e(this).attr("data-folder-tooltip","Expand"),e("#js-tree-menu").jstree("close_all")):(e(this).addClass("all-open"),statusType=1,e(this).attr("data-folder-tooltip","Collapse"),e("#js-tree-menu").jstree("open_all")),f="",e("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){f+=e(this).attr("id")+","}),""!=f&&(e(".form-loader-count").css("width","100%"),s=wcp_settings.nonce,jQuery.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_all_status&status="+statusType+"&folders="+f+"&nonce="+s,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=jQuery.parseJSON(t)).status&&(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),T()}),e(document).ready(function(){e(document).on("click","body, html",function(){e(".folder-order").removeClass("active")}),e(document).on("click","#sort-order-list",function(t){t.stopPropagation(),e(".folder-order").toggleClass("active")}),e(document).on("click",".folder-sort-menu a",function(t){t.stopPropagation(),t.preventDefault(),e(".form-loader-count").css("width","100%"),e(".folder-order").removeClass("active"),lastOrderStatus=e(this).attr("data-sort"),jQuery.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_folders_by_order&nonce="+wcp_settings.nonce+"&order="+e(this).attr("data-sort"),method:"post",success:function(t){1==(t=jQuery.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),S()),e(".form-loader-count").css("width","0"),x()}})})}),e(document).ready(function(){e(document).on("keyup","#folder-search",function(){D()}),e(document).on("change","#folder-search",function(){D()}),e(document).on("blur","#folder-search",function(){D()})}),e(document).ready(function(){e(".wcp-move-file").livequery(function(){e(this).draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(t,s){e(this).closest("td").addClass("wcp-draggable"),e("body").addClass("no-hover-css")},stop:function(t,s){e(this).closest("td").removeClass("wcp-draggable"),e("body").removeClass("no-hover-css")}})}),e(".wcp-move-multiple").livequery(function(){e(this).draggable({revert:"invalid",containment:"document",helper:function(t,s){return e(".selected-items").remove(),selectedItems=e("#the-list th input:checked").length,selectedItems>0?(selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")):e("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")},start:function(t,s){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,s){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}})})}),"attachment"==wcp_settings.post_type){e(document).ready(function(){"show"==wcp_settings.show_in_page&&e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div><div class="folders-toggle-button"><span></span></div></div>'),b(),N()}),e(window).on("load",function(){e("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Bulk Organize</button>"),e(".media-toolbar-secondary").append("<span class='media-info-message'>Drag and drop your media files to the relevant folders</span>"),e(".delete-selected-button").before("<button type='button' class='button button-primary select-all-item-btn'>Select All</button>"),e(".media-toolbar-secondary").after("<div class='custom-media-select'>Move Selected files to: <select class='media-select-folder'></select></div>"),e(".media-toolbar").append("<div style='clear:both;'></div><div class='media-folder-loader'><span>Uploading files</span> <span id='current_upload_files'></span>/<span id='total_upload_files'></span><div class='folder-progress'><div class='folder-meter orange-bg'><span></span></div></div></div>"),e(".wcp-custom-form").length&&(wp.Uploader!==t&&wp.Uploader.queue.on("reset",function(){z(1)}),e(document).ajaxComplete(function(e,t,s){actionName=s.data,"undefined"!=typeof actionName&&actionName.length&&0==actionName.indexOf("action=delete-post&id=")&&z(0)})),setTimeout(function(){docReferrar=document.referrer,-1!=docReferrar.indexOf("wp-admin/upload.php")?(mediaMode=function(e){for(var t=e+"=",s=document.cookie.split(";"),o=0;o<s.length;o++){for(var a=s[o];" "==a.charAt(0);)a=a.substring(1,a.length);if(0==a.indexOf(t))return a.substring(t.length,a.length)}return null}("media-select-mode"),"on"==mediaMode&&(e("button.button.media-button.select-mode-toggle-button").trigger("click"),e(".media-frame").hasClass("mode-select")?e(".media-info-message").addClass("active"):e(".media-info-message, .custom-media-select").removeClass("active"))):J("media-select-mode"),z(1)},1e3),e(document).on("click",".attachments-browser ul.attachments .thumbnail",function(){e(".media-toolbar").hasClass("media-toolbar-mode-select")&&(0==e("ul.attachments li.selected").length?e(".custom-media-select").removeClass("active"):e(".custom-media-select").addClass("active"))}),e(document).on("change",".media-select-folder",function(){if(""!=e(this).val()){var t="";e(".attachments-browser li.attachment.selected").each(function(){t+=e(this).attr("data-id")+","}),"-1"==e(this).val()?jQuery.ajax({url:wcp_settings.ajax_url,data:"post_id="+t+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+e(this).val()+"&nonce="+wcp_settings.nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(e){y(),H()}}):(s=jQuery.trim(e("#wcp_folder_"+e(this).val()).data("nonce")),jQuery.ajax({url:wcp_settings.ajax_url,data:"post_ids="+t+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+e(this).val()+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+l,method:"post",success:function(t){t=jQuery.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(y(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}}))}})});var O=null;function z(s){O=e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_get_default_list&active_id="+l,method:"post",beforeSend:function(){null!=O&&O.abort()},success:function(o){if(o=e.parseJSON(o),e(".header-posts .total-count").text(o.total_items),e(".un-categorised-items .total-count").text(o.empty_items),selectedVal=e("#media-attachment-taxonomy-filter").val(),"all"!=selectedVal&&1==s){var a=parent.wp;a.media!=t&&(a.media.frame.setState("insert"),null!==a.media.frame.content.get()?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):a.media.frame.library.props.set({ignore:+new Date}))}if(o.taxonomies.length){if(e("#media-attachment-taxonomy-filter").length){folders_media_options.terms=o.taxonomies;var r=e("#media-attachment-taxonomy-filter");for(r.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),e(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),i=0;i<o.taxonomies.length;i++)r.append("<option value='"+o.taxonomies[i].term_id+"'>"+o.taxonomies[i].name+" ("+o.taxonomies[i].trash_count+")</option>"),e(".media-select-folder").append("<option value='"+o.taxonomies[i].term_id+"'>"+o.taxonomies[i].name+" ("+o.taxonomies[i].trash_count+")</option>"),e("#title_"+o.taxonomies[i].term_id).attr("title",o.taxonomies[i].term_name),e("#title_"+o.taxonomies[i].term_id+" .title-text").html(o.taxonomies[i].term_name);r.val(selectedVal),e(".media-select-folder").val("")}if(e("select.folder_for_media").length){for(selectedVal=e("select.folder_for_media").val(),e("select.folder_for_media option:not(:first-child):not(:last-child)").remove(),i=0;i<o.taxonomies.length;i++)e("select.folder_for_media option:last-child").before("<option value='"+o.taxonomies[i].term_id+"'>"+o.taxonomies[i].name+"</option>");""!=selectedVal&&e(".folder_for_media").val(selectedVal)}for(e("span.premio-folder-count").text(""),i=0;i<o.taxonomies.length;i++)0!=parseInt(o.taxonomies[i].trash_count)&&(e(".jstree-node[id='"+o.taxonomies[i].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(o.taxonomies[i].trash_count),e(".sticky-folder-"+o.taxonomies[i].term_id+" .premio-folder-count").text(o.taxonomies[i].trash_count))}""!=l&&e("#wcp_folder_"+l).addClass("active-item"),n&&(e("#title_"+p).trigger("click"),n=!1)}})}function Q(){e(".media-frame-content .media-toolbar").width(e(".media-frame-content").width()-20)}function q(e,t,s){var o="";if(s){var a=new Date;a.setTime(a.getTime()+24*s*60*60*1e3),o="; expires="+a.toUTCString()}document.cookie=e+"="+(t||"")+o+"; path=/"}function J(e){document.cookie=e+"=; Max-Age=-99999999;"}Q(),e(window).resize(function(){Q()}),e(document).ready(function(){}),e(document).on("click",".button.organize-button",function(){e(".media-frame").hasClass("mode-select")?J("media-select-mode"):q("media-select-mode","on",7),e("button.button.media-button.select-mode-toggle-button").trigger("click"),e(".media-frame").hasClass("mode-select")?(e(".media-info-message").addClass("active"),e(".select-all-item-btn").addClass("active")):(e(".media-info-message, .custom-media-select").removeClass("active"),e(".select-all-item-btn").removeClass("active"))}),e(document).on("click",".select-mode-toggle-button",function(){setTimeout(function(){e(".media-frame").hasClass("mode-select")||q("media-select-mode","off",-1),e(".media-frame").hasClass("mode-select")?(e(".media-info-message").addClass("active"),e(".select-all-item-btn").addClass("active")):(e(".media-info-message, .custom-media-select").removeClass("active"),e(".select-all-item-btn").removeClass("active"))},10)}),e(document).on("click",".select-all-item-btn",function(){e("ul.attachments li:not(.selected)").trigger("click")}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(p=0,n=!0,k())}),e(window).scroll(function(){})}else;});
1
+ (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module!=="undefined"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(D,n){var B="#js-tree-menu";var s;var b="";var o=false;var E=false;var h;var A;var x=0;var c=0;var U=0;var w=false;var p="";var v=[];var e=wcp_settings.page_url;var O=[];var r="<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'><div class='folder-item is-folder' data-id='__folder_id__'><a title='__folder_name__' id='folder_view___folder_id__'class='folder-view __append_class__ has-new-folder'data-id='__folder_id__'><span class='folder item-name'><span id='wcp_folder_text___folder_id__'class='folder-title'>__folder_name__</span></span></a></div></li>";D(document).ready(function(){O=wcp_settings.taxonomies;h=parseInt(wcp_settings.is_key_active);A=parseInt(wcp_settings.folders);b=parseInt(wcp_settings.selected_taxonomy);P();I();var V=(wcp_settings.isRTL=="1"||wcp_settings.isRTL==1)?"w":"e";D(".wcp-content").resizable({resizeHeight:false,handles:V,minWidth:100,maxWidth:500,resize:function(Y,X){var W=X.size.width;if(W<=275){D(".plugin-button").addClass("d-block")}else{D(".plugin-button").removeClass("d-block")}if(W<=225){W=225}if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right",(W+20)+"px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left",(W+20)+"px")}newWidth=W-40;cssString="";classString="";for(i=0;i<=15;i++){classString+=" .space > .jstree-node >";currentWidth=newWidth-(13+(20*i));cssString+="#js-tree-menu > "+classString+" .title { width: "+currentWidth+"px !important; } ";cssString+="#js-tree-menu > "+classString+" .dynamic-menu { left: "+(currentWidth-190)+"px !important; } ";L()}D("#wcp-custom-style").html("<style>"+cssString+"</style>");if(X.size.width<=185){folderStatus="hide";D(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active");D(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active");D("#wcp-content").addClass("hide-folders-area");if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right","20px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left","20px")}}else{if(D("#wcp-content").hasClass("hide-folders-area")){folderStatus="show";D(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active");D(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active");D("#wcp-content").addClass("no-transition");D("#wcp-content").removeClass("hide-folders-area");if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right",(wcp_settings.folder_width+20)+"px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left",(wcp_settings.folder_width+20)+"px")}setTimeout(function(){D("#wcp-content").removeClass("no-transition")},250)}}},stop:function(Y,X){var W=X.size.width;if(X.size.width<=275){D(".plugin-button").addClass("d-block")}else{D(".plugin-button").removeClass("d-block")}if(W<=225){W=225}if(X.size.width<=185){folderStatus="hide";D(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active");D(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active");D("#wcp-content").addClass("hide-folders-area");if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right","20px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left","20px")}D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+folderStatus+"&nonce="+s,method:"post",success:function(Z){L()}})}else{if(D("#wcp-content").hasClass("hide-folders-area")){folderStatus="show";D(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active");D(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active");D("#wcp-content").addClass("no-transition");D("#wcp-content").removeClass("hide-folders-area");if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right",(wcp_settings.folder_width+20)+"px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left",(wcp_settings.folder_width+20)+"px")}setTimeout(function(){D("#wcp-content").removeClass("no-transition")},250)}}s=wcp_settings.nonce;wcp_settings.folder_width=X.size.width;D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_post_width&width="+W+"&nonce="+s,method:"post",success:function(Z){L()}});if(X.size.width<=225){D(".wcp-content").width(225);wcp_settings.folder_width=225}}});D(document).on("contextmenu",".jstree-anchor",function(W){D(this).find("span.folder-inline-edit").trigger("click");return false});D(document).on("click",".folder-actions span.folder-inline-edit",function(W){W.stopImmediatePropagation();W.stopPropagation();if(wcp_settings.can_manage_folder==0){return}isHigh=D(this).closest("li.jstree-node").hasClass("is-high");isSticky=D(this).closest("li.jstree-node").hasClass("is-sticky");isStickyClass=(isSticky)?true:false;D(".dynamic-menu").remove();D(".active-menu").removeClass("active-menu");menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span> Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+((isHigh)?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>";hasPosts=parseInt(D(this).closest("a.jstree-anchor").find(".premio-folder-count").text());if(wcp_settings.post_type=="attachment"&&hasPosts){menuHtml+="<li target='_blank' class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"}menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>";D(this).closest("a.jstree-anchor").after(menuHtml);D(this).parents("li.jstree-node").addClass("active-menu");if((D(this).offset().top+D(".dynamic-menu").height())>(D(window).height()-20)){D(".dynamic-menu").addClass("bottom-fix");if(D(".dynamic-menu.bottom-fix").offset().top<D("#custom-scroll-menu").offset().top){D(".dynamic-menu").removeClass("bottom-fix")}}});D(document).on("click",".sticky-folders .sticky-fldr > a",function(X){X.stopPropagation();var W=D(this).closest("li").data("folder-id");if(D(".jstree-node[id='"+W+"']").length){D(".jstree-clicked").removeClass("jstree-clicked");D(".active-item").removeClass("active-item");D("#js-tree-menu").jstree("select_node",b);D(".jstree-node[id='"+W+"'] > a.jstree-anchor").trigger("click");D(".jstree-node[id='"+W+"'] > a.jstree-anchor").addClass("jstree-clicked");D(".sticky-folders .sticky-folder-"+W+" a").addClass("active-item")}});D(document).on("contextmenu",".sticky-folders li .sticky-fldr > a",function(W){D(this).find("span.update-inline-record").trigger("click");return false});D(document).on("click",".update-inline-record",function(W){W.stopImmediatePropagation();W.stopPropagation();if(wcp_settings.can_manage_folder==0){return}isHigh=D(this).closest("li.sticky-fldr").hasClass("is-high");isSticky=D(this).closest("li.sticky-fldr").hasClass("is-sticky");isStickyClass=(isSticky)?true:false;D(".dynamic-menu").remove();D(".active-menu").removeClass("active-menu");menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+((isHigh)?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>";hasPosts=parseInt(D(this).closest("li.jstree-node").find("h3.title:first > .total-count").text());if(wcp_settings.post_type=="attachment"&&hasPosts){menuHtml+="<li class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"}menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>";D(this).closest("li").append(menuHtml);if((D(this).offset().top+D(".dynamic-menu").height())>(D(window).height()-20)){D(".dynamic-menu").addClass("bottom-fix");if(D(".dynamic-menu.bottom-fix").offset().top<D("#custom-scroll-menu").offset().top){D(".dynamic-menu").removeClass("bottom-fix")}}});D(document).on("click",".dynamic-menu",function(W){W.stopImmediatePropagation();W.stopPropagation()});D(document).on("click","body, html",function(){D(".dynamic-menu").remove()});D(".wcp-hide-show-buttons .toggle-buttons").click(function(){var W="show";if(D(this).hasClass("hide-folders")){W="hide"}D(".wcp-hide-show-buttons .toggle-buttons").toggleClass("active");s=wcp_settings.nonce;if(W=="show"){D("#wcp-content").addClass("no-transition");D("#wcp-content").removeClass("hide-folders-area");if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right",(wcp_settings.folder_width+20)+"px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left",(wcp_settings.folder_width+20)+"px")}setTimeout(function(){D("#wcp-content").removeClass("no-transition")},250)}else{D("#wcp-content").addClass("hide-folders-area");if(wcp_settings.isRTL=="1"){D("#wpcontent").css("padding-right","20px");D("#wpcontent").css("padding-left","0px")}else{D("#wpcontent").css("padding-left","20px")}}D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+W+"&nonce="+s,method:"post",success:function(X){L()}})});D(".jstree-anchor").livequery(function(){D(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(W,X){folderID=D(this).closest("li.jstree-node").attr("id");if(X.draggable.hasClass("wcp-move-multiple")){if(D(".wp-list-table input:checked").length){chkStr="";D(".wp-list-table input:checked").each(function(){chkStr+=D(this).val()+","});s=R(folderID,"nonce");D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Y=D.parseJSON(Y);if(Y.status=="1"){Q()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(Y.message);D("#error-folder-popup").show()}}})}}else{if(X.draggable.hasClass("wcp-move-file")){postID=X.draggable[0].attributes["data-id"].nodeValue;s=R(folderID,"nonce");chkStr=postID+",";D(".wp-list-table input:checked").each(function(){if(D(this).val()!=postID){chkStr+=D(this).val()+","}});D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Y=D.parseJSON(Y);if(Y.status=="1"){Q()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(Y.message);D("#error-folder-popup").show()}}})}else{if(X.draggable.hasClass("attachment")){chkStr=X.draggable[0].attributes["data-id"].nodeValue;s=R(folderID,"nonce");if(D(".attachments-browser li.attachment.selected").length>1){chkStr="";D(".attachments-browser li.attachment.selected").each(function(){chkStr+=D(this).data("id")+","})}p=chkStr;D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q()}})}}}}})});D(".un-categorised-items").livequery(function(){D(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(W,X){folderID=-1;s=wcp_settings.nonce;if(X.draggable.hasClass("wcp-move-multiple")){if(D(".wp-list-table input:checked").length){chkStr="";D(".wp-list-table input:checked").each(function(){chkStr+=D(this).val()+","});D.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q()}})}}else{if(X.draggable.hasClass("wcp-move-file")){postID=X.draggable[0].attributes["data-id"].nodeValue;chkStr=postID+",";D(".wp-list-table input:checked").each(function(){if(postID!=D(this).val()){chkStr+=D(this).val()+","}});D.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q()}})}else{if(X.draggable.hasClass("attachment")){chkStr=X.draggable[0].attributes["data-id"].nodeValue;if(D(".attachments-browser li.attachment.selected").length>1){chkStr="";D(".attachments-browser li.attachment.selected").each(function(){chkStr+=D(this).data("id")+","})}p=chkStr;D.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q()}})}}}}})});D(".attachments-browser li.attachment").livequery(function(){D(this).draggable({revert:"invalid",containment:"document",helper:function(W,X){D(".selected-items").remove();selectedItems=D(".attachments-browser li.attachment.selected").length;selectedItems=(selectedItems==0||selectedItems==1)?"1 Item":selectedItems+" Items";return D("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")},start:function(W,X){D("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(W,X){D(".selected-items").remove();D("body").removeClass("no-hover-css")}})});D(".tree-structure .folder-item").livequery(function(){D(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(W,X){D("body").removeClass("no-hover-css");folderID=D(this).data("id");if(X.draggable.hasClass("wcp-move-multiple")){s=R(folderID,"nonce");if(D(".wp-list-table input:checked").length){chkStr="";D(".wp-list-table input:checked").each(function(){chkStr+=D(this).val()+","});D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q();J()}})}}else{if(X.draggable.hasClass("wcp-move-file")){postID=X.draggable[0].attributes["data-id"].nodeValue;s=R(folderID,"nonce");chkStr=postID+",";D(".wp-list-table input:checked").each(function(){if(D(this).val()!=postID){chkStr+=D(this).val()+","}});D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q();J()}})}else{if(X.draggable.hasClass("attachment")){chkStr=X.draggable[0].attributes["data-id"].nodeValue;s=R(folderID,"nonce");if(D(".attachments-browser li.attachment.selected").length>1){chkStr="";D(".attachments-browser li.attachment.selected").each(function(){chkStr+=D(this).data("id")+","})}D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q();J()}})}}}}})});D(".sticky-folders li a").livequery(function(){D(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(W,X){folderID=D(this).closest("li").data("folder-id");if(X.draggable.hasClass("wcp-move-multiple")){if(D(".wp-list-table input:checked").length){chkStr="";D(".wp-list-table input:checked").each(function(){chkStr+=D(this).val()+","});s=R(folderID,"nonce");D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Y=D.parseJSON(Y);if(Y.status=="1"){Q();J()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(Y.message);D("#error-folder-popup").show()}}})}}else{if(X.draggable.hasClass("wcp-move-file")){postID=X.draggable[0].attributes["data-id"].nodeValue;s=R(folderID,"nonce");chkStr=postID+",";D(".wp-list-table input:checked").each(function(){if(D(this).val()!=postID){chkStr+=D(this).val()+","}});D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Y=D.parseJSON(Y);if(Y.status=="1"){Q();J()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(Y.message);D("#error-folder-popup").show()}}})}else{if(X.draggable.hasClass("attachment")){chkStr=X.draggable[0].attributes["data-id"].nodeValue;s=R(folderID,"nonce");if(D(".attachments-browser li.attachment.selected").length>1){chkStr="";D(".attachments-browser li.attachment.selected").each(function(){chkStr+=D(this).data("id")+","})}p=chkStr;D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(Y){Q();J()}})}}}}})})});function m(){D("#js-tree-menu .jstree-node").each(function(){var W=parseInt(D(this).data("count"));if(W>0){D(".jstree-node[id='"+D(this).attr("id")+"'] > a span.premio-folder-count").text(W)}var V={folder_id:D(this).attr("id"),folder_count:W,is_sticky:D(this).hasClass("is-sticky")?1:0,is_high:D(this).hasClass("is-high")?1:0,nonce:D(this).data("nonce"),slug:D(this).data("slug"),is_deleted:0};v.push(V)});if(b!=""&&b!=0){if(D(".jstree-node[id='"+b+"']").length){D("#js-tree-menu").jstree("select_node",b);if(D(".sticky-folders .sticky-folder-"+b+" a").length){D(".sticky-folders .sticky-folder-"+b+" a").addClass("active-item")}}}D(".ajax-preloader").hide();D(".js-tree-data").show();I();t();if(D(".sticky-folders ul > li").length>0){D(".sticky-folders").addClass("active")}S()}function R(V,W){if(v.length>0){for(i=0;i<v.length;i++){if(parseInt(v[i]["folder_id"])==parseInt(V)){return v[i][W]}}}return""}function q(V){if(v.length>0){for(i=0;i<v.length;i++){if(parseInt(v[i]["folder_id"])==parseInt(V)){return i}}}return null}function Q(){if(D(".media-toolbar").hasClass("media-toolbar-mode-select")){if(D("ul.attachments li.selected").length){D("ul.attachments li.selected").trigger("click");D(".select-mode-toggle-button").trigger("click")}}if(p!=""&&(D("#js-tree-menu a.jstree-clicked").length>0||b=="-1")){if(D("#media-attachment-taxonomy-filter").length){p=p.split(",");for(var V=0;V<p.length;V++){if(p[V]!=""){D(".attachments-browser li[data-id='"+p[V]+"']").remove()}}}p=""}if(D("#media-attachment-taxonomy-filter").length){y(0)}else{D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=get_folders_default_list",method:"post",success:function(W){W=D.parseJSON(W);D(".header-posts .total-count").text(W.total_items);D(".un-categorised-items .total-count").text(W.empty_items);for(V=0;V<W.taxonomies.length;V++){if(!D("#title_"+W.taxonomies[V].term_id+" .total-count").length){D("#title_"+W.taxonomies[V].term_id+" .star-icon").before("<span class='total-count'></span>")}D("#title_"+W.taxonomies[V].term_id+" .total-count").text(parseInt(W.taxonomies[V].trash_count))}D("span.premio-folder-count").text("");D(".folder-count").text("");for(V=0;V<W.taxonomies.length;V++){if(parseInt(W.taxonomies[V].trash_count)!=0){D(".jstree-node[id='"+W.taxonomies[V].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(W.taxonomies[V].trash_count);D(".sticky-folder-"+W.taxonomies[V].term_id+" .premio-folder-count").text(W.taxonomies[V].trash_count)}}}});D(".folder-loader-ajax").addClass("active");if(D("#folder-posts-filter").length){D("#folder-posts-filter").load(e+" #posts-filter",function(){var W={Title:"",Url:e};history.pushState(W,W.Title,W.Url);if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}S();G()})}else{D("#wpbody").load(e+" #wpbody-content",false,function(W){var X={Title:"",Url:e};history.pushState(X,X.Title,X.Url);if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}S()})}}}function G(){S();D(".form-loader-count").css("width","0");if(typeof inlineEditPost=="object"){inlineEditPost.init();D("#the-list").on("click",".editinline",function(){D(this).attr("aria-expanded","true");inlineEditPost.edit(this)});D(document).on("click",".inline-edit-save .save",function(){var V=D(this).closest("tr").attr("id");V=V.replace("edit-","");V=V.replace("post-","");inlineEditPost.save(V)});D(document).on("click",".inline-edit-save .cancel",function(){var V=D(this).closest("tr").attr("id");V=V.replace("edit-","");V=V.replace("post-","");inlineEditPost.revert(V)})}if(wcp_settings.post_type=="attachment"){if(!D(".move-to-folder-top").length){D("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>")}if(!D(".move-to-folder-bottom").length){D("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>")}}}function S(){if(v.length){D("li.jstree-node").each(function(){folderPostId=q(D(this).attr("id"));if(folderPostId!=null){if(v[folderPostId]["is_high"]==1){D(this).addClass("is-high")}else{D(this).removeClass("is-high")}if(v[folderPostId]["is_sticky"]==1){D(this).addClass("is-sticky")}else{D(this).removeClass("is-sticky")}}})}folderId=0;D(".tree-structure ul").html("");folderStatus=true;if(D(".jstree-clicked").length){folderID=D(".jstree-clicked").closest(".jstree-node").attr("id");if(D(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").length){folderStatus=false;D(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").each(function(){fID=D(this).attr("id");fName=D.trim(D("#js-tree-menu").jstree(true).get_node(fID).text);liHtml=r.replace(/__folder_id__/g,fID);liHtml=liHtml.replace(/__folder_name__/g,fName);selectedClass=D(this).hasClass("is-high")?"is-high":"";liHtml=liHtml.replace(/__append_class__/g,selectedClass);D(".tree-structure ul").append(liHtml)})}else{if(!D(".jstree-node[id='"+folderID+"']").closest("ul").hasClass("jstree-container-ul")){folderStatus=false}}}if(folderStatus){D("#js-tree-menu > ul > li.jstree-node").each(function(){fID=D(this).attr("id");fName=D.trim(D("#js-tree-menu").jstree(true).get_node(fID).text);liHtml=r.replace(/__folder_id__/g,fID);liHtml=liHtml.replace(/__folder_name__/g,fName);selectedClass=D(this).hasClass("is-high")?"is-high":"";liHtml=liHtml.replace(/__append_class__/g,selectedClass);D(".tree-structure ul").append(liHtml)})}a();if(wcp_settings.post_type=="attachment"){if(!D(".move-to-folder-top").length){D("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>")}if(!D(".move-to-folder-bottom").length){D("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>")}}D(".sticky-folders .active-item").removeClass("active-item");if(D("#js-tree-menu li.jstree-node.active-item").length){var V=D("#js-tree-menu li.jstree-node.active-item").data("folder-id");D(".sticky-folders .sticky-folder-"+V+" a").addClass("active-item")}}D(window).on("resize",function(){I();L()});D(window).scroll(function(){L()});function I(){}D(document).ready(function(){D("#add-new-folder").livequery(function(){D(this).click(function(){if(D("#js-tree-menu a.jstree-clicked").length){c=D("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id")}else{c=0}o=false;K()})});D(".new-folder").livequery(function(){D(this).click(function(){if(D(this).closest("li.jstree-node").length){c=D(this).closest("li.jstree-node").attr("id")}else{c=D(this).closest("li.sticky-fldr").data("folder-id")}o=false;K()})});D(".duplicate-folder").livequery(function(){D(this).click(function(V){V.stopPropagation();if(D(this).closest("li.jstree-node").length){c=D(this).closest("li.jstree-node").attr("id")}else{c=D(this).closest("li.sticky-fldr").data("folder-id")}D(".dynamic-menu").remove();o=false;E=true;K();N()})});D(document).on("submit","#save-folder-form",function(V){V.stopPropagation();V.preventDefault();folderNameDynamic=D.trim(D("#add-update-folder-name").val());if(D.trim(folderNameDynamic)==""){D(".folder-form-errors").addClass("active");D("#add-update-folder-name").focus()}else{D("#save-folder-data").html('<span class="dashicons dashicons-update"></span>');D("#add-update-folder").addClass("disabled");var W=c;if(o){W=0}if(W==0){U=D("#js-tree-menu > ul > li.jstree-node").length}else{U=D("#js-tree-menu > ul > li.jstree-node[id='"+W+"'] > ul.jstree-children > li").length+1}D.ajax({url:wcp_settings.ajax_url,data:{parent_id:W,type:wcp_settings.post_type,action:"wcp_add_new_folder",nonce:wcp_settings.nonce,term_id:W,order:U,name:folderNameDynamic,is_duplicate:E,duplicate_from:x},method:"post",success:function(X){result=D.parseJSON(X);if(result.status=="1"){h=parseInt(result.is_key_active);A=parseInt(result.folders);D("#current-folder").text(A);D("#ttl-fldr").text((4*4)-(2*2)-2);z();N();D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");var Y={folder_id:result.term_id,folder_count:0,is_sticky:0,is_high:0,nonce:result.nonce,slug:result.slug,is_deleted:0};v.push(Y);J();t();D("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.term_id,text:" "+result.title},"last",function(){D(".jstree-node[id='"+result.term_id+"']").attr("data-nonce",result.nonce);D(".jstree-node[id='"+result.term_id+"']").attr("data-slug",result.slug)});if(D("#media-attachment-taxonomy-filter").length){c=result.term_id;y(0)}}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(result.message);D("#error-folder-popup").show()}}})}return false})});function N(){S()}function K(){if(h==0&&A>=((4*4)-(3*3)+(4/4)+(8/(2*2)))){D("#folder-limitation-message").html("You've reached the "+((4*4)-(2*2)-2)+" folder limitation!");D("#no-more-folder-credit").show();return false}D("#add-update-folder-title").text("Add new folder");D("#save-folder-data").text("Submit");D(".folder-form-errors").removeClass("active");D("#add-update-folder-name").val("");if(E){x=c;D("#add-update-folder-name").val(D.trim(D("#js-tree-menu").jstree(true).get_node(c).text)+" #2");if(D("#"+c+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")){c=D("#"+c+"_anchor").closest(".jstree-node").parent().parent().attr("id")}else{c=0}}D("#add-update-folder").removeClass("disabled");D("#add-update-folder").show();D("#add-update-folder-name").focus();D(".dynamic-menu").remove()}D(document).ready(function(){D("#inline-update").click(function(){if(D("#js-tree-menu a.jstree-clicked").length){c=D("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");H()}});D(".rename-folder").livequery(function(){D(this).click(function(V){V.stopPropagation();if(D(this).closest("li.jstree-node").length){c=D(this).closest("li.jstree-node").attr("id")}else{c=D(this).closest("li.sticky-fldr").data("folder-id")}H();D(".dynamic-menu").remove()})});D(document).on("click",".form-cancel-btn",function(){D(".folder-popup-form").hide()});D(document).on("click",".folder-popup-form",function(V){D(".folder-popup-form").hide()});D(document).on("click",".popup-form-content",function(V){V.stopPropagation()});D(document).on("submit","#update-folder-form",function(V){V.stopPropagation();V.preventDefault();folderNameDynamic=D("#update-folder-item-name").val();if(D.trim(folderNameDynamic)==""){D(".folder-form-errors").addClass("active");D("#update-folder-item-name").focus()}else{D("#update-folder-data").html('<span class="dashicons dashicons-update"></span>');D("#update-folder-item").addClass("disabled");s=R(c,"nonce");parentID=D(".jstree-node[id='"+c+"']").closest("li.jstree-node").attr("id");if(parentID==n){parentID=0}D.ajax({url:wcp_settings.ajax_url,data:{parent_id:parentID,type:wcp_settings.post_type,action:"wcp_update_folder",nonce:s,term_id:c,order:U,name:folderNameDynamic},method:"post",success:function(W){result=D.parseJSON(W);if(result.status=="1"){D("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title);folderPostId=q(result.id);if(folderPostId!=null){v[folderPostId]["nonce"]=result.nonce;v[folderPostId]["slug"]=result.slug}N();D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");J();if(D("#media-attachment-taxonomy-filter").length){y(0)}}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(result.message);D("#error-folder-popup").show()}}})}return false})});function H(){folderName=D.trim(D("#js-tree-menu").jstree(true).get_node(c).text);parentID=D("#wcp_folder_"+c).closest("li.jstree-node").data("folder-id");if(parentID==n){parentID=0}D("#update-folder-data").text("Submit");D(".folder-form-errors").removeClass("active");D("#update-folder-item-name").val(folderName);D("#update-folder-item").removeClass("disabled");D("#update-folder-item").show();D("#update-folder-item-name").focus();D(".dynamic-menu").remove()}D(document).ready(function(){D("#inline-remove").click(function(){if(D("#js-tree-menu a.jstree-clicked").length){c=D("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");M(1);D(".dynamic-menu").remove();D(".active-menu").removeClass("active-menu")}else{if(D("#folder-hide-show-checkbox").is(":checked")){D(".dynamic-menu").remove();M(1)}}});D(document).on("click","#folder-hide-show-checkbox",function(){if(D(this).is(":checked")){D("#js-tree-menu").addClass("show-folder-checkbox")}else{D("#js-tree-menu input.checkbox").attr("checked",false);D("#js-tree-menu").removeClass("show-folder-checkbox")}});D(document).on("click",".folder-checkbox, .input-checkbox",function(V){V.stopImmediatePropagation();V.stopPropagation()});D(".remove-folder").livequery(function(){D(this).click(function(){folderID=D(this).closest("li.jstree-node").data("id");if(D(this).closest("li.jstree-node").length){c=D(this).closest("li.jstree-node").attr("id")}else{c=D(this).closest("li.sticky-fldr").data("folder-id")}M(0);D(".dynamic-menu").remove();D(".active-menu").removeClass("active-menu")})});D(document).on("click","#remove-folder-item",function(V){V.stopPropagation();D(".folder-popup-form").addClass("disabled");D("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>');s=R(c,"nonce");if(w){l()}else{D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_folder&term_id="+c+"&nonce="+s,method:"post",success:function(W){W=D.parseJSON(W);if(W.status=="1"){D("#js-tree-menu").jstree().delete_node(c);h=parseInt(W.is_key_active);A=parseInt(W.folders);D("#current-folder").text(A);D("#ttl-fldr").text((3*3)+(4/(2*2)));D(".sticky-folders .sticky-folder-"+c).remove();N();J();D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");Q();t();if(b==c){D(".header-posts").trigger("click")}}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(W.message);D("#error-folder-popup").show()}}})}})});function T(){D("#js-tree-menu li.jstree-node").removeClass("has-sub-tree");D("#js-tree-menu li.jstree-node").each(function(){if(D(this).find("ul.ui-sortable li").length){D(this).addClass("has-sub-tree")}else{D(this).removeClass("active")}})}function l(){if(D("#folder-hide-show-checkbox").is(":checked")){if(D("#js-tree-menu input.checkbox:checked").length>0){var V="";var W=false;D("#js-tree-menu input.checkbox:checked").each(function(){V+=D(this).closest("li.jstree-node").attr("id")+",";if(D(this).closest("li.jstree-node").hasClass("jstree-clicked")){W=true}});D(".form-loader-count").css("width","100%");D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_muliple_folder&term_id="+V+"&nonce="+wcp_settings.nonce,method:"post",success:function(X){X=D.parseJSON(X);D(".form-loader-count").css("width","0px");if(X.status=="1"){h=parseInt(X.is_key_active);A=parseInt(X.folders);D("#current-folder").text(A);for(i=0;i<X.term_ids.length;i++){D("#js-tree-menu").jstree().delete_node(X.term_ids[i])}D("#ttl-fldr").text((4*2)+(4/2));J();D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");Q();t();J();T();if(!D("#wcp_folder_"+b).length){D(".header-posts a").trigger("click");b=0}}else{window.location.reload()}D("#folder-hide-show-checkbox").attr("checked",false);D("#js-tree-menu input.checkbox").attr("checked",false);D("#js-tree-menu").removeClass("show-folder-checkbox")}})}else{}}}function M(V){var W="Are you sure you want to delete the selected folder?";var X="Items in the folder will not be deleted.";w=false;if(V==1){if(D("#folder-hide-show-checkbox").is(":checked")){w=true;if(D("#js-tree-menu input.checkbox:checked").length==0){D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html("Please select at least one folder to delete");D("#error-folder-popup").show();return}else{if(D("#js-tree-menu input.checkbox:checked").length>1){W="Are you sure you want to delete the selected folders?";X="Items in the selected folders will not be deleted."}}}}D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#remove-folder-item").text("Yes, Delete it!");D("#remove-folder-message").text(W);D("#remove-folder-notice").text(X);D("#confirm-remove-folder").show();D("#remove-folder-item").focus()}D(document).ready(function(){D(".mark-folder").livequery(function(){D(this).click(function(V){V.stopPropagation();if(D(this).closest("li.jstree-node").length){folderID=D(this).closest("li.jstree-node").attr("id")}else{folderID=D(this).closest("li.sticky-fldr").data("folder-id")}s=R(folderID,"nonce");D(".form-loader-count").css("width","100%");D(".dynamic-menu").remove();D(".active-menu").removeClass("active-menu");D.ajax({url:wcp_settings.ajax_url,data:"term_id="+folderID+"&type="+wcp_settings.post_type+"&action=wcp_mark_un_mark_folder&nonce="+s,method:"post",cache:false,success:function(W){W=D.parseJSON(W);D(".form-loader-count").css("width","0%");if(W.status=="1"){folderPostId=q(W.id);if(W.marked=="1"){D("li.jstree-node[id='"+W.id+"']").addClass("is-high");D(".sticky-folder-"+W.id).addClass("is-high");if(folderPostId!=null){v[folderPostId]["is_high"]=1}}else{D("li.jstree-node[id='"+W.id+"']").removeClass("is-high");D(".sticky-folder-"+W.id).removeClass("is-high");if(folderPostId!=null){v[folderPostId]["is_high"]=0}}N();J()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(W.message);D("#error-folder-popup").show()}}})})})});D(document).ready(function(){D(".jstree-node .jstree-icon").livequery(function(){D(this).click(function(){folderID=D(this).closest("li.jstree-node").attr("id");if(D("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")){folderStatus=0}else{folderStatus=1}D(".form-loader-count").css("width","100%");s=R(folderID,"nonce");z();D.ajax({url:wcp_settings.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+folderID+"&nonce="+s,method:"post",success:function(V){D(".form-loader-count").css("width","0");V=D.parseJSON(V);if(V.status=="0"){}else{if(D("#wcp_folder_"+folderID).hasClass("active")){D("#wcp_folder_"+folderID).removeClass("active");D("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp();folderStatus=0}else{D("#wcp_folder_"+folderID).addClass("active");D("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown();folderStatus=1}J()}}})})})});D(document).ready(function(){D(document).on("click","a.jstree-anchor",function(Y){Y.stopPropagation();D(".un-categorised-items").removeClass("active-item");D(".header-posts a").removeClass("active-item");D("active-item").removeClass("active-item");b=D(this).closest("li.jstree-node").attr("id");c=D(this).closest("li.jstree-node").attr("id");D(".sticky-folders .sticky-folder-"+b+" a").addClass("active-item");if(!D("#media-attachment-taxonomy-filter").length){var X=R(b,"slug");e=wcp_settings.page_url+X;D(".form-loader-count").css("width","100%");if(D("#folder-posts-filter").length){D("#folder-posts-filter").load(e+" #posts-filter",function(){var Z={Title:X,Url:e};history.pushState(Z,Z.Title,Z.Url);j(X);if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>')}G()})}else{D("#wpbody").load(e+" #wpbody-content",function(){var Z={Title:X,Url:e};history.pushState(Z,Z.Title,Z.Url);j(X);if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>')}G()})}}else{var W=D(this).closest("li.jstree-node").attr("id");D("#media-attachment-taxonomy-filter").val(W);D("#media-attachment-taxonomy-filter").trigger("change");thisSlug=R(W,"slug");e=wcp_settings.page_url+thisSlug;var V={Title:thisSlug,Url:e};history.pushState(V,V.Title,V.Url);j(thisSlug);D(".custom-media-select").removeClass("active")}S();D(".sticky-folders .sticky-folder-"+b+" a").addClass("active-item")});D(".header-posts").click(function(){b="";D(".wcp-container .route").removeClass("active-item");D(".un-categorised-items").removeClass("active-item");D(".sticky-folders .active-item").removeClass("active-item");D(".header-posts a").addClass("active-item");D(".jstree-clicked").removeClass("jstree-clicked");if(!D("#media-attachment-taxonomy-filter").length){e=wcp_settings.page_url;D(".form-loader-count").css("width","100%");if(D("#folder-posts-filter").length){D("#folder-posts-filter").load(e+" #posts-filter",function(){var W={Title:"",Url:e};history.pushState(W,W.Title,W.Url);j("all");if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>')}S();G()})}else{D("#wpbody").load(e+" #wpbody-content",function(){var W={Title:"",Url:e};history.pushState(W,W.Title,W.Url);j("all");if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>')}S();G()})}}else{b="";D("#media-attachment-taxonomy-filter").val("all");D("#media-attachment-taxonomy-filter").trigger("change");var V={Title:"",Url:wcp_settings.page_url};history.pushState(V,V.Title,V.Url);j("all");S()}});D(".un-categorised-items").click(function(){b="-1";D(".wcp-container .route").removeClass("active-item");D(".header-posts a").removeClass("active-item");D(".un-categorised-items").addClass("active-item");D(".sticky-folders .active-item").removeClass("active-item");D(".jstree-clicked").removeClass("jstree-clicked");if(!D("#media-attachment-taxonomy-filter").length){e=wcp_settings.page_url+"-1";D(".form-loader-count").css("width","100%");if(D("#folder-posts-filter").length){D("#folder-posts-filter").load(e+" #posts-filter",function(){var W={Title:"",Url:e};history.pushState(W,W.Title,W.Url);j("-1");if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>')}S();G()})}else{D("#wpbody").load(e+" #wpbody-content",function(){var W={Title:"",Url:e};history.pushState(W,W.Title,W.Url);j("-1");if(wcp_settings.show_in_page=="show"&&!D(".tree-structure").length){D(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>')}S();G()})}}else{D("#media-attachment-taxonomy-filter").val("unassigned");D("#media-attachment-taxonomy-filter").trigger("change");var V={Title:"",Url:wcp_settings.page_url+"-1"};history.pushState(V,V.Title,V.Url);j("-1");S()}});D("#expand-collapse-list").click(function(V){V.stopPropagation();statusType=0;if(D(this).hasClass("all-open")){D(this).removeClass("all-open");statusType=0;D(this).attr("data-folder-tooltip","Expand");D("#js-tree-menu").jstree("close_all")}else{D(this).addClass("all-open");statusType=1;D(this).attr("data-folder-tooltip","Collapse");D("#js-tree-menu").jstree("open_all")}p="";D("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){p+=D(this).attr("id")+","});if(p!=""){D(".form-loader-count").css("width","100%");s=wcp_settings.nonce;D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_all_status&status="+statusType+"&folders="+p+"&nonce="+s,method:"post",success:function(W){D(".form-loader-count").css("width","0");W=D.parseJSON(W);if(W.status=="0"){D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(W.message);D("#error-folder-popup").show();window.location.reload(true)}}})}});z()});function P(){D(B).jstree({core:{cache:false,animation:0,check_callback:function(X,V,Z,W,Y){D("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up");if(("move_node"===X||"copy_node"===X)&&Y&&Y.dnd){switch(Y.pos){case"a":Y.origin.get_node(Y.ref,!0).addClass("drag-bot");nodeId=D(".drag-bot").attr("id");D("#jstree-dnd").text("Below "+D.trim(D("#js-tree-menu").jstree(true).get_node(nodeId).text));break;case"i":Y.origin.get_node(Y.ref,!0).addClass("drag-in");nodeId=D(".drag-in").attr("id");D("#jstree-dnd").text("Inside "+D.trim(D("#js-tree-menu").jstree(true).get_node(nodeId).text));break;case"b":Y.origin.get_node(Y.ref,!0).addClass("drag-up");nodeId=D(".drag-up").attr("id");D("#jstree-dnd").text("Above "+D.trim(D("#js-tree-menu").jstree(true).get_node(nodeId).text));break;default:D("#jstree-dnd").text(D("#jstree-dnd").data("txt"));break}}return !0}},data:{cache:false},select_node:false,search:{show_only_matches:true,case_sensitive:false,fuzzy:false},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",(function(){m()})).bind("move_node.jstree",(function(V,W){folderMoveId=W.node.id;orderString="";D(".jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){if(D(this).attr("id")!="undefined"){orderString+=D(this).attr("id")+","}});if(D("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")){parentID=D("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id")}else{parentID=0}if(orderString!=""){D(".form-loader-count").css("width","100%");D.ajax({url:wcp_settings.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+wcp_settings.post_type+"&nonce="+wcp_settings.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(X){X=D.parseJSON(X);if(X.status=="1"){D("#wcp_folder_parent").html(X.options);D(".form-loader-count").css("width","0");Q();J();F()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(X.message);D("#error-folder-popup").show();window.location.reload(true)}}})}}))}D(document).ready(function(){D(document).on("click","body, html",function(){D(".folder-order").removeClass("active")});D(document).on("click","#sort-order-list",function(V){V.stopPropagation();D(".folder-order").toggleClass("active")});D(document).on("click",".folder-sort-menu a",function(V){V.stopPropagation();V.preventDefault();D(".form-loader-count").css("width","100%");D(".folder-order").removeClass("active");lastOrderStatus=D(this).attr("data-sort");D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_folders_by_order&nonce="+wcp_settings.nonce+"&order="+D(this).attr("data-sort"),method:"post",success:function(W){W=D.parseJSON(W);if(W.status==1){D("#js-tree-menu").jstree().destroy();D("#js-tree-menu").append("<ul></ul>");D("#js-tree-menu ul").html(W.data);P();O=W.terms;F()}D(".form-loader-count").css("width","0");S()}})})});D(document).ready(function(){D(document).on("keyup","#folder-search",function(){C()});D(document).on("change","#folder-search",function(){C()});D(document).on("blur","#folder-search",function(){C()})});function C(){var V=D.trim(D("#folder-search").val());D("#js-tree-menu").jstree("search",V)}D(document).ready(function(){D(".wcp-move-file").livequery(function(){D(this).draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(V,W){D(this).closest("td").addClass("wcp-draggable");D("body").addClass("no-hover-css")},stop:function(V,W){D(this).closest("td").removeClass("wcp-draggable");D("body").removeClass("no-hover-css")}})});D(".wcp-move-multiple").livequery(function(){D(this).draggable({revert:"invalid",containment:"document",helper:function(V,W){D(".selected-items").remove();selectedItems=D("#the-list th input:checked").length;if(selectedItems>0){selectedItems=(selectedItems==0||selectedItems==1)?"1 Item":selectedItems+" Items";return D("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")}else{return D("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")}},start:function(V,W){D("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(V,W){D(".selected-items").remove();D("body").removeClass("no-hover-css")}})});D(document).on("click",".folders-toggle-button",function(){dbStatus="show";if(D(".tree-structure-content").hasClass("active")){D(".tree-structure-content .tree-structure").animate({height:"40px"},100,function(){D(".tree-structure-content").removeClass("active")});dbStatus="hide"}else{newHeight=parseInt(D(".tree-structure-content .tree-structure").attr("data-height"));D(".tree-structure-content .tree-structure").animate({height:newHeight},100,function(){D(".tree-structure-content").addClass("active")})}D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_hide_folders&status="+dbStatus+"&nonce="+wcp_settings.nonce,method:"post",success:function(V){L()}})})});function j(V){D.ajax({url:wcp_settings.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+wcp_settings.post_type+"&post_id="+V+"&nonce="+wcp_settings.nonce,cache:false,async:false,success:function(){}})}function z(){setTimeout(function(){currentStatus=true;if(D("#js-tree-menu .jstree-node.jstree-leaf").length==D("#js-tree-menu .jstree-node").length){D("#expand-collapse-list").removeClass("all-open");D("#expand-collapse-list").attr("data-folder-tooltip","Expand")}else{var V=D("#js-tree-menu .jstree-node.jstree-closed").length+D("#js-tree-menu .jstree-node.jstree-open").length;if(D("#js-tree-menu .jstree-node.jstree-closed").length==V){D("#expand-collapse-list").removeClass("all-open");D("#expand-collapse-list").attr("data-folder-tooltip","Expand")}else{D("#expand-collapse-list").addClass("all-open");D("#expand-collapse-list").attr("data-folder-tooltip","Collapse")}}},500)}function a(){if(D(".tree-structure-content .tree-structure li").length==0){D(".tree-structure-content").hide()}else{D(".tree-structure-content").show();oldHeight=D(".tree-structure-content .tree-structure").height();D(".tree-structure-content .tree-structure").height("auto");if(D(".tree-structure-content .tree-structure").height()>56){D(".folders-toggle-button").show()}else{D(".folders-toggle-button").hide()}newHeight=D(".tree-structure-content .tree-structure").height();D(".tree-structure-content .tree-structure").attr("data-height",newHeight);if(D(".tree-structure-content").hasClass("active")){D(".tree-structure-content .tree-structure").height(newHeight);D(".tree-structure-content .tree-structure").attr("data-height",newHeight)}else{D(".tree-structure-content .tree-structure").height(oldHeight)}}}function J(){D(".folder-loader-ajax").addClass("active");D(".folder-loader-ajax img").removeClass("active");D(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated");setTimeout(function(){D(".folder-loader-ajax").removeClass("active");D(".folder-loader-ajax img").addClass("active");D(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2000)}function t(){D(".sticky-folders > ul").html("");var V="";D("#js-tree-menu li.jstree-node.is-sticky").each(function(){var Y=D(this).attr("id");var Z=D.trim(D("#js-tree-menu").jstree(true).get_node(Y).text);var aa=D("li.jstree-node[id='"+Y+"'] > a span.premio-folder-count").text();var X=D("li.jstree-node[id='"+Y+"']").hasClass("is-high")?" is-high ":"";V+="<li data-folder-id='"+Y+"' class='sticky-fldr "+X+" sticky-folder-"+Y+"'><a href='javascript:;'><span class='folder-title'>"+Z+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'>"+aa+"</span></span></a></li>"});D(".sticky-folders > ul").html(V);if(D(".jstree-anchor.jstree-clicked").length){var W=D(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");D(".sticky-folders .sticky-folder-"+W+" a").addClass("active-item")}if(D(".sticky-folders > ul > li").length>0){D(".sticky-folders").addClass("active")}else{D(".sticky-folders").removeClass("active")}I()}function F(){if(D("#media-attachment-taxonomy-filter").length){D("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=O;var X=D(this);currentDDVal=D(this).val();X.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");lastFolderData=O;for(var Y=0;Y<O.length;Y++){X.append("<option value='"+O[Y].term_id+"'>"+O[Y].name+" ("+O[Y].trash_count+")</option>")}X.val(currentDDVal).trigger("change")});if(D("select.folder_for_media").length){var W=D("select.folder_for_media").val();D("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var V=0;V<O.length;V++){D("select.folder_for_media option:last-child").before("<option value='"+O[V].term_id+"'>"+O[V].name+"</option>")}if(W!=""){D(".folder_for_media").val(W)}}}D("span.premio-folder-count").text("");D(".folder-count").text("");for(V=0;V<O.length;V++){if(parseInt(O[V].trash_count)!=0){D(".jstree-node[id='"+O[V].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(O[V].trash_count);D(".sticky-folder-"+O[V].term_id+" .premio-folder-count").text(O[V].trash_count)}}if(b!=""){D("#wcp_folder_"+b).addClass("active-item")}if(o){D("#title_"+c).trigger("click");o=false}}if(wcp_settings.post_type=="attachment"){D(document).ready(function(){if(wcp_settings.show_in_page=="show"){D(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div><div class="folders-toggle-button"><span></span></div></div>')}N();a()});D(window).on("load",function(){D("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Bulk Organize</button>");D(".media-toolbar-secondary").append("<span class='media-info-message'>Drag and drop your media files to the relevant folders</span>");D(".delete-selected-button").before("<button type='button' class='button button-primary select-all-item-btn'>Select All</button>");D(".media-toolbar-secondary").after("<div class='custom-media-select'>Move Selected files to: <select class='media-select-folder'></select></div>");D(".media-toolbar").append("<div style='clear:both;'></div><div class='media-folder-loader'><span>Uploading files</span> <span id='current_upload_files'></span>/<span id='total_upload_files'></span><div class='folder-progress'><div class='folder-meter orange-bg'><span></span></div></div></div>");if(D(".wcp-custom-form").length){if(wp.Uploader!==n){wp.Uploader.queue.on("reset",function(){y(1)})}D(document).ajaxComplete(function(X,W,V){actionName=V.data;if(typeof actionName!="undefined"){if(actionName.length&&actionName.indexOf("action=delete-post&id=")==0){y(0)}}})}setTimeout(function(){docReferrar=document.referrer;if(docReferrar.indexOf("wp-admin/upload.php")!=-1){mediaMode=d("media-select-mode");if(mediaMode=="on"){D("button.button.media-button.select-mode-toggle-button").trigger("click");if(D(".media-frame").hasClass("mode-select")){D(".media-info-message").addClass("active")}else{D(".media-info-message, .custom-media-select").removeClass("active")}}}else{u("media-select-mode")}y(1)},1000);D(document).on("click",".attachments-browser ul.attachments .thumbnail",function(){if(D(".media-toolbar").hasClass("media-toolbar-mode-select")){if(D("ul.attachments li.selected").length==0){D(".custom-media-select").removeClass("active")}else{D(".custom-media-select").addClass("active")}}});D(document).on("change",".media-select-folder",function(){if(D(this).val()!=""){var V="";D(".attachments-browser li.attachment.selected").each(function(){V+=D(this).attr("data-id")+","});if(D(this).val()=="-1"){D.ajax({url:wcp_settings.ajax_url,data:"post_id="+V+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+D(this).val()+"&nonce="+wcp_settings.nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(W){Q();J()}})}else{s=D.trim(D("#wcp_folder_"+D(this).val()).data("nonce"));D.ajax({url:wcp_settings.ajax_url,data:"post_ids="+V+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+D(this).val()+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+b,method:"post",success:function(W){W=D.parseJSON(W);D("#bulk-move-folder").hide();if(W.status=="1"){Q();J()}else{D(".folder-popup-form").hide();D(".folder-popup-form").removeClass("disabled");D("#error-folder-popup-message").html(W.message);D("#error-folder-popup").show()}}})}}})});var g=null;function y(V){g=D.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_get_default_list&active_id="+b,method:"post",beforeSend:function(){if(g!=null){g.abort()}},success:function(W){W=D.parseJSON(W);D(".header-posts .total-count").text(W.total_items);D(".un-categorised-items .total-count").text(W.empty_items);selectedVal=D("#media-attachment-taxonomy-filter").val();if(selectedVal!="all"&&V==1){var X=parent.wp;if(X.media!=n){X.media.frame.setState("insert");if(X.media.frame.content.get()!==null){X.media.frame.content.get().collection.props.set({ignore:(+new Date())});X.media.frame.content.get().options.selection.reset()}else{X.media.frame.library.props.set({ignore:(+new Date())})}}}O=W.taxonomies;F();if(b!=""){D("#wcp_folder_"+b).addClass("active-item")}if(o){D("#title_"+c).trigger("click");o=false}}})}function f(){D(".media-frame-content .media-toolbar").width(D(".media-frame-content").width()-20)}f();D(window).resize(function(){f()});D(document).ready(function(){});D(document).on("click",".button.organize-button",function(){if(!D(".media-frame").hasClass("mode-select")){k("media-select-mode","on",7)}else{u("media-select-mode")}D("button.button.media-button.select-mode-toggle-button").trigger("click");if(D(".media-frame").hasClass("mode-select")){D(".media-info-message").addClass("active");D(".select-all-item-btn").addClass("active")}else{D(".media-info-message, .custom-media-select").removeClass("active");D(".select-all-item-btn").removeClass("active")}});D(document).on("click",".select-mode-toggle-button",function(){setTimeout(function(){if(!D(".media-frame").hasClass("mode-select")){k("media-select-mode","off",-1)}if(D(".media-frame").hasClass("mode-select")){D(".media-info-message").addClass("active");D(".select-all-item-btn").addClass("active")}else{D(".media-info-message, .custom-media-select").removeClass("active");D(".select-all-item-btn").removeClass("active")}},10)});D(document).on("click",".select-all-item-btn",function(){D("ul.attachments li:not(.selected)").trigger("click")});D(document).on("change",".folder_for_media",function(){if(D(this).val()=="add-folder"){c=0;o=true;K()}});function k(X,Y,Z){var V="";if(Z){var W=new Date();W.setTime(W.getTime()+(Z*24*60*60*1000));V="; expires="+W.toUTCString()}document.cookie=X+"="+(Y||"")+V+"; path=/"}function d(W){var Y=W+"=";var V=document.cookie.split(";");for(var X=0;X<V.length;X++){var Z=V[X];while(Z.charAt(0)==" "){Z=Z.substring(1,Z.length)}if(Z.indexOf(Y)==0){return Z.substring(Y.length,Z.length)}}return null}function u(V){document.cookie=V+"=; Max-Age=-99999999;"}function L(){if(!D(".media-position").length){D(".media-frame-content .media-toolbar").before("<div class='media-position'></div>")}if(D(".media-position").length){f();thisPosition=D(".media-position").offset().top-D(window).scrollTop();if(thisPosition<=32){D(".media-frame-content .media-toolbar").addClass("sticky-media");D(".media-position").height(D(".media-frame-content .media-toolbar").outerHeight())}else{D(".media-frame-content .media-toolbar").removeClass("sticky-media");D(".media-position").height(1)}}}D(window).scroll(function(){L()})}else{function L(){}}}));
assets/js/jstree.js CHANGED
@@ -1,8701 +1,8701 @@
1
- /*globals jQuery, define, module, exports, require, window, document, postMessage */
2
- (function (factory) {
3
- "use strict";
4
- if (typeof define === 'function' && define.amd) {
5
- define(['jquery'], factory);
6
- }
7
- else if(typeof module !== 'undefined' && module.exports) {
8
- module.exports = factory(require('jquery'));
9
- }
10
- else {
11
- factory(jQuery);
12
- }
13
- }(function ($, undefined) {
14
- "use strict";
15
- /*!
16
- * jsTree 3.3.10
17
- * http://jstree.com/
18
- *
19
- * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
20
- *
21
- * Licensed same as jquery - under the terms of the MIT License
22
- * http://www.opensource.org/licenses/mit-license.php
23
- */
24
- /*!
25
- * if using jslint please allow for the jQuery global and use following options:
26
- * jslint: loopfunc: true, browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
27
- */
28
- /*jshint -W083 */
29
-
30
- // prevent another load? maybe there is a better way?
31
- if($.jstree) {
32
- return;
33
- }
34
-
35
- /**
36
- * ### jsTree core functionality
37
- */
38
-
39
- // internal variables
40
- var instance_counter = 0,
41
- ccp_node = false,
42
- ccp_mode = false,
43
- ccp_inst = false,
44
- themes_loaded = [],
45
- src = $('script:last').attr('src'),
46
- document = window.document; // local variable is always faster to access then a global
47
-
48
- var setImmediate = window.setImmediate;
49
- var Promise = window.Promise;
50
- if (!setImmediate && Promise) {
51
- // Good enough approximation of setImmediate
52
- setImmediate = function (cb, arg) {
53
- Promise.resolve(arg).then(cb);
54
- };
55
- }
56
-
57
- /**
58
- * holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances.
59
- * @name $.jstree
60
- */
61
- $.jstree = {
62
- /**
63
- * specifies the jstree version in use
64
- * @name $.jstree.version
65
- */
66
- version : '3.3.10',
67
- /**
68
- * holds all the default options used when creating new instances
69
- * @name $.jstree.defaults
70
- */
71
- defaults : {
72
- /**
73
- * configure which plugins will be active on an instance. Should be an array of strings, where each element is a plugin name. The default is `[]`
74
- * @name $.jstree.defaults.plugins
75
- */
76
- plugins : []
77
- },
78
- /**
79
- * stores all loaded jstree plugins (used internally)
80
- * @name $.jstree.plugins
81
- */
82
- plugins : {},
83
- path : src && src.indexOf('/') !== -1 ? src.replace(/\/[^\/]+$/,'') : '',
84
- idregex : /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,
85
- root : '#'
86
- };
87
-
88
- /**
89
- * creates a jstree instance
90
- * @name $.jstree.create(el [, options])
91
- * @param {DOMElement|jQuery|String} el the element to create the instance on, can be jQuery extended or a selector
92
- * @param {Object} options options for this instance (extends `$.jstree.defaults`)
93
- * @return {jsTree} the new instance
94
- */
95
- $.jstree.create = function (el, options) {
96
- var tmp = new $.jstree.core(++instance_counter),
97
- opt = options;
98
- options = $.extend(true, {}, $.jstree.defaults, options);
99
- if(opt && opt.plugins) {
100
- options.plugins = opt.plugins;
101
- }
102
- $.each(options.plugins, function (i, k) {
103
- if(i !== 'core') {
104
- tmp = tmp.plugin(k, options[k]);
105
- }
106
- });
107
- $(el).data('jstree', tmp);
108
- tmp.init(el, options);
109
- return tmp;
110
- };
111
- /**
112
- * remove all traces of jstree from the DOM and destroy all instances
113
- * @name $.jstree.destroy()
114
- */
115
- $.jstree.destroy = function () {
116
- $('.jstree:jstree').jstree('destroy');
117
- $(document).off('.jstree');
118
- };
119
- /**
120
- * the jstree class constructor, used only internally
121
- * @private
122
- * @name $.jstree.core(id)
123
- * @param {Number} id this instance's index
124
- */
125
- $.jstree.core = function (id) {
126
- this._id = id;
127
- this._cnt = 0;
128
- this._wrk = null;
129
- this._data = {
130
- core : {
131
- themes : {
132
- name : false,
133
- dots : false,
134
- icons : false,
135
- ellipsis : false
136
- },
137
- selected : [],
138
- last_error : {},
139
- working : false,
140
- worker_queue : [],
141
- focused : null
142
- }
143
- };
144
- };
145
- /**
146
- * get a reference to an existing instance
147
- *
148
- * __Examples__
149
- *
150
- * // provided a container with an ID of "tree", and a nested node with an ID of "branch"
151
- * // all of there will return the same instance
152
- * $.jstree.reference('tree');
153
- * $.jstree.reference('#tree');
154
- * $.jstree.reference($('#tree'));
155
- * $.jstree.reference(document.getElementByID('tree'));
156
- * $.jstree.reference('branch');
157
- * $.jstree.reference('#branch');
158
- * $.jstree.reference($('#branch'));
159
- * $.jstree.reference(document.getElementByID('branch'));
160
- *
161
- * @name $.jstree.reference(needle)
162
- * @param {DOMElement|jQuery|String} needle
163
- * @return {jsTree|null} the instance or `null` if not found
164
- */
165
- $.jstree.reference = function (needle) {
166
- var tmp = null,
167
- obj = null;
168
- if(needle && needle.id && (!needle.tagName || !needle.nodeType)) { needle = needle.id; }
169
-
170
- if(!obj || !obj.length) {
171
- try { obj = $(needle); } catch (ignore) { }
172
- }
173
- if(!obj || !obj.length) {
174
- try { obj = $('#' + needle.replace($.jstree.idregex,'\\$&')); } catch (ignore) { }
175
- }
176
- if(obj && obj.length && (obj = obj.closest('.jstree')).length && (obj = obj.data('jstree'))) {
177
- tmp = obj;
178
- }
179
- else {
180
- $('.jstree').each(function () {
181
- var inst = $(this).data('jstree');
182
- if(inst && inst._model.data[needle]) {
183
- tmp = inst;
184
- return false;
185
- }
186
- });
187
- }
188
- return tmp;
189
- };
190
- /**
191
- * Create an instance, get an instance or invoke a command on a instance.
192
- *
193
- * If there is no instance associated with the current node a new one is created and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken).
194
- *
195
- * If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function).
196
- *
197
- * If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`).
198
- *
199
- * In any other case - nothing is returned and chaining is not broken.
200
- *
201
- * __Examples__
202
- *
203
- * $('#tree1').jstree(); // creates an instance
204
- * $('#tree2').jstree({ plugins : [] }); // create an instance with some options
205
- * $('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments
206
- * $('#tree2').jstree(); // get an existing instance (or create an instance)
207
- * $('#tree2').jstree(true); // get an existing instance (will not create new instance)
208
- * $('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method)
209
- *
210
- * @name $().jstree([arg])
211
- * @param {String|Object} arg
212
- * @return {Mixed}
213
- */
214
- $.fn.jstree = function (arg) {
215
- // check for string argument
216
- var is_method = (typeof arg === 'string'),
217
- args = Array.prototype.slice.call(arguments, 1),
218
- result = null;
219
- if(arg === true && !this.length) { return false; }
220
- this.each(function () {
221
- // get the instance (if there is one) and method (if it exists)
222
- var instance = $.jstree.reference(this),
223
- method = is_method && instance ? instance[arg] : null;
224
- // if calling a method, and method is available - execute on the instance
225
- result = is_method && method ?
226
- method.apply(instance, args) :
227
- null;
228
- // if there is no instance and no method is being called - create one
229
- if(!instance && !is_method && (arg === undefined || $.isPlainObject(arg))) {
230
- $.jstree.create(this, arg);
231
- }
232
- // if there is an instance and no method is called - return the instance
233
- if( (instance && !is_method) || arg === true ) {
234
- result = instance || false;
235
- }
236
- // if there was a method call which returned a result - break and return the value
237
- if(result !== null && result !== undefined) {
238
- return false;
239
- }
240
- });
241
- // if there was a method call with a valid return value - return that, otherwise continue the chain
242
- return result !== null && result !== undefined ?
243
- result : this;
244
- };
245
- /**
246
- * used to find elements containing an instance
247
- *
248
- * __Examples__
249
- *
250
- * $('div:jstree').each(function () {
251
- * $(this).jstree('destroy');
252
- * });
253
- *
254
- * @name $(':jstree')
255
- * @return {jQuery}
256
- */
257
- $.expr.pseudos.jstree = $.expr.createPseudo(function(search) {
258
- return function(a) {
259
- return $(a).hasClass('jstree') &&
260
- $(a).data('jstree') !== undefined;
261
- };
262
- });
263
-
264
- /**
265
- * stores all defaults for the core
266
- * @name $.jstree.defaults.core
267
- */
268
- $.jstree.defaults.core = {
269
- /**
270
- * data configuration
271
- *
272
- * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items).
273
- *
274
- * You can also pass in a HTML string or a JSON array here.
275
- *
276
- * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree.
277
- * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used.
278
- *
279
- * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result.
280
- *
281
- * __Examples__
282
- *
283
- * // AJAX
284
- * $('#tree').jstree({
285
- * 'core' : {
286
- * 'data' : {
287
- * 'url' : '/get/children/',
288
- * 'data' : function (node) {
289
- * return { 'id' : node.id };
290
- * }
291
- * }
292
- * });
293
- *
294
- * // direct data
295
- * $('#tree').jstree({
296
- * 'core' : {
297
- * 'data' : [
298
- * 'Simple root node',
299
- * {
300
- * 'id' : 'node_2',
301
- * 'text' : 'Root node with options',
302
- * 'state' : { 'opened' : true, 'selected' : true },
303
- * 'children' : [ { 'text' : 'Child 1' }, 'Child 2']
304
- * }
305
- * ]
306
- * }
307
- * });
308
- *
309
- * // function
310
- * $('#tree').jstree({
311
- * 'core' : {
312
- * 'data' : function (obj, callback) {
313
- * callback.call(this, ['Root 1', 'Root 2']);
314
- * }
315
- * });
316
- *
317
- * @name $.jstree.defaults.core.data
318
- */
319
- data : false,
320
- /**
321
- * configure the various strings used throughout the tree
322
- *
323
- * You can use an object where the key is the string you need to replace and the value is your replacement.
324
- * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement.
325
- * If left as `false` no replacement is made.
326
- *
327
- * __Examples__
328
- *
329
- * $('#tree').jstree({
330
- * 'core' : {
331
- * 'strings' : {
332
- * 'Loading ...' : 'Please wait ...'
333
- * }
334
- * }
335
- * });
336
- *
337
- * @name $.jstree.defaults.core.strings
338
- */
339
- strings : false,
340
- /**
341
- * determines what happens when a user tries to modify the structure of the tree
342
- * If left as `false` all operations like create, rename, delete, move or copy are prevented.
343
- * You can set this to `true` to allow all interactions or use a function to have better control.
344
- *
345
- * __Examples__
346
- *
347
- * $('#tree').jstree({
348
- * 'core' : {
349
- * 'check_callback' : function (operation, node, node_parent, node_position, more) {
350
- * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit'
351
- * // in case of 'rename_node' node_position is filled with the new node name
352
- * return operation === 'rename_node' ? true : false;
353
- * }
354
- * }
355
- * });
356
- *
357
- * @name $.jstree.defaults.core.check_callback
358
- */
359
- check_callback : false,
360
- /**
361
- * a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc)
362
- * @name $.jstree.defaults.core.error
363
- */
364
- error : $.noop,
365
- /**
366
- * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`)
367
- * @name $.jstree.defaults.core.animation
368
- */
369
- animation : 200,
370
- /**
371
- * a boolean indicating if multiple nodes can be selected
372
- * @name $.jstree.defaults.core.multiple
373
- */
374
- multiple : true,
375
- /**
376
- * theme configuration object
377
- * @name $.jstree.defaults.core.themes
378
- */
379
- themes : {
380
- /**
381
- * the name of the theme to use (if left as `false` the default theme is used)
382
- * @name $.jstree.defaults.core.themes.name
383
- */
384
- name : false,
385
- /**
386
- * the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme.
387
- * @name $.jstree.defaults.core.themes.url
388
- */
389
- url : false,
390
- /**
391
- * the location of all jstree themes - only used if `url` is set to `true`
392
- * @name $.jstree.defaults.core.themes.dir
393
- */
394
- dir : false,
395
- /**
396
- * a boolean indicating if connecting dots are shown
397
- * @name $.jstree.defaults.core.themes.dots
398
- */
399
- dots : true,
400
- /**
401
- * a boolean indicating if node icons are shown
402
- * @name $.jstree.defaults.core.themes.icons
403
- */
404
- icons : true,
405
- /**
406
- * a boolean indicating if node ellipsis should be shown - this only works with a fixed with on the container
407
- * @name $.jstree.defaults.core.themes.ellipsis
408
- */
409
- ellipsis : false,
410
- /**
411
- * a boolean indicating if the tree background is striped
412
- * @name $.jstree.defaults.core.themes.stripes
413
- */
414
- stripes : false,
415
- /**
416
- * a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants)
417
- * @name $.jstree.defaults.core.themes.variant
418
- */
419
- variant : false,
420
- /**
421
- * a boolean specifying if a reponsive version of the theme should kick in on smaller screens (if the theme supports it). Defaults to `false`.
422
- * @name $.jstree.defaults.core.themes.responsive
423
- */
424
- responsive : false
425
- },
426
- /**
427
- * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user)
428
- * @name $.jstree.defaults.core.expand_selected_onload
429
- */
430
- expand_selected_onload : true,
431
- /**
432
- * if left as `true` web workers will be used to parse incoming JSON data where possible, so that the UI will not be blocked by large requests. Workers are however about 30% slower. Defaults to `true`
433
- * @name $.jstree.defaults.core.worker
434
- */
435
- worker : true,
436
- /**
437
- * Force node text to plain text (and escape HTML). Defaults to `false`
438
- * @name $.jstree.defaults.core.force_text
439
- */
440
- force_text : false,
441
- /**
442
- * Should the node be toggled if the text is double clicked. Defaults to `true`
443
- * @name $.jstree.defaults.core.dblclick_toggle
444
- */
445
- dblclick_toggle : true,
446
- /**
447
- * Should the loaded nodes be part of the state. Defaults to `false`
448
- * @name $.jstree.defaults.core.loaded_state
449
- */
450
- loaded_state : false,
451
- /**
452
- * Should the last active node be focused when the tree container is blurred and the focused again. This helps working with screen readers. Defaults to `true`
453
- * @name $.jstree.defaults.core.restore_focus
454
- */
455
- restore_focus : true,
456
- /**
457
- * Default keyboard shortcuts (an object where each key is the button name or combo - like 'enter', 'ctrl-space', 'p', etc and the value is the function to execute in the instance's scope)
458
- * @name $.jstree.defaults.core.keyboard
459
- */
460
- keyboard : {
461
- 'ctrl-space': function (e) {
462
- // aria defines space only with Ctrl
463
- e.type = "click";
464
- $(e.currentTarget).trigger(e);
465
- },
466
- 'enter': function (e) {
467
- // enter
468
- e.type = "click";
469
- $(e.currentTarget).trigger(e);
470
- },
471
- 'left': function (e) {
472
- // left
473
- e.preventDefault();
474
- if(this.is_open(e.currentTarget)) {
475
- this.close_node(e.currentTarget);
476
- }
477
- else {
478
- var o = this.get_parent(e.currentTarget);
479
- if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); }
480
- }
481
- },
482
- 'up': function (e) {
483
- // up
484
- e.preventDefault();
485
- var o = this.get_prev_dom(e.currentTarget);
486
- if(o && o.length) { o.children('.jstree-anchor').focus(); }
487
- },
488
- 'right': function (e) {
489
- // right
490
- e.preventDefault();
491
- if(this.is_closed(e.currentTarget)) {
492
- this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); });
493
- }
494
- else if (this.is_open(e.currentTarget)) {
495
- var o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
496
- if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); }
497
- }
498
- },
499
- 'down': function (e) {
500
- // down
501
- e.preventDefault();
502
- var o = this.get_next_dom(e.currentTarget);
503
- if(o && o.length) { o.children('.jstree-anchor').focus(); }
504
- },
505
- '*': function (e) {
506
- // aria defines * on numpad as open_all - not very common
507
- this.open_all();
508
- },
509
- 'home': function (e) {
510
- // home
511
- e.preventDefault();
512
- var o = this._firstChild(this.get_container_ul()[0]);
513
- if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); }
514
- },
515
- 'end': function (e) {
516
- // end
517
- e.preventDefault();
518
- this.element.find('.jstree-anchor').filter(':visible').last().focus();
519
- },
520
- 'f2': function (e) {
521
- // f2 - safe to include - if check_callback is false it will fail
522
- e.preventDefault();
523
- this.edit(e.currentTarget);
524
- }
525
- }
526
- };
527
- $.jstree.core.prototype = {
528
- /**
529
- * used to decorate an instance with a plugin. Used internally.
530
- * @private
531
- * @name plugin(deco [, opts])
532
- * @param {String} deco the plugin to decorate with
533
- * @param {Object} opts options for the plugin
534
- * @return {jsTree}
535
- */
536
- plugin : function (deco, opts) {
537
- var Child = $.jstree.plugins[deco];
538
- if(Child) {
539
- this._data[deco] = {};
540
- Child.prototype = this;
541
- return new Child(opts, this);
542
- }
543
- return this;
544
- },
545
- /**
546
- * initialize the instance. Used internally.
547
- * @private
548
- * @name init(el, optons)
549
- * @param {DOMElement|jQuery|String} el the element we are transforming
550
- * @param {Object} options options for this instance
551
- * @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree
552
- */
553
- init : function (el, options) {
554
- this._model = {
555
- data : {},
556
- changed : [],
557
- force_full_redraw : false,
558
- redraw_timeout : false,
559
- default_state : {
560
- loaded : true,
561
- opened : false,
562
- selected : false,
563
- disabled : false
564
- }
565
- };
566
- this._model.data[$.jstree.root] = {
567
- id : $.jstree.root,
568
- parent : null,
569
- parents : [],
570
- children : [],
571
- children_d : [],
572
- state : { loaded : false }
573
- };
574
-
575
- this.element = $(el).addClass('jstree jstree-' + this._id);
576
- this.settings = options;
577
-
578
- this._data.core.ready = false;
579
- this._data.core.loaded = false;
580
- this._data.core.rtl = (this.element.css("direction") === "rtl");
581
- this.element[this._data.core.rtl ? 'addClass' : 'removeClass']("jstree-rtl");
582
- this.element.attr('role','tree');
583
- if(this.settings.core.multiple) {
584
- this.element.attr('aria-multiselectable', true);
585
- }
586
- if(!this.element.attr('tabindex')) {
587
- this.element.attr('tabindex','0');
588
- }
589
-
590
- this.bind();
591
- /**
592
- * triggered after all events are bound
593
- * @event
594
- * @name init.jstree
595
- */
596
- this.trigger("init");
597
-
598
- this._data.core.original_container_html = this.element.find(" > ul > li").clone(true);
599
- this._data.core.original_container_html
600
- .find("li").addBack()
601
- .contents().filter(function() {
602
- return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue));
603
- })
604
- .remove();
605
- this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='presentation'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden pfolder-folder-close'></i>" + this.get_string("Loading ...") + "</a></li></ul>");
606
- this.element.attr('aria-activedescendant','j' + this._id + '_loading');
607
- this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24;
608
- this._data.core.node = this._create_prototype_node();
609
- /**
610
- * triggered after the loading text is shown and before loading starts
611
- * @event
612
- * @name loading.jstree
613
- */
614
- this.trigger("loading");
615
- this.load_node($.jstree.root);
616
- },
617
- /**
618
- * destroy an instance
619
- * @name destroy()
620
- * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact
621
- */
622
- destroy : function (keep_html) {
623
- /**
624
- * triggered before the tree is destroyed
625
- * @event
626
- * @name destroy.jstree
627
- */
628
- this.trigger("destroy");
629
- if(this._wrk) {
630
- try {
631
- window.URL.revokeObjectURL(this._wrk);
632
- this._wrk = null;
633
- }
634
- catch (ignore) { }
635
- }
636
- if(!keep_html) { this.element.empty(); }
637
- this.teardown();
638
- },
639
- /**
640
- * Create a prototype node
641
- * @name _create_prototype_node()
642
- * @return {DOMElement}
643
- */
644
- _create_prototype_node : function () {
645
- var _node = document.createElement('LI'), _temp1, _temp2;
646
- _node.setAttribute('role', 'presentation');
647
- _temp1 = document.createElement('I');
648
- _temp1.className = 'jstree-icon jstree-ocl';
649
- _temp1.setAttribute('role', 'presentation');
650
- _node.appendChild(_temp1);
651
- _temp1 = document.createElement('A');
652
- _temp1.className = 'jstree-anchor';
653
- _temp1.setAttribute('href','#');
654
- _temp1.setAttribute('tabindex','-1');
655
- _temp1.setAttribute('role', 'treeitem');
656
- _temp2 = document.createElement('I');
657
- _temp2.className = 'pfolder-folder-close';
658
- _temp2.setAttribute('role', 'presentation');
659
- _temp1.appendChild(_temp2);
660
-
661
- var _tempSpan = document.createElement('span');
662
- _tempSpan.className = 'folder-checkbox';
663
- _temp1.appendChild(_tempSpan);
664
-
665
- var _inputCheck = document.createElement('input');
666
- _inputCheck.setAttribute('type', 'checkbox');
667
- _inputCheck.setAttribute('class', 'checkbox');
668
- _tempSpan.appendChild(_inputCheck);
669
-
670
- var _temp3 = document.createElement('span');
671
- _temp3.className = 'folder-actions';
672
- _temp1.appendChild(_temp3);
673
-
674
- /* for inline edit */
675
- var _temp4 = document.createElement('span');
676
- _temp4.className = 'folder-inline-edit';
677
- _temp3.appendChild(_temp4);
678
-
679
- var _temp5 = document.createElement('i');
680
- _temp5.className = 'pfolder-edit-folder';
681
- _temp4.appendChild(_temp5);
682
-
683
- /* for star */
684
- var _temp6 = document.createElement('span');
685
- _temp6.className = 'star-icon';
686
- _temp3.appendChild(_temp6);
687
-
688
- var _temp7 = document.createElement('i');
689
- _temp7.className = 'pfolder-star';
690
- _temp6.appendChild(_temp7);
691
-
692
- /* for star */
693
- var _temp8 = document.createElement('span');
694
- _temp8.className = 'sticky-icon';
695
- _temp3.appendChild(_temp8);
696
-
697
- var _temp9 = document.createElement('i');
698
- _temp9.className = 'pfolder-pin';
699
- _temp8.appendChild(_temp9);
700
-
701
- /* for star */
702
- var _temp10 = document.createElement('span');
703
- _temp10.className = 'premio-folder-count';
704
- _temp3.appendChild(_temp10);
705
-
706
- _node.appendChild(_temp1);
707
- _temp1 = _temp2 = null;
708
-
709
- return _node;
710
- },
711
- _kbevent_to_func : function (e) {
712
- var keys = {
713
- 8: "Backspace", 9: "Tab", 13: "Enter", 19: "Pause", 27: "Esc",
714
- 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home",
715
- 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "Print", 45: "Insert",
716
- 46: "Delete", 96: "Numpad0", 97: "Numpad1", 98: "Numpad2", 99 : "Numpad3",
717
- 100: "Numpad4", 101: "Numpad5", 102: "Numpad6", 103: "Numpad7",
718
- 104: "Numpad8", 105: "Numpad9", '-13': "NumpadEnter", 112: "F1",
719
- 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7",
720
- 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "Numlock",
721
- 145: "Scrolllock", 16: 'Shift', 17: 'Ctrl', 18: 'Alt',
722
- 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
723
- 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
724
- 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
725
- 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
726
- 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
727
- 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
728
- 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
729
- 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*', 173: '-'
730
- };
731
- var parts = [];
732
- if (e.ctrlKey) { parts.push('ctrl'); }
733
- if (e.altKey) { parts.push('alt'); }
734
- if (e.shiftKey) { parts.push('shift'); }
735
- parts.push(keys[e.which] || e.which);
736
- parts = parts.sort().join('-').toLowerCase();
737
- if (parts === 'shift-shift' || parts === 'ctrl-ctrl' || parts === 'alt-alt') {
738
- return null;
739
- }
740
-
741
- var kb = this.settings.core.keyboard, i, tmp;
742
- for (i in kb) {
743
- if (kb.hasOwnProperty(i)) {
744
- tmp = i;
745
- if (tmp !== '-' && tmp !== '+') {
746
- tmp = tmp.replace('--', '-MINUS').replace('+-', '-MINUS').replace('++', '-PLUS').replace('-+', '-PLUS');
747
- tmp = tmp.split(/-|\+/).sort().join('-').replace('MINUS', '-').replace('PLUS', '+').toLowerCase();
748
- }
749
- if (tmp === parts) {
750
- return kb[i];
751
- }
752
- }
753
- }
754
- return null;
755
- },
756
- /**
757
- * part of the destroying of an instance. Used internally.
758
- * @private
759
- * @name teardown()
760
- */
761
- teardown : function () {
762
- this.unbind();
763
- this.element
764
- .removeClass('jstree')
765
- .removeData('jstree')
766
- .find("[class^='jstree']")
767
- .addBack()
768
- .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
769
- this.element = null;
770
- },
771
- /**
772
- * bind all events. Used internally.
773
- * @private
774
- * @name bind()
775
- */
776
- bind : function () {
777
- var word = '',
778
- tout = null,
779
- was_click = 0;
780
- this.element
781
- .on("dblclick.jstree", function (e) {
782
- if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
783
- if(document.selection && document.selection.empty) {
784
- document.selection.empty();
785
- }
786
- else {
787
- if(window.getSelection) {
788
- var sel = window.getSelection();
789
- try {
790
- sel.removeAllRanges();
791
- sel.collapse();
792
- } catch (ignore) { }
793
- }
794
- }
795
- })
796
- .on("mousedown.jstree", $.proxy(function (e) {
797
- if(e.target === this.element[0]) {
798
- e.preventDefault(); // prevent losing focus when clicking scroll arrows (FF, Chrome)
799
- was_click = +(new Date()); // ie does not allow to prevent losing focus
800
- }
801
- }, this))
802
- .on("mousedown.jstree", ".jstree-ocl", function (e) {
803
- e.preventDefault(); // prevent any node inside from losing focus when clicking the open/close icon
804
- })
805
- .on("click.jstree", ".jstree-ocl", $.proxy(function (e) {
806
- this.toggle_node(e.target);
807
- }, this))
808
- .on("dblclick.jstree", ".jstree-anchor", $.proxy(function (e) {
809
- if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
810
- if(this.settings.core.dblclick_toggle) {
811
- this.toggle_node(e.target);
812
- }
813
- }, this))
814
- .on("click.jstree", ".jstree-anchor", $.proxy(function (e) {
815
- if(e.target.className != 'pfolder-edit-folder' && e.target.className != 'checkbox') {
816
- e.preventDefault();
817
- if(e.currentTarget !== document.activeElement) { $(e.currentTarget).focus(); }
818
- this.activate_node(e.currentTarget, e);
819
- }
820
- }, this))
821
- .on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) {
822
- if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
823
- if(this._data.core.rtl) {
824
- if(e.which === 37) { e.which = 39; }
825
- else if(e.which === 39) { e.which = 37; }
826
- }
827
- var f = this._kbevent_to_func(e);
828
- if (f) {
829
- var r = f.call(this, e);
830
- if (r === false || r === true) {
831
- return r;
832
- }
833
- }
834
- }, this))
835
- .on("load_node.jstree", $.proxy(function (e, data) {
836
- if(data.status) {
837
- if(data.node.id === $.jstree.root && !this._data.core.loaded) {
838
- this._data.core.loaded = true;
839
- if(this._firstChild(this.get_container_ul()[0])) {
840
- this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id);
841
- }
842
- /**
843
- * triggered after the root node is loaded for the first time
844
- * @event
845
- * @name loaded.jstree
846
- */
847
- this.trigger("loaded");
848
- }
849
- if(!this._data.core.ready) {
850
- setTimeout($.proxy(function() {
851
- if(this.element && !this.get_container_ul().find('.jstree-loading').length) {
852
- this._data.core.ready = true;
853
- if(this._data.core.selected.length) {
854
- if(this.settings.core.expand_selected_onload) {
855
- var tmp = [], i, j;
856
- for(i = 0, j = this._data.core.selected.length; i < j; i++) {
857
- tmp = tmp.concat(this._model.data[this._data.core.selected[i]].parents);
858
- }
859
- tmp = $.vakata.array_unique(tmp);
860
- for(i = 0, j = tmp.length; i < j; i++) {
861
- this.open_node(tmp[i], false, 0);
862
- }
863
- }
864
- this.trigger('changed', { 'action' : 'ready', 'selected' : this._data.core.selected });
865
- }
866
- /**
867
- * triggered after all nodes are finished loading
868
- * @event
869
- * @name ready.jstree
870
- */
871
- this.trigger("ready");
872
- }
873
- }, this), 0);
874
- }
875
- }
876
- }, this))
877
- // quick searching when the tree is focused
878
- .on('keypress.jstree', $.proxy(function (e) {
879
- if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
880
- if(tout) { clearTimeout(tout); }
881
- tout = setTimeout(function () {
882
- word = '';
883
- }, 500);
884
-
885
- var chr = String.fromCharCode(e.which).toLowerCase(),
886
- col = this.element.find('.jstree-anchor').filter(':visible'),
887
- ind = col.index(document.activeElement) || 0,
888
- end = false;
889
- word += chr;
890
-
891
- // match for whole word from current node down (including the current node)
892
- if(word.length > 1) {
893
- col.slice(ind).each($.proxy(function (i, v) {
894
- if($(v).text().toLowerCase().indexOf(word) === 0) {
895
- $(v).focus();
896
- end = true;
897
- return false;
898
- }
899
- }, this));
900
- if(end) { return; }
901
-
902
- // match for whole word from the beginning of the tree
903
- col.slice(0, ind).each($.proxy(function (i, v) {
904
- if($(v).text().toLowerCase().indexOf(word) === 0) {
905
- $(v).focus();
906
- end = true;
907
- return false;
908
- }
909
- }, this));
910
- if(end) { return; }
911
- }
912
- // list nodes that start with that letter (only if word consists of a single char)
913
- if(new RegExp('^' + chr.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '+$').test(word)) {
914
- // search for the next node starting with that letter
915
- col.slice(ind + 1).each($.proxy(function (i, v) {
916
- if($(v).text().toLowerCase().charAt(0) === chr) {
917
- $(v).focus();
918
- end = true;
919
- return false;
920
- }
921
- }, this));
922
- if(end) { return; }
923
-
924
- // search from the beginning
925
- col.slice(0, ind + 1).each($.proxy(function (i, v) {
926
- if($(v).text().toLowerCase().charAt(0) === chr) {
927
- $(v).focus();
928
- end = true;
929
- return false;
930
- }
931
- }, this));
932
- if(end) { return; }
933
- }
934
- }, this))
935
- // THEME RELATED
936
- .on("init.jstree", $.proxy(function () {
937
- var s = this.settings.core.themes;
938
- this._data.core.themes.dots = s.dots;
939
- this._data.core.themes.stripes = s.stripes;
940
- this._data.core.themes.icons = s.icons;
941
- this._data.core.themes.ellipsis = s.ellipsis;
942
- this.set_theme(s.name || "default", s.url);
943
- this.set_theme_variant(s.variant);
944
- }, this))
945
- .on("loading.jstree", $.proxy(function () {
946
- this[ this._data.core.themes.dots ? "show_dots" : "hide_dots" ]();
947
- this[ this._data.core.themes.icons ? "show_icons" : "hide_icons" ]();
948
- this[ this._data.core.themes.stripes ? "show_stripes" : "hide_stripes" ]();
949
- this[ this._data.core.themes.ellipsis ? "show_ellipsis" : "hide_ellipsis" ]();
950
- }, this))
951
- .on('blur.jstree', '.jstree-anchor', $.proxy(function (e) {
952
- this._data.core.focused = null;
953
- $(e.currentTarget).filter('.jstree-hovered').trigger('mouseleave');
954
- this.element.attr('tabindex', '0');
955
- }, this))
956
- .on('focus.jstree', '.jstree-anchor', $.proxy(function (e) {
957
- var tmp = this.get_node(e.currentTarget);
958
- if(tmp && tmp.id) {
959
- this._data.core.focused = tmp.id;
960
- }
961
- this.element.find('.jstree-hovered').not(e.currentTarget).trigger('mouseleave');
962
- $(e.currentTarget).trigger('mouseenter');
963
- this.element.attr('tabindex', '-1');
964
- }, this))
965
- .on('focus.jstree', $.proxy(function () {
966
- if(+(new Date()) - was_click > 500 && !this._data.core.focused && this.settings.core.restore_focus) {
967
- was_click = 0;
968
- var act = this.get_node(this.element.attr('aria-activedescendant'), true);
969
- if(act) {
970
- act.find('> .jstree-anchor').focus();
971
- }
972
- }
973
- }, this))
974
- .on('mouseenter.jstree', '.jstree-anchor', $.proxy(function (e) {
975
- this.hover_node(e.currentTarget);
976
- }, this))
977
- .on('mouseleave.jstree', '.jstree-anchor', $.proxy(function (e) {
978
- this.dehover_node(e.currentTarget);
979
- }, this));
980
- },
981
- /**
982
- * part of the destroying of an instance. Used internally.
983
- * @private
984
- * @name unbind()
985
- */
986
- unbind : function () {
987
- this.element.off('.jstree');
988
- $(document).off('.jstree-' + this._id);
989
- },
990
- /**
991
- * trigger an event. Used internally.
992
- * @private
993
- * @name trigger(ev [, data])
994
- * @param {String} ev the name of the event to trigger
995
- * @param {Object} data additional data to pass with the event
996
- */
997
- trigger : function (ev, data) {
998
- if(!data) {
999
- data = {};
1000
- }
1001
- data.instance = this;
1002
- this.element.triggerHandler(ev.replace('.jstree','') + '.jstree', data);
1003
- },
1004
- /**
1005
- * returns the jQuery extended instance container
1006
- * @name get_container()
1007
- * @return {jQuery}
1008
- */
1009
- get_container : function () {
1010
- return this.element;
1011
- },
1012
- /**
1013
- * returns the jQuery extended main UL node inside the instance container. Used internally.
1014
- * @private
1015
- * @name get_container_ul()
1016
- * @return {jQuery}
1017
- */
1018
- get_container_ul : function () {
1019
- return this.element.children(".jstree-children").first();
1020
- },
1021
- /**
1022
- * gets string replacements (localization). Used internally.
1023
- * @private
1024
- * @name get_string(key)
1025
- * @param {String} key
1026
- * @return {String}
1027
- */
1028
- get_string : function (key) {
1029
- var a = this.settings.core.strings;
1030
- if($.isFunction(a)) { return a.call(this, key); }
1031
- if(a && a[key]) { return a[key]; }
1032
- return key;
1033
- },
1034
- /**
1035
- * gets the first child of a DOM node. Used internally.
1036
- * @private
1037
- * @name _firstChild(dom)
1038
- * @param {DOMElement} dom
1039
- * @return {DOMElement}
1040
- */
1041
- _firstChild : function (dom) {
1042
- dom = dom ? dom.firstChild : null;
1043
- while(dom !== null && dom.nodeType !== 1) {
1044
- dom = dom.nextSibling;
1045
- }
1046
- return dom;
1047
- },
1048
- /**
1049
- * gets the next sibling of a DOM node. Used internally.
1050
- * @private
1051
- * @name _nextSibling(dom)
1052
- * @param {DOMElement} dom
1053
- * @return {DOMElement}
1054
- */
1055
- _nextSibling : function (dom) {
1056
- dom = dom ? dom.nextSibling : null;
1057
- while(dom !== null && dom.nodeType !== 1) {
1058
- dom = dom.nextSibling;
1059
- }
1060
- return dom;
1061
- },
1062
- /**
1063
- * gets the previous sibling of a DOM node. Used internally.
1064
- * @private
1065
- * @name _previousSibling(dom)
1066
- * @param {DOMElement} dom
1067
- * @return {DOMElement}
1068
- */
1069
- _previousSibling : function (dom) {
1070
- dom = dom ? dom.previousSibling : null;
1071
- while(dom !== null && dom.nodeType !== 1) {
1072
- dom = dom.previousSibling;
1073
- }
1074
- return dom;
1075
- },
1076
- /**
1077
- * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc)
1078
- * @name get_node(obj [, as_dom])
1079
- * @param {mixed} obj
1080
- * @param {Boolean} as_dom
1081
- * @return {Object|jQuery}
1082
- */
1083
- get_node : function (obj, as_dom) {
1084
- if(obj && obj.id) {
1085
- obj = obj.id;
1086
- }
1087
- if (obj instanceof $ && obj.length && obj[0].id) {
1088
- obj = obj[0].id;
1089
- }
1090
- var dom;
1091
- try {
1092
- if(this._model.data[obj]) {
1093
- obj = this._model.data[obj];
1094
- }
1095
- else if(typeof obj === "string" && this._model.data[obj.replace(/^#/, '')]) {
1096
- obj = this._model.data[obj.replace(/^#/, '')];
1097
- }
1098
- else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
1099
- obj = this._model.data[dom.closest('.jstree-node').attr('id')];
1100
- }
1101
- else if((dom = this.element.find(obj)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
1102
- obj = this._model.data[dom.closest('.jstree-node').attr('id')];
1103
- }
1104
- else if((dom = this.element.find(obj)).length && dom.hasClass('jstree')) {
1105
- obj = this._model.data[$.jstree.root];
1106
- }
1107
- else {
1108
- return false;
1109
- }
1110
-
1111
- if(as_dom) {
1112
- obj = obj.id === $.jstree.root ? this.element : $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element);
1113
- }
1114
- return obj;
1115
- } catch (ex) { return false; }
1116
- },
1117
- /**
1118
- * get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array)
1119
- * @name get_path(obj [, glue, ids])
1120
- * @param {mixed} obj the node
1121
- * @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned
1122
- * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used
1123
- * @return {mixed}
1124
- */
1125
- get_path : function (obj, glue, ids) {
1126
- obj = obj.parents ? obj : this.get_node(obj);
1127
- if(!obj || obj.id === $.jstree.root || !obj.parents) {
1128
- return false;
1129
- }
1130
- var i, j, p = [];
1131
- p.push(ids ? obj.id : obj.text);
1132
- for(i = 0, j = obj.parents.length; i < j; i++) {
1133
- p.push(ids ? obj.parents[i] : this.get_text(obj.parents[i]));
1134
- }
1135
- p = p.reverse().slice(1);
1136
- return glue ? p.join(glue) : p;
1137
- },
1138
- /**
1139
- * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
1140
- * @name get_next_dom(obj [, strict])
1141
- * @param {mixed} obj
1142
- * @param {Boolean} strict
1143
- * @return {jQuery}
1144
- */
1145
- get_next_dom : function (obj, strict) {
1146
- var tmp;
1147
- obj = this.get_node(obj, true);
1148
- if(obj[0] === this.element[0]) {
1149
- tmp = this._firstChild(this.get_container_ul()[0]);
1150
- while (tmp && tmp.offsetHeight === 0) {
1151
- tmp = this._nextSibling(tmp);
1152
- }
1153
- return tmp ? $(tmp) : false;
1154
- }
1155
- if(!obj || !obj.length) {
1156
- return false;
1157
- }
1158
- if(strict) {
1159
- tmp = obj[0];
1160
- do {
1161
- tmp = this._nextSibling(tmp);
1162
- } while (tmp && tmp.offsetHeight === 0);
1163
- return tmp ? $(tmp) : false;
1164
- }
1165
- if(obj.hasClass("jstree-open")) {
1166
- tmp = this._firstChild(obj.children('.jstree-children')[0]);
1167
- while (tmp && tmp.offsetHeight === 0) {
1168
- tmp = this._nextSibling(tmp);
1169
- }
1170
- if(tmp !== null) {
1171
- return $(tmp);
1172
- }
1173
- }
1174
- tmp = obj[0];
1175
- do {
1176
- tmp = this._nextSibling(tmp);
1177
- } while (tmp && tmp.offsetHeight === 0);
1178
- if(tmp !== null) {
1179
- return $(tmp);
1180
- }
1181
- return obj.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first();
1182
- },
1183
- /**
1184
- * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
1185
- * @name get_prev_dom(obj [, strict])
1186
- * @param {mixed} obj
1187
- * @param {Boolean} strict
1188
- * @return {jQuery}
1189
- */
1190
- get_prev_dom : function (obj, strict) {
1191
- var tmp;
1192
- obj = this.get_node(obj, true);
1193
- if(obj[0] === this.element[0]) {
1194
- tmp = this.get_container_ul()[0].lastChild;
1195
- while (tmp && tmp.offsetHeight === 0) {
1196
- tmp = this._previousSibling(tmp);
1197
- }
1198
- return tmp ? $(tmp) : false;
1199
- }
1200
- if(!obj || !obj.length) {
1201
- return false;
1202
- }
1203
- if(strict) {
1204
- tmp = obj[0];
1205
- do {
1206
- tmp = this._previousSibling(tmp);
1207
- } while (tmp && tmp.offsetHeight === 0);
1208
- return tmp ? $(tmp) : false;
1209
- }
1210
- tmp = obj[0];
1211
- do {
1212
- tmp = this._previousSibling(tmp);
1213
- } while (tmp && tmp.offsetHeight === 0);
1214
- if(tmp !== null) {
1215
- obj = $(tmp);
1216
- while(obj.hasClass("jstree-open")) {
1217
- obj = obj.children(".jstree-children").first().children(".jstree-node:visible:last");
1218
- }
1219
- return obj;
1220
- }
1221
- tmp = obj[0].parentNode.parentNode;
1222
- return tmp && tmp.className && tmp.className.indexOf('jstree-node') !== -1 ? $(tmp) : false;
1223
- },
1224
- /**
1225
- * get the parent ID of a node
1226
- * @name get_parent(obj)
1227
- * @param {mixed} obj
1228
- * @return {String}
1229
- */
1230
- get_parent : function (obj) {
1231
- obj = this.get_node(obj);
1232
- if(!obj || obj.id === $.jstree.root) {
1233
- return false;
1234
- }
1235
- return obj.parent;
1236
- },
1237
- /**
1238
- * get a jQuery collection of all the children of a node (node must be rendered), returns false on error
1239
- * @name get_children_dom(obj)
1240
- * @param {mixed} obj
1241
- * @return {jQuery}
1242
- */
1243
- get_children_dom : function (obj) {
1244
- obj = this.get_node(obj, true);
1245
- if(obj[0] === this.element[0]) {
1246
- return this.get_container_ul().children(".jstree-node");
1247
- }
1248
- if(!obj || !obj.length) {
1249
- return false;
1250
- }
1251
- return obj.children(".jstree-children").children(".jstree-node");
1252
- },
1253
- /**
1254
- * checks if a node has children
1255
- * @name is_parent(obj)
1256
- * @param {mixed} obj
1257
- * @return {Boolean}
1258
- */
1259
- is_parent : function (obj) {
1260
- obj = this.get_node(obj);
1261
- return obj && (obj.state.loaded === false || obj.children.length > 0);
1262
- },
1263
- /**
1264
- * checks if a node is loaded (its children are available)
1265
- * @name is_loaded(obj)
1266
- * @param {mixed} obj
1267
- * @return {Boolean}
1268
- */
1269
- is_loaded : function (obj) {
1270
- obj = this.get_node(obj);
1271
- return obj && obj.state.loaded;
1272
- },
1273
- /**
1274
- * check if a node is currently loading (fetching children)
1275
- * @name is_loading(obj)
1276
- * @param {mixed} obj
1277
- * @return {Boolean}
1278
- */
1279
- is_loading : function (obj) {
1280
- obj = this.get_node(obj);
1281
- return obj && obj.state && obj.state.loading;
1282
- },
1283
- /**
1284
- * check if a node is opened
1285
- * @name is_open(obj)
1286
- * @param {mixed} obj
1287
- * @return {Boolean}
1288
- */
1289
- is_open : function (obj) {
1290
- obj = this.get_node(obj);
1291
- return obj && obj.state.opened;
1292
- },
1293
- /**
1294
- * check if a node is in a closed state
1295
- * @name is_closed(obj)
1296
- * @param {mixed} obj
1297
- * @return {Boolean}
1298
- */
1299
- is_closed : function (obj) {
1300
- obj = this.get_node(obj);
1301
- return obj && this.is_parent(obj) && !obj.state.opened;
1302
- },
1303
- /**
1304
- * check if a node has no children
1305
- * @name is_leaf(obj)
1306
- * @param {mixed} obj
1307
- * @return {Boolean}
1308
- */
1309
- is_leaf : function (obj) {
1310
- return !this.is_parent(obj);
1311
- },
1312
- /**
1313
- * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array.
1314
- * @name load_node(obj [, callback])
1315
- * @param {mixed} obj
1316
- * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives two arguments - the node and a boolean status
1317
- * @return {Boolean}
1318
- * @trigger load_node.jstree
1319
- */
1320
- load_node : function (obj, callback) {
1321
- var k, l, i, j, c;
1322
- if($.isArray(obj)) {
1323
- this._load_nodes(obj.slice(), callback);
1324
- return true;
1325
- }
1326
- obj = this.get_node(obj);
1327
- if(!obj) {
1328
- if(callback) { callback.call(this, obj, false); }
1329
- return false;
1330
- }
1331
- // if(obj.state.loading) { } // the node is already loading - just wait for it to load and invoke callback? but if called implicitly it should be loaded again?
1332
- if(obj.state.loaded) {
1333
- obj.state.loaded = false;
1334
- for(i = 0, j = obj.parents.length; i < j; i++) {
1335
- this._model.data[obj.parents[i]].children_d = $.vakata.array_filter(this._model.data[obj.parents[i]].children_d, function (v) {
1336
- return $.inArray(v, obj.children_d) === -1;
1337
- });
1338
- }
1339
- for(k = 0, l = obj.children_d.length; k < l; k++) {
1340
- if(this._model.data[obj.children_d[k]].state.selected) {
1341
- c = true;
1342
- }
1343
- delete this._model.data[obj.children_d[k]];
1344
- }
1345
- if (c) {
1346
- this._data.core.selected = $.vakata.array_filter(this._data.core.selected, function (v) {
1347
- return $.inArray(v, obj.children_d) === -1;
1348
- });
1349
- }
1350
- obj.children = [];
1351
- obj.children_d = [];
1352
- if(c) {
1353
- this.trigger('changed', { 'action' : 'load_node', 'node' : obj, 'selected' : this._data.core.selected });
1354
- }
1355
- }
1356
- obj.state.failed = false;
1357
- obj.state.loading = true;
1358
- this.get_node(obj, true).addClass("jstree-loading").attr('aria-busy',true);
1359
- this._load_node(obj, $.proxy(function (status) {
1360
- obj = this._model.data[obj.id];
1361
- obj.state.loading = false;
1362
- obj.state.loaded = status;
1363
- obj.state.failed = !obj.state.loaded;
1364
- var dom = this.get_node(obj, true), i = 0, j = 0, m = this._model.data, has_children = false;
1365
- for(i = 0, j = obj.children.length; i < j; i++) {
1366
- if(m[obj.children[i]] && !m[obj.children[i]].state.hidden) {
1367
- has_children = true;
1368
- break;
1369
- }
1370
- }
1371
- if(obj.state.loaded && dom && dom.length) {
1372
- dom.removeClass('jstree-closed jstree-open jstree-leaf');
1373
- if (!has_children) {
1374
- dom.addClass('jstree-leaf');
1375
- }
1376
- else {
1377
- if (obj.id !== '#') {
1378
- dom.addClass(obj.state.opened ? 'jstree-open' : 'jstree-closed');
1379
- }
1380
- }
1381
- }
1382
- dom.removeClass("jstree-loading").attr('aria-busy',false);
1383
- /**
1384
- * triggered after a node is loaded
1385
- * @event
1386
- * @name load_node.jstree
1387
- * @param {Object} node the node that was loading
1388
- * @param {Boolean} status was the node loaded successfully
1389
- */
1390
- this.trigger('load_node', { "node" : obj, "status" : status });
1391
- if(callback) {
1392
- callback.call(this, obj, status);
1393
- }
1394
- }, this));
1395
- return true;
1396
- },
1397
- /**
1398
- * load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
1399
- * @private
1400
- * @name _load_nodes(nodes [, callback])
1401
- * @param {array} nodes
1402
- * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes
1403
- */
1404
- _load_nodes : function (nodes, callback, is_callback, force_reload) {
1405
- var r = true,
1406
- c = function () { this._load_nodes(nodes, callback, true); },
1407
- m = this._model.data, i, j, tmp = [];
1408
- for(i = 0, j = nodes.length; i < j; i++) {
1409
- if(m[nodes[i]] && ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || (!is_callback && force_reload) )) {
1410
- if(!this.is_loading(nodes[i])) {
1411
- this.load_node(nodes[i], c);
1412
- }
1413
- r = false;
1414
- }
1415
- }
1416
- if(r) {
1417
- for(i = 0, j = nodes.length; i < j; i++) {
1418
- if(m[nodes[i]] && m[nodes[i]].state.loaded) {
1419
- tmp.push(nodes[i]);
1420
- }
1421
- }
1422
- if(callback && !callback.done) {
1423
- callback.call(this, tmp);
1424
- callback.done = true;
1425
- }
1426
- }
1427
- },
1428
- /**
1429
- * loads all unloaded nodes
1430
- * @name load_all([obj, callback])
1431
- * @param {mixed} obj the node to load recursively, omit to load all nodes in the tree
1432
- * @param {function} callback a function to be executed once loading all the nodes is complete,
1433
- * @trigger load_all.jstree
1434
- */
1435
- load_all : function (obj, callback) {
1436
- if(!obj) { obj = $.jstree.root; }
1437
- obj = this.get_node(obj);
1438
- if(!obj) { return false; }
1439
- var to_load = [],
1440
- m = this._model.data,
1441
- c = m[obj.id].children_d,
1442
- i, j;
1443
- if(obj.state && !obj.state.loaded) {
1444
- to_load.push(obj.id);
1445
- }
1446
- for(i = 0, j = c.length; i < j; i++) {
1447
- if(m[c[i]] && m[c[i]].state && !m[c[i]].state.loaded) {
1448
- to_load.push(c[i]);
1449
- }
1450
- }
1451
- if(to_load.length) {
1452
- this._load_nodes(to_load, function () {
1453
- this.load_all(obj, callback);
1454
- });
1455
- }
1456
- else {
1457
- /**
1458
- * triggered after a load_all call completes
1459
- * @event
1460
- * @name load_all.jstree
1461
- * @param {Object} node the recursively loaded node
1462
- */
1463
- if(callback) { callback.call(this, obj); }
1464
- this.trigger('load_all', { "node" : obj });
1465
- }
1466
- },
1467
- /**
1468
- * handles the actual loading of a node. Used only internally.
1469
- * @private
1470
- * @name _load_node(obj [, callback])
1471
- * @param {mixed} obj
1472
- * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status
1473
- * @return {Boolean}
1474
- */
1475
- _load_node : function (obj, callback) {
1476
- var s = this.settings.core.data, t;
1477
- var notTextOrCommentNode = function notTextOrCommentNode () {
1478
- return this.nodeType !== 3 && this.nodeType !== 8;
1479
- };
1480
- // use original HTML
1481
- if(!s) {
1482
- if(obj.id === $.jstree.root) {
1483
- return this._append_html_data(obj, this._data.core.original_container_html.clone(true), function (status) {
1484
- callback.call(this, status);
1485
- });
1486
- }
1487
- else {
1488
- return callback.call(this, false);
1489
- }
1490
- // return callback.call(this, obj.id === $.jstree.root ? this._append_html_data(obj, this._data.core.original_container_html.clone(true)) : false);
1491
- }
1492
- if($.isFunction(s)) {
1493
- return s.call(this, obj, $.proxy(function (d) {
1494
- if(d === false) {
1495
- callback.call(this, false);
1496
- }
1497
- else {
1498
- this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $($.parseHTML(d)).filter(notTextOrCommentNode) : d, function (status) {
1499
- callback.call(this, status);
1500
- });
1501
- }
1502
- // return d === false ? callback.call(this, false) : callback.call(this, this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d));
1503
- }, this));
1504
- }
1505
- if(typeof s === 'object') {
1506
- if(s.url) {
1507
- s = $.extend(true, {}, s);
1508
- if($.isFunction(s.url)) {
1509
- s.url = s.url.call(this, obj);
1510
- }
1511
- if($.isFunction(s.data)) {
1512
- s.data = s.data.call(this, obj);
1513
- }
1514
- return $.ajax(s)
1515
- .done($.proxy(function (d,t,x) {
1516
- var type = x.getResponseHeader('Content-Type');
1517
- if((type && type.indexOf('json') !== -1) || typeof d === "object") {
1518
- return this._append_json_data(obj, d, function (status) { callback.call(this, status); });
1519
- //return callback.call(this, this._append_json_data(obj, d));
1520
- }
1521
- if((type && type.indexOf('html') !== -1) || typeof d === "string") {
1522
- return this._append_html_data(obj, $($.parseHTML(d)).filter(notTextOrCommentNode), function (status) { callback.call(this, status); });
1523
- // return callback.call(this, this._append_html_data(obj, $(d)));
1524
- }
1525
- this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : x }) };
1526
- this.settings.core.error.call(this, this._data.core.last_error);
1527
- return callback.call(this, false);
1528
- }, this))
1529
- .fail($.proxy(function (f) {
1530
- this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : f }) };
1531
- callback.call(this, false);
1532
- this.settings.core.error.call(this, this._data.core.last_error);
1533
- }, this));
1534
- }
1535
- if ($.isArray(s)) {
1536
- t = $.extend(true, [], s);
1537
- } else if ($.isPlainObject(s)) {
1538
- t = $.extend(true, {}, s);
1539
- } else {
1540
- t = s;
1541
- }
1542
- if(obj.id === $.jstree.root) {
1543
- return this._append_json_data(obj, t, function (status) {
1544
- callback.call(this, status);
1545
- });
1546
- }
1547
- else {
1548
- this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_05', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) };
1549
- this.settings.core.error.call(this, this._data.core.last_error);
1550
- return callback.call(this, false);
1551
- }
1552
- //return callback.call(this, (obj.id === $.jstree.root ? this._append_json_data(obj, t) : false) );
1553
- }
1554
- if(typeof s === 'string') {
1555
- if(obj.id === $.jstree.root) {
1556
- return this._append_html_data(obj, $($.parseHTML(s)).filter(notTextOrCommentNode), function (status) {
1557
- callback.call(this, status);
1558
- });
1559
- }
1560
- else {
1561
- this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_06', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) };
1562
- this.settings.core.error.call(this, this._data.core.last_error);
1563
- return callback.call(this, false);
1564
- }
1565
- //return callback.call(this, (obj.id === $.jstree.root ? this._append_html_data(obj, $(s)) : false) );
1566
- }
1567
- return callback.call(this, false);
1568
- },
1569
- /**
1570
- * adds a node to the list of nodes to redraw. Used only internally.
1571
- * @private
1572
- * @name _node_changed(obj [, callback])
1573
- * @param {mixed} obj
1574
- */
1575
- _node_changed : function (obj) {
1576
- obj = this.get_node(obj);
1577
- if (obj && $.inArray(obj.id, this._model.changed) === -1) {
1578
- this._model.changed.push(obj.id);
1579
- }
1580
- },
1581
- /**
1582
- * appends HTML content to the tree. Used internally.
1583
- * @private
1584
- * @name _append_html_data(obj, data)
1585
- * @param {mixed} obj the node to append to
1586
- * @param {String} data the HTML string to parse and append
1587
- * @trigger model.jstree, changed.jstree
1588
- */
1589
- _append_html_data : function (dom, data, cb) {
1590
- dom = this.get_node(dom);
1591
- dom.children = [];
1592
- dom.children_d = [];
1593
- var dat = data.is('ul') ? data.children() : data,
1594
- par = dom.id,
1595
- chd = [],
1596
- dpc = [],
1597
- m = this._model.data,
1598
- p = m[par],
1599
- s = this._data.core.selected.length,
1600
- tmp, i, j;
1601
- dat.each($.proxy(function (i, v) {
1602
- tmp = this._parse_model_from_html($(v), par, p.parents.concat());
1603
- if(tmp) {
1604
- chd.push(tmp);
1605
- dpc.push(tmp);
1606
- if(m[tmp].children_d.length) {
1607
- dpc = dpc.concat(m[tmp].children_d);
1608
- }
1609
- }
1610
- }, this));
1611
- p.children = chd;
1612
- p.children_d = dpc;
1613
- for(i = 0, j = p.parents.length; i < j; i++) {
1614
- m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
1615
- }
1616
- /**
1617
- * triggered when new data is inserted to the tree model
1618
- * @event
1619
- * @name model.jstree
1620
- * @param {Array} nodes an array of node IDs
1621
- * @param {String} parent the parent ID of the nodes
1622
- */
1623
- this.trigger('model', { "nodes" : dpc, 'parent' : par });
1624
- if(par !== $.jstree.root) {
1625
- this._node_changed(par);
1626
- this.redraw();
1627
- }
1628
- else {
1629
- this.get_container_ul().children('.jstree-initial-node').remove();
1630
- this.redraw(true);
1631
- }
1632
- if(this._data.core.selected.length !== s) {
1633
- this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected });
1634
- }
1635
- cb.call(this, true);
1636
- },
1637
- /**
1638
- * appends JSON content to the tree. Used internally.
1639
- * @private
1640
- * @name _append_json_data(obj, data)
1641
- * @param {mixed} obj the node to append to
1642
- * @param {String} data the JSON object to parse and append
1643
- * @param {Boolean} force_processing internal param - do not set
1644
- * @trigger model.jstree, changed.jstree
1645
- */
1646
- _append_json_data : function (dom, data, cb, force_processing) {
1647
- if(this.element === null) { return; }
1648
- dom = this.get_node(dom);
1649
- dom.children = [];
1650
- dom.children_d = [];
1651
- // *%$@!!!
1652
- if(data.d) {
1653
- data = data.d;
1654
- if(typeof data === "string") {
1655
- data = JSON.parse(data);
1656
- }
1657
- }
1658
- if(!$.isArray(data)) { data = [data]; }
1659
- var w = null,
1660
- args = {
1661
- 'df' : this._model.default_state,
1662
- 'dat' : data,
1663
- 'par' : dom.id,
1664
- 'm' : this._model.data,
1665
- 't_id' : this._id,
1666
- 't_cnt' : this._cnt,
1667
- 'sel' : this._data.core.selected
1668
- },
1669
- inst = this,
1670
- func = function (data, undefined) {
1671
- if(data.data) { data = data.data; }
1672
- var dat = data.dat,
1673
- par = data.par,
1674
- chd = [],
1675
- dpc = [],
1676
- add = [],
1677
- df = data.df,
1678
- t_id = data.t_id,
1679
- t_cnt = data.t_cnt,
1680
- m = data.m,
1681
- p = m[par],
1682
- sel = data.sel,
1683
- tmp, i, j, rslt,
1684
- parse_flat = function (d, p, ps) {
1685
- if(!ps) { ps = []; }
1686
- else { ps = ps.concat(); }
1687
- if(p) { ps.unshift(p); }
1688
- var tid = d.id.toString(),
1689
- i, j, c, e,
1690
- tmp = {
1691
- id : tid,
1692
- text : d.text || '',
1693
- icon : d.icon !== undefined ? d.icon : true,
1694
- parent : p,
1695
- parents : ps,
1696
- children : d.children || [],
1697
- children_d : d.children_d || [],
1698
- data : d.data,
1699
- state : { },
1700
- li_attr : { id : false },
1701
- a_attr : { href : '#' },
1702
- original : false
1703
- };
1704
- for(i in df) {
1705
- if(df.hasOwnProperty(i)) {
1706
- tmp.state[i] = df[i];
1707
- }
1708
- }
1709
- if(d && d.data && d.data.jstree && d.data.jstree.icon) {
1710
- tmp.icon = d.data.jstree.icon;
1711
- }
1712
- if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
1713
- tmp.icon = true;
1714
- }
1715
- if(d && d.data) {
1716
- tmp.data = d.data;
1717
- if(d.data.jstree) {
1718
- for(i in d.data.jstree) {
1719
- if(d.data.jstree.hasOwnProperty(i)) {
1720
- tmp.state[i] = d.data.jstree[i];
1721
- }
1722
- }
1723
- }
1724
- }
1725
- if(d && typeof d.state === 'object') {
1726
- for (i in d.state) {
1727
- if(d.state.hasOwnProperty(i)) {
1728
- tmp.state[i] = d.state[i];
1729
- }
1730
- }
1731
- }
1732
- if(d && typeof d.li_attr === 'object') {
1733
- for (i in d.li_attr) {
1734
- if(d.li_attr.hasOwnProperty(i)) {
1735
- tmp.li_attr[i] = d.li_attr[i];
1736
- }
1737
- }
1738
- }
1739
- if(!tmp.li_attr.id) {
1740
- tmp.li_attr.id = tid;
1741
- }
1742
- if(d && typeof d.a_attr === 'object') {
1743
- for (i in d.a_attr) {
1744
- if(d.a_attr.hasOwnProperty(i)) {
1745
- tmp.a_attr[i] = d.a_attr[i];
1746
- }
1747
- }
1748
- }
1749
- if(d && d.children && d.children === true) {
1750
- tmp.state.loaded = false;
1751
- tmp.children = [];
1752
- tmp.children_d = [];
1753
- }
1754
- m[tmp.id] = tmp;
1755
- for(i = 0, j = tmp.children.length; i < j; i++) {
1756
- c = parse_flat(m[tmp.children[i]], tmp.id, ps);
1757
- e = m[c];
1758
- tmp.children_d.push(c);
1759
- if(e.children_d.length) {
1760
- tmp.children_d = tmp.children_d.concat(e.children_d);
1761
- }
1762
- }
1763
- delete d.data;
1764
- delete d.children;
1765
- m[tmp.id].original = d;
1766
- if(tmp.state.selected) {
1767
- add.push(tmp.id);
1768
- }
1769
- return tmp.id;
1770
- },
1771
- parse_nest = function (d, p, ps) {
1772
- if(!ps) { ps = []; }
1773
- else { ps = ps.concat(); }
1774
- if(p) { ps.unshift(p); }
1775
- var tid = false, i, j, c, e, tmp;
1776
- do {
1777
- tid = 'j' + t_id + '_' + (++t_cnt);
1778
- } while(m[tid]);
1779
-
1780
- tmp = {
1781
- id : false,
1782
- text : typeof d === 'string' ? d : '',
1783
- icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
1784
- parent : p,
1785
- parents : ps,
1786
- children : [],
1787
- children_d : [],
1788
- data : null,
1789
- state : { },
1790
- li_attr : { id : false },
1791
- a_attr : { href : '#' },
1792
- original : false
1793
- };
1794
- for(i in df) {
1795
- if(df.hasOwnProperty(i)) {
1796
- tmp.state[i] = df[i];
1797
- }
1798
- }
1799
- if(d && d.id) { tmp.id = d.id.toString(); }
1800
- if(d && d.text) { tmp.text = d.text; }
1801
- if(d && d.data && d.data.jstree && d.data.jstree.icon) {
1802
- tmp.icon = d.data.jstree.icon;
1803
- }
1804
- if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
1805
- tmp.icon = true;
1806
- }
1807
- if(d && d.data) {
1808
- tmp.data = d.data;
1809
- if(d.data.jstree) {
1810
- for(i in d.data.jstree) {
1811
- if(d.data.jstree.hasOwnProperty(i)) {
1812
- tmp.state[i] = d.data.jstree[i];
1813
- }
1814
- }
1815
- }
1816
- }
1817
- if(d && typeof d.state === 'object') {
1818
- for (i in d.state) {
1819
- if(d.state.hasOwnProperty(i)) {
1820
- tmp.state[i] = d.state[i];
1821
- }
1822
- }
1823
- }
1824
- if(d && typeof d.li_attr === 'object') {
1825
- for (i in d.li_attr) {
1826
- if(d.li_attr.hasOwnProperty(i)) {
1827
- tmp.li_attr[i] = d.li_attr[i];
1828
- }
1829
- }
1830
- }
1831
- if(tmp.li_attr.id && !tmp.id) {
1832
- tmp.id = tmp.li_attr.id.toString();
1833
- }
1834
- if(!tmp.id) {
1835
- tmp.id = tid;
1836
- }
1837
- if(!tmp.li_attr.id) {
1838
- tmp.li_attr.id = tmp.id;
1839
- }
1840
- if(d && typeof d.a_attr === 'object') {
1841
- for (i in d.a_attr) {
1842
- if(d.a_attr.hasOwnProperty(i)) {
1843
- tmp.a_attr[i] = d.a_attr[i];
1844
- }
1845
- }
1846
- }
1847
- if(d && d.children && d.children.length) {
1848
- for(i = 0, j = d.children.length; i < j; i++) {
1849
- c = parse_nest(d.children[i], tmp.id, ps);
1850
- e = m[c];
1851
- tmp.children.push(c);
1852
- if(e.children_d.length) {
1853
- tmp.children_d = tmp.children_d.concat(e.children_d);
1854
- }
1855
- }
1856
- tmp.children_d = tmp.children_d.concat(tmp.children);
1857
- }
1858
- if(d && d.children && d.children === true) {
1859
- tmp.state.loaded = false;
1860
- tmp.children = [];
1861
- tmp.children_d = [];
1862
- }
1863
- delete d.data;
1864
- delete d.children;
1865
- tmp.original = d;
1866
- m[tmp.id] = tmp;
1867
- if(tmp.state.selected) {
1868
- add.push(tmp.id);
1869
- }
1870
- return tmp.id;
1871
- };
1872
-
1873
- if(dat.length && dat[0].id !== undefined && dat[0].parent !== undefined) {
1874
- // Flat JSON support (for easy import from DB):
1875
- // 1) convert to object (foreach)
1876
- for(i = 0, j = dat.length; i < j; i++) {
1877
- if(!dat[i].children) {
1878
- dat[i].children = [];
1879
- }
1880
- if(!dat[i].state) {
1881
- dat[i].state = {};
1882
- }
1883
- m[dat[i].id.toString()] = dat[i];
1884
- }
1885
- // 2) populate children (foreach)
1886
- for(i = 0, j = dat.length; i < j; i++) {
1887
- if (!m[dat[i].parent.toString()]) {
1888
- if (typeof inst !== "undefined") {
1889
- inst._data.core.last_error = { 'error' : 'parse', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Node with invalid parent', 'data' : JSON.stringify({ 'id' : dat[i].id.toString(), 'parent' : dat[i].parent.toString() }) };
1890
- inst.settings.core.error.call(inst, inst._data.core.last_error);
1891
- }
1892
- continue;
1893
- }
1894
-
1895
- m[dat[i].parent.toString()].children.push(dat[i].id.toString());
1896
- // populate parent.children_d
1897
- p.children_d.push(dat[i].id.toString());
1898
- }
1899
- // 3) normalize && populate parents and children_d with recursion
1900
- for(i = 0, j = p.children.length; i < j; i++) {
1901
- tmp = parse_flat(m[p.children[i]], par, p.parents.concat());
1902
- dpc.push(tmp);
1903
- if(m[tmp].children_d.length) {
1904
- dpc = dpc.concat(m[tmp].children_d);
1905
- }
1906
- }
1907
- for(i = 0, j = p.parents.length; i < j; i++) {
1908
- m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
1909
- }
1910
- // ?) three_state selection - p.state.selected && t - (if three_state foreach(dat => ch) -> foreach(parents) if(parent.selected) child.selected = true;
1911
- rslt = {
1912
- 'cnt' : t_cnt,
1913
- 'mod' : m,
1914
- 'sel' : sel,
1915
- 'par' : par,
1916
- 'dpc' : dpc,
1917
- 'add' : add
1918
- };
1919
- }
1920
- else {
1921
- for(i = 0, j = dat.length; i < j; i++) {
1922
- tmp = parse_nest(dat[i], par, p.parents.concat());
1923
- if(tmp) {
1924
- chd.push(tmp);
1925
- dpc.push(tmp);
1926
- if(m[tmp].children_d.length) {
1927
- dpc = dpc.concat(m[tmp].children_d);
1928
- }
1929
- }
1930
- }
1931
- p.children = chd;
1932
- p.children_d = dpc;
1933
- for(i = 0, j = p.parents.length; i < j; i++) {
1934
- m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
1935
- }
1936
- rslt = {
1937
- 'cnt' : t_cnt,
1938
- 'mod' : m,
1939
- 'sel' : sel,
1940
- 'par' : par,
1941
- 'dpc' : dpc,
1942
- 'add' : add
1943
- };
1944
- }
1945
- if(typeof window === 'undefined' || typeof window.document === 'undefined') {
1946
- postMessage(rslt);
1947
- }
1948
- else {
1949
- return rslt;
1950
- }
1951
- },
1952
- rslt = function (rslt, worker) {
1953
- if(this.element === null) { return; }
1954
- this._cnt = rslt.cnt;
1955
- var i, m = this._model.data;
1956
- for (i in m) {
1957
- if (m.hasOwnProperty(i) && m[i].state && m[i].state.loading && rslt.mod[i]) {
1958
- rslt.mod[i].state.loading = true;
1959
- }
1960
- }
1961
- this._model.data = rslt.mod; // breaks the reference in load_node - careful
1962
-
1963
- if(worker) {
1964
- var j, a = rslt.add, r = rslt.sel, s = this._data.core.selected.slice();
1965
- m = this._model.data;
1966
- // if selection was changed while calculating in worker
1967
- if(r.length !== s.length || $.vakata.array_unique(r.concat(s)).length !== r.length) {
1968
- // deselect nodes that are no longer selected
1969
- for(i = 0, j = r.length; i < j; i++) {
1970
- if($.inArray(r[i], a) === -1 && $.inArray(r[i], s) === -1) {
1971
- m[r[i]].state.selected = false;
1972
- }
1973
- }
1974
- // select nodes that were selected in the mean time
1975
- for(i = 0, j = s.length; i < j; i++) {
1976
- if($.inArray(s[i], r) === -1) {
1977
- m[s[i]].state.selected = true;
1978
- }
1979
- }
1980
- }
1981
- }
1982
- if(rslt.add.length) {
1983
- this._data.core.selected = this._data.core.selected.concat(rslt.add);
1984
- }
1985
-
1986
- this.trigger('model', { "nodes" : rslt.dpc, 'parent' : rslt.par });
1987
-
1988
- if(rslt.par !== $.jstree.root) {
1989
- this._node_changed(rslt.par);
1990
- this.redraw();
1991
- }
1992
- else {
1993
- // this.get_container_ul().children('.jstree-initial-node').remove();
1994
- this.redraw(true);
1995
- }
1996
- if(rslt.add.length) {
1997
- this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected });
1998
- }
1999
-
2000
- // If no worker, try to mimic worker behavioour, by invoking cb asynchronously
2001
- if (!worker && setImmediate) {
2002
- setImmediate(function(){
2003
- cb.call(inst, true);
2004
- });
2005
- }
2006
- else {
2007
- cb.call(inst, true);
2008
- }
2009
- };
2010
- if(this.settings.core.worker && window.Blob && window.URL && window.Worker) {
2011
- try {
2012
- if(this._wrk === null) {
2013
- this._wrk = window.URL.createObjectURL(
2014
- new window.Blob(
2015
- ['self.onmessage = ' + func.toString()],
2016
- {type:"text/javascript"}
2017
- )
2018
- );
2019
- }
2020
- if(!this._data.core.working || force_processing) {
2021
- this._data.core.working = true;
2022
- w = new window.Worker(this._wrk);
2023
- w.onmessage = $.proxy(function (e) {
2024
- rslt.call(this, e.data, true);
2025
- try { w.terminate(); w = null; } catch(ignore) { }
2026
- if(this._data.core.worker_queue.length) {
2027
- this._append_json_data.apply(this, this._data.core.worker_queue.shift());
2028
- }
2029
- else {
2030
- this._data.core.working = false;
2031
- }
2032
- }, this);
2033
- if(!args.par) {
2034
- if(this._data.core.worker_queue.length) {
2035
- this._append_json_data.apply(this, this._data.core.worker_queue.shift());
2036
- }
2037
- else {
2038
- this._data.core.working = false;
2039
- }
2040
- }
2041
- else {
2042
- w.postMessage(args);
2043
- }
2044
- }
2045
- else {
2046
- this._data.core.worker_queue.push([dom, data, cb, true]);
2047
- }
2048
- }
2049
- catch(e) {
2050
- rslt.call(this, func(args), false);
2051
- if(this._data.core.worker_queue.length) {
2052
- this._append_json_data.apply(this, this._data.core.worker_queue.shift());
2053
- }
2054
- else {
2055
- this._data.core.working = false;
2056
- }
2057
- }
2058
- }
2059
- else {
2060
- rslt.call(this, func(args), false);
2061
- }
2062
- },
2063
- /**
2064
- * parses a node from a jQuery object and appends them to the in memory tree model. Used internally.
2065
- * @private
2066
- * @name _parse_model_from_html(d [, p, ps])
2067
- * @param {jQuery} d the jQuery object to parse
2068
- * @param {String} p the parent ID
2069
- * @param {Array} ps list of all parents
2070
- * @return {String} the ID of the object added to the model
2071
- */
2072
- _parse_model_from_html : function (d, p, ps) {
2073
- if(!ps) { ps = []; }
2074
- else { ps = [].concat(ps); }
2075
- if(p) { ps.unshift(p); }
2076
- var c, e, m = this._model.data,
2077
- data = {
2078
- id : false,
2079
- text : false,
2080
- icon : true,
2081
- parent : p,
2082
- parents : ps,
2083
- children : [],
2084
- children_d : [],
2085
- data : null,
2086
- state : { },
2087
- li_attr : { id : false },
2088
- a_attr : { href : '#' },
2089
- original : false
2090
- }, i, tmp, tid;
2091
- for(i in this._model.default_state) {
2092
- if(this._model.default_state.hasOwnProperty(i)) {
2093
- data.state[i] = this._model.default_state[i];
2094
- }
2095
- }
2096
- tmp = $.vakata.attributes(d, true);
2097
- $.each(tmp, function (i, v) {
2098
- v = $.trim(v);
2099
- if(!v.length) { return true; }
2100
- data.li_attr[i] = v;
2101
- if(i === 'id') {
2102
- data.id = v.toString();
2103
- }
2104
- });
2105
- tmp = d.children('a').first();
2106
- if(tmp.length) {
2107
- tmp = $.vakata.attributes(tmp, true);
2108
- $.each(tmp, function (i, v) {
2109
- v = $.trim(v);
2110
- if(v.length) {
2111
- data.a_attr[i] = v;
2112
- }
2113
- });
2114
- }
2115
- tmp = d.children("a").first().length ? d.children("a").first().clone() : d.clone();
2116
- tmp.children("ins, i, ul").remove();
2117
- tmp = tmp.html();
2118
- tmp = $('<div></div>').html(tmp);
2119
- data.text = this.settings.core.force_text ? tmp.text() : tmp.html();
2120
- tmp = d.data();
2121
- data.data = tmp ? $.extend(true, {}, tmp) : null;
2122
- data.state.opened = d.hasClass('jstree-open');
2123
- data.state.selected = d.children('a').hasClass('jstree-clicked');
2124
- data.state.disabled = d.children('a').hasClass('jstree-disabled');
2125
- if(data.data && data.data.jstree) {
2126
- for(i in data.data.jstree) {
2127
- if(data.data.jstree.hasOwnProperty(i)) {
2128
- data.state[i] = data.data.jstree[i];
2129
- }
2130
- }
2131
- }
2132
- tmp = d.children("a").children(".jstree-themeicon");
2133
- if(tmp.length) {
2134
- data.icon = tmp.hasClass('jstree-themeicon-hidden') ? false : tmp.attr('rel');
2135
- }
2136
- if(data.state.icon !== undefined) {
2137
- data.icon = data.state.icon;
2138
- }
2139
- if(data.icon === undefined || data.icon === null || data.icon === "") {
2140
- data.icon = true;
2141
- }
2142
- tmp = d.children("ul").children("li");
2143
- do {
2144
- tid = 'j' + this._id + '_' + (++this._cnt);
2145
- } while(m[tid]);
2146
- data.id = data.li_attr.id ? data.li_attr.id.toString() : tid;
2147
- if(tmp.length) {
2148
- tmp.each($.proxy(function (i, v) {
2149
- c = this._parse_model_from_html($(v), data.id, ps);
2150
- e = this._model.data[c];
2151
- data.children.push(c);
2152
- if(e.children_d.length) {
2153
- data.children_d = data.children_d.concat(e.children_d);
2154
- }
2155
- }, this));
2156
- data.children_d = data.children_d.concat(data.children);
2157
- }
2158
- else {
2159
- if(d.hasClass('jstree-closed')) {
2160
- data.state.loaded = false;
2161
- }
2162
- }
2163
- if(data.li_attr['class']) {
2164
- data.li_attr['class'] = data.li_attr['class'].replace('jstree-closed','').replace('jstree-open','');
2165
- }
2166
- if(data.a_attr['class']) {
2167
- data.a_attr['class'] = data.a_attr['class'].replace('jstree-clicked','').replace('jstree-disabled','');
2168
- }
2169
- m[data.id] = data;
2170
- if(data.state.selected) {
2171
- this._data.core.selected.push(data.id);
2172
- }
2173
- return data.id;
2174
- },
2175
- /**
2176
- * parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally.
2177
- * @private
2178
- * @name _parse_model_from_flat_json(d [, p, ps])
2179
- * @param {Object} d the JSON object to parse
2180
- * @param {String} p the parent ID
2181
- * @param {Array} ps list of all parents
2182
- * @return {String} the ID of the object added to the model
2183
- */
2184
- _parse_model_from_flat_json : function (d, p, ps) {
2185
- if(!ps) { ps = []; }
2186
- else { ps = ps.concat(); }
2187
- if(p) { ps.unshift(p); }
2188
- var tid = d.id.toString(),
2189
- m = this._model.data,
2190
- df = this._model.default_state,
2191
- i, j, c, e,
2192
- tmp = {
2193
- id : tid,
2194
- text : d.text || '',
2195
- icon : d.icon !== undefined ? d.icon : true,
2196
- parent : p,
2197
- parents : ps,
2198
- children : d.children || [],
2199
- children_d : d.children_d || [],
2200
- data : d.data,
2201
- state : { },
2202
- li_attr : { id : false },
2203
- a_attr : { href : '#' },
2204
- original : false
2205
- };
2206
- for(i in df) {
2207
- if(df.hasOwnProperty(i)) {
2208
- tmp.state[i] = df[i];
2209
- }
2210
- }
2211
- if(d && d.data && d.data.jstree && d.data.jstree.icon) {
2212
- tmp.icon = d.data.jstree.icon;
2213
- }
2214
- if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
2215
- tmp.icon = true;
2216
- }
2217
- if(d && d.data) {
2218
- tmp.data = d.data;
2219
- if(d.data.jstree) {
2220
- for(i in d.data.jstree) {
2221
- if(d.data.jstree.hasOwnProperty(i)) {
2222
- tmp.state[i] = d.data.jstree[i];
2223
- }
2224
- }
2225
- }
2226
- }
2227
- if(d && typeof d.state === 'object') {
2228
- for (i in d.state) {
2229
- if(d.state.hasOwnProperty(i)) {
2230
- tmp.state[i] = d.state[i];
2231
- }
2232
- }
2233
- }
2234
- if(d && typeof d.li_attr === 'object') {
2235
- for (i in d.li_attr) {
2236
- if(d.li_attr.hasOwnProperty(i)) {
2237
- tmp.li_attr[i] = d.li_attr[i];
2238
- }
2239
- }
2240
- }
2241
- if(!tmp.li_attr.id) {
2242
- tmp.li_attr.id = tid;
2243
- }
2244
- if(d && typeof d.a_attr === 'object') {
2245
- for (i in d.a_attr) {
2246
- if(d.a_attr.hasOwnProperty(i)) {
2247
- tmp.a_attr[i] = d.a_attr[i];
2248
- }
2249
- }
2250
- }
2251
- if(d && d.children && d.children === true) {
2252
- tmp.state.loaded = false;
2253
- tmp.children = [];
2254
- tmp.children_d = [];
2255
- }
2256
- m[tmp.id] = tmp;
2257
- for(i = 0, j = tmp.children.length; i < j; i++) {
2258
- c = this._parse_model_from_flat_json(m[tmp.children[i]], tmp.id, ps);
2259
- e = m[c];
2260
- tmp.children_d.push(c);
2261
- if(e.children_d.length) {
2262
- tmp.children_d = tmp.children_d.concat(e.children_d);
2263
- }
2264
- }
2265
- delete d.data;
2266
- delete d.children;
2267
- m[tmp.id].original = d;
2268
- if(tmp.state.selected) {
2269
- this._data.core.selected.push(tmp.id);
2270
- }
2271
- return tmp.id;
2272
- },
2273
- /**
2274
- * parses a node from a JSON object and appends it to the in memory tree model. Used internally.
2275
- * @private
2276
- * @name _parse_model_from_json(d [, p, ps])
2277
- * @param {Object} d the JSON object to parse
2278
- * @param {String} p the parent ID
2279
- * @param {Array} ps list of all parents
2280
- * @return {String} the ID of the object added to the model
2281
- */
2282
- _parse_model_from_json : function (d, p, ps) {
2283
- if(!ps) { ps = []; }
2284
- else { ps = ps.concat(); }
2285
- if(p) { ps.unshift(p); }
2286
- var tid = false, i, j, c, e, m = this._model.data, df = this._model.default_state, tmp;
2287
- do {
2288
- tid = 'j' + this._id + '_' + (++this._cnt);
2289
- } while(m[tid]);
2290
-
2291
- tmp = {
2292
- id : false,
2293
- text : typeof d === 'string' ? d : '',
2294
- icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
2295
- parent : p,
2296
- parents : ps,
2297
- children : [],
2298
- children_d : [],
2299
- data : null,
2300
- state : { },
2301
- li_attr : { id : false },
2302
- a_attr : { href : '#' },
2303
- original : false
2304
- };
2305
- for(i in df) {
2306
- if(df.hasOwnProperty(i)) {
2307
- tmp.state[i] = df[i];
2308
- }
2309
- }
2310
- if(d && d.id) { tmp.id = d.id.toString(); }
2311
- if(d && d.text) { tmp.text = d.text; }
2312
- if(d && d.data && d.data.jstree && d.data.jstree.icon) {
2313
- tmp.icon = d.data.jstree.icon;
2314
- }
2315
- if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
2316
- tmp.icon = true;
2317
- }
2318
- if(d && d.data) {
2319
- tmp.data = d.data;
2320
- if(d.data.jstree) {
2321
- for(i in d.data.jstree) {
2322
- if(d.data.jstree.hasOwnProperty(i)) {
2323
- tmp.state[i] = d.data.jstree[i];
2324
- }
2325
- }
2326
- }
2327
- }
2328
- if(d && typeof d.state === 'object') {
2329
- for (i in d.state) {
2330
- if(d.state.hasOwnProperty(i)) {
2331
- tmp.state[i] = d.state[i];
2332
- }
2333
- }
2334
- }
2335
- if(d && typeof d.li_attr === 'object') {
2336
- for (i in d.li_attr) {
2337
- if(d.li_attr.hasOwnProperty(i)) {
2338
- tmp.li_attr[i] = d.li_attr[i];
2339
- }
2340
- }
2341
- }
2342
- if(tmp.li_attr.id && !tmp.id) {
2343
- tmp.id = tmp.li_attr.id.toString();
2344
- }
2345
- if(!tmp.id) {
2346
- tmp.id = tid;
2347
- }
2348
- if(!tmp.li_attr.id) {
2349
- tmp.li_attr.id = tmp.id;
2350
- }
2351
- if(d && typeof d.a_attr === 'object') {
2352
- for (i in d.a_attr) {
2353
- if(d.a_attr.hasOwnProperty(i)) {
2354
- tmp.a_attr[i] = d.a_attr[i];
2355
- }
2356
- }
2357
- }
2358
- if(d && d.children && d.children.length) {
2359
- for(i = 0, j = d.children.length; i < j; i++) {
2360
- c = this._parse_model_from_json(d.children[i], tmp.id, ps);
2361
- e = m[c];
2362
- tmp.children.push(c);
2363
- if(e.children_d.length) {
2364
- tmp.children_d = tmp.children_d.concat(e.children_d);
2365
- }
2366
- }
2367
- tmp.children_d = tmp.children.concat(tmp.children_d);
2368
- }
2369
- if(d && d.children && d.children === true) {
2370
- tmp.state.loaded = false;
2371
- tmp.children = [];
2372
- tmp.children_d = [];
2373
- }
2374
- delete d.data;
2375
- delete d.children;
2376
- tmp.original = d;
2377
- m[tmp.id] = tmp;
2378
- if(tmp.state.selected) {
2379
- this._data.core.selected.push(tmp.id);
2380
- }
2381
- return tmp.id;
2382
- },
2383
- /**
2384
- * redraws all nodes that need to be redrawn. Used internally.
2385
- * @private
2386
- * @name _redraw()
2387
- * @trigger redraw.jstree
2388
- */
2389
- _redraw : function () {
2390
- var nodes = this._model.force_full_redraw ? this._model.data[$.jstree.root].children.concat([]) : this._model.changed.concat([]),
2391
- f = document.createElement('UL'), tmp, i, j, fe = this._data.core.focused;
2392
- for(i = 0, j = nodes.length; i < j; i++) {
2393
- tmp = this.redraw_node(nodes[i], true, this._model.force_full_redraw);
2394
- if(tmp && this._model.force_full_redraw) {
2395
- f.appendChild(tmp);
2396
- }
2397
- }
2398
- if(this._model.force_full_redraw) {
2399
- f.className = this.get_container_ul()[0].className;
2400
- f.setAttribute('role','group');
2401
- this.element.empty().append(f);
2402
- //this.get_container_ul()[0].appendChild(f);
2403
- }
2404
- if(fe !== null && this.settings.core.restore_focus) {
2405
- tmp = this.get_node(fe, true);
2406
- if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) {
2407
- tmp.children('.jstree-anchor').focus();
2408
- }
2409
- else {
2410
- this._data.core.focused = null;
2411
- }
2412
- }
2413
- this._model.force_full_redraw = false;
2414
- this._model.changed = [];
2415
- /**
2416
- * triggered after nodes are redrawn
2417
- * @event
2418
- * @name redraw.jstree
2419
- * @param {array} nodes the redrawn nodes
2420
- */
2421
- this.trigger('redraw', { "nodes" : nodes });
2422
- },
2423
- /**
2424
- * redraws all nodes that need to be redrawn or optionally - the whole tree
2425
- * @name redraw([full])
2426
- * @param {Boolean} full if set to `true` all nodes are redrawn.
2427
- */
2428
- redraw : function (full) {
2429
- if(full) {
2430
- this._model.force_full_redraw = true;
2431
- }
2432
- //if(this._model.redraw_timeout) {
2433
- // clearTimeout(this._model.redraw_timeout);
2434
- //}
2435
- //this._model.redraw_timeout = setTimeout($.proxy(this._redraw, this),0);
2436
- this._redraw();
2437
- },
2438
- /**
2439
- * redraws a single node's children. Used internally.
2440
- * @private
2441
- * @name draw_children(node)
2442
- * @param {mixed} node the node whose children will be redrawn
2443
- */
2444
- draw_children : function (node) {
2445
- var obj = this.get_node(node),
2446
- i = false,
2447
- j = false,
2448
- k = false,
2449
- d = document;
2450
- if(!obj) { return false; }
2451
- if(obj.id === $.jstree.root) { return this.redraw(true); }
2452
- node = this.get_node(node, true);
2453
- if(!node || !node.length) { return false; } // TODO: quick toggle
2454
-
2455
- node.children('.jstree-children').remove();
2456
- node = node[0];
2457
- if(obj.children.length && obj.state.loaded) {
2458
- k = d.createElement('UL');
2459
- k.setAttribute('role', 'group');
2460
- k.className = 'jstree-children';
2461
- for(i = 0, j = obj.children.length; i < j; i++) {
2462
- k.appendChild(this.redraw_node(obj.children[i], true, true));
2463
- }
2464
- node.appendChild(k);
2465
- }
2466
- },
2467
- /**
2468
- * redraws a single node. Used internally.
2469
- * @private
2470
- * @name redraw_node(node, deep, is_callback, force_render)
2471
- * @param {mixed} node the node to redraw
2472
- * @param {Boolean} deep should child nodes be redrawn too
2473
- * @param {Boolean} is_callback is this a recursion call
2474
- * @param {Boolean} force_render should children of closed parents be drawn anyway
2475
- */
2476
- redraw_node : function (node, deep, is_callback, force_render) {
2477
- var obj = this.get_node(node),
2478
- par = false,
2479
- ind = false,
2480
- old = false,
2481
- i = false,
2482
- j = false,
2483
- k = false,
2484
- c = '',
2485
- d = document,
2486
- m = this._model.data,
2487
- f = false,
2488
- s = false,
2489
- tmp = null,
2490
- t = 0,
2491
- l = 0,
2492
- has_children = false,
2493
- last_sibling = false;
2494
- if(!obj) { return false; }
2495
- if(obj.id === $.jstree.root) { return this.redraw(true); }
2496
- deep = deep || obj.children.length === 0;
2497
- node = !document.querySelector ? document.getElementById(obj.id) : this.element[0].querySelector('#' + ("0123456789".indexOf(obj.id[0]) !== -1 ? '\\3' + obj.id[0] + ' ' + obj.id.substr(1).replace($.jstree.idregex,'\\$&') : obj.id.replace($.jstree.idregex,'\\$&')) ); //, this.element);
2498
- if(!node) {
2499
- deep = true;
2500
- //node = d.createElement('LI');
2501
- if(!is_callback) {
2502
- par = obj.parent !== $.jstree.root ? $('#' + obj.parent.replace($.jstree.idregex,'\\$&'), this.element)[0] : null;
2503
- if(par !== null && (!par || !m[obj.parent].state.opened)) {
2504
- return false;
2505
- }
2506
- ind = $.inArray(obj.id, par === null ? m[$.jstree.root].children : m[obj.parent].children);
2507
- }
2508
- }
2509
- else {
2510
- node = $(node);
2511
- if(!is_callback) {
2512
- par = node.parent().parent()[0];
2513
- if(par === this.element[0]) {
2514
- par = null;
2515
- }
2516
- ind = node.index();
2517
- }
2518
- // m[obj.id].data = node.data(); // use only node's data, no need to touch jquery storage
2519
- if(!deep && obj.children.length && !node.children('.jstree-children').length) {
2520
- deep = true;
2521
- }
2522
- if(!deep) {
2523
- old = node.children('.jstree-children')[0];
2524
- }
2525
- f = node.children('.jstree-anchor')[0] === document.activeElement;
2526
- node.remove();
2527
- //node = d.createElement('LI');
2528
- //node = node[0];
2529
- }
2530
- node = this._data.core.node.cloneNode(true);
2531
- // node is DOM, deep is boolean
2532
-
2533
- c = 'jstree-node ';
2534
- for(i in obj.li_attr) {
2535
- if(obj.li_attr.hasOwnProperty(i)) {
2536
- if(i === 'id') { continue; }
2537
- if(i !== 'class') {
2538
- node.setAttribute(i, obj.li_attr[i]);
2539
- }
2540
- else {
2541
- c += obj.li_attr[i];
2542
- }
2543
- }
2544
- }
2545
- if(!obj.a_attr.id) {
2546
- obj.a_attr.id = obj.id + '_anchor';
2547
- }
2548
- node.setAttribute('aria-selected', !!obj.state.selected);
2549
- node.childNodes[1].setAttribute('aria-selected', !!obj.state.selected);
2550
- node.setAttribute('aria-level', obj.parents.length);
2551
- node.childNodes[1].setAttribute('aria-level', obj.parents.length);
2552
-
2553
- node.setAttribute('aria-labelledby', obj.a_attr.id);
2554
- node.setAttribute('data-folder', obj.id);
2555
- if(obj.state.disabled) {
2556
- node.setAttribute('aria-disabled', true);
2557
- node.childNodes[1].setAttribute('aria-disabled', true);
2558
- }
2559
-
2560
- for(i = 0, j = obj.children.length; i < j; i++) {
2561
- if(!m[obj.children[i]].state.hidden) {
2562
- has_children = true;
2563
- break;
2564
- }
2565
- }
2566
- if(obj.parent !== null && m[obj.parent] && !obj.state.hidden) {
2567
- i = $.inArray(obj.id, m[obj.parent].children);
2568
- last_sibling = obj.id;
2569
- if(i !== -1) {
2570
- i++;
2571
- for(j = m[obj.parent].children.length; i < j; i++) {
2572
- if(!m[m[obj.parent].children[i]].state.hidden) {
2573
- last_sibling = m[obj.parent].children[i];
2574
- }
2575
- if(last_sibling !== obj.id) {
2576
- break;
2577
- }
2578
- }
2579
- }
2580
- }
2581
-
2582
- if(obj.state.hidden) {
2583
- c += ' jstree-hidden';
2584
- }
2585
- if (obj.state.loading) {
2586
- c += ' jstree-loading';
2587
- }
2588
- if(obj.state.loaded && !has_children) {
2589
- c += ' jstree-leaf';
2590
- }
2591
- else {
2592
- c += obj.state.opened && obj.state.loaded ? ' jstree-open' : ' jstree-closed';
2593
- node.setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) );
2594
- node.childNodes[1].setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) );
2595
- }
2596
- if(last_sibling === obj.id) {
2597
- c += ' jstree-last';
2598
- }
2599
- node.id = obj.id;
2600
- node.className = c;
2601
- c = ( obj.state.selected ? ' jstree-clicked' : '') + ( obj.state.disabled ? ' jstree-disabled' : '');
2602
- for(j in obj.a_attr) {
2603
- if(obj.a_attr.hasOwnProperty(j)) {
2604
- if(j === 'href' && obj.a_attr[j] === '#') { continue; }
2605
- if(j !== 'class') {
2606
- node.childNodes[1].setAttribute(j, obj.a_attr[j]);
2607
- }
2608
- else {
2609
- c += ' ' + obj.a_attr[j];
2610
- }
2611
- }
2612
- }
2613
- if(c.length) {
2614
- node.childNodes[1].className = 'jstree-anchor ' + c;
2615
- }
2616
- if((obj.icon && obj.icon !== true) || obj.icon === false) {
2617
- if(obj.icon === false) {
2618
- node.childNodes[1].childNodes[0].className += ' jstree-themeicon-hidden';
2619
- }
2620
- else if(obj.icon.indexOf('/') === -1 && obj.icon.indexOf('.') === -1) {
2621
- node.childNodes[1].childNodes[0].className += ' ' + obj.icon + ' jstree-themeicon-custom';
2622
- }
2623
- else {
2624
- node.childNodes[1].childNodes[0].style.backgroundImage = 'url("'+obj.icon+'")';
2625
- node.childNodes[1].childNodes[0].style.backgroundPosition = 'center center';
2626
- node.childNodes[1].childNodes[0].style.backgroundSize = 'auto';
2627
- node.childNodes[1].childNodes[0].className += ' jstree-themeicon-custom';
2628
- }
2629
- }
2630
-
2631
- if(this.settings.core.force_text) {
2632
- node.childNodes[1].appendChild(d.createTextNode(obj.text));
2633
- }
2634
- else {
2635
- node.childNodes[1].innerHTML += obj.text;
2636
- }
2637
-
2638
-
2639
- if(deep && obj.children.length && (obj.state.opened || force_render) && obj.state.loaded) {
2640
- k = d.createElement('UL');
2641
- k.setAttribute('role', 'group');
2642
- k.className = 'jstree-children';
2643
- for(i = 0, j = obj.children.length; i < j; i++) {
2644
- k.appendChild(this.redraw_node(obj.children[i], deep, true));
2645
- }
2646
- node.appendChild(k);
2647
- }
2648
- if(old) {
2649
- node.appendChild(old);
2650
- }
2651
- if(!is_callback) {
2652
- // append back using par / ind
2653
- if(!par) {
2654
- par = this.element[0];
2655
- }
2656
- for(i = 0, j = par.childNodes.length; i < j; i++) {
2657
- if(par.childNodes[i] && par.childNodes[i].className && par.childNodes[i].className.indexOf('jstree-children') !== -1) {
2658
- tmp = par.childNodes[i];
2659
- break;
2660
- }
2661
- }
2662
- if(!tmp) {
2663
- tmp = d.createElement('UL');
2664
- tmp.setAttribute('role', 'group');
2665
- tmp.className = 'jstree-children';
2666
- par.appendChild(tmp);
2667
- }
2668
- par = tmp;
2669
-
2670
- if(ind < par.childNodes.length) {
2671
- par.insertBefore(node, par.childNodes[ind]);
2672
- }
2673
- else {
2674
- par.appendChild(node);
2675
- }
2676
- if(f) {
2677
- t = this.element[0].scrollTop;
2678
- l = this.element[0].scrollLeft;
2679
- node.childNodes[1].focus();
2680
- this.element[0].scrollTop = t;
2681
- this.element[0].scrollLeft = l;
2682
- }
2683
- }
2684
- if(obj.state.opened && !obj.state.loaded) {
2685
- obj.state.opened = false;
2686
- setTimeout($.proxy(function () {
2687
- this.open_node(obj.id, false, 0);
2688
- }, this), 0);
2689
- }
2690
- return node;
2691
- },
2692
- /**
2693
- * opens a node, revealing its children. If the node is not loaded it will be loaded and opened once ready.
2694
- * @name open_node(obj [, callback, animation])
2695
- * @param {mixed} obj the node to open
2696
- * @param {Function} callback a function to execute once the node is opened
2697
- * @param {Number} animation the animation duration in milliseconds when opening the node (overrides the `core.animation` setting). Use `false` for no animation.
2698
- * @trigger open_node.jstree, after_open.jstree, before_open.jstree
2699
- */
2700
- open_node : function (obj, callback, animation) {
2701
- var t1, t2, d, t;
2702
- if($.isArray(obj)) {
2703
- obj = obj.slice();
2704
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2705
- this.open_node(obj[t1], callback, animation);
2706
- }
2707
- return true;
2708
- }
2709
- obj = this.get_node(obj);
2710
- if(!obj || obj.id === $.jstree.root) {
2711
- return false;
2712
- }
2713
- animation = animation === undefined ? this.settings.core.animation : animation;
2714
- if(!this.is_closed(obj)) {
2715
- if(callback) {
2716
- callback.call(this, obj, false);
2717
- }
2718
- return false;
2719
- }
2720
- if(!this.is_loaded(obj)) {
2721
- if(this.is_loading(obj)) {
2722
- return setTimeout($.proxy(function () {
2723
- this.open_node(obj, callback, animation);
2724
- }, this), 500);
2725
- }
2726
- this.load_node(obj, function (o, ok) {
2727
- return ok ? this.open_node(o, callback, animation) : (callback ? callback.call(this, o, false) : false);
2728
- });
2729
- }
2730
- else {
2731
- d = this.get_node(obj, true);
2732
- t = this;
2733
- if(d.length) {
2734
- if(animation && d.children(".jstree-children").length) {
2735
- d.children(".jstree-children").stop(true, true);
2736
- }
2737
- if(obj.children.length && !this._firstChild(d.children('.jstree-children')[0])) {
2738
- this.draw_children(obj);
2739
- //d = this.get_node(obj, true);
2740
- }
2741
- if(!animation) {
2742
- this.trigger('before_open', { "node" : obj });
2743
- d[0].className = d[0].className.replace('jstree-closed', 'jstree-open');
2744
- d[0].setAttribute("aria-expanded", true);
2745
- d[0].childNodes[1].setAttribute("aria-expanded", true);
2746
- }
2747
- else {
2748
- this.trigger('before_open', { "node" : obj });
2749
- d
2750
- .children(".jstree-children").css("display","none").end()
2751
- .removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded", true)
2752
- .children('.jstree-anchor').attr("aria-expanded", true).end()
2753
- .children(".jstree-children").stop(true, true)
2754
- .slideDown(animation, function () {
2755
- this.style.display = "";
2756
- if (t.element) {
2757
- t.trigger("after_open", { "node" : obj });
2758
- }
2759
- });
2760
- }
2761
- }
2762
- obj.state.opened = true;
2763
- if(callback) {
2764
- callback.call(this, obj, true);
2765
- }
2766
- if(!d.length) {
2767
- /**
2768
- * triggered when a node is about to be opened (if the node is supposed to be in the DOM, it will be, but it won't be visible yet)
2769
- * @event
2770
- * @name before_open.jstree
2771
- * @param {Object} node the opened node
2772
- */
2773
- this.trigger('before_open', { "node" : obj });
2774
- }
2775
- /**
2776
- * triggered when a node is opened (if there is an animation it will not be completed yet)
2777
- * @event
2778
- * @name open_node.jstree
2779
- * @param {Object} node the opened node
2780
- */
2781
- this.trigger('open_node', { "node" : obj });
2782
- if(!animation || !d.length) {
2783
- /**
2784
- * triggered when a node is opened and the animation is complete
2785
- * @event
2786
- * @name after_open.jstree
2787
- * @param {Object} node the opened node
2788
- */
2789
- this.trigger("after_open", { "node" : obj });
2790
- }
2791
- return true;
2792
- }
2793
- },
2794
- /**
2795
- * opens every parent of a node (node should be loaded)
2796
- * @name _open_to(obj)
2797
- * @param {mixed} obj the node to reveal
2798
- * @private
2799
- */
2800
- _open_to : function (obj) {
2801
- obj = this.get_node(obj);
2802
- if(!obj || obj.id === $.jstree.root) {
2803
- return false;
2804
- }
2805
- var i, j, p = obj.parents;
2806
- for(i = 0, j = p.length; i < j; i+=1) {
2807
- if(i !== $.jstree.root) {
2808
- this.open_node(p[i], false, 0);
2809
- }
2810
- }
2811
- return $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element);
2812
- },
2813
- /**
2814
- * closes a node, hiding its children
2815
- * @name close_node(obj [, animation])
2816
- * @param {mixed} obj the node to close
2817
- * @param {Number} animation the animation duration in milliseconds when closing the node (overrides the `core.animation` setting). Use `false` for no animation.
2818
- * @trigger close_node.jstree, after_close.jstree
2819
- */
2820
- close_node : function (obj, animation) {
2821
- var t1, t2, t, d;
2822
- if($.isArray(obj)) {
2823
- obj = obj.slice();
2824
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2825
- this.close_node(obj[t1], animation);
2826
- }
2827
- return true;
2828
- }
2829
- obj = this.get_node(obj);
2830
- if(!obj || obj.id === $.jstree.root) {
2831
- return false;
2832
- }
2833
- if(this.is_closed(obj)) {
2834
- return false;
2835
- }
2836
- animation = animation === undefined ? this.settings.core.animation : animation;
2837
- t = this;
2838
- d = this.get_node(obj, true);
2839
-
2840
- obj.state.opened = false;
2841
- /**
2842
- * triggered when a node is closed (if there is an animation it will not be complete yet)
2843
- * @event
2844
- * @name close_node.jstree
2845
- * @param {Object} node the closed node
2846
- */
2847
- this.trigger('close_node',{ "node" : obj });
2848
- if(!d.length) {
2849
- /**
2850
- * triggered when a node is closed and the animation is complete
2851
- * @event
2852
- * @name after_close.jstree
2853
- * @param {Object} node the closed node
2854
- */
2855
- this.trigger("after_close", { "node" : obj });
2856
- }
2857
- else {
2858
- if(!animation) {
2859
- d[0].className = d[0].className.replace('jstree-open', 'jstree-closed');
2860
- d.children('.jstree-anchor').attr("aria-expanded", false);
2861
- d.attr("aria-expanded", false).children('.jstree-children').remove();
2862
- this.trigger("after_close", { "node" : obj });
2863
- }
2864
- else {
2865
- d
2866
- .children(".jstree-children").attr("style","display:block !important").end()
2867
- .removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded", false)
2868
- .children('.jstree-anchor').attr("aria-expanded", false).end()
2869
- .children(".jstree-children").stop(true, true).slideUp(animation, function () {
2870
- this.style.display = "";
2871
- d.children('.jstree-children').remove();
2872
- if (t.element) {
2873
- t.trigger("after_close", { "node" : obj });
2874
- }
2875
- });
2876
- }
2877
- }
2878
- },
2879
- /**
2880
- * toggles a node - closing it if it is open, opening it if it is closed
2881
- * @name toggle_node(obj)
2882
- * @param {mixed} obj the node to toggle
2883
- */
2884
- toggle_node : function (obj) {
2885
- var t1, t2;
2886
- if($.isArray(obj)) {
2887
- obj = obj.slice();
2888
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2889
- this.toggle_node(obj[t1]);
2890
- }
2891
- return true;
2892
- }
2893
- if(this.is_closed(obj)) {
2894
- return this.open_node(obj);
2895
- }
2896
- if(this.is_open(obj)) {
2897
- return this.close_node(obj);
2898
- }
2899
- },
2900
- /**
2901
- * opens all nodes within a node (or the tree), revealing their children. If the node is not loaded it will be loaded and opened once ready.
2902
- * @name open_all([obj, animation, original_obj])
2903
- * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree
2904
- * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation
2905
- * @param {jQuery} reference to the node that started the process (internal use)
2906
- * @trigger open_all.jstree
2907
- */
2908
- open_all : function (obj, animation, original_obj) {
2909
- if(!obj) { obj = $.jstree.root; }
2910
- obj = this.get_node(obj);
2911
- if(!obj) { return false; }
2912
- var dom = obj.id === $.jstree.root ? this.get_container_ul() : this.get_node(obj, true), i, j, _this;
2913
- if(!dom.length) {
2914
- for(i = 0, j = obj.children_d.length; i < j; i++) {
2915
- if(this.is_closed(this._model.data[obj.children_d[i]])) {
2916
- this._model.data[obj.children_d[i]].state.opened = true;
2917
- }
2918
- }
2919
- return this.trigger('open_all', { "node" : obj });
2920
- }
2921
- original_obj = original_obj || dom;
2922
- _this = this;
2923
- dom = this.is_closed(obj) ? dom.find('.jstree-closed').addBack() : dom.find('.jstree-closed');
2924
- dom.each(function () {
2925
- _this.open_node(
2926
- this,
2927
- function(node, status) { if(status && this.is_parent(node)) { this.open_all(node, animation, original_obj); } },
2928
- animation || 0
2929
- );
2930
- });
2931
- if(original_obj.find('.jstree-closed').length === 0) {
2932
- /**
2933
- * triggered when an `open_all` call completes
2934
- * @event
2935
- * @name open_all.jstree
2936
- * @param {Object} node the opened node
2937
- */
2938
- this.trigger('open_all', { "node" : this.get_node(original_obj) });
2939
- }
2940
- },
2941
- /**
2942
- * closes all nodes within a node (or the tree), revealing their children
2943
- * @name close_all([obj, animation])
2944
- * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree
2945
- * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation
2946
- * @trigger close_all.jstree
2947
- */
2948
- close_all : function (obj, animation) {
2949
- if(!obj) { obj = $.jstree.root; }
2950
- obj = this.get_node(obj);
2951
- if(!obj) { return false; }
2952
- var dom = obj.id === $.jstree.root ? this.get_container_ul() : this.get_node(obj, true),
2953
- _this = this, i, j;
2954
- if(dom.length) {
2955
- dom = this.is_open(obj) ? dom.find('.jstree-open').addBack() : dom.find('.jstree-open');
2956
- $(dom.get().reverse()).each(function () { _this.close_node(this, animation || 0); });
2957
- }
2958
- for(i = 0, j = obj.children_d.length; i < j; i++) {
2959
- this._model.data[obj.children_d[i]].state.opened = false;
2960
- }
2961
- /**
2962
- * triggered when an `close_all` call completes
2963
- * @event
2964
- * @name close_all.jstree
2965
- * @param {Object} node the closed node
2966
- */
2967
- this.trigger('close_all', { "node" : obj });
2968
- },
2969
- /**
2970
- * checks if a node is disabled (not selectable)
2971
- * @name is_disabled(obj)
2972
- * @param {mixed} obj
2973
- * @return {Boolean}
2974
- */
2975
- is_disabled : function (obj) {
2976
- obj = this.get_node(obj);
2977
- return obj && obj.state && obj.state.disabled;
2978
- },
2979
- /**
2980
- * enables a node - so that it can be selected
2981
- * @name enable_node(obj)
2982
- * @param {mixed} obj the node to enable
2983
- * @trigger enable_node.jstree
2984
- */
2985
- enable_node : function (obj) {
2986
- var t1, t2;
2987
- if($.isArray(obj)) {
2988
- obj = obj.slice();
2989
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2990
- this.enable_node(obj[t1]);
2991
- }
2992
- return true;
2993
- }
2994
- obj = this.get_node(obj);
2995
- if(!obj || obj.id === $.jstree.root) {
2996
- return false;
2997
- }
2998
- obj.state.disabled = false;
2999
- this.get_node(obj,true).children('.jstree-anchor').removeClass('jstree-disabled').attr('aria-disabled', false);
3000
- /**
3001
- * triggered when an node is enabled
3002
- * @event
3003
- * @name enable_node.jstree
3004
- * @param {Object} node the enabled node
3005
- */
3006
- this.trigger('enable_node', { 'node' : obj });
3007
- },
3008
- /**
3009
- * disables a node - so that it can not be selected
3010
- * @name disable_node(obj)
3011
- * @param {mixed} obj the node to disable
3012
- * @trigger disable_node.jstree
3013
- */
3014
- disable_node : function (obj) {
3015
- var t1, t2;
3016
- if($.isArray(obj)) {
3017
- obj = obj.slice();
3018
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3019
- this.disable_node(obj[t1]);
3020
- }
3021
- return true;
3022
- }
3023
- obj = this.get_node(obj);
3024
- if(!obj || obj.id === $.jstree.root) {
3025
- return false;
3026
- }
3027
- obj.state.disabled = true;
3028
- this.get_node(obj,true).children('.jstree-anchor').addClass('jstree-disabled').attr('aria-disabled', true);
3029
- /**
3030
- * triggered when an node is disabled
3031
- * @event
3032
- * @name disable_node.jstree
3033
- * @param {Object} node the disabled node
3034
- */
3035
- this.trigger('disable_node', { 'node' : obj });
3036
- },
3037
- /**
3038
- * determines if a node is hidden
3039
- * @name is_hidden(obj)
3040
- * @param {mixed} obj the node
3041
- */
3042
- is_hidden : function (obj) {
3043
- obj = this.get_node(obj);
3044
- return obj.state.hidden === true;
3045
- },
3046
- /**
3047
- * hides a node - it is still in the structure but will not be visible
3048
- * @name hide_node(obj)
3049
- * @param {mixed} obj the node to hide
3050
- * @param {Boolean} skip_redraw internal parameter controlling if redraw is called
3051
- * @trigger hide_node.jstree
3052
- */
3053
- hide_node : function (obj, skip_redraw) {
3054
- var t1, t2;
3055
- if($.isArray(obj)) {
3056
- obj = obj.slice();
3057
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3058
- this.hide_node(obj[t1], true);
3059
- }
3060
- if (!skip_redraw) {
3061
- this.redraw();
3062
- }
3063
- return true;
3064
- }
3065
- obj = this.get_node(obj);
3066
- if(!obj || obj.id === $.jstree.root) {
3067
- return false;
3068
- }
3069
- if(!obj.state.hidden) {
3070
- obj.state.hidden = true;
3071
- this._node_changed(obj.parent);
3072
- if(!skip_redraw) {
3073
- this.redraw();
3074
- }
3075
- /**
3076
- * triggered when an node is hidden
3077
- * @event
3078
- * @name hide_node.jstree
3079
- * @param {Object} node the hidden node
3080
- */
3081
- this.trigger('hide_node', { 'node' : obj });
3082
- }
3083
- },
3084
- /**
3085
- * shows a node
3086
- * @name show_node(obj)
3087
- * @param {mixed} obj the node to show
3088
- * @param {Boolean} skip_redraw internal parameter controlling if redraw is called
3089
- * @trigger show_node.jstree
3090
- */
3091
- show_node : function (obj, skip_redraw) {
3092
- var t1, t2;
3093
- if($.isArray(obj)) {
3094
- obj = obj.slice();
3095
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3096
- this.show_node(obj[t1], true);
3097
- }
3098
- if (!skip_redraw) {
3099
- this.redraw();
3100
- }
3101
- return true;
3102
- }
3103
- obj = this.get_node(obj);
3104
- if(!obj || obj.id === $.jstree.root) {
3105
- return false;
3106
- }
3107
- if(obj.state.hidden) {
3108
- obj.state.hidden = false;
3109
- this._node_changed(obj.parent);
3110
- if(!skip_redraw) {
3111
- this.redraw();
3112
- }
3113
- /**
3114
- * triggered when an node is shown
3115
- * @event
3116
- * @name show_node.jstree
3117
- * @param {Object} node the shown node
3118
- */
3119
- this.trigger('show_node', { 'node' : obj });
3120
- }
3121
- },
3122
- /**
3123
- * hides all nodes
3124
- * @name hide_all()
3125
- * @trigger hide_all.jstree
3126
- */
3127
- hide_all : function (skip_redraw) {
3128
- var i, m = this._model.data, ids = [];
3129
- for(i in m) {
3130
- if(m.hasOwnProperty(i) && i !== $.jstree.root && !m[i].state.hidden) {
3131
- m[i].state.hidden = true;
3132
- ids.push(i);
3133
- }
3134
- }
3135
- this._model.force_full_redraw = true;
3136
- if(!skip_redraw) {
3137
- this.redraw();
3138
- }
3139
- /**
3140
- * triggered when all nodes are hidden
3141
- * @event
3142
- * @name hide_all.jstree
3143
- * @param {Array} nodes the IDs of all hidden nodes
3144
- */
3145
- this.trigger('hide_all', { 'nodes' : ids });
3146
- return ids;
3147
- },
3148
- /**
3149
- * shows all nodes
3150
- * @name show_all()
3151
- * @trigger show_all.jstree
3152
- */
3153
- show_all : function (skip_redraw) {
3154
- var i, m = this._model.data, ids = [];
3155
- for(i in m) {
3156
- if(m.hasOwnProperty(i) && i !== $.jstree.root && m[i].state.hidden) {
3157
- m[i].state.hidden = false;
3158
- ids.push(i);
3159
- }
3160
- }
3161
- this._model.force_full_redraw = true;
3162
- if(!skip_redraw) {
3163
- this.redraw();
3164
- }
3165
- /**
3166
- * triggered when all nodes are shown
3167
- * @event
3168
- * @name show_all.jstree
3169
- * @param {Array} nodes the IDs of all shown nodes
3170
- */
3171
- this.trigger('show_all', { 'nodes' : ids });
3172
- return ids;
3173
- },
3174
- /**
3175
- * called when a node is selected by the user. Used internally.
3176
- * @private
3177
- * @name activate_node(obj, e)
3178
- * @param {mixed} obj the node
3179
- * @param {Object} e the related event
3180
- * @trigger activate_node.jstree, changed.jstree
3181
- */
3182
- activate_node : function (obj, e) {
3183
- if(typeof e.isTrigger !== "undefined" && e.isTrigger >0) {
3184
- return false;
3185
- }
3186
- if(this.is_disabled(obj)) {
3187
- return false;
3188
- }
3189
- if(!e || typeof e !== 'object') {
3190
- e = {};
3191
- }
3192
-
3193
- // ensure last_clicked is still in the DOM, make it fresh (maybe it was moved?) and make sure it is still selected, if not - make last_clicked the last selected node
3194
- this._data.core.last_clicked = this._data.core.last_clicked && this._data.core.last_clicked.id !== undefined ? this.get_node(this._data.core.last_clicked.id) : null;
3195
- if(this._data.core.last_clicked && !this._data.core.last_clicked.state.selected) { this._data.core.last_clicked = null; }
3196
- if(!this._data.core.last_clicked && this._data.core.selected.length) { this._data.core.last_clicked = this.get_node(this._data.core.selected[this._data.core.selected.length - 1]); }
3197
-
3198
- if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {
3199
- if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
3200
- this.deselect_node(obj, false, e);
3201
- }
3202
- else {
3203
- this.deselect_all(true);
3204
- this.select_node(obj, false, false, e);
3205
- this._data.core.last_clicked = this.get_node(obj);
3206
- }
3207
- }
3208
- else {
3209
- if(e.shiftKey) {
3210
- var o = this.get_node(obj).id,
3211
- l = this._data.core.last_clicked.id,
3212
- p = this.get_node(this._data.core.last_clicked.parent).children,
3213
- c = false,
3214
- i, j;
3215
- for(i = 0, j = p.length; i < j; i += 1) {
3216
- // separate IFs work whem o and l are the same
3217
- if(p[i] === o) {
3218
- c = !c;
3219
- }
3220
- if(p[i] === l) {
3221
- c = !c;
3222
- }
3223
- if(!this.is_disabled(p[i]) && (c || p[i] === o || p[i] === l)) {
3224
- if (!this.is_hidden(p[i])) {
3225
- this.select_node(p[i], true, false, e);
3226
- }
3227
- }
3228
- else {
3229
- this.deselect_node(p[i], true, e);
3230
- }
3231
- }
3232
- this.trigger('changed', { 'action' : 'select_node', 'node' : this.get_node(obj), 'selected' : this._data.core.selected, 'event' : e });
3233
- }
3234
- else {
3235
- if(!this.is_selected(obj)) {
3236
- this.select_node(obj, false, false, e);
3237
- }
3238
- else {
3239
- this.deselect_node(obj, false, e);
3240
- }
3241
- }
3242
- }
3243
- /**
3244
- * triggered when an node is clicked or intercated with by the user
3245
- * @event
3246
- * @name activate_node.jstree
3247
- * @param {Object} node
3248
- * @param {Object} event the ooriginal event (if any) which triggered the call (may be an empty object)
3249
- */
3250
- this.trigger('activate_node', { 'node' : this.get_node(obj), 'event' : e });
3251
- },
3252
- /**
3253
- * applies the hover state on a node, called when a node is hovered by the user. Used internally.
3254
- * @private
3255
- * @name hover_node(obj)
3256
- * @param {mixed} obj
3257
- * @trigger hover_node.jstree
3258
- */
3259
- hover_node : function (obj) {
3260
- obj = this.get_node(obj, true);
3261
- if(!obj || !obj.length || obj.children('.jstree-hovered').length) {
3262
- return false;
3263
- }
3264
- var o = this.element.find('.jstree-hovered'), t = this.element;
3265
- if(o && o.length) { this.dehover_node(o); }
3266
-
3267
- obj.children('.jstree-anchor').addClass('jstree-hovered');
3268
- /**
3269
- * triggered when an node is hovered
3270
- * @event
3271
- * @name hover_node.jstree
3272
- * @param {Object} node
3273
- */
3274
- this.trigger('hover_node', { 'node' : this.get_node(obj) });
3275
- setTimeout(function () { t.attr('aria-activedescendant', obj[0].id); }, 0);
3276
- },
3277
- /**
3278
- * removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally.
3279
- * @private
3280
- * @name dehover_node(obj)
3281
- * @param {mixed} obj
3282
- * @trigger dehover_node.jstree
3283
- */
3284
- dehover_node : function (obj) {
3285
- obj = this.get_node(obj, true);
3286
- if(!obj || !obj.length || !obj.children('.jstree-hovered').length) {
3287
- return false;
3288
- }
3289
- obj.children('.jstree-anchor').removeClass('jstree-hovered');
3290
- /**
3291
- * triggered when an node is no longer hovered
3292
- * @event
3293
- * @name dehover_node.jstree
3294
- * @param {Object} node
3295
- */
3296
- this.trigger('dehover_node', { 'node' : this.get_node(obj) });
3297
- },
3298
- /**
3299
- * select a node
3300
- * @name select_node(obj [, supress_event, prevent_open])
3301
- * @param {mixed} obj an array can be used to select multiple nodes
3302
- * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3303
- * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened
3304
- * @trigger select_node.jstree, changed.jstree
3305
- */
3306
- select_node : function (obj, supress_event, prevent_open, e) {
3307
- var dom, t1, t2, th;
3308
- if($.isArray(obj)) {
3309
- obj = obj.slice();
3310
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3311
- this.select_node(obj[t1], supress_event, prevent_open, e);
3312
- }
3313
- return true;
3314
- }
3315
- obj = this.get_node(obj);
3316
- if(!obj || obj.id === $.jstree.root) {
3317
- return false;
3318
- }
3319
- dom = this.get_node(obj, true);
3320
- if(!obj.state.selected) {
3321
- obj.state.selected = true;
3322
- this._data.core.selected.push(obj.id);
3323
- if(!prevent_open) {
3324
- dom = this._open_to(obj);
3325
- }
3326
- if(dom && dom.length) {
3327
- dom.attr('aria-selected', true).children('.jstree-anchor').addClass('jstree-clicked').attr('aria-selected', true);
3328
- }
3329
- /**
3330
- * triggered when an node is selected
3331
- * @event
3332
- * @name select_node.jstree
3333
- * @param {Object} node
3334
- * @param {Array} selected the current selection
3335
- * @param {Object} event the event (if any) that triggered this select_node
3336
- */
3337
- this.trigger('select_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3338
- if(!supress_event) {
3339
- /**
3340
- * triggered when selection changes
3341
- * @event
3342
- * @name changed.jstree
3343
- * @param {Object} node
3344
- * @param {Object} action the action that caused the selection to change
3345
- * @param {Array} selected the current selection
3346
- * @param {Object} event the event (if any) that triggered this changed event
3347
- */
3348
- this.trigger('changed', { 'action' : 'select_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3349
- }
3350
- }
3351
- },
3352
- /**
3353
- * deselect a node
3354
- * @name deselect_node(obj [, supress_event])
3355
- * @param {mixed} obj an array can be used to deselect multiple nodes
3356
- * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3357
- * @trigger deselect_node.jstree, changed.jstree
3358
- */
3359
- deselect_node : function (obj, supress_event, e) {
3360
- var t1, t2, dom;
3361
- if($.isArray(obj)) {
3362
- obj = obj.slice();
3363
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3364
- this.deselect_node(obj[t1], supress_event, e);
3365
- }
3366
- return true;
3367
- }
3368
- obj = this.get_node(obj);
3369
- if(!obj || obj.id === $.jstree.root) {
3370
- return false;
3371
- }
3372
- dom = this.get_node(obj, true);
3373
- if(obj.state.selected) {
3374
- obj.state.selected = false;
3375
- this._data.core.selected = $.vakata.array_remove_item(this._data.core.selected, obj.id);
3376
- if(dom.length) {
3377
- dom.attr('aria-selected', false).children('.jstree-anchor').removeClass('jstree-clicked').attr('aria-selected', false);
3378
- }
3379
- /**
3380
- * triggered when an node is deselected
3381
- * @event
3382
- * @name deselect_node.jstree
3383
- * @param {Object} node
3384
- * @param {Array} selected the current selection
3385
- * @param {Object} event the event (if any) that triggered this deselect_node
3386
- */
3387
- this.trigger('deselect_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3388
- if(!supress_event) {
3389
- this.trigger('changed', { 'action' : 'deselect_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3390
- }
3391
- }
3392
- },
3393
- /**
3394
- * select all nodes in the tree
3395
- * @name select_all([supress_event])
3396
- * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3397
- * @trigger select_all.jstree, changed.jstree
3398
- */
3399
- select_all : function (supress_event) {
3400
- var tmp = this._data.core.selected.concat([]), i, j;
3401
- this._data.core.selected = this._model.data[$.jstree.root].children_d.concat();
3402
- for(i = 0, j = this._data.core.selected.length; i < j; i++) {
3403
- if(this._model.data[this._data.core.selected[i]]) {
3404
- this._model.data[this._data.core.selected[i]].state.selected = true;
3405
- }
3406
- }
3407
- this.redraw(true);
3408
- /**
3409
- * triggered when all nodes are selected
3410
- * @event
3411
- * @name select_all.jstree
3412
- * @param {Array} selected the current selection
3413
- */
3414
- this.trigger('select_all', { 'selected' : this._data.core.selected });
3415
- if(!supress_event) {
3416
- this.trigger('changed', { 'action' : 'select_all', 'selected' : this._data.core.selected, 'old_selection' : tmp });
3417
- }
3418
- },
3419
- /**
3420
- * deselect all selected nodes
3421
- * @name deselect_all([supress_event])
3422
- * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3423
- * @trigger deselect_all.jstree, changed.jstree
3424
- */
3425
- deselect_all : function (supress_event) {
3426
- var tmp = this._data.core.selected.concat([]), i, j;
3427
- for(i = 0, j = this._data.core.selected.length; i < j; i++) {
3428
- if(this._model.data[this._data.core.selected[i]]) {
3429
- this._model.data[this._data.core.selected[i]].state.selected = false;
3430
- }
3431
- }
3432
- this._data.core.selected = [];
3433
- this.element.find('.jstree-clicked').removeClass('jstree-clicked').attr('aria-selected', false).parent().attr('aria-selected', false);
3434
- /**
3435
- * triggered when all nodes are deselected
3436
- * @event
3437
- * @name deselect_all.jstree
3438
- * @param {Object} node the previous selection
3439
- * @param {Array} selected the current selection
3440
- */
3441
- this.trigger('deselect_all', { 'selected' : this._data.core.selected, 'node' : tmp });
3442
- if(!supress_event) {
3443
- this.trigger('changed', { 'action' : 'deselect_all', 'selected' : this._data.core.selected, 'old_selection' : tmp });
3444
- }
3445
- },
3446
- /**
3447
- * checks if a node is selected
3448
- * @name is_selected(obj)
3449
- * @param {mixed} obj
3450
- * @return {Boolean}
3451
- */
3452
- is_selected : function (obj) {
3453
- obj = this.get_node(obj);
3454
- if(!obj || obj.id === $.jstree.root) {
3455
- return false;
3456
- }
3457
- return obj.state.selected;
3458
- },
3459
- /**
3460
- * get an array of all selected nodes
3461
- * @name get_selected([full])
3462
- * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
3463
- * @return {Array}
3464
- */
3465
- get_selected : function (full) {
3466
- return full ? $.map(this._data.core.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.core.selected.slice();
3467
- },
3468
- /**
3469
- * get an array of all top level selected nodes (ignoring children of selected nodes)
3470
- * @name get_top_selected([full])
3471
- * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
3472
- * @return {Array}
3473
- */
3474
- get_top_selected : function (full) {
3475
- var tmp = this.get_selected(true),
3476
- obj = {}, i, j, k, l;
3477
- for(i = 0, j = tmp.length; i < j; i++) {
3478
- obj[tmp[i].id] = tmp[i];
3479
- }
3480
- for(i = 0, j = tmp.length; i < j; i++) {
3481
- for(k = 0, l = tmp[i].children_d.length; k < l; k++) {
3482
- if(obj[tmp[i].children_d[k]]) {
3483
- delete obj[tmp[i].children_d[k]];
3484
- }
3485
- }
3486
- }
3487
- tmp = [];
3488
- for(i in obj) {
3489
- if(obj.hasOwnProperty(i)) {
3490
- tmp.push(i);
3491
- }
3492
- }
3493
- return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp;
3494
- },
3495
- /**
3496
- * get an array of all bottom level selected nodes (ignoring selected parents)
3497
- * @name get_bottom_selected([full])
3498
- * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
3499
- * @return {Array}
3500
- */
3501
- get_bottom_selected : function (full) {
3502
- var tmp = this.get_selected(true),
3503
- obj = [], i, j;
3504
- for(i = 0, j = tmp.length; i < j; i++) {
3505
- if(!tmp[i].children.length) {
3506
- obj.push(tmp[i].id);
3507
- }
3508
- }
3509
- return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj;
3510
- },
3511
- /**
3512
- * gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally.
3513
- * @name get_state()
3514
- * @private
3515
- * @return {Object}
3516
- */
3517
- get_state : function () {
3518
- var state = {
3519
- 'core' : {
3520
- 'open' : [],
3521
- 'loaded' : [],
3522
- 'scroll' : {
3523
- 'left' : this.element.scrollLeft(),
3524
- 'top' : this.element.scrollTop()
3525
- },
3526
- /*!
3527
- 'themes' : {
3528
- 'name' : this.get_theme(),
3529
- 'icons' : this._data.core.themes.icons,
3530
- 'dots' : this._data.core.themes.dots
3531
- },
3532
- */
3533
- 'selected' : []
3534
- }
3535
- }, i;
3536
- for(i in this._model.data) {
3537
- if(this._model.data.hasOwnProperty(i)) {
3538
- if(i !== $.jstree.root) {
3539
- if(this._model.data[i].state.loaded && this.settings.core.loaded_state) {
3540
- state.core.loaded.push(i);
3541
- }
3542
- if(this._model.data[i].state.opened) {
3543
- state.core.open.push(i);
3544
- }
3545
- if(this._model.data[i].state.selected) {
3546
- state.core.selected.push(i);
3547
- }
3548
- }
3549
- }
3550
- }
3551
- return state;
3552
- },
3553
- /**
3554
- * sets the state of the tree. Used internally.
3555
- * @name set_state(state [, callback])
3556
- * @private
3557
- * @param {Object} state the state to restore. Keep in mind this object is passed by reference and jstree will modify it.
3558
- * @param {Function} callback an optional function to execute once the state is restored.
3559
- * @trigger set_state.jstree
3560
- */
3561
- set_state : function (state, callback) {
3562
- if(state) {
3563
- if(state.core && state.core.selected && state.core.initial_selection === undefined) {
3564
- state.core.initial_selection = this._data.core.selected.concat([]).sort().join(',');
3565
- }
3566
- if(state.core) {
3567
- var res, n, t, _this, i;
3568
- if(state.core.loaded) {
3569
- if(!this.settings.core.loaded_state || !$.isArray(state.core.loaded) || !state.core.loaded.length) {
3570
- delete state.core.loaded;
3571
- this.set_state(state, callback);
3572
- }
3573
- else {
3574
- this._load_nodes(state.core.loaded, function (nodes) {
3575
- delete state.core.loaded;
3576
- this.set_state(state, callback);
3577
- });
3578
- }
3579
- return false;
3580
- }
3581
- if(state.core.open) {
3582
- if(!$.isArray(state.core.open) || !state.core.open.length) {
3583
- delete state.core.open;
3584
- this.set_state(state, callback);
3585
- }
3586
- else {
3587
- this._load_nodes(state.core.open, function (nodes) {
3588
- this.open_node(nodes, false, 0);
3589
- delete state.core.open;
3590
- this.set_state(state, callback);
3591
- });
3592
- }
3593
- return false;
3594
- }
3595
- if(state.core.scroll) {
3596
- if(state.core.scroll && state.core.scroll.left !== undefined) {
3597
- this.element.scrollLeft(state.core.scroll.left);
3598
- }
3599
- if(state.core.scroll && state.core.scroll.top !== undefined) {
3600
- this.element.scrollTop(state.core.scroll.top);
3601
- }
3602
- delete state.core.scroll;
3603
- this.set_state(state, callback);
3604
- return false;
3605
- }
3606
- if(state.core.selected) {
3607
- _this = this;
3608
- if (state.core.initial_selection === undefined ||
3609
- state.core.initial_selection === this._data.core.selected.concat([]).sort().join(',')
3610
- ) {
3611
- this.deselect_all();
3612
- $.each(state.core.selected, function (i, v) {
3613
- _this.select_node(v, false, true);
3614
- });
3615
- }
3616
- delete state.core.initial_selection;
3617
- delete state.core.selected;
3618
- this.set_state(state, callback);
3619
- return false;
3620
- }
3621
- for(i in state) {
3622
- if(state.hasOwnProperty(i) && i !== "core" && $.inArray(i, this.settings.plugins) === -1) {
3623
- delete state[i];
3624
- }
3625
- }
3626
- if($.isEmptyObject(state.core)) {
3627
- delete state.core;
3628
- this.set_state(state, callback);
3629
- return false;
3630
- }
3631
- }
3632
- if($.isEmptyObject(state)) {
3633
- state = null;
3634
- if(callback) { callback.call(this); }
3635
- /**
3636
- * triggered when a `set_state` call completes
3637
- * @event
3638
- * @name set_state.jstree
3639
- */
3640
- this.trigger('set_state');
3641
- return false;
3642
- }
3643
- return true;
3644
- }
3645
- return false;
3646
- },
3647
- /**
3648
- * refreshes the tree - all nodes are reloaded with calls to `load_node`.
3649
- * @name refresh()
3650
- * @param {Boolean} skip_loading an option to skip showing the loading indicator
3651
- * @param {Mixed} forget_state if set to `true` state will not be reapplied, if set to a function (receiving the current state as argument) the result of that function will be used as state
3652
- * @trigger refresh.jstree
3653
- */
3654
- refresh : function (skip_loading, forget_state) {
3655
- this._data.core.state = forget_state === true ? {} : this.get_state();
3656
- if(forget_state && $.isFunction(forget_state)) { this._data.core.state = forget_state.call(this, this._data.core.state); }
3657
- this._cnt = 0;
3658
- this._model.data = {};
3659
- this._model.data[$.jstree.root] = {
3660
- id : $.jstree.root,
3661
- parent : null,
3662
- parents : [],
3663
- children : [],
3664
- children_d : [],
3665
- state : { loaded : false }
3666
- };
3667
- this._data.core.selected = [];
3668
- this._data.core.last_clicked = null;
3669
- this._data.core.focused = null;
3670
-
3671
- var c = this.get_container_ul()[0].className;
3672
- if(!skip_loading) {
3673
- this.element.html("<"+"ul class='"+c+"' role='group'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='presentation' id='j"+this._id+"_loading'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden pfolder-folder-close'></i>" + this.get_string("Loading ...") + "</a></li></ul>");
3674
- this.element.attr('aria-activedescendant','j'+this._id+'_loading');
3675
- }
3676
- this.load_node($.jstree.root, function (o, s) {
3677
- if(s) {
3678
- this.get_container_ul()[0].className = c;
3679
- if(this._firstChild(this.get_container_ul()[0])) {
3680
- this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id);
3681
- }
3682
- this.set_state($.extend(true, {}, this._data.core.state), function () {
3683
- /**
3684
- * triggered when a `refresh` call completes
3685
- * @event
3686
- * @name refresh.jstree
3687
- */
3688
- this.trigger('refresh');
3689
- });
3690
- }
3691
- this._data.core.state = null;
3692
- });
3693
- },
3694
- /**
3695
- * refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`.
3696
- * @name refresh_node(obj)
3697
- * @param {mixed} obj the node
3698
- * @trigger refresh_node.jstree
3699
- */
3700
- refresh_node : function (obj) {
3701
- obj = this.get_node(obj);
3702
- if(!obj || obj.id === $.jstree.root) { return false; }
3703
- var opened = [], to_load = [], s = this._data.core.selected.concat([]);
3704
- to_load.push(obj.id);
3705
- if(obj.state.opened === true) { opened.push(obj.id); }
3706
- this.get_node(obj, true).find('.jstree-open').each(function() { to_load.push(this.id); opened.push(this.id); });
3707
- this._load_nodes(to_load, $.proxy(function (nodes) {
3708
- this.open_node(opened, false, 0);
3709
- this.select_node(s);
3710
- /**
3711
- * triggered when a node is refreshed
3712
- * @event
3713
- * @name refresh_node.jstree
3714
- * @param {Object} node - the refreshed node
3715
- * @param {Array} nodes - an array of the IDs of the nodes that were reloaded
3716
- */
3717
- this.trigger('refresh_node', { 'node' : obj, 'nodes' : nodes });
3718
- }, this), false, true);
3719
- },
3720
- /**
3721
- * set (change) the ID of a node
3722
- * @name set_id(obj, id)
3723
- * @param {mixed} obj the node
3724
- * @param {String} id the new ID
3725
- * @return {Boolean}
3726
- * @trigger set_id.jstree
3727
- */
3728
- set_id : function (obj, id) {
3729
- obj = this.get_node(obj);
3730
- if(!obj || obj.id === $.jstree.root) { return false; }
3731
- var i, j, m = this._model.data, old = obj.id;
3732
- id = id.toString();
3733
- // update parents (replace current ID with new one in children and children_d)
3734
- m[obj.parent].children[$.inArray(obj.id, m[obj.parent].children)] = id;
3735
- for(i = 0, j = obj.parents.length; i < j; i++) {
3736
- m[obj.parents[i]].children_d[$.inArray(obj.id, m[obj.parents[i]].children_d)] = id;
3737
- }
3738
- // update children (replace current ID with new one in parent and parents)
3739
- for(i = 0, j = obj.children.length; i < j; i++) {
3740
- m[obj.children[i]].parent = id;
3741
- }
3742
- for(i = 0, j = obj.children_d.length; i < j; i++) {
3743
- m[obj.children_d[i]].parents[$.inArray(obj.id, m[obj.children_d[i]].parents)] = id;
3744
- }
3745
- i = $.inArray(obj.id, this._data.core.selected);
3746
- if(i !== -1) { this._data.core.selected[i] = id; }
3747
- // update model and obj itself (obj.id, this._model.data[KEY])
3748
- i = this.get_node(obj.id, true);
3749
- if(i) {
3750
- i.attr('id', id); //.children('.jstree-anchor').attr('id', id + '_anchor').end().attr('aria-labelledby', id + '_anchor');
3751
- if(this.element.attr('aria-activedescendant') === obj.id) {
3752
- this.element.attr('aria-activedescendant', id);
3753
- }
3754
- }
3755
- delete m[obj.id];
3756
- obj.id = id;
3757
- obj.li_attr.id = id;
3758
- m[id] = obj;
3759
- /**
3760
- * triggered when a node id value is changed
3761
- * @event
3762
- * @name set_id.jstree
3763
- * @param {Object} node
3764
- * @param {String} old the old id
3765
- */
3766
- this.trigger('set_id',{ "node" : obj, "new" : obj.id, "old" : old });
3767
- return true;
3768
- },
3769
- /**
3770
- * get the text value of a node
3771
- * @name get_text(obj)
3772
- * @param {mixed} obj the node
3773
- * @return {String}
3774
- */
3775
- get_text : function (obj) {
3776
- obj = this.get_node(obj);
3777
- return (!obj || obj.id === $.jstree.root) ? false : obj.text;
3778
- },
3779
- /**
3780
- * set the text value of a node. Used internally, please use `rename_node(obj, val)`.
3781
- * @private
3782
- * @name set_text(obj, val)
3783
- * @param {mixed} obj the node, you can pass an array to set the text on multiple nodes
3784
- * @param {String} val the new text value
3785
- * @return {Boolean}
3786
- * @trigger set_text.jstree
3787
- */
3788
- set_text : function (obj, val) {
3789
- var t1, t2;
3790
- if($.isArray(obj)) {
3791
- obj = obj.slice();
3792
- console.log(obj);
3793
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3794
- this.set_text(obj[t1], val);
3795
- }
3796
- return true;
3797
- }
3798
- obj = this.get_node(obj);
3799
- if(!obj || obj.id === $.jstree.root) { return false; }
3800
- obj.text = val;
3801
- if(this.get_node(obj, true).length) {
3802
- this.redraw_node(obj.id);
3803
- }
3804
- /**
3805
- * triggered when a node text value is changed
3806
- * @event
3807
- * @name set_text.jstree
3808
- * @param {Object} obj
3809
- * @param {String} text the new value
3810
- */
3811
- this.trigger('set_text',{ "obj" : obj, "text" : val });
3812
- return true;
3813
- },
3814
- /**
3815
- * gets a JSON representation of a node (or the whole tree)
3816
- * @name get_json([obj, options])
3817
- * @param {mixed} obj
3818
- * @param {Object} options
3819
- * @param {Boolean} options.no_state do not return state information
3820
- * @param {Boolean} options.no_id do not return ID
3821
- * @param {Boolean} options.no_children do not include children
3822
- * @param {Boolean} options.no_data do not include node data
3823
- * @param {Boolean} options.no_li_attr do not include LI attributes
3824
- * @param {Boolean} options.no_a_attr do not include A attributes
3825
- * @param {Boolean} options.flat return flat JSON instead of nested
3826
- * @return {Object}
3827
- */
3828
- get_json : function (obj, options, flat) {
3829
- obj = this.get_node(obj || $.jstree.root);
3830
- if(!obj) { return false; }
3831
- if(options && options.flat && !flat) { flat = []; }
3832
- var tmp = {
3833
- 'id' : obj.id,
3834
- 'text' : obj.text,
3835
- 'icon' : this.get_icon(obj),
3836
- 'li_attr' : $.extend(true, {}, obj.li_attr),
3837
- 'a_attr' : $.extend(true, {}, obj.a_attr),
3838
- 'state' : {},
3839
- 'data' : options && options.no_data ? false : $.extend(true, $.isArray(obj.data)?[]:{}, obj.data)
3840
- //( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ),
3841
- }, i, j;
3842
- if(options && options.flat) {
3843
- tmp.parent = obj.parent;
3844
- }
3845
- else {
3846
- tmp.children = [];
3847
- }
3848
- if(!options || !options.no_state) {
3849
- for(i in obj.state) {
3850
- if(obj.state.hasOwnProperty(i)) {
3851
- tmp.state[i] = obj.state[i];
3852
- }
3853
- }
3854
- } else {
3855
- delete tmp.state;
3856
- }
3857
- if(options && options.no_li_attr) {
3858
- delete tmp.li_attr;
3859
- }
3860
- if(options && options.no_a_attr) {
3861
- delete tmp.a_attr;
3862
- }
3863
- if(options && options.no_id) {
3864
- delete tmp.id;
3865
- if(tmp.li_attr && tmp.li_attr.id) {
3866
- delete tmp.li_attr.id;
3867
- }
3868
- if(tmp.a_attr && tmp.a_attr.id) {
3869
- delete tmp.a_attr.id;
3870
- }
3871
- }
3872
- if(options && options.flat && obj.id !== $.jstree.root) {
3873
- flat.push(tmp);
3874
- }
3875
- if(!options || !options.no_children) {
3876
- for(i = 0, j = obj.children.length; i < j; i++) {
3877
- if(options && options.flat) {
3878
- this.get_json(obj.children[i], options, flat);
3879
- }
3880
- else {
3881
- tmp.children.push(this.get_json(obj.children[i], options));
3882
- }
3883
- }
3884
- }
3885
- return options && options.flat ? flat : (obj.id === $.jstree.root ? tmp.children : tmp);
3886
- },
3887
- /**
3888
- * create a new node (do not confuse with load_node)
3889
- * @name create_node([par, node, pos, callback, is_loaded])
3890
- * @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`)
3891
- * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name)
3892
- * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last"
3893
- * @param {Function} callback a function to be called once the node is created
3894
- * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded
3895
- * @return {String} the ID of the newly create node
3896
- * @trigger model.jstree, create_node.jstree
3897
- */
3898
- create_node : function (par, node, pos, callback, is_loaded) {
3899
- if(par === null) { par = $.jstree.root; }
3900
- par = this.get_node(par);
3901
- if(!par) { return false; }
3902
- pos = pos === undefined ? "last" : pos;
3903
- if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
3904
- return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); });
3905
- }
3906
- if(!node) { node = { "text" : this.get_string('New node') }; }
3907
- if(typeof node === "string") {
3908
- node = { "text" : node };
3909
- } else {
3910
- node = $.extend(true, {}, node);
3911
- }
3912
- if(node.text === undefined) { node.text = this.get_string('New node'); }
3913
- var tmp, dpc, i, j;
3914
-
3915
- if(par.id === $.jstree.root) {
3916
- if(pos === "before") { pos = "first"; }
3917
- if(pos === "after") { pos = "last"; }
3918
- }
3919
- switch(pos) {
3920
- case "before":
3921
- tmp = this.get_node(par.parent);
3922
- pos = $.inArray(par.id, tmp.children);
3923
- par = tmp;
3924
- break;
3925
- case "after" :
3926
- tmp = this.get_node(par.parent);
3927
- pos = $.inArray(par.id, tmp.children) + 1;
3928
- par = tmp;
3929
- break;
3930
- case "inside":
3931
- case "first":
3932
- pos = 0;
3933
- break;
3934
- case "last":
3935
- pos = par.children.length;
3936
- break;
3937
- default:
3938
- if(!pos) { pos = 0; }
3939
- break;
3940
- }
3941
- if(pos > par.children.length) { pos = par.children.length; }
3942
- if(!node.id) { node.id = true; }
3943
- if(!this.check("create_node", node, par, pos)) {
3944
- this.settings.core.error.call(this, this._data.core.last_error);
3945
- return false;
3946
- }
3947
- if(node.id === true) { delete node.id; }
3948
- node = this._parse_model_from_json(node, par.id, par.parents.concat());
3949
- if(!node) { return false; }
3950
- tmp = this.get_node(node);
3951
- dpc = [];
3952
- dpc.push(node);
3953
- dpc = dpc.concat(tmp.children_d);
3954
- this.trigger('model', { "nodes" : dpc, "parent" : par.id });
3955
-
3956
- par.children_d = par.children_d.concat(dpc);
3957
- for(i = 0, j = par.parents.length; i < j; i++) {
3958
- this._model.data[par.parents[i]].children_d = this._model.data[par.parents[i]].children_d.concat(dpc);
3959
- }
3960
- node = tmp;
3961
- tmp = [];
3962
- for(i = 0, j = par.children.length; i < j; i++) {
3963
- tmp[i >= pos ? i+1 : i] = par.children[i];
3964
- }
3965
- tmp[pos] = node.id;
3966
- par.children = tmp;
3967
-
3968
- this.redraw_node(par, true);
3969
- /**
3970
- * triggered when a node is created
3971
- * @event
3972
- * @name create_node.jstree
3973
- * @param {Object} node
3974
- * @param {String} parent the parent's ID
3975
- * @param {Number} position the position of the new node among the parent's children
3976
- */
3977
- this.trigger('create_node', { "node" : this.get_node(node), "parent" : par.id, "position" : pos });
3978
- if(callback) { callback.call(this, this.get_node(node)); }
3979
- return node.id;
3980
- },
3981
- /**
3982
- * set the text value of a node
3983
- * @name rename_node(obj, val)
3984
- * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name
3985
- * @param {String} val the new text value
3986
- * @return {Boolean}
3987
- * @trigger rename_node.jstree
3988
- */
3989
- rename_node : function (obj, val) {
3990
- var t1, t2, old;
3991
- if($.isArray(obj)) {
3992
- obj = obj.slice();
3993
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3994
- this.rename_node(obj[t1], val);
3995
- }
3996
- return true;
3997
- }
3998
- obj = this.get_node(obj);
3999
- if(!obj || obj.id === $.jstree.root) { return false; }
4000
- old = obj.text;
4001
- if(!this.check("rename_node", obj, this.get_parent(obj), val)) {
4002
- this.settings.core.error.call(this, this._data.core.last_error);
4003
- return false;
4004
- }
4005
- this.set_text(obj, val); // .apply(this, Array.prototype.slice.call(arguments))
4006
- /**
4007
- * triggered when a node is renamed
4008
- * @event
4009
- * @name rename_node.jstree
4010
- * @param {Object} node
4011
- * @param {String} text the new value
4012
- * @param {String} old the old value
4013
- */
4014
- this.trigger('rename_node', { "node" : obj, "text" : val, "old" : old });
4015
- return true;
4016
- },
4017
- /**
4018
- * remove a node
4019
- * @name delete_node(obj)
4020
- * @param {mixed} obj the node, you can pass an array to delete multiple nodes
4021
- * @return {Boolean}
4022
- * @trigger delete_node.jstree, changed.jstree
4023
- */
4024
- delete_node : function (obj) {
4025
- var t1, t2, par, pos, tmp, i, j, k, l, c, top, lft;
4026
- if($.isArray(obj)) {
4027
- obj = obj.slice();
4028
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4029
- this.delete_node(obj[t1]);
4030
- }
4031
- return true;
4032
- }
4033
- obj = this.get_node(obj);
4034
- if(!obj || obj.id === $.jstree.root) { return false; }
4035
- par = this.get_node(obj.parent);
4036
- pos = $.inArray(obj.id, par.children);
4037
- c = false;
4038
- if(!this.check("delete_node", obj, par, pos)) {
4039
- this.settings.core.error.call(this, this._data.core.last_error);
4040
- return false;
4041
- }
4042
- if(pos !== -1) {
4043
- par.children = $.vakata.array_remove(par.children, pos);
4044
- }
4045
- tmp = obj.children_d.concat([]);
4046
- tmp.push(obj.id);
4047
- for(i = 0, j = obj.parents.length; i < j; i++) {
4048
- this._model.data[obj.parents[i]].children_d = $.vakata.array_filter(this._model.data[obj.parents[i]].children_d, function (v) {
4049
- return $.inArray(v, tmp) === -1;
4050
- });
4051
- }
4052
- for(k = 0, l = tmp.length; k < l; k++) {
4053
- if(this._model.data[tmp[k]].state.selected) {
4054
- c = true;
4055
- break;
4056
- }
4057
- }
4058
- if (c) {
4059
- this._data.core.selected = $.vakata.array_filter(this._data.core.selected, function (v) {
4060
- return $.inArray(v, tmp) === -1;
4061
- });
4062
- }
4063
- /**
4064
- * triggered when a node is deleted
4065
- * @event
4066
- * @name delete_node.jstree
4067
- * @param {Object} node
4068
- * @param {String} parent the parent's ID
4069
- */
4070
- this.trigger('delete_node', { "node" : obj, "parent" : par.id });
4071
- if(c) {
4072
- this.trigger('changed', { 'action' : 'delete_node', 'node' : obj, 'selected' : this._data.core.selected, 'parent' : par.id });
4073
- }
4074
- for(k = 0, l = tmp.length; k < l; k++) {
4075
- delete this._model.data[tmp[k]];
4076
- }
4077
- if($.inArray(this._data.core.focused, tmp) !== -1) {
4078
- this._data.core.focused = null;
4079
- top = this.element[0].scrollTop;
4080
- lft = this.element[0].scrollLeft;
4081
- if(par.id === $.jstree.root) {
4082
- if (this._model.data[$.jstree.root].children[0]) {
4083
- this.get_node(this._model.data[$.jstree.root].children[0], true).children('.jstree-anchor').focus();
4084
- }
4085
- }
4086
- else {
4087
- this.get_node(par, true).children('.jstree-anchor').focus();
4088
- }
4089
- this.element[0].scrollTop = top;
4090
- this.element[0].scrollLeft = lft;
4091
- }
4092
- this.redraw_node(par, true);
4093
- return true;
4094
- },
4095
- /**
4096
- * check if an operation is premitted on the tree. Used internally.
4097
- * @private
4098
- * @name check(chk, obj, par, pos)
4099
- * @param {String} chk the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node"
4100
- * @param {mixed} obj the node
4101
- * @param {mixed} par the parent
4102
- * @param {mixed} pos the position to insert at, or if "rename_node" - the new name
4103
- * @param {mixed} more some various additional information, for example if a "move_node" operations is triggered by DND this will be the hovered node
4104
- * @return {Boolean}
4105
- */
4106
- check : function (chk, obj, par, pos, more) {
4107
- obj = obj && obj.id ? obj : this.get_node(obj);
4108
- par = par && par.id ? par : this.get_node(par);
4109
- var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj,
4110
- chc = this.settings.core.check_callback;
4111
- if(chk === "move_node" || chk === "copy_node") {
4112
- if((!more || !more.is_multi) && (chk === "move_node" && $.inArray(obj.id, par.children) === pos)) {
4113
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_08', 'reason' : 'Moving node to its current position', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4114
- return false;
4115
- }
4116
- if((!more || !more.is_multi) && (obj.id === par.id || (chk === "move_node" && $.inArray(obj.id, par.children) === pos) || $.inArray(par.id, obj.children_d) !== -1)) {
4117
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_01', 'reason' : 'Moving parent inside child', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4118
- return false;
4119
- }
4120
- }
4121
- if(tmp && tmp.data) { tmp = tmp.data; }
4122
- if(tmp && tmp.functions && (tmp.functions[chk] === false || tmp.functions[chk] === true)) {
4123
- if(tmp.functions[chk] === false) {
4124
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_02', 'reason' : 'Node data prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4125
- }
4126
- return tmp.functions[chk];
4127
- }
4128
- if(chc === false || ($.isFunction(chc) && chc.call(this, chk, obj, par, pos, more) === false) || (chc && chc[chk] === false)) {
4129
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_03', 'reason' : 'User config for core.check_callback prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4130
- return false;
4131
- }
4132
- return true;
4133
- },
4134
- /**
4135
- * get the last error
4136
- * @name last_error()
4137
- * @return {Object}
4138
- */
4139
- last_error : function () {
4140
- return this._data.core.last_error;
4141
- },
4142
- /**
4143
- * move a node to a new parent
4144
- * @name move_node(obj, par [, pos, callback, is_loaded])
4145
- * @param {mixed} obj the node to move, pass an array to move multiple nodes
4146
- * @param {mixed} par the new parent
4147
- * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
4148
- * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
4149
- * @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
4150
- * @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
4151
- * @param {Boolean} instance internal parameter indicating if the node comes from another instance
4152
- * @trigger move_node.jstree
4153
- */
4154
- move_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) {
4155
- var t1, t2, old_par, old_pos, new_par, old_ins, is_multi, dpc, tmp, i, j, k, l, p;
4156
-
4157
- par = this.get_node(par);
4158
- pos = pos === undefined ? 0 : pos;
4159
- if(!par) { return false; }
4160
- if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
4161
- return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true, false, origin); });
4162
- }
4163
-
4164
- if($.isArray(obj)) {
4165
- if(obj.length === 1) {
4166
- obj = obj[0];
4167
- }
4168
- else {
4169
- //obj = obj.slice();
4170
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4171
- if((tmp = this.move_node(obj[t1], par, pos, callback, is_loaded, false, origin))) {
4172
- par = tmp;
4173
- pos = "after";
4174
- }
4175
- }
4176
- this.redraw();
4177
- return true;
4178
- }
4179
- }
4180
- obj = obj && obj.id ? obj : this.get_node(obj);
4181
-
4182
- if(!obj || obj.id === $.jstree.root) { return false; }
4183
-
4184
- old_par = (obj.parent || $.jstree.root).toString();
4185
- new_par = (!pos.toString().match(/^(before|after)$/) || par.id === $.jstree.root) ? par : this.get_node(par.parent);
4186
- old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id));
4187
- is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id);
4188
- old_pos = old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1;
4189
- if(old_ins && old_ins._id) {
4190
- obj = old_ins._model.data[obj.id];
4191
- }
4192
-
4193
- if(is_multi) {
4194
- if((tmp = this.copy_node(obj, par, pos, callback, is_loaded, false, origin))) {
4195
- if(old_ins) { old_ins.delete_node(obj); }
4196
- return tmp;
4197
- }
4198
- return false;
4199
- }
4200
- //var m = this._model.data;
4201
- if(par.id === $.jstree.root) {
4202
- if(pos === "before") { pos = "first"; }
4203
- if(pos === "after") { pos = "last"; }
4204
- }
4205
- switch(pos) {
4206
- case "before":
4207
- pos = $.inArray(par.id, new_par.children);
4208
- break;
4209
- case "after" :
4210
- pos = $.inArray(par.id, new_par.children) + 1;
4211
- break;
4212
- case "inside":
4213
- case "first":
4214
- pos = 0;
4215
- break;
4216
- case "last":
4217
- pos = new_par.children.length;
4218
- break;
4219
- default:
4220
- if(!pos) { pos = 0; }
4221
- break;
4222
- }
4223
- if(pos > new_par.children.length) { pos = new_par.children.length; }
4224
- if(!this.check("move_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
4225
- this.settings.core.error.call(this, this._data.core.last_error);
4226
- return false;
4227
- }
4228
- if(obj.parent === new_par.id) {
4229
- dpc = new_par.children.concat();
4230
- tmp = $.inArray(obj.id, dpc);
4231
- if(tmp !== -1) {
4232
- dpc = $.vakata.array_remove(dpc, tmp);
4233
- if(pos > tmp) { pos--; }
4234
- }
4235
- tmp = [];
4236
- for(i = 0, j = dpc.length; i < j; i++) {
4237
- tmp[i >= pos ? i+1 : i] = dpc[i];
4238
- }
4239
- tmp[pos] = obj.id;
4240
- new_par.children = tmp;
4241
- this._node_changed(new_par.id);
4242
- this.redraw(new_par.id === $.jstree.root);
4243
- }
4244
- else {
4245
- // clean old parent and up
4246
- tmp = obj.children_d.concat();
4247
- tmp.push(obj.id);
4248
- for(i = 0, j = obj.parents.length; i < j; i++) {
4249
- dpc = [];
4250
- p = old_ins._model.data[obj.parents[i]].children_d;
4251
- for(k = 0, l = p.length; k < l; k++) {
4252
- if($.inArray(p[k], tmp) === -1) {
4253
- dpc.push(p[k]);
4254
- }
4255
- }
4256
- old_ins._model.data[obj.parents[i]].children_d = dpc;
4257
- }
4258
- old_ins._model.data[old_par].children = $.vakata.array_remove_item(old_ins._model.data[old_par].children, obj.id);
4259
-
4260
- // insert into new parent and up
4261
- for(i = 0, j = new_par.parents.length; i < j; i++) {
4262
- this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(tmp);
4263
- }
4264
- dpc = [];
4265
- for(i = 0, j = new_par.children.length; i < j; i++) {
4266
- dpc[i >= pos ? i+1 : i] = new_par.children[i];
4267
- }
4268
- dpc[pos] = obj.id;
4269
- new_par.children = dpc;
4270
- new_par.children_d.push(obj.id);
4271
- new_par.children_d = new_par.children_d.concat(obj.children_d);
4272
-
4273
- // update object
4274
- obj.parent = new_par.id;
4275
- tmp = new_par.parents.concat();
4276
- tmp.unshift(new_par.id);
4277
- p = obj.parents.length;
4278
- obj.parents = tmp;
4279
-
4280
- // update object children
4281
- tmp = tmp.concat();
4282
- for(i = 0, j = obj.children_d.length; i < j; i++) {
4283
- this._model.data[obj.children_d[i]].parents = this._model.data[obj.children_d[i]].parents.slice(0,p*-1);
4284
- Array.prototype.push.apply(this._model.data[obj.children_d[i]].parents, tmp);
4285
- }
4286
-
4287
- if(old_par === $.jstree.root || new_par.id === $.jstree.root) {
4288
- this._model.force_full_redraw = true;
4289
- }
4290
- if(!this._model.force_full_redraw) {
4291
- this._node_changed(old_par);
4292
- this._node_changed(new_par.id);
4293
- }
4294
- if(!skip_redraw) {
4295
- this.redraw();
4296
- }
4297
- }
4298
- if(callback) { callback.call(this, obj, new_par, pos); }
4299
- /**
4300
- * triggered when a node is moved
4301
- * @event
4302
- * @name move_node.jstree
4303
- * @param {Object} node
4304
- * @param {String} parent the parent's ID
4305
- * @param {Number} position the position of the node among the parent's children
4306
- * @param {String} old_parent the old parent of the node
4307
- * @param {Number} old_position the old position of the node
4308
- * @param {Boolean} is_multi do the node and new parent belong to different instances
4309
- * @param {jsTree} old_instance the instance the node came from
4310
- * @param {jsTree} new_instance the instance of the new parent
4311
- */
4312
- this.trigger('move_node', { "node" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_pos, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this });
4313
- return obj.id;
4314
- },
4315
- /**
4316
- * copy a node to a new parent
4317
- * @name copy_node(obj, par [, pos, callback, is_loaded])
4318
- * @param {mixed} obj the node to copy, pass an array to copy multiple nodes
4319
- * @param {mixed} par the new parent
4320
- * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
4321
- * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
4322
- * @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
4323
- * @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
4324
- * @param {Boolean} instance internal parameter indicating if the node comes from another instance
4325
- * @trigger model.jstree copy_node.jstree
4326
- */
4327
- copy_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) {
4328
- var t1, t2, dpc, tmp, i, j, node, old_par, new_par, old_ins, is_multi;
4329
-
4330
- par = this.get_node(par);
4331
- pos = pos === undefined ? 0 : pos;
4332
- if(!par) { return false; }
4333
- if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
4334
- return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true, false, origin); });
4335
- }
4336
-
4337
- if($.isArray(obj)) {
4338
- if(obj.length === 1) {
4339
- obj = obj[0];
4340
- }
4341
- else {
4342
- //obj = obj.slice();
4343
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4344
- if((tmp = this.copy_node(obj[t1], par, pos, callback, is_loaded, true, origin))) {
4345
- par = tmp;
4346
- pos = "after";
4347
- }
4348
- }
4349
- this.redraw();
4350
- return true;
4351
- }
4352
- }
4353
- obj = obj && obj.id ? obj : this.get_node(obj);
4354
- if(!obj || obj.id === $.jstree.root) { return false; }
4355
-
4356
- old_par = (obj.parent || $.jstree.root).toString();
4357
- new_par = (!pos.toString().match(/^(before|after)$/) || par.id === $.jstree.root) ? par : this.get_node(par.parent);
4358
- old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id));
4359
- is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id);
4360
-
4361
- if(old_ins && old_ins._id) {
4362
- obj = old_ins._model.data[obj.id];
4363
- }
4364
-
4365
- if(par.id === $.jstree.root) {
4366
- if(pos === "before") { pos = "first"; }
4367
- if(pos === "after") { pos = "last"; }
4368
- }
4369
- switch(pos) {
4370
- case "before":
4371
- pos = $.inArray(par.id, new_par.children);
4372
- break;
4373
- case "after" :
4374
- pos = $.inArray(par.id, new_par.children) + 1;
4375
- break;
4376
- case "inside":
4377
- case "first":
4378
- pos = 0;
4379
- break;
4380
- case "last":
4381
- pos = new_par.children.length;
4382
- break;
4383
- default:
4384
- if(!pos) { pos = 0; }
4385
- break;
4386
- }
4387
- if(pos > new_par.children.length) { pos = new_par.children.length; }
4388
- if(!this.check("copy_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
4389
- this.settings.core.error.call(this, this._data.core.last_error);
4390
- return false;
4391
- }
4392
- node = old_ins ? old_ins.get_json(obj, { no_id : true, no_data : true, no_state : true }) : obj;
4393
- if(!node) { return false; }
4394
- if(node.id === true) { delete node.id; }
4395
- node = this._parse_model_from_json(node, new_par.id, new_par.parents.concat());
4396
- if(!node) { return false; }
4397
- tmp = this.get_node(node);
4398
- if(obj && obj.state && obj.state.loaded === false) { tmp.state.loaded = false; }
4399
- dpc = [];
4400
- dpc.push(node);
4401
- dpc = dpc.concat(tmp.children_d);
4402
- this.trigger('model', { "nodes" : dpc, "parent" : new_par.id });
4403
-
4404
- // insert into new parent and up
4405
- for(i = 0, j = new_par.parents.length; i < j; i++) {
4406
- this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(dpc);
4407
- }
4408
- dpc = [];
4409
- for(i = 0, j = new_par.children.length; i < j; i++) {
4410
- dpc[i >= pos ? i+1 : i] = new_par.children[i];
4411
- }
4412
- dpc[pos] = tmp.id;
4413
- new_par.children = dpc;
4414
- new_par.children_d.push(tmp.id);
4415
- new_par.children_d = new_par.children_d.concat(tmp.children_d);
4416
-
4417
- if(new_par.id === $.jstree.root) {
4418
- this._model.force_full_redraw = true;
4419
- }
4420
- if(!this._model.force_full_redraw) {
4421
- this._node_changed(new_par.id);
4422
- }
4423
- if(!skip_redraw) {
4424
- this.redraw(new_par.id === $.jstree.root);
4425
- }
4426
- if(callback) { callback.call(this, tmp, new_par, pos); }
4427
- /**
4428
- * triggered when a node is copied
4429
- * @event
4430
- * @name copy_node.jstree
4431
- * @param {Object} node the copied node
4432
- * @param {Object} original the original node
4433
- * @param {String} parent the parent's ID
4434
- * @param {Number} position the position of the node among the parent's children
4435
- * @param {String} old_parent the old parent of the node
4436
- * @param {Number} old_position the position of the original node
4437
- * @param {Boolean} is_multi do the node and new parent belong to different instances
4438
- * @param {jsTree} old_instance the instance the node came from
4439
- * @param {jsTree} new_instance the instance of the new parent
4440
- */
4441
- this.trigger('copy_node', { "node" : tmp, "original" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1,'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this });
4442
- return tmp.id;
4443
- },
4444
- /**
4445
- * cut a node (a later call to `paste(obj)` would move the node)
4446
- * @name cut(obj)
4447
- * @param {mixed} obj multiple objects can be passed using an array
4448
- * @trigger cut.jstree
4449
- */
4450
- cut : function (obj) {
4451
- if(!obj) { obj = this._data.core.selected.concat(); }
4452
- if(!$.isArray(obj)) { obj = [obj]; }
4453
- if(!obj.length) { return false; }
4454
- var tmp = [], o, t1, t2;
4455
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4456
- o = this.get_node(obj[t1]);
4457
- if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); }
4458
- }
4459
- if(!tmp.length) { return false; }
4460
- ccp_node = tmp;
4461
- ccp_inst = this;
4462
- ccp_mode = 'move_node';
4463
- /**
4464
- * triggered when nodes are added to the buffer for moving
4465
- * @event
4466
- * @name cut.jstree
4467
- * @param {Array} node
4468
- */
4469
- this.trigger('cut', { "node" : obj });
4470
- },
4471
- /**
4472
- * copy a node (a later call to `paste(obj)` would copy the node)
4473
- * @name copy(obj)
4474
- * @param {mixed} obj multiple objects can be passed using an array
4475
- * @trigger copy.jstree
4476
- */
4477
- copy : function (obj) {
4478
- if(!obj) { obj = this._data.core.selected.concat(); }
4479
- if(!$.isArray(obj)) { obj = [obj]; }
4480
- if(!obj.length) { return false; }
4481
- var tmp = [], o, t1, t2;
4482
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4483
- o = this.get_node(obj[t1]);
4484
- if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); }
4485
- }
4486
- if(!tmp.length) { return false; }
4487
- ccp_node = tmp;
4488
- ccp_inst = this;
4489
- ccp_mode = 'copy_node';
4490
- /**
4491
- * triggered when nodes are added to the buffer for copying
4492
- * @event
4493
- * @name copy.jstree
4494
- * @param {Array} node
4495
- */
4496
- this.trigger('copy', { "node" : obj });
4497
- },
4498
- /**
4499
- * get the current buffer (any nodes that are waiting for a paste operation)
4500
- * @name get_buffer()
4501
- * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance)
4502
- */
4503
- get_buffer : function () {
4504
- return { 'mode' : ccp_mode, 'node' : ccp_node, 'inst' : ccp_inst };
4505
- },
4506
- /**
4507
- * check if there is something in the buffer to paste
4508
- * @name can_paste()
4509
- * @return {Boolean}
4510
- */
4511
- can_paste : function () {
4512
- return ccp_mode !== false && ccp_node !== false; // && ccp_inst._model.data[ccp_node];
4513
- },
4514
- /**
4515
- * copy or move the previously cut or copied nodes to a new parent
4516
- * @name paste(obj [, pos])
4517
- * @param {mixed} obj the new parent
4518
- * @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0`
4519
- * @trigger paste.jstree
4520
- */
4521
- paste : function (obj, pos) {
4522
- obj = this.get_node(obj);
4523
- if(!obj || !ccp_mode || !ccp_mode.match(/^(copy_node|move_node)$/) || !ccp_node) { return false; }
4524
- if(this[ccp_mode](ccp_node, obj, pos, false, false, false, ccp_inst)) {
4525
- /**
4526
- * triggered when paste is invoked
4527
- * @event
4528
- * @name paste.jstree
4529
- * @param {String} parent the ID of the receiving node
4530
- * @param {Array} node the nodes in the buffer
4531
- * @param {String} mode the performed operation - "copy_node" or "move_node"
4532
- */
4533
- this.trigger('paste', { "parent" : obj.id, "node" : ccp_node, "mode" : ccp_mode });
4534
- }
4535
- ccp_node = false;
4536
- ccp_mode = false;
4537
- ccp_inst = false;
4538
- },
4539
- /**
4540
- * clear the buffer of previously copied or cut nodes
4541
- * @name clear_buffer()
4542
- * @trigger clear_buffer.jstree
4543
- */
4544
- clear_buffer : function () {
4545
- ccp_node = false;
4546
- ccp_mode = false;
4547
- ccp_inst = false;
4548
- /**
4549
- * triggered when the copy / cut buffer is cleared
4550
- * @event
4551
- * @name clear_buffer.jstree
4552
- */
4553
- this.trigger('clear_buffer');
4554
- },
4555
- /**
4556
- * put a node in edit mode (input field to rename the node)
4557
- * @name edit(obj [, default_text, callback])
4558
- * @param {mixed} obj
4559
- * @param {String} default_text the text to populate the input with (if omitted or set to a non-string value the node's text value is used)
4560
- * @param {Function} callback a function to be called once the text box is blurred, it is called in the instance's scope and receives the node, a status parameter (true if the rename is successful, false otherwise) and a boolean indicating if the user cancelled the edit. You can access the node's title using .text
4561
- */
4562
- edit : function (obj, default_text, callback) {
4563
- var rtl, w, a, s, t, h1, h2, fn, tmp, cancel = false;
4564
- obj = this.get_node(obj);
4565
- if(!obj) { return false; }
4566
- if(!this.check("edit", obj, this.get_parent(obj))) {
4567
- this.settings.core.error.call(this, this._data.core.last_error);
4568
- return false;
4569
- }
4570
- tmp = obj;
4571
- default_text = typeof default_text === 'string' ? default_text : obj.text;
4572
- this.set_text(obj, "");
4573
- obj = this._open_to(obj);
4574
- tmp.text = default_text;
4575
-
4576
- rtl = this._data.core.rtl;
4577
- w = this.element.width();
4578
- this._data.core.focused = tmp.id;
4579
- a = obj.children('.jstree-anchor').focus();
4580
- s = $('<span></span>');
4581
- /*!
4582
- oi = obj.children("i:visible"),
4583
- ai = a.children("i:visible"),
4584
- w1 = oi.width() * oi.length,
4585
- w2 = ai.width() * ai.length,
4586
- */
4587
- t = default_text;
4588
- h1 = $("<"+"div></div>", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo(document.body);
4589
- h2 = $("<"+"input />", {
4590
- "value" : t,
4591
- "class" : "jstree-rename-input",
4592
- // "size" : t.length,
4593
- "css" : {
4594
- "padding" : "0",
4595
- "border" : "1px solid silver",
4596
- "box-sizing" : "border-box",
4597
- "display" : "inline-block",
4598
- "height" : (this._data.core.li_height) + "px",
4599
- "lineHeight" : (this._data.core.li_height) + "px",
4600
- "width" : "150px" // will be set a bit further down
4601
- },
4602
- "blur" : $.proxy(function (e) {
4603
- e.stopImmediatePropagation();
4604
- e.preventDefault();
4605
- var i = s.children(".jstree-rename-input"),
4606
- v = i.val(),
4607
- f = this.settings.core.force_text,
4608
- nv;
4609
- if(v === "") { v = t; }
4610
- h1.remove();
4611
- s.replaceWith(a);
4612
- s.remove();
4613
- t = f ? t : $('<div></div>').append($.parseHTML(t)).html();
4614
- obj = this.get_node(obj);
4615
- this.set_text(obj, t);
4616
- nv = !!this.rename_node(obj, f ? $('<div></div>').text(v).text() : $('<div></div>').append($.parseHTML(v)).html());
4617
- if(!nv) {
4618
- this.set_text(obj, t); // move this up? and fix #483
4619
- }
4620
- this._data.core.focused = tmp.id;
4621
- setTimeout($.proxy(function () {
4622
- var node = this.get_node(tmp.id, true);
4623
- if(node.length) {
4624
- this._data.core.focused = tmp.id;
4625
- node.children('.jstree-anchor').focus();
4626
- }
4627
- }, this), 0);
4628
- if(callback) {
4629
- callback.call(this, tmp, nv, cancel);
4630
- }
4631
- h2 = null;
4632
- }, this),
4633
- "keydown" : function (e) {
4634
- var key = e.which;
4635
- if(key === 27) {
4636
- cancel = true;
4637
- this.value = t;
4638
- }
4639
- if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) {
4640
- e.stopImmediatePropagation();
4641
- }
4642
- if(key === 27 || key === 13) {
4643
- e.preventDefault();
4644
- this.blur();
4645
- }
4646
- },
4647
- "click" : function (e) { e.stopImmediatePropagation(); },
4648
- "mousedown" : function (e) { e.stopImmediatePropagation(); },
4649
- "keyup" : function (e) {
4650
- h2.width(Math.min(h1.text("pW" + this.value).width(),w));
4651
- },
4652
- "keypress" : function(e) {
4653
- if(e.which === 13) { return false; }
4654
- }
4655
- });
4656
- fn = {
4657
- fontFamily : a.css('fontFamily') || '',
4658
- fontSize : a.css('fontSize') || '',
4659
- fontWeight : a.css('fontWeight') || '',
4660
- fontStyle : a.css('fontStyle') || '',
4661
- fontStretch : a.css('fontStretch') || '',
4662
- fontVariant : a.css('fontVariant') || '',
4663
- letterSpacing : a.css('letterSpacing') || '',
4664
- wordSpacing : a.css('wordSpacing') || ''
4665
- };
4666
- s.attr('class', a.attr('class')).append(a.contents().clone()).append(h2);
4667
- a.replaceWith(s);
4668
- h1.css(fn);
4669
- h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
4670
- $(document).one('mousedown.jstree touchstart.jstree dnd_start.vakata', function (e) {
4671
- if (h2 && e.target !== h2) {
4672
- $(h2).blur();
4673
- }
4674
- });
4675
- },
4676
-
4677
-
4678
- /**
4679
- * changes the theme
4680
- * @name set_theme(theme_name [, theme_url])
4681
- * @param {String} theme_name the name of the new theme to apply
4682
- * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory.
4683
- * @trigger set_theme.jstree
4684
- */
4685
- set_theme : function (theme_name, theme_url) {
4686
- if(!theme_name) { return false; }
4687
- if(theme_url === true) {
4688
- var dir = this.settings.core.themes.dir;
4689
- if(!dir) { dir = $.jstree.path + '/themes'; }
4690
- theme_url = dir + '/' + theme_name + '/style.css';
4691
- }
4692
- if(theme_url && $.inArray(theme_url, themes_loaded) === -1) {
4693
- $('head').append('<'+'link rel="stylesheet" href="' + theme_url + '" type="text/css" />');
4694
- themes_loaded.push(theme_url);
4695
- }
4696
- if(this._data.core.themes.name) {
4697
- this.element.removeClass('jstree-' + this._data.core.themes.name);
4698
- }
4699
- this._data.core.themes.name = theme_name;
4700
- this.element.addClass('jstree-' + theme_name);
4701
- this.element[this.settings.core.themes.responsive ? 'addClass' : 'removeClass' ]('jstree-' + theme_name + '-responsive');
4702
- /**
4703
- * triggered when a theme is set
4704
- * @event
4705
- * @name set_theme.jstree
4706
- * @param {String} theme the new theme
4707
- */
4708
- this.trigger('set_theme', { 'theme' : theme_name });
4709
- },
4710
- /**
4711
- * gets the name of the currently applied theme name
4712
- * @name get_theme()
4713
- * @return {String}
4714
- */
4715
- get_theme : function () { return this._data.core.themes.name; },
4716
- /**
4717
- * changes the theme variant (if the theme has variants)
4718
- * @name set_theme_variant(variant_name)
4719
- * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed)
4720
- */
4721
- set_theme_variant : function (variant_name) {
4722
- if(this._data.core.themes.variant) {
4723
- this.element.removeClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant);
4724
- }
4725
- this._data.core.themes.variant = variant_name;
4726
- if(variant_name) {
4727
- this.element.addClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant);
4728
- }
4729
- },
4730
- /**
4731
- * gets the name of the currently applied theme variant
4732
- * @name get_theme()
4733
- * @return {String}
4734
- */
4735
- get_theme_variant : function () { return this._data.core.themes.variant; },
4736
- /**
4737
- * shows a striped background on the container (if the theme supports it)
4738
- * @name show_stripes()
4739
- */
4740
- show_stripes : function () {
4741
- this._data.core.themes.stripes = true;
4742
- this.get_container_ul().addClass("jstree-striped");
4743
- /**
4744
- * triggered when stripes are shown
4745
- * @event
4746
- * @name show_stripes.jstree
4747
- */
4748
- this.trigger('show_stripes');
4749
- },
4750
- /**
4751
- * hides the striped background on the container
4752
- * @name hide_stripes()
4753
- */
4754
- hide_stripes : function () {
4755
- this._data.core.themes.stripes = false;
4756
- this.get_container_ul().removeClass("jstree-striped");
4757
- /**
4758
- * triggered when stripes are hidden
4759
- * @event
4760
- * @name hide_stripes.jstree
4761
- */
4762
- this.trigger('hide_stripes');
4763
- },
4764
- /**
4765
- * toggles the striped background on the container
4766
- * @name toggle_stripes()
4767
- */
4768
- toggle_stripes : function () { if(this._data.core.themes.stripes) { this.hide_stripes(); } else { this.show_stripes(); } },
4769
- /**
4770
- * shows the connecting dots (if the theme supports it)
4771
- * @name show_dots()
4772
- */
4773
- show_dots : function () {
4774
- this._data.core.themes.dots = true;
4775
- this.get_container_ul().removeClass("jstree-no-dots");
4776
- /**
4777
- * triggered when dots are shown
4778
- * @event
4779
- * @name show_dots.jstree
4780
- */
4781
- this.trigger('show_dots');
4782
- },
4783
- /**
4784
- * hides the connecting dots
4785
- * @name hide_dots()
4786
- */
4787
- hide_dots : function () {
4788
- this._data.core.themes.dots = false;
4789
- this.get_container_ul().addClass("jstree-no-dots");
4790
- /**
4791
- * triggered when dots are hidden
4792
- * @event
4793
- * @name hide_dots.jstree
4794
- */
4795
- this.trigger('hide_dots');
4796
- },
4797
- /**
4798
- * toggles the connecting dots
4799
- * @name toggle_dots()
4800
- */
4801
- toggle_dots : function () { if(this._data.core.themes.dots) { this.hide_dots(); } else { this.show_dots(); } },
4802
- /**
4803
- * show the node icons
4804
- * @name show_icons()
4805
- */
4806
- show_icons : function () {
4807
- this._data.core.themes.icons = true;
4808
- this.get_container_ul().removeClass("jstree-no-icons");
4809
- /**
4810
- * triggered when icons are shown
4811
- * @event
4812
- * @name show_icons.jstree
4813
- */
4814
- this.trigger('show_icons');
4815
- },
4816
- /**
4817
- * hide the node icons
4818
- * @name hide_icons()
4819
- */
4820
- hide_icons : function () {
4821
- this._data.core.themes.icons = false;
4822
- this.get_container_ul().addClass("jstree-no-icons");
4823
- /**
4824
- * triggered when icons are hidden
4825
- * @event
4826
- * @name hide_icons.jstree
4827
- */
4828
- this.trigger('hide_icons');
4829
- },
4830
- /**
4831
- * toggle the node icons
4832
- * @name toggle_icons()
4833
- */
4834
- toggle_icons : function () { if(this._data.core.themes.icons) { this.hide_icons(); } else { this.show_icons(); } },
4835
- /**
4836
- * show the node ellipsis
4837
- * @name show_icons()
4838
- */
4839
- show_ellipsis : function () {
4840
- this._data.core.themes.ellipsis = true;
4841
- this.get_container_ul().addClass("jstree-ellipsis");
4842
- /**
4843
- * triggered when ellisis is shown
4844
- * @event
4845
- * @name show_ellipsis.jstree
4846
- */
4847
- this.trigger('show_ellipsis');
4848
- },
4849
- /**
4850
- * hide the node ellipsis
4851
- * @name hide_ellipsis()
4852
- */
4853
- hide_ellipsis : function () {
4854
- this._data.core.themes.ellipsis = false;
4855
- this.get_container_ul().removeClass("jstree-ellipsis");
4856
- /**
4857
- * triggered when ellisis is hidden
4858
- * @event
4859
- * @name hide_ellipsis.jstree
4860
- */
4861
- this.trigger('hide_ellipsis');
4862
- },
4863
- /**
4864
- * toggle the node ellipsis
4865
- * @name toggle_icons()
4866
- */
4867
- toggle_ellipsis : function () { if(this._data.core.themes.ellipsis) { this.hide_ellipsis(); } else { this.show_ellipsis(); } },
4868
- /**
4869
- * set the node icon for a node
4870
- * @name set_icon(obj, icon)
4871
- * @param {mixed} obj
4872
- * @param {String} icon the new icon - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
4873
- */
4874
- set_icon : function (obj, icon) {
4875
- var t1, t2, dom, old;
4876
- if($.isArray(obj)) {
4877
- obj = obj.slice();
4878
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4879
- this.set_icon(obj[t1], icon);
4880
- }
4881
- return true;
4882
- }
4883
- obj = this.get_node(obj);
4884
- if(!obj || obj.id === $.jstree.root) { return false; }
4885
- old = obj.icon;
4886
- obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon;
4887
- dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon");
4888
- if(icon === false) {
4889
- dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
4890
- this.hide_icon(obj);
4891
- }
4892
- else if(icon === true || icon === null || icon === undefined || icon === '') {
4893
- dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
4894
- if(old === false) { this.show_icon(obj); }
4895
- }
4896
- else if(icon.indexOf("/") === -1 && icon.indexOf(".") === -1) {
4897
- dom.removeClass(old).css("background","");
4898
- dom.addClass(icon + ' jstree-themeicon-custom').attr("rel",icon);
4899
- if(old === false) { this.show_icon(obj); }
4900
- }
4901
- else {
4902
- dom.removeClass(old).css("background","");
4903
- dom.addClass('jstree-themeicon-custom').css("background", "url('" + icon + "') center center no-repeat").attr("rel",icon);
4904
- if(old === false) { this.show_icon(obj); }
4905
- }
4906
- return true;
4907
- },
4908
- /**
4909
- * get the node icon for a node
4910
- * @name get_icon(obj)
4911
- * @param {mixed} obj
4912
- * @return {String}
4913
- */
4914
- get_icon : function (obj) {
4915
- obj = this.get_node(obj);
4916
- return (!obj || obj.id === $.jstree.root) ? false : obj.icon;
4917
- },
4918
- /**
4919
- * hide the icon on an individual node
4920
- * @name hide_icon(obj)
4921
- * @param {mixed} obj
4922
- */
4923
- hide_icon : function (obj) {
4924
- var t1, t2;
4925
- if($.isArray(obj)) {
4926
- obj = obj.slice();
4927
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4928
- this.hide_icon(obj[t1]);
4929
- }
4930
- return true;
4931
- }
4932
- obj = this.get_node(obj);
4933
- if(!obj || obj === $.jstree.root) { return false; }
4934
- obj.icon = false;
4935
- this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon").addClass('jstree-themeicon-hidden');
4936
- return true;
4937
- },
4938
- /**
4939
- * show the icon on an individual node
4940
- * @name show_icon(obj)
4941
- * @param {mixed} obj
4942
- */
4943
- show_icon : function (obj) {
4944
- var t1, t2, dom;
4945
- if($.isArray(obj)) {
4946
- obj = obj.slice();
4947
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4948
- this.show_icon(obj[t1]);
4949
- }
4950
- return true;
4951
- }
4952
- obj = this.get_node(obj);
4953
- if(!obj || obj === $.jstree.root) { return false; }
4954
- dom = this.get_node(obj, true);
4955
- obj.icon = dom.length ? dom.children(".jstree-anchor").children(".jstree-themeicon").attr('rel') : true;
4956
- if(!obj.icon) { obj.icon = true; }
4957
- dom.children(".jstree-anchor").children(".jstree-themeicon").removeClass('jstree-themeicon-hidden');
4958
- return true;
4959
- }
4960
- };
4961
-
4962
- // helpers
4963
- $.vakata = {};
4964
- // collect attributes
4965
- $.vakata.attributes = function(node, with_values) {
4966
- node = $(node)[0];
4967
- var attr = with_values ? {} : [];
4968
- if(node && node.attributes) {
4969
- $.each(node.attributes, function (i, v) {
4970
- if($.inArray(v.name.toLowerCase(),['style','contenteditable','hasfocus','tabindex']) !== -1) { return; }
4971
- if(v.value !== null && $.trim(v.value) !== '') {
4972
- if(with_values) { attr[v.name] = v.value; }
4973
- else { attr.push(v.name); }
4974
- }
4975
- });
4976
- }
4977
- return attr;
4978
- };
4979
- $.vakata.array_unique = function(array) {
4980
- var a = [], i, j, l, o = {};
4981
- for(i = 0, l = array.length; i < l; i++) {
4982
- if(o[array[i]] === undefined) {
4983
- a.push(array[i]);
4984
- o[array[i]] = true;
4985
- }
4986
- }
4987
- return a;
4988
- };
4989
- // remove item from array
4990
- $.vakata.array_remove = function(array, from) {
4991
- array.splice(from, 1);
4992
- return array;
4993
- //var rest = array.slice((to || from) + 1 || array.length);
4994
- //array.length = from < 0 ? array.length + from : from;
4995
- //array.push.apply(array, rest);
4996
- //return array;
4997
- };
4998
- // remove item from array
4999
- $.vakata.array_remove_item = function(array, item) {
5000
- var tmp = $.inArray(item, array);
5001
- return tmp !== -1 ? $.vakata.array_remove(array, tmp) : array;
5002
- };
5003
- $.vakata.array_filter = function(c,a,b,d,e) {
5004
- if (c.filter) {
5005
- return c.filter(a, b);
5006
- }
5007
- d=[];
5008
- for (e in c) {
5009
- if (~~e+''===e+'' && e>=0 && a.call(b,c[e],+e,c)) {
5010
- d.push(c[e]);
5011
- }
5012
- }
5013
- return d;
5014
- };
5015
-
5016
-
5017
- /**
5018
- * ### Changed plugin
5019
- *
5020
- * This plugin adds more information to the `changed.jstree` event. The new data is contained in the `changed` event data property, and contains a lists of `selected` and `deselected` nodes.
5021
- */
5022
-
5023
- $.jstree.plugins.changed = function (options, parent) {
5024
- var last = [];
5025
- this.trigger = function (ev, data) {
5026
- var i, j;
5027
- if(!data) {
5028
- data = {};
5029
- }
5030
- if(ev.replace('.jstree','') === 'changed') {
5031
- data.changed = { selected : [], deselected : [] };
5032
- var tmp = {};
5033
- for(i = 0, j = last.length; i < j; i++) {
5034
- tmp[last[i]] = 1;
5035
- }
5036
- for(i = 0, j = data.selected.length; i < j; i++) {
5037
- if(!tmp[data.selected[i]]) {
5038
- data.changed.selected.push(data.selected[i]);
5039
- }
5040
- else {
5041
- tmp[data.selected[i]] = 2;
5042
- }
5043
- }
5044
- for(i = 0, j = last.length; i < j; i++) {
5045
- if(tmp[last[i]] === 1) {
5046
- data.changed.deselected.push(last[i]);
5047
- }
5048
- }
5049
- last = data.selected.slice();
5050
- }
5051
- /**
5052
- * triggered when selection changes (the "changed" plugin enhances the original event with more data)
5053
- * @event
5054
- * @name changed.jstree
5055
- * @param {Object} node
5056
- * @param {Object} action the action that caused the selection to change
5057
- * @param {Array} selected the current selection
5058
- * @param {Object} changed an object containing two properties `selected` and `deselected` - both arrays of node IDs, which were selected or deselected since the last changed event
5059
- * @param {Object} event the event (if any) that triggered this changed event
5060
- * @plugin changed
5061
- */
5062
- parent.trigger.call(this, ev, data);
5063
- };
5064
- this.refresh = function (skip_loading, forget_state) {
5065
- last = [];
5066
- return parent.refresh.apply(this, arguments);
5067
- };
5068
- };
5069
-
5070
- /**
5071
- * ### Checkbox plugin
5072
- *
5073
- * This plugin renders checkbox icons in front of each node, making multiple selection much easier.
5074
- * It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up.
5075
- */
5076
-
5077
- var _i = document.createElement('I');
5078
- _i.className = 'jstree-icon jstree-checkbox';
5079
- _i.setAttribute('role', 'presentation');
5080
- /**
5081
- * stores all defaults for the checkbox plugin
5082
- * @name $.jstree.defaults.checkbox
5083
- * @plugin checkbox
5084
- */
5085
- $.jstree.defaults.checkbox = {
5086
- /**
5087
- * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`.
5088
- * @name $.jstree.defaults.checkbox.visible
5089
- * @plugin checkbox
5090
- */
5091
- visible : true,
5092
- /**
5093
- * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`.
5094
- * @name $.jstree.defaults.checkbox.three_state
5095
- * @plugin checkbox
5096
- */
5097
- three_state : true,
5098
- /**
5099
- * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`.
5100
- * @name $.jstree.defaults.checkbox.whole_node
5101
- * @plugin checkbox
5102
- */
5103
- whole_node : true,
5104
- /**
5105
- * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`.
5106
- * @name $.jstree.defaults.checkbox.keep_selected_style
5107
- * @plugin checkbox
5108
- */
5109
- keep_selected_style : true,
5110
- /**
5111
- * This setting controls how cascading and undetermined nodes are applied.
5112
- * If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used.
5113
- * If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''.
5114
- * @name $.jstree.defaults.checkbox.cascade
5115
- * @plugin checkbox
5116
- */
5117
- cascade : '',
5118
- /**
5119
- * This setting controls if checkbox are bound to the general tree selection or to an internal array maintained by the checkbox plugin. Defaults to `true`, only set to `false` if you know exactly what you are doing.
5120
- * @name $.jstree.defaults.checkbox.tie_selection
5121
- * @plugin checkbox
5122
- */
5123
- tie_selection : true,
5124
-
5125
- /**
5126
- * This setting controls if cascading down affects disabled checkboxes
5127
- * @name $.jstree.defaults.checkbox.cascade_to_disabled
5128
- * @plugin checkbox
5129
- */
5130
- cascade_to_disabled : true,
5131
-
5132
- /**
5133
- * This setting controls if cascading down affects hidden checkboxes
5134
- * @name $.jstree.defaults.checkbox.cascade_to_hidden
5135
- * @plugin checkbox
5136
- */
5137
- cascade_to_hidden : true
5138
- };
5139
- $.jstree.plugins.checkbox = function (options, parent) {
5140
- this.bind = function () {
5141
- parent.bind.call(this);
5142
- this._data.checkbox.uto = false;
5143
- this._data.checkbox.selected = [];
5144
- if(this.settings.checkbox.three_state) {
5145
- this.settings.checkbox.cascade = 'up+down+undetermined';
5146
- }
5147
- this.element
5148
- .on("init.jstree", $.proxy(function () {
5149
- this._data.checkbox.visible = this.settings.checkbox.visible;
5150
- if(!this.settings.checkbox.keep_selected_style) {
5151
- this.element.addClass('jstree-checkbox-no-clicked');
5152
- }
5153
- if(this.settings.checkbox.tie_selection) {
5154
- this.element.addClass('jstree-checkbox-selection');
5155
- }
5156
- }, this))
5157
- .on("loading.jstree", $.proxy(function () {
5158
- this[ this._data.checkbox.visible ? 'show_checkboxes' : 'hide_checkboxes' ]();
5159
- }, this));
5160
- if(this.settings.checkbox.cascade.indexOf('undetermined') !== -1) {
5161
- this.element
5162
- .on('changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree', $.proxy(function () {
5163
- // only if undetermined is in setting
5164
- if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); }
5165
- this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50);
5166
- }, this));
5167
- }
5168
- if(!this.settings.checkbox.tie_selection) {
5169
- this.element
5170
- .on('model.jstree', $.proxy(function (e, data) {
5171
- var m = this._model.data,
5172
- p = m[data.parent],
5173
- dpc = data.nodes,
5174
- i, j;
5175
- for(i = 0, j = dpc.length; i < j; i++) {
5176
- m[dpc[i]].state.checked = m[dpc[i]].state.checked || (m[dpc[i]].original && m[dpc[i]].original.state && m[dpc[i]].original.state.checked);
5177
- if(m[dpc[i]].state.checked) {
5178
- this._data.checkbox.selected.push(dpc[i]);
5179
- }
5180
- }
5181
- }, this));
5182
- }
5183
- if(this.settings.checkbox.cascade.indexOf('up') !== -1 || this.settings.checkbox.cascade.indexOf('down') !== -1) {
5184
- this.element
5185
- .on('model.jstree', $.proxy(function (e, data) {
5186
- var m = this._model.data,
5187
- p = m[data.parent],
5188
- dpc = data.nodes,
5189
- chd = [],
5190
- c, i, j, k, l, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection;
5191
-
5192
- if(s.indexOf('down') !== -1) {
5193
- // apply down
5194
- if(p.state[ t ? 'selected' : 'checked' ]) {
5195
- for(i = 0, j = dpc.length; i < j; i++) {
5196
- m[dpc[i]].state[ t ? 'selected' : 'checked' ] = true;
5197
- }
5198
-
5199
- this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(dpc);
5200
- }
5201
- else {
5202
- for(i = 0, j = dpc.length; i < j; i++) {
5203
- if(m[dpc[i]].state[ t ? 'selected' : 'checked' ]) {
5204
- for(k = 0, l = m[dpc[i]].children_d.length; k < l; k++) {
5205
- m[m[dpc[i]].children_d[k]].state[ t ? 'selected' : 'checked' ] = true;
5206
- }
5207
- this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(m[dpc[i]].children_d);
5208
- }
5209
- }
5210
- }
5211
- }
5212
-
5213
- if(s.indexOf('up') !== -1) {
5214
- // apply up
5215
- for(i = 0, j = p.children_d.length; i < j; i++) {
5216
- if(!m[p.children_d[i]].children.length) {
5217
- chd.push(m[p.children_d[i]].parent);
5218
- }
5219
- }
5220
- chd = $.vakata.array_unique(chd);
5221
- for(k = 0, l = chd.length; k < l; k++) {
5222
- p = m[chd[k]];
5223
- while(p && p.id !== $.jstree.root) {
5224
- c = 0;
5225
- for(i = 0, j = p.children.length; i < j; i++) {
5226
- c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5227
- }
5228
- if(c === j) {
5229
- p.state[ t ? 'selected' : 'checked' ] = true;
5230
- this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5231
- tmp = this.get_node(p, true);
5232
- if(tmp && tmp.length) {
5233
- tmp.attr('aria-selected', true).children('.jstree-anchor').addClass( t ? 'jstree-clicked' : 'jstree-checked');
5234
- }
5235
- }
5236
- else {
5237
- break;
5238
- }
5239
- p = this.get_node(p.parent);
5240
- }
5241
- }
5242
- }
5243
-
5244
- this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected);
5245
- }, this))
5246
- .on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', $.proxy(function (e, data) {
5247
- var self = this,
5248
- obj = data.node,
5249
- m = this._model.data,
5250
- par = this.get_node(obj.parent),
5251
- i, j, c, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection,
5252
- sel = {}, cur = this._data[ t ? 'core' : 'checkbox' ].selected;
5253
-
5254
- for (i = 0, j = cur.length; i < j; i++) {
5255
- sel[cur[i]] = true;
5256
- }
5257
-
5258
- // apply down
5259
- if(s.indexOf('down') !== -1) {
5260
- //this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d));
5261
- var selectedIds = this._cascade_new_checked_state(obj.id, true);
5262
- var temp = obj.children_d.concat(obj.id);
5263
- for (i = 0, j = temp.length; i < j; i++) {
5264
- if (selectedIds.indexOf(temp[i]) > -1) {
5265
- sel[temp[i]] = true;
5266
- }
5267
- else {
5268
- delete sel[temp[i]];
5269
- }
5270
- }
5271
- }
5272
-
5273
- // apply up
5274
- if(s.indexOf('up') !== -1) {
5275
- while(par && par.id !== $.jstree.root) {
5276
- c = 0;
5277
- for(i = 0, j = par.children.length; i < j; i++) {
5278
- c += m[par.children[i]].state[ t ? 'selected' : 'checked' ];
5279
- }
5280
- if(c === j) {
5281
- par.state[ t ? 'selected' : 'checked' ] = true;
5282
- sel[par.id] = true;
5283
- //this._data[ t ? 'core' : 'checkbox' ].selected.push(par.id);
5284
- tmp = this.get_node(par, true);
5285
- if(tmp && tmp.length) {
5286
- tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5287
- }
5288
- }
5289
- else {
5290
- break;
5291
- }
5292
- par = this.get_node(par.parent);
5293
- }
5294
- }
5295
-
5296
- cur = [];
5297
- for (i in sel) {
5298
- if (sel.hasOwnProperty(i)) {
5299
- cur.push(i);
5300
- }
5301
- }
5302
- this._data[ t ? 'core' : 'checkbox' ].selected = cur;
5303
- }, this))
5304
- .on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', $.proxy(function (e, data) {
5305
- var obj = this.get_node($.jstree.root),
5306
- m = this._model.data,
5307
- i, j, tmp;
5308
- for(i = 0, j = obj.children_d.length; i < j; i++) {
5309
- tmp = m[obj.children_d[i]];
5310
- if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) {
5311
- tmp.original.state.undetermined = false;
5312
- }
5313
- }
5314
- }, this))
5315
- .on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', $.proxy(function (e, data) {
5316
- var self = this,
5317
- obj = data.node,
5318
- dom = this.get_node(obj, true),
5319
- i, j, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection,
5320
- cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {},
5321
- stillSelectedIds = [],
5322
- allIds = obj.children_d.concat(obj.id);
5323
-
5324
- // apply down
5325
- if(s.indexOf('down') !== -1) {
5326
- var selectedIds = this._cascade_new_checked_state(obj.id, false);
5327
-
5328
- cur = $.vakata.array_filter(cur, function(id) {
5329
- return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1;
5330
- });
5331
- }
5332
-
5333
- // only apply up if cascade up is enabled and if this node is not selected
5334
- // (if all child nodes are disabled and cascade_to_disabled === false then this node will till be selected).
5335
- if(s.indexOf('up') !== -1 && cur.indexOf(obj.id) === -1) {
5336
- for(i = 0, j = obj.parents.length; i < j; i++) {
5337
- tmp = this._model.data[obj.parents[i]];
5338
- tmp.state[ t ? 'selected' : 'checked' ] = false;
5339
- if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) {
5340
- tmp.original.state.undetermined = false;
5341
- }
5342
- tmp = this.get_node(obj.parents[i], true);
5343
- if(tmp && tmp.length) {
5344
- tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5345
- }
5346
- }
5347
-
5348
- cur = $.vakata.array_filter(cur, function(id) {
5349
- return obj.parents.indexOf(id) === -1;
5350
- });
5351
- }
5352
-
5353
- this._data[ t ? 'core' : 'checkbox' ].selected = cur;
5354
- }, this));
5355
- }
5356
- if(this.settings.checkbox.cascade.indexOf('up') !== -1) {
5357
- this.element
5358
- .on('delete_node.jstree', $.proxy(function (e, data) {
5359
- // apply up (whole handler)
5360
- var p = this.get_node(data.parent),
5361
- m = this._model.data,
5362
- i, j, c, tmp, t = this.settings.checkbox.tie_selection;
5363
- while(p && p.id !== $.jstree.root && !p.state[ t ? 'selected' : 'checked' ]) {
5364
- c = 0;
5365
- for(i = 0, j = p.children.length; i < j; i++) {
5366
- c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5367
- }
5368
- if(j > 0 && c === j) {
5369
- p.state[ t ? 'selected' : 'checked' ] = true;
5370
- this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5371
- tmp = this.get_node(p, true);
5372
- if(tmp && tmp.length) {
5373
- tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5374
- }
5375
- }
5376
- else {
5377
- break;
5378
- }
5379
- p = this.get_node(p.parent);
5380
- }
5381
- }, this))
5382
- .on('move_node.jstree', $.proxy(function (e, data) {
5383
- // apply up (whole handler)
5384
- var is_multi = data.is_multi,
5385
- old_par = data.old_parent,
5386
- new_par = this.get_node(data.parent),
5387
- m = this._model.data,
5388
- p, c, i, j, tmp, t = this.settings.checkbox.tie_selection;
5389
- if(!is_multi) {
5390
- p = this.get_node(old_par);
5391
- while(p && p.id !== $.jstree.root && !p.state[ t ? 'selected' : 'checked' ]) {
5392
- c = 0;
5393
- for(i = 0, j = p.children.length; i < j; i++) {
5394
- c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5395
- }
5396
- if(j > 0 && c === j) {
5397
- p.state[ t ? 'selected' : 'checked' ] = true;
5398
- this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5399
- tmp = this.get_node(p, true);
5400
- if(tmp && tmp.length) {
5401
- tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5402
- }
5403
- }
5404
- else {
5405
- break;
5406
- }
5407
- p = this.get_node(p.parent);
5408
- }
5409
- }
5410
- p = new_par;
5411
- while(p && p.id !== $.jstree.root) {
5412
- c = 0;
5413
- for(i = 0, j = p.children.length; i < j; i++) {
5414
- c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5415
- }
5416
- if(c === j) {
5417
- if(!p.state[ t ? 'selected' : 'checked' ]) {
5418
- p.state[ t ? 'selected' : 'checked' ] = true;
5419
- this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5420
- tmp = this.get_node(p, true);
5421
- if(tmp && tmp.length) {
5422
- tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5423
- }
5424
- }
5425
- }
5426
- else {
5427
- if(p.state[ t ? 'selected' : 'checked' ]) {
5428
- p.state[ t ? 'selected' : 'checked' ] = false;
5429
- this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_remove_item(this._data[ t ? 'core' : 'checkbox' ].selected, p.id);
5430
- tmp = this.get_node(p, true);
5431
- if(tmp && tmp.length) {
5432
- tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5433
- }
5434
- }
5435
- else {
5436
- break;
5437
- }
5438
- }
5439
- p = this.get_node(p.parent);
5440
- }
5441
- }, this));
5442
- }
5443
- };
5444
- /**
5445
- * get an array of all nodes whose state is "undetermined"
5446
- * @name get_undetermined([full])
5447
- * @param {boolean} full: if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5448
- * @return {Array}
5449
- * @plugin checkbox
5450
- */
5451
- this.get_undetermined = function (full) {
5452
- if (this.settings.checkbox.cascade.indexOf('undetermined') === -1) {
5453
- return [];
5454
- }
5455
- var i, j, k, l, o = {}, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this, r = [];
5456
- for(i = 0, j = s.length; i < j; i++) {
5457
- if(m[s[i]] && m[s[i]].parents) {
5458
- for(k = 0, l = m[s[i]].parents.length; k < l; k++) {
5459
- if(o[m[s[i]].parents[k]] !== undefined) {
5460
- break;
5461
- }
5462
- if(m[s[i]].parents[k] !== $.jstree.root) {
5463
- o[m[s[i]].parents[k]] = true;
5464
- p.push(m[s[i]].parents[k]);
5465
- }
5466
- }
5467
- }
5468
- }
5469
- // attempt for server side undetermined state
5470
- this.element.find('.jstree-closed').not(':has(.jstree-children)')
5471
- .each(function () {
5472
- var tmp = tt.get_node(this), tmp2;
5473
-
5474
- if(!tmp) { return; }
5475
-
5476
- if(!tmp.state.loaded) {
5477
- if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) {
5478
- if(o[tmp.id] === undefined && tmp.id !== $.jstree.root) {
5479
- o[tmp.id] = true;
5480
- p.push(tmp.id);
5481
- }
5482
- for(k = 0, l = tmp.parents.length; k < l; k++) {
5483
- if(o[tmp.parents[k]] === undefined && tmp.parents[k] !== $.jstree.root) {
5484
- o[tmp.parents[k]] = true;
5485
- p.push(tmp.parents[k]);
5486
- }
5487
- }
5488
- }
5489
- }
5490
- else {
5491
- for(i = 0, j = tmp.children_d.length; i < j; i++) {
5492
- tmp2 = m[tmp.children_d[i]];
5493
- if(!tmp2.state.loaded && tmp2.original && tmp2.original.state && tmp2.original.state.undetermined && tmp2.original.state.undetermined === true) {
5494
- if(o[tmp2.id] === undefined && tmp2.id !== $.jstree.root) {
5495
- o[tmp2.id] = true;
5496
- p.push(tmp2.id);
5497
- }
5498
- for(k = 0, l = tmp2.parents.length; k < l; k++) {
5499
- if(o[tmp2.parents[k]] === undefined && tmp2.parents[k] !== $.jstree.root) {
5500
- o[tmp2.parents[k]] = true;
5501
- p.push(tmp2.parents[k]);
5502
- }
5503
- }
5504
- }
5505
- }
5506
- }
5507
- });
5508
- for (i = 0, j = p.length; i < j; i++) {
5509
- if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
5510
- r.push(full ? m[p[i]] : p[i]);
5511
- }
5512
- }
5513
- return r;
5514
- };
5515
- /**
5516
- * set the undetermined state where and if necessary. Used internally.
5517
- * @private
5518
- * @name _undetermined()
5519
- * @plugin checkbox
5520
- */
5521
- this._undetermined = function () {
5522
- if(this.element === null) { return; }
5523
- var p = this.get_undetermined(false), i, j, s;
5524
-
5525
- this.element.find('.jstree-undetermined').removeClass('jstree-undetermined');
5526
- for (i = 0, j = p.length; i < j; i++) {
5527
- s = this.get_node(p[i], true);
5528
- if(s && s.length) {
5529
- s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
5530
- }
5531
- }
5532
- };
5533
- this.redraw_node = function(obj, deep, is_callback, force_render) {
5534
- obj = parent.redraw_node.apply(this, arguments);
5535
- if(obj) {
5536
- var i, j, tmp = null, icon = null;
5537
- for(i = 0, j = obj.childNodes.length; i < j; i++) {
5538
- if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) {
5539
- tmp = obj.childNodes[i];
5540
- break;
5541
- }
5542
- }
5543
- if(tmp) {
5544
- if(!this.settings.checkbox.tie_selection && this._model.data[obj.id].state.checked) { tmp.className += ' jstree-checked'; }
5545
- icon = _i.cloneNode(false);
5546
- if(this._model.data[obj.id].state.checkbox_disabled) { icon.className += ' jstree-checkbox-disabled'; }
5547
- tmp.insertBefore(icon, tmp.childNodes[0]);
5548
- }
5549
- }
5550
- if(!is_callback && this.settings.checkbox.cascade.indexOf('undetermined') !== -1) {
5551
- if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); }
5552
- this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50);
5553
- }
5554
- return obj;
5555
- };
5556
- /**
5557
- * show the node checkbox icons
5558
- * @name show_checkboxes()
5559
- * @plugin checkbox
5560
- */
5561
- this.show_checkboxes = function () { this._data.core.themes.checkboxes = true; this.get_container_ul().removeClass("jstree-no-checkboxes"); };
5562
- /**
5563
- * hide the node checkbox icons
5564
- * @name hide_checkboxes()
5565
- * @plugin checkbox
5566
- */
5567
- this.hide_checkboxes = function () { this._data.core.themes.checkboxes = false; this.get_container_ul().addClass("jstree-no-checkboxes"); };
5568
- /**
5569
- * toggle the node icons
5570
- * @name toggle_checkboxes()
5571
- * @plugin checkbox
5572
- */
5573
- this.toggle_checkboxes = function () { if(this._data.core.themes.checkboxes) { this.hide_checkboxes(); } else { this.show_checkboxes(); } };
5574
- /**
5575
- * checks if a node is in an undetermined state
5576
- * @name is_undetermined(obj)
5577
- * @param {mixed} obj
5578
- * @return {Boolean}
5579
- */
5580
- this.is_undetermined = function (obj) {
5581
- obj = this.get_node(obj);
5582
- var s = this.settings.checkbox.cascade, i, j, t = this.settings.checkbox.tie_selection, d = this._data[ t ? 'core' : 'checkbox' ].selected, m = this._model.data;
5583
- if(!obj || obj.state[ t ? 'selected' : 'checked' ] === true || s.indexOf('undetermined') === -1 || (s.indexOf('down') === -1 && s.indexOf('up') === -1)) {
5584
- return false;
5585
- }
5586
- if(!obj.state.loaded && obj.original.state.undetermined === true) {
5587
- return true;
5588
- }
5589
- for(i = 0, j = obj.children_d.length; i < j; i++) {
5590
- if($.inArray(obj.children_d[i], d) !== -1 || (!m[obj.children_d[i]].state.loaded && m[obj.children_d[i]].original.state.undetermined)) {
5591
- return true;
5592
- }
5593
- }
5594
- return false;
5595
- };
5596
- /**
5597
- * disable a node's checkbox
5598
- * @name disable_checkbox(obj)
5599
- * @param {mixed} obj an array can be used too
5600
- * @trigger disable_checkbox.jstree
5601
- * @plugin checkbox
5602
- */
5603
- this.disable_checkbox = function (obj) {
5604
- var t1, t2, dom;
5605
- if($.isArray(obj)) {
5606
- obj = obj.slice();
5607
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5608
- this.disable_checkbox(obj[t1]);
5609
- }
5610
- return true;
5611
- }
5612
- obj = this.get_node(obj);
5613
- if(!obj || obj.id === $.jstree.root) {
5614
- return false;
5615
- }
5616
- dom = this.get_node(obj, true);
5617
- if(!obj.state.checkbox_disabled) {
5618
- obj.state.checkbox_disabled = true;
5619
- if(dom && dom.length) {
5620
- dom.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-checkbox-disabled');
5621
- }
5622
- /**
5623
- * triggered when an node's checkbox is disabled
5624
- * @event
5625
- * @name disable_checkbox.jstree
5626
- * @param {Object} node
5627
- * @plugin checkbox
5628
- */
5629
- this.trigger('disable_checkbox', { 'node' : obj });
5630
- }
5631
- };
5632
- /**
5633
- * enable a node's checkbox
5634
- * @name enable_checkbox(obj)
5635
- * @param {mixed} obj an array can be used too
5636
- * @trigger enable_checkbox.jstree
5637
- * @plugin checkbox
5638
- */
5639
- this.enable_checkbox = function (obj) {
5640
- var t1, t2, dom;
5641
- if($.isArray(obj)) {
5642
- obj = obj.slice();
5643
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5644
- this.enable_checkbox(obj[t1]);
5645
- }
5646
- return true;
5647
- }
5648
- obj = this.get_node(obj);
5649
- if(!obj || obj.id === $.jstree.root) {
5650
- return false;
5651
- }
5652
- dom = this.get_node(obj, true);
5653
- if(obj.state.checkbox_disabled) {
5654
- obj.state.checkbox_disabled = false;
5655
- if(dom && dom.length) {
5656
- dom.children('.jstree-anchor').children('.jstree-checkbox').removeClass('jstree-checkbox-disabled');
5657
- }
5658
- /**
5659
- * triggered when an node's checkbox is enabled
5660
- * @event
5661
- * @name enable_checkbox.jstree
5662
- * @param {Object} node
5663
- * @plugin checkbox
5664
- */
5665
- this.trigger('enable_checkbox', { 'node' : obj });
5666
- }
5667
- };
5668
-
5669
- this.activate_node = function (obj, e) {
5670
- if($(e.target).hasClass('jstree-checkbox-disabled')) {
5671
- return false;
5672
- }
5673
- if(this.settings.checkbox.tie_selection && (this.settings.checkbox.whole_node || $(e.target).hasClass('jstree-checkbox'))) {
5674
- e.ctrlKey = true;
5675
- }
5676
- if(this.settings.checkbox.tie_selection || (!this.settings.checkbox.whole_node && !$(e.target).hasClass('jstree-checkbox'))) {
5677
- return parent.activate_node.call(this, obj, e);
5678
- }
5679
- if(this.is_disabled(obj)) {
5680
- return false;
5681
- }
5682
- if(this.is_checked(obj)) {
5683
- this.uncheck_node(obj, e);
5684
- }
5685
- else {
5686
- this.check_node(obj, e);
5687
- }
5688
- this.trigger('activate_node', { 'node' : this.get_node(obj) });
5689
- };
5690
-
5691
- /**
5692
- * Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
5693
- * However if these unaffected nodes are already selected their ids will be included in the returned array.
5694
- * @private
5695
- * @param {string} id the node ID
5696
- * @param {bool} checkedState should the nodes be checked or not
5697
- * @returns {Array} Array of all node id's (in this tree branch) that are checked.
5698
- */
5699
- this._cascade_new_checked_state = function (id, checkedState) {
5700
- var self = this;
5701
- var t = this.settings.checkbox.tie_selection;
5702
- var node = this._model.data[id];
5703
- var selectedNodeIds = [];
5704
- var selectedChildrenIds = [], i, j, selectedChildIds;
5705
-
5706
- if (
5707
- (this.settings.checkbox.cascade_to_disabled || !node.state.disabled) &&
5708
- (this.settings.checkbox.cascade_to_hidden || !node.state.hidden)
5709
- ) {
5710
- //First try and check/uncheck the children
5711
- if (node.children) {
5712
- for (i = 0, j = node.children.length; i < j; i++) {
5713
- var childId = node.children[i];
5714
- selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
5715
- selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5716
- if (selectedChildIds.indexOf(childId) > -1) {
5717
- selectedChildrenIds.push(childId);
5718
- }
5719
- }
5720
- }
5721
-
5722
- var dom = self.get_node(node, true);
5723
-
5724
- //A node's state is undetermined if some but not all of it's children are checked/selected .
5725
- var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length;
5726
-
5727
- if(node.original && node.original.state && node.original.state.undetermined) {
5728
- node.original.state.undetermined = undetermined;
5729
- }
5730
-
5731
- //If a node is undetermined then remove selected class
5732
- if (undetermined) {
5733
- node.state[ t ? 'selected' : 'checked' ] = false;
5734
- dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5735
- }
5736
- //Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children),
5737
- //check the node and style it correctly.
5738
- else if (checkedState && selectedChildrenIds.length === node.children.length) {
5739
- node.state[ t ? 'selected' : 'checked' ] = checkedState;
5740
- selectedNodeIds.push(node.id);
5741
-
5742
- dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5743
- }
5744
- else {
5745
- node.state[ t ? 'selected' : 'checked' ] = false;
5746
- dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5747
- }
5748
- }
5749
- else {
5750
- selectedChildIds = this.get_checked_descendants(id);
5751
-
5752
- if (node.state[ t ? 'selected' : 'checked' ]) {
5753
- selectedChildIds.push(node.id);
5754
- }
5755
-
5756
- selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5757
- }
5758
-
5759
- return selectedNodeIds;
5760
- };
5761
-
5762
- /**
5763
- * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id)
5764
- * @name get_checked_descendants(obj)
5765
- * @param {string} id the node ID
5766
- * @return {Array} array of IDs
5767
- * @plugin checkbox
5768
- */
5769
- this.get_checked_descendants = function (id) {
5770
- var self = this;
5771
- var t = self.settings.checkbox.tie_selection;
5772
- var node = self._model.data[id];
5773
-
5774
- return $.vakata.array_filter(node.children_d, function(_id) {
5775
- return self._model.data[_id].state[ t ? 'selected' : 'checked' ];
5776
- });
5777
- };
5778
-
5779
- /**
5780
- * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally)
5781
- * @name check_node(obj)
5782
- * @param {mixed} obj an array can be used to check multiple nodes
5783
- * @trigger check_node.jstree
5784
- * @plugin checkbox
5785
- */
5786
- this.check_node = function (obj, e) {
5787
- if(this.settings.checkbox.tie_selection) { return this.select_node(obj, false, true, e); }
5788
- var dom, t1, t2, th;
5789
- if($.isArray(obj)) {
5790
- obj = obj.slice();
5791
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5792
- this.check_node(obj[t1], e);
5793
- }
5794
- return true;
5795
- }
5796
- obj = this.get_node(obj);
5797
- if(!obj || obj.id === $.jstree.root) {
5798
- return false;
5799
- }
5800
- dom = this.get_node(obj, true);
5801
- if(!obj.state.checked) {
5802
- obj.state.checked = true;
5803
- this._data.checkbox.selected.push(obj.id);
5804
- if(dom && dom.length) {
5805
- dom.children('.jstree-anchor').addClass('jstree-checked');
5806
- }
5807
- /**
5808
- * triggered when an node is checked (only if tie_selection in checkbox settings is false)
5809
- * @event
5810
- * @name check_node.jstree
5811
- * @param {Object} node
5812
- * @param {Array} selected the current selection
5813
- * @param {Object} event the event (if any) that triggered this check_node
5814
- * @plugin checkbox
5815
- */
5816
- this.trigger('check_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e });
5817
- }
5818
- };
5819
- /**
5820
- * uncheck a node (only if tie_selection in checkbox settings is false, otherwise deselect_node will be called internally)
5821
- * @name uncheck_node(obj)
5822
- * @param {mixed} obj an array can be used to uncheck multiple nodes
5823
- * @trigger uncheck_node.jstree
5824
- * @plugin checkbox
5825
- */
5826
- this.uncheck_node = function (obj, e) {
5827
- if(this.settings.checkbox.tie_selection) { return this.deselect_node(obj, false, e); }
5828
- var t1, t2, dom;
5829
- if($.isArray(obj)) {
5830
- obj = obj.slice();
5831
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5832
- this.uncheck_node(obj[t1], e);
5833
- }
5834
- return true;
5835
- }
5836
- obj = this.get_node(obj);
5837
- if(!obj || obj.id === $.jstree.root) {
5838
- return false;
5839
- }
5840
- dom = this.get_node(obj, true);
5841
- if(obj.state.checked) {
5842
- obj.state.checked = false;
5843
- this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, obj.id);
5844
- if(dom.length) {
5845
- dom.children('.jstree-anchor').removeClass('jstree-checked');
5846
- }
5847
- /**
5848
- * triggered when an node is unchecked (only if tie_selection in checkbox settings is false)
5849
- * @event
5850
- * @name uncheck_node.jstree
5851
- * @param {Object} node
5852
- * @param {Array} selected the current selection
5853
- * @param {Object} event the event (if any) that triggered this uncheck_node
5854
- * @plugin checkbox
5855
- */
5856
- this.trigger('uncheck_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e });
5857
- }
5858
- };
5859
-
5860
- /**
5861
- * checks all nodes in the tree (only if tie_selection in checkbox settings is false, otherwise select_all will be called internally)
5862
- * @name check_all()
5863
- * @trigger check_all.jstree, changed.jstree
5864
- * @plugin checkbox
5865
- */
5866
- this.check_all = function () {
5867
- if(this.settings.checkbox.tie_selection) { return this.select_all(); }
5868
- var tmp = this._data.checkbox.selected.concat([]), i, j;
5869
- this._data.checkbox.selected = this._model.data[$.jstree.root].children_d.concat();
5870
- for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) {
5871
- if(this._model.data[this._data.checkbox.selected[i]]) {
5872
- this._model.data[this._data.checkbox.selected[i]].state.checked = true;
5873
- }
5874
- }
5875
- this.redraw(true);
5876
- /**
5877
- * triggered when all nodes are checked (only if tie_selection in checkbox settings is false)
5878
- * @event
5879
- * @name check_all.jstree
5880
- * @param {Array} selected the current selection
5881
- * @plugin checkbox
5882
- */
5883
- this.trigger('check_all', { 'selected' : this._data.checkbox.selected });
5884
- };
5885
- /**
5886
- * uncheck all checked nodes (only if tie_selection in checkbox settings is false, otherwise deselect_all will be called internally)
5887
- * @name uncheck_all()
5888
- * @trigger uncheck_all.jstree
5889
- * @plugin checkbox
5890
- */
5891
- this.uncheck_all = function () {
5892
- if(this.settings.checkbox.tie_selection) { return this.deselect_all(); }
5893
- var tmp = this._data.checkbox.selected.concat([]), i, j;
5894
- for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) {
5895
- if(this._model.data[this._data.checkbox.selected[i]]) {
5896
- this._model.data[this._data.checkbox.selected[i]].state.checked = false;
5897
- }
5898
- }
5899
- this._data.checkbox.selected = [];
5900
- this.element.find('.jstree-checked').removeClass('jstree-checked');
5901
- /**
5902
- * triggered when all nodes are unchecked (only if tie_selection in checkbox settings is false)
5903
- * @event
5904
- * @name uncheck_all.jstree
5905
- * @param {Object} node the previous selection
5906
- * @param {Array} selected the current selection
5907
- * @plugin checkbox
5908
- */
5909
- this.trigger('uncheck_all', { 'selected' : this._data.checkbox.selected, 'node' : tmp });
5910
- };
5911
- /**
5912
- * checks if a node is checked (if tie_selection is on in the settings this function will return the same as is_selected)
5913
- * @name is_checked(obj)
5914
- * @param {mixed} obj
5915
- * @return {Boolean}
5916
- * @plugin checkbox
5917
- */
5918
- this.is_checked = function (obj) {
5919
- if(this.settings.checkbox.tie_selection) { return this.is_selected(obj); }
5920
- obj = this.get_node(obj);
5921
- if(!obj || obj.id === $.jstree.root) { return false; }
5922
- return obj.state.checked;
5923
- };
5924
- /**
5925
- * get an array of all checked nodes (if tie_selection is on in the settings this function will return the same as get_selected)
5926
- * @name get_checked([full])
5927
- * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5928
- * @return {Array}
5929
- * @plugin checkbox
5930
- */
5931
- this.get_checked = function (full) {
5932
- if(this.settings.checkbox.tie_selection) { return this.get_selected(full); }
5933
- return full ? $.map(this._data.checkbox.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.checkbox.selected.slice();
5934
- };
5935
- /**
5936
- * get an array of all top level checked nodes (ignoring children of checked nodes) (if tie_selection is on in the settings this function will return the same as get_top_selected)
5937
- * @name get_top_checked([full])
5938
- * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5939
- * @return {Array}
5940
- * @plugin checkbox
5941
- */
5942
- this.get_top_checked = function (full) {
5943
- if(this.settings.checkbox.tie_selection) { return this.get_top_selected(full); }
5944
- var tmp = this.get_checked(true),
5945
- obj = {}, i, j, k, l;
5946
- for(i = 0, j = tmp.length; i < j; i++) {
5947
- obj[tmp[i].id] = tmp[i];
5948
- }
5949
- for(i = 0, j = tmp.length; i < j; i++) {
5950
- for(k = 0, l = tmp[i].children_d.length; k < l; k++) {
5951
- if(obj[tmp[i].children_d[k]]) {
5952
- delete obj[tmp[i].children_d[k]];
5953
- }
5954
- }
5955
- }
5956
- tmp = [];
5957
- for(i in obj) {
5958
- if(obj.hasOwnProperty(i)) {
5959
- tmp.push(i);
5960
- }
5961
- }
5962
- return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp;
5963
- };
5964
- /**
5965
- * get an array of all bottom level checked nodes (ignoring selected parents) (if tie_selection is on in the settings this function will return the same as get_bottom_selected)
5966
- * @name get_bottom_checked([full])
5967
- * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5968
- * @return {Array}
5969
- * @plugin checkbox
5970
- */
5971
- this.get_bottom_checked = function (full) {
5972
- if(this.settings.checkbox.tie_selection) { return this.get_bottom_selected(full); }
5973
- var tmp = this.get_checked(true),
5974
- obj = [], i, j;
5975
- for(i = 0, j = tmp.length; i < j; i++) {
5976
- if(!tmp[i].children.length) {
5977
- obj.push(tmp[i].id);
5978
- }
5979
- }
5980
- return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj;
5981
- };
5982
- this.load_node = function (obj, callback) {
5983
- var k, l, i, j, c, tmp;
5984
- if(!$.isArray(obj) && !this.settings.checkbox.tie_selection) {
5985
- tmp = this.get_node(obj);
5986
- if(tmp && tmp.state.loaded) {
5987
- for(k = 0, l = tmp.children_d.length; k < l; k++) {
5988
- if(this._model.data[tmp.children_d[k]].state.checked) {
5989
- c = true;
5990
- this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, tmp.children_d[k]);
5991
- }
5992
- }
5993
- }
5994
- }
5995
- return parent.load_node.apply(this, arguments);
5996
- };
5997
- this.get_state = function () {
5998
- var state = parent.get_state.apply(this, arguments);
5999
- if(this.settings.checkbox.tie_selection) { return state; }
6000
- state.checkbox = this._data.checkbox.selected.slice();
6001
- return state;
6002
- };
6003
- this.set_state = function (state, callback) {
6004
- var res = parent.set_state.apply(this, arguments);
6005
- if(res && state.checkbox) {
6006
- if(!this.settings.checkbox.tie_selection) {
6007
- this.uncheck_all();
6008
- var _this = this;
6009
- $.each(state.checkbox, function (i, v) {
6010
- _this.check_node(v);
6011
- });
6012
- }
6013
- delete state.checkbox;
6014
- this.set_state(state, callback);
6015
- return false;
6016
- }
6017
- return res;
6018
- };
6019
- this.refresh = function (skip_loading, forget_state) {
6020
- if(this.settings.checkbox.tie_selection) {
6021
- this._data.checkbox.selected = [];
6022
- }
6023
- return parent.refresh.apply(this, arguments);
6024
- };
6025
- };
6026
-
6027
- // include the checkbox plugin by default
6028
- // $.jstree.defaults.plugins.push("checkbox");
6029
-
6030
-
6031
- /**
6032
- * ### Conditionalselect plugin
6033
- *
6034
- * This plugin allows defining a callback to allow or deny node selection by user input (activate node method).
6035
- */
6036
-
6037
- /**
6038
- * a callback (function) which is invoked in the instance's scope and receives two arguments - the node and the event that triggered the `activate_node` call. Returning false prevents working with the node, returning true allows invoking activate_node. Defaults to returning `true`.
6039
- * @name $.jstree.defaults.checkbox.visible
6040
- * @plugin checkbox
6041
- */
6042
- $.jstree.defaults.conditionalselect = function () { return true; };
6043
- $.jstree.plugins.conditionalselect = function (options, parent) {
6044
- // own function
6045
- this.activate_node = function (obj, e) {
6046
- if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) {
6047
- return parent.activate_node.call(this, obj, e);
6048
- }
6049
- };
6050
- };
6051
-
6052
-
6053
- /**
6054
- * ### Contextmenu plugin
6055
- *
6056
- * Shows a context menu when a node is right-clicked.
6057
- */
6058
-
6059
- /**
6060
- * stores all defaults for the contextmenu plugin
6061
- * @name $.jstree.defaults.contextmenu
6062
- * @plugin contextmenu
6063
- */
6064
- $.jstree.defaults.contextmenu = {
6065
- /**
6066
- * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`.
6067
- * @name $.jstree.defaults.contextmenu.select_node
6068
- * @plugin contextmenu
6069
- */
6070
- select_node : true,
6071
- /**
6072
- * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used.
6073
- * @name $.jstree.defaults.contextmenu.show_at_node
6074
- * @plugin contextmenu
6075
- */
6076
- show_at_node : true,
6077
- /**
6078
- * an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too).
6079
- *
6080
- * Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required). Once a menu item is activated the `action` function will be invoked with an object containing the following keys: item - the contextmenu item definition as seen below, reference - the DOM node that was used (the tree node), element - the contextmenu DOM element, position - an object with x/y properties indicating the position of the menu.
6081
- *
6082
- * * `separator_before` - a boolean indicating if there should be a separator before this item
6083
- * * `separator_after` - a boolean indicating if there should be a separator after this item
6084
- * * `_disabled` - a boolean indicating if this action should be disabled
6085
- * * `label` - a string - the name of the action (could be a function returning a string)
6086
- * * `title` - a string - an optional tooltip for the item
6087
- * * `action` - a function to be executed if this item is chosen, the function will receive
6088
- * * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
6089
- * * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2)
6090
- * * `shortcut_label` - shortcut label (like for example `F2` for rename)
6091
- * * `submenu` - an object with the same structure as $.jstree.defaults.contextmenu.items which can be used to create a submenu - each key will be rendered as a separate option in a submenu that will appear once the current item is hovered
6092
- *
6093
- * @name $.jstree.defaults.contextmenu.items
6094
- * @plugin contextmenu
6095
- */
6096
- items : function (o, cb) { // Could be an object directly
6097
- return {
6098
- "create" : {
6099
- "separator_before" : false,
6100
- "separator_after" : true,
6101
- "_disabled" : false, //(this.check("create_node", data.reference, {}, "last")),
6102
- "label" : "Create",
6103
- "action" : function (data) {
6104
- var inst = $.jstree.reference(data.reference),
6105
- obj = inst.get_node(data.reference);
6106
- inst.create_node(obj, {}, "last", function (new_node) {
6107
- try {
6108
- inst.edit(new_node);
6109
- } catch (ex) {
6110
- setTimeout(function () { inst.edit(new_node); },0);
6111
- }
6112
- });
6113
- }
6114
- },
6115
- "rename" : {
6116
- "separator_before" : false,
6117
- "separator_after" : false,
6118
- "_disabled" : false, //(this.check("rename_node", data.reference, this.get_parent(data.reference), "")),
6119
- "label" : "Rename",
6120
- /*!
6121
- "shortcut" : 113,
6122
- "shortcut_label" : 'F2',
6123
- "icon" : "glyphicon glyphicon-leaf",
6124
- */
6125
- "action" : function (data) {
6126
- var inst = $.jstree.reference(data.reference),
6127
- obj = inst.get_node(data.reference);
6128
- inst.edit(obj);
6129
- }
6130
- },
6131
- "remove" : {
6132
- "separator_before" : false,
6133
- "icon" : false,
6134
- "separator_after" : false,
6135
- "_disabled" : false, //(this.check("delete_node", data.reference, this.get_parent(data.reference), "")),
6136
- "label" : "Delete",
6137
- "action" : function (data) {
6138
- var inst = $.jstree.reference(data.reference),
6139
- obj = inst.get_node(data.reference);
6140
- if(inst.is_selected(obj)) {
6141
- inst.delete_node(inst.get_selected());
6142
- }
6143
- else {
6144
- inst.delete_node(obj);
6145
- }
6146
- }
6147
- },
6148
- "ccp" : {
6149
- "separator_before" : true,
6150
- "icon" : false,
6151
- "separator_after" : false,
6152
- "label" : "Edit",
6153
- "action" : false,
6154
- "submenu" : {
6155
- "cut" : {
6156
- "separator_before" : false,
6157
- "separator_after" : false,
6158
- "label" : "Cut",
6159
- "action" : function (data) {
6160
- var inst = $.jstree.reference(data.reference),
6161
- obj = inst.get_node(data.reference);
6162
- if(inst.is_selected(obj)) {
6163
- inst.cut(inst.get_top_selected());
6164
- }
6165
- else {
6166
- inst.cut(obj);
6167
- }
6168
- }
6169
- },
6170
- "copy" : {
6171
- "separator_before" : false,
6172
- "icon" : false,
6173
- "separator_after" : false,
6174
- "label" : "Copy",
6175
- "action" : function (data) {
6176
- var inst = $.jstree.reference(data.reference),
6177
- obj = inst.get_node(data.reference);
6178
- if(inst.is_selected(obj)) {
6179
- inst.copy(inst.get_top_selected());
6180
- }
6181
- else {
6182
- inst.copy(obj);
6183
- }
6184
- }
6185
- },
6186
- "paste" : {
6187
- "separator_before" : false,
6188
- "icon" : false,
6189
- "_disabled" : function (data) {
6190
- return !$.jstree.reference(data.reference).can_paste();
6191
- },
6192
- "separator_after" : false,
6193
- "label" : "Paste",
6194
- "action" : function (data) {
6195
- var inst = $.jstree.reference(data.reference),
6196
- obj = inst.get_node(data.reference);
6197
- inst.paste(obj);
6198
- }
6199
- }
6200
- }
6201
- }
6202
- };
6203
- }
6204
- };
6205
-
6206
- $.jstree.plugins.contextmenu = function (options, parent) {
6207
- this.bind = function () {
6208
- parent.bind.call(this);
6209
-
6210
- var last_ts = 0, cto = null, ex, ey;
6211
- this.element
6212
- .on("init.jstree loading.jstree ready.jstree", $.proxy(function () {
6213
- this.get_container_ul().addClass('jstree-contextmenu');
6214
- }, this))
6215
- .on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) {
6216
- if (e.target.tagName.toLowerCase() === 'input') {
6217
- return;
6218
- }
6219
- e.preventDefault();
6220
- last_ts = e.ctrlKey ? +new Date() : 0;
6221
- if(data || cto) {
6222
- last_ts = (+new Date()) + 10000;
6223
- }
6224
- if(cto) {
6225
- clearTimeout(cto);
6226
- }
6227
- if(!this.is_loading(e.currentTarget)) {
6228
- this.show_contextmenu(e.currentTarget, e.pageX, e.pageY, e);
6229
- }
6230
- }, this))
6231
- .on("click.jstree", ".jstree-anchor", $.proxy(function (e) {
6232
- if(this._data.contextmenu.visible && (!last_ts || (+new Date()) - last_ts > 250)) { // work around safari & macOS ctrl+click
6233
- $.vakata.context.hide();
6234
- }
6235
- last_ts = 0;
6236
- }, this))
6237
- .on("touchstart.jstree", ".jstree-anchor", function (e) {
6238
- if(!e.originalEvent || !e.originalEvent.changedTouches || !e.originalEvent.changedTouches[0]) {
6239
- return;
6240
- }
6241
- ex = e.originalEvent.changedTouches[0].clientX;
6242
- ey = e.originalEvent.changedTouches[0].clientY;
6243
- cto = setTimeout(function () {
6244
- $(e.currentTarget).trigger('contextmenu', true);
6245
- }, 750);
6246
- })
6247
- .on('touchmove.vakata.jstree', function (e) {
6248
- if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) > 10 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 10)) {
6249
- clearTimeout(cto);
6250
- $.vakata.context.hide();
6251
- }
6252
- })
6253
- .on('touchend.vakata.jstree', function (e) {
6254
- if(cto) {
6255
- clearTimeout(cto);
6256
- }
6257
- });
6258
-
6259
- /*!
6260
- if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) {
6261
- var el = null, tm = null;
6262
- this.element
6263
- .on("touchstart", ".jstree-anchor", function (e) {
6264
- el = e.currentTarget;
6265
- tm = +new Date();
6266
- $(document).one("touchend", function (e) {
6267
- e.target = document.elementFromPoint(e.originalEvent.targetTouches[0].pageX - window.pageXOffset, e.originalEvent.targetTouches[0].pageY - window.pageYOffset);
6268
- e.currentTarget = e.target;
6269
- tm = ((+(new Date())) - tm);
6270
- if(e.target === el && tm > 600 && tm < 1000) {
6271
- e.preventDefault();
6272
- $(el).trigger('contextmenu', e);
6273
- }
6274
- el = null;
6275
- tm = null;
6276
- });
6277
- });
6278
- }
6279
- */
6280
- $(document).on("context_hide.vakata.jstree", $.proxy(function (e, data) {
6281
- this._data.contextmenu.visible = false;
6282
- $(data.reference).removeClass('jstree-context');
6283
- }, this));
6284
- };
6285
- this.teardown = function () {
6286
- if(this._data.contextmenu.visible) {
6287
- $.vakata.context.hide();
6288
- }
6289
- parent.teardown.call(this);
6290
- };
6291
-
6292
- /**
6293
- * prepare and show the context menu for a node
6294
- * @name show_contextmenu(obj [, x, y])
6295
- * @param {mixed} obj the node
6296
- * @param {Number} x the x-coordinate relative to the document to show the menu at
6297
- * @param {Number} y the y-coordinate relative to the document to show the menu at
6298
- * @param {Object} e the event if available that triggered the contextmenu
6299
- * @plugin contextmenu
6300
- * @trigger show_contextmenu.jstree
6301
- */
6302
- this.show_contextmenu = function (obj, x, y, e) {
6303
- obj = this.get_node(obj);
6304
- if(!obj || obj.id === $.jstree.root) { return false; }
6305
- var s = this.settings.contextmenu,
6306
- d = this.get_node(obj, true),
6307
- a = d.children(".jstree-anchor"),
6308
- o = false,
6309
- i = false;
6310
- if(s.show_at_node || x === undefined || y === undefined) {
6311
- o = a.offset();
6312
- x = o.left;
6313
- y = o.top + this._data.core.li_height;
6314
- }
6315
- if(this.settings.contextmenu.select_node && !this.is_selected(obj)) {
6316
- this.activate_node(obj, e);
6317
- }
6318
-
6319
- i = s.items;
6320
- if($.isFunction(i)) {
6321
- i = i.call(this, obj, $.proxy(function (i) {
6322
- this._show_contextmenu(obj, x, y, i);
6323
- }, this));
6324
- }
6325
- if($.isPlainObject(i)) {
6326
- this._show_contextmenu(obj, x, y, i);
6327
- }
6328
- };
6329
- /**
6330
- * show the prepared context menu for a node
6331
- * @name _show_contextmenu(obj, x, y, i)
6332
- * @param {mixed} obj the node
6333
- * @param {Number} x the x-coordinate relative to the document to show the menu at
6334
- * @param {Number} y the y-coordinate relative to the document to show the menu at
6335
- * @param {Number} i the object of items to show
6336
- * @plugin contextmenu
6337
- * @trigger show_contextmenu.jstree
6338
- * @private
6339
- */
6340
- this._show_contextmenu = function (obj, x, y, i) {
6341
- var d = this.get_node(obj, true),
6342
- a = d.children(".jstree-anchor");
6343
- $(document).one("context_show.vakata.jstree", $.proxy(function (e, data) {
6344
- var cls = 'jstree-contextmenu jstree-' + this.get_theme() + '-contextmenu';
6345
- $(data.element).addClass(cls);
6346
- a.addClass('jstree-context');
6347
- }, this));
6348
- this._data.contextmenu.visible = true;
6349
- $.vakata.context.show(a, { 'x' : x, 'y' : y }, i);
6350
- /**
6351
- * triggered when the contextmenu is shown for a node
6352
- * @event
6353
- * @name show_contextmenu.jstree
6354
- * @param {Object} node the node
6355
- * @param {Number} x the x-coordinate of the menu relative to the document
6356
- * @param {Number} y the y-coordinate of the menu relative to the document
6357
- * @plugin contextmenu
6358
- */
6359
- this.trigger('show_contextmenu', { "node" : obj, "x" : x, "y" : y });
6360
- };
6361
- };
6362
-
6363
- // contextmenu helper
6364
- (function ($) {
6365
- var right_to_left = false,
6366
- vakata_context = {
6367
- element : false,
6368
- reference : false,
6369
- position_x : 0,
6370
- position_y : 0,
6371
- items : [],
6372
- html : "",
6373
- is_visible : false
6374
- };
6375
-
6376
- $.vakata.context = {
6377
- settings : {
6378
- hide_onmouseleave : 0,
6379
- icons : true
6380
- },
6381
- _trigger : function (event_name) {
6382
- $(document).triggerHandler("context_" + event_name + ".vakata", {
6383
- "reference" : vakata_context.reference,
6384
- "element" : vakata_context.element,
6385
- "position" : {
6386
- "x" : vakata_context.position_x,
6387
- "y" : vakata_context.position_y
6388
- }
6389
- });
6390
- },
6391
- _execute : function (i) {
6392
- i = vakata_context.items[i];
6393
- return i && (!i._disabled || ($.isFunction(i._disabled) && !i._disabled({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }))) && i.action ? i.action.call(null, {
6394
- "item" : i,
6395
- "reference" : vakata_context.reference,
6396
- "element" : vakata_context.element,
6397
- "position" : {
6398
- "x" : vakata_context.position_x,
6399
- "y" : vakata_context.position_y
6400
- }
6401
- }) : false;
6402
- },
6403
- _parse : function (o, is_callback) {
6404
- if(!o) { return false; }
6405
- if(!is_callback) {
6406
- vakata_context.html = "";
6407
- vakata_context.items = [];
6408
- }
6409
- var str = "",
6410
- sep = false,
6411
- tmp;
6412
-
6413
- if(is_callback) { str += "<"+"ul>"; }
6414
- $.each(o, function (i, val) {
6415
- if(!val) { return true; }
6416
- vakata_context.items.push(val);
6417
- if(!sep && val.separator_before) {
6418
- str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;<"+"/a><"+"/li>";
6419
- }
6420
- sep = false;
6421
- str += "<"+"li class='" + (val._class || "") + (val._disabled === true || ($.isFunction(val._disabled) && val._disabled({ "item" : val, "reference" : vakata_context.reference, "element" : vakata_context.element })) ? " vakata-contextmenu-disabled " : "") + "' "+(val.shortcut?" data-shortcut='"+val.shortcut+"' ":'')+">";
6422
- str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "' " + (val.title ? "title='" + val.title + "'" : "") + ">";
6423
- if($.vakata.context.settings.icons) {
6424
- str += "<"+"i ";
6425
- if(val.icon) {
6426
- if(val.icon.indexOf("/") !== -1 || val.icon.indexOf(".") !== -1) { str += " style='background:url(\"" + val.icon + "\") center center no-repeat' "; }
6427
- else { str += " class='" + val.icon + "' "; }
6428
- }
6429
- str += "><"+"/i><"+"span class='vakata-contextmenu-sep'>&#160;<"+"/span>";
6430
- }
6431
- str += ($.isFunction(val.label) ? val.label({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }) : val.label) + (val.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+val.shortcut+'">'+ (val.shortcut_label || '') +'</span>':'') + "<"+"/a>";
6432
- if(val.submenu) {
6433
- tmp = $.vakata.context._parse(val.submenu, true);
6434
- if(tmp) { str += tmp; }
6435
- }
6436
- str += "<"+"/li>";
6437
- if(val.separator_after) {
6438
- str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;<"+"/a><"+"/li>";
6439
- sep = true;
6440
- }
6441
- });
6442
- str = str.replace(/<li class\='vakata-context-separator'\><\/li\>$/,"");
6443
- if(is_callback) { str += "</ul>"; }
6444
- /**
6445
- * triggered on the document when the contextmenu is parsed (HTML is built)
6446
- * @event
6447
- * @plugin contextmenu
6448
- * @name context_parse.vakata
6449
- * @param {jQuery} reference the element that was right clicked
6450
- * @param {jQuery} element the DOM element of the menu itself
6451
- * @param {Object} position the x & y coordinates of the menu
6452
- */
6453
- if(!is_callback) { vakata_context.html = str; $.vakata.context._trigger("parse"); }
6454
- return str.length > 10 ? str : false;
6455
- },
6456
- _show_submenu : function (o) {
6457
- o = $(o);
6458
- if(!o.length || !o.children("ul").length) { return; }
6459
- var e = o.children("ul"),
6460
- xl = o.offset().left,
6461
- x = xl + o.outerWidth(),
6462
- y = o.offset().top,
6463
- w = e.width(),
6464
- h = e.height(),
6465
- dw = $(window).width() + $(window).scrollLeft(),
6466
- dh = $(window).height() + $(window).scrollTop();
6467
- // може да се спести е една проверка - дали няма някой от класовете вече нагоре
6468
- if(right_to_left) {
6469
- o[x - (w + 10 + o.outerWidth()) < 0 ? "addClass" : "removeClass"]("vakata-context-left");
6470
- }
6471
- else {
6472
- o[x + w > dw && xl > dw - x ? "addClass" : "removeClass"]("vakata-context-right");
6473
- }
6474
- if(y + h + 10 > dh) {
6475
- e.css("bottom","-1px");
6476
- }
6477
-
6478
- //if does not fit - stick it to the side
6479
- if (o.hasClass('vakata-context-right')) {
6480
- if (xl < w) {
6481
- e.css("margin-right", xl - w);
6482
- }
6483
- } else {
6484
- if (dw - x < w) {
6485
- e.css("margin-left", dw - x - w);
6486
- }
6487
- }
6488
-
6489
- e.show();
6490
- },
6491
- show : function (reference, position, data) {
6492
- var o, e, x, y, w, h, dw, dh, cond = true;
6493
- if(vakata_context.element && vakata_context.element.length) {
6494
- vakata_context.element.width('');
6495
- }
6496
- switch(cond) {
6497
- case (!position && !reference):
6498
- return false;
6499
- case (!!position && !!reference):
6500
- vakata_context.reference = reference;
6501
- vakata_context.position_x = position.x;
6502
- vakata_context.position_y = position.y;
6503
- break;
6504
- case (!position && !!reference):
6505
- vakata_context.reference = reference;
6506
- o = reference.offset();
6507
- vakata_context.position_x = o.left + reference.outerHeight();
6508
- vakata_context.position_y = o.top;
6509
- break;
6510
- case (!!position && !reference):
6511
- vakata_context.position_x = position.x;
6512
- vakata_context.position_y = position.y;
6513
- break;
6514
- }
6515
- if(!!reference && !data && $(reference).data('vakata_contextmenu')) {
6516
- data = $(reference).data('vakata_contextmenu');
6517
- }
6518
- if($.vakata.context._parse(data)) {
6519
- vakata_context.element.html(vakata_context.html);
6520
- }
6521
- if(vakata_context.items.length) {
6522
- vakata_context.element.appendTo(document.body);
6523
- e = vakata_context.element;
6524
- x = vakata_context.position_x;
6525
- y = vakata_context.position_y;
6526
- w = e.width();
6527
- h = e.height();
6528
- dw = $(window).width() + $(window).scrollLeft();
6529
- dh = $(window).height() + $(window).scrollTop();
6530
- if(right_to_left) {
6531
- x -= (e.outerWidth() - $(reference).outerWidth());
6532
- if(x < $(window).scrollLeft() + 20) {
6533
- x = $(window).scrollLeft() + 20;
6534
- }
6535
- }
6536
- if(x + w + 20 > dw) {
6537
- x = dw - (w + 20);
6538
- }
6539
- if(y + h + 20 > dh) {
6540
- y = dh - (h + 20);
6541
- }
6542
-
6543
- vakata_context.element
6544
- .css({ "left" : x, "top" : y })
6545
- .show()
6546
- .find('a').first().focus().parent().addClass("vakata-context-hover");
6547
- vakata_context.is_visible = true;
6548
- /**
6549
- * triggered on the document when the contextmenu is shown
6550
- * @event
6551
- * @plugin contextmenu
6552
- * @name context_show.vakata
6553
- * @param {jQuery} reference the element that was right clicked
6554
- * @param {jQuery} element the DOM element of the menu itself
6555
- * @param {Object} position the x & y coordinates of the menu
6556
- */
6557
- $.vakata.context._trigger("show");
6558
- }
6559
- },
6560
- hide : function () {
6561
- if(vakata_context.is_visible) {
6562
- vakata_context.element.hide().find("ul").hide().end().find(':focus').blur().end().detach();
6563
- vakata_context.is_visible = false;
6564
- /**
6565
- * triggered on the document when the contextmenu is hidden
6566
- * @event
6567
- * @plugin contextmenu
6568
- * @name context_hide.vakata
6569
- * @param {jQuery} reference the element that was right clicked
6570
- * @param {jQuery} element the DOM element of the menu itself
6571
- * @param {Object} position the x & y coordinates of the menu
6572
- */
6573
- $.vakata.context._trigger("hide");
6574
- }
6575
- }
6576
- };
6577
- $(function () {
6578
- right_to_left = $(document.body).css("direction") === "rtl";
6579
- var to = false;
6580
-
6581
- vakata_context.element = $("<ul class='vakata-context'></ul>");
6582
- vakata_context.element
6583
- .on("mouseenter", "li", function (e) {
6584
- e.stopImmediatePropagation();
6585
-
6586
- if($.contains(this, e.relatedTarget)) {
6587
- // премахнато заради delegate mouseleave по-долу
6588
- // $(this).find(".vakata-context-hover").removeClass("vakata-context-hover");
6589
- return;
6590
- }
6591
-
6592
- if(to) { clearTimeout(to); }
6593
- vakata_context.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end();
6594
-
6595
- $(this)
6596
- .siblings().find("ul").hide().end().end()
6597
- .parentsUntil(".vakata-context", "li").addBack().addClass("vakata-context-hover");
6598
- $.vakata.context._show_submenu(this);
6599
- })
6600
- // тестово - дали не натоварва?
6601
- .on("mouseleave", "li", function (e) {
6602
- if($.contains(this, e.relatedTarget)) { return; }
6603
- $(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover");
6604
- })
6605
- .on("mouseleave", function (e) {
6606
- $(this).find(".vakata-context-hover").removeClass("vakata-context-hover");
6607
- if($.vakata.context.settings.hide_onmouseleave) {
6608
- to = setTimeout(
6609
- (function (t) {
6610
- return function () { $.vakata.context.hide(); };
6611
- }(this)), $.vakata.context.settings.hide_onmouseleave);
6612
- }
6613
- })
6614
- .on("click", "a", function (e) {
6615
- e.preventDefault();
6616
- //})
6617
- //.on("mouseup", "a", function (e) {
6618
- if(!$(this).blur().parent().hasClass("vakata-context-disabled") && $.vakata.context._execute($(this).attr("rel")) !== false) {
6619
- $.vakata.context.hide();
6620
- }
6621
- })
6622
- .on('keydown', 'a', function (e) {
6623
- var o = null;
6624
- switch(e.which) {
6625
- case 13:
6626
- case 32:
6627
- e.type = "click";
6628
- e.preventDefault();
6629
- $(e.currentTarget).trigger(e);
6630
- break;
6631
- case 37:
6632
- if(vakata_context.is_visible) {
6633
- vakata_context.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children('a').focus();
6634
- e.stopImmediatePropagation();
6635
- e.preventDefault();
6636
- }
6637
- break;
6638
- case 38:
6639
- if(vakata_context.is_visible) {
6640
- o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();
6641
- if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last(); }
6642
- o.addClass("vakata-context-hover").children('a').focus();
6643
- e.stopImmediatePropagation();
6644
- e.preventDefault();
6645
- }
6646
- break;
6647
- case 39:
6648
- if(vakata_context.is_visible) {
6649
- vakata_context.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children('a').focus();
6650
- e.stopImmediatePropagation();
6651
- e.preventDefault();
6652
- }
6653
- break;
6654
- case 40:
6655
- if(vakata_context.is_visible) {
6656
- o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();
6657
- if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first(); }
6658
- o.addClass("vakata-context-hover").children('a').focus();
6659
- e.stopImmediatePropagation();
6660
- e.preventDefault();
6661
- }
6662
- break;
6663
- case 27:
6664
- $.vakata.context.hide();
6665
- e.preventDefault();
6666
- break;
6667
- default:
6668
- //console.log(e.which);
6669
- break;
6670
- }
6671
- })
6672
- .on('keydown', function (e) {
6673
- e.preventDefault();
6674
- var a = vakata_context.element.find('.vakata-contextmenu-shortcut-' + e.which).parent();
6675
- if(a.parent().not('.vakata-context-disabled')) {
6676
- a.click();
6677
- }
6678
- });
6679
-
6680
- $(document)
6681
- .on("mousedown.vakata.jstree", function (e) {
6682
- if(vakata_context.is_visible && vakata_context.element[0] !== e.target && !$.contains(vakata_context.element[0], e.target)) {
6683
- $.vakata.context.hide();
6684
- }
6685
- })
6686
- .on("context_show.vakata.jstree", function (e, data) {
6687
- vakata_context.element.find("li:has(ul)").children("a").addClass("vakata-context-parent");
6688
- if(right_to_left) {
6689
- vakata_context.element.addClass("vakata-context-rtl").css("direction", "rtl");
6690
- }
6691
- // also apply a RTL class?
6692
- vakata_context.element.find("ul").hide().end();
6693
- });
6694
- });
6695
- }($));
6696
- // $.jstree.defaults.plugins.push("contextmenu");
6697
-
6698
-
6699
- /**
6700
- * ### Drag'n'drop plugin
6701
- *
6702
- * Enables dragging and dropping of nodes in the tree, resulting in a move or copy operations.
6703
- */
6704
-
6705
- /**
6706
- * stores all defaults for the drag'n'drop plugin
6707
- * @name $.jstree.defaults.dnd
6708
- * @plugin dnd
6709
- */
6710
- $.jstree.defaults.dnd = {
6711
- /**
6712
- * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`.
6713
- * @name $.jstree.defaults.dnd.copy
6714
- * @plugin dnd
6715
- */
6716
- copy : true,
6717
- /**
6718
- * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`.
6719
- * @name $.jstree.defaults.dnd.open_timeout
6720
- * @plugin dnd
6721
- */
6722
- open_timeout : 500,
6723
- /**
6724
- * a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) and the event that started the drag - return `false` to prevent dragging
6725
- * @name $.jstree.defaults.dnd.is_draggable
6726
- * @plugin dnd
6727
- */
6728
- is_draggable : true,
6729
- /**
6730
- * a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true`
6731
- * @name $.jstree.defaults.dnd.check_while_dragging
6732
- * @plugin dnd
6733
- */
6734
- check_while_dragging : true,
6735
- /**
6736
- * a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false`
6737
- * @name $.jstree.defaults.dnd.always_copy
6738
- * @plugin dnd
6739
- */
6740
- always_copy : false,
6741
- /**
6742
- * when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0`
6743
- * @name $.jstree.defaults.dnd.inside_pos
6744
- * @plugin dnd
6745
- */
6746
- inside_pos : 0,
6747
- /**
6748
- * when starting the drag on a node that is selected this setting controls if all selected nodes are dragged or only the single node, default is `true`, which means all selected nodes are dragged when the drag is started on a selected node
6749
- * @name $.jstree.defaults.dnd.drag_selection
6750
- * @plugin dnd
6751
- */
6752
- drag_selection : true,
6753
- /**
6754
- * controls whether dnd works on touch devices. If left as boolean true dnd will work the same as in desktop browsers, which in some cases may impair scrolling. If set to boolean false dnd will not work on touch devices. There is a special third option - string "selected" which means only selected nodes can be dragged on touch devices.
6755
- * @name $.jstree.defaults.dnd.touch
6756
- * @plugin dnd
6757
- */
6758
- touch : true,
6759
- /**
6760
- * controls whether items can be dropped anywhere on the node, not just on the anchor, by default only the node anchor is a valid drop target. Works best with the wholerow plugin. If enabled on mobile depending on the interface it might be hard for the user to cancel the drop, since the whole tree container will be a valid drop target.
6761
- * @name $.jstree.defaults.dnd.large_drop_target
6762
- * @plugin dnd
6763
- */
6764
- large_drop_target : false,
6765
- /**
6766
- * controls whether a drag can be initiated from any part of the node and not just the text/icon part, works best with the wholerow plugin. Keep in mind it can cause problems with tree scrolling on mobile depending on the interface - in that case set the touch option to "selected".
6767
- * @name $.jstree.defaults.dnd.large_drag_target
6768
- * @plugin dnd
6769
- */
6770
- large_drag_target : false,
6771
- /**
6772
- * controls whether use HTML5 dnd api instead of classical. That will allow better integration of dnd events with other HTML5 controls.
6773
- * @reference http://caniuse.com/#feat=dragndrop
6774
- * @name $.jstree.defaults.dnd.use_html5
6775
- * @plugin dnd
6776
- */
6777
- use_html5: false
6778
- };
6779
- var drg, elm;
6780
- // TODO: now check works by checking for each node individually, how about max_children, unique, etc?
6781
- $.jstree.plugins.dnd = function (options, parent) {
6782
- this.init = function (el, options) {
6783
- parent.init.call(this, el, options);
6784
- this.settings.dnd.use_html5 = this.settings.dnd.use_html5 && ('draggable' in document.createElement('span'));
6785
- };
6786
- this.bind = function () {
6787
- parent.bind.call(this);
6788
-
6789
- this.element
6790
- .on(this.settings.dnd.use_html5 ? 'dragstart.jstree' : 'mousedown.jstree touchstart.jstree', this.settings.dnd.large_drag_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) {
6791
- if(this.settings.dnd.large_drag_target && $(e.target).closest('.jstree-node')[0] !== e.currentTarget) {
6792
- return true;
6793
- }
6794
- if(e.type === "touchstart" && (!this.settings.dnd.touch || (this.settings.dnd.touch === 'selected' && !$(e.currentTarget).closest('.jstree-node').children('.jstree-anchor').hasClass('jstree-clicked')))) {
6795
- return true;
6796
- }
6797
- var obj = this.get_node(e.target),
6798
- mlt = this.is_selected(obj) && this.settings.dnd.drag_selection ? this.get_top_selected().length : 1,
6799
- txt = (mlt > 1 ? mlt + ' ' + this.get_string('nodes') : this.get_text(e.currentTarget));
6800
- if(this.settings.core.force_text) {
6801
- txt = $.vakata.html.escape(txt);
6802
- }
6803
- if(obj && obj.id && obj.id !== $.jstree.root && (e.which === 1 || e.type === "touchstart" || e.type === "dragstart") &&
6804
- (this.settings.dnd.is_draggable === true || ($.isFunction(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.get_top_selected(true) : [obj]), e)))
6805
- ) {
6806
- drg = { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_top_selected() : [obj.id] };
6807
- elm = e.currentTarget;
6808
- if (this.settings.dnd.use_html5) {
6809
- $.vakata.dnd._trigger('start', e, { 'helper': $(), 'element': elm, 'data': drg });
6810
- } else {
6811
- this.element.trigger('mousedown.jstree');
6812
- return $.vakata.dnd.start(e, drg, '<div id="jstree-dnd" data-txt="'+txt+'" class="jstree-' + this.get_theme() + ' jstree-' + this.get_theme() + '-' + this.get_theme_variant() + ' ' + ( this.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ) + '">'+txt+'</div>');
6813
- }
6814
- }
6815
- }, this));
6816
- if (this.settings.dnd.use_html5) {
6817
- this.element
6818
- .on('dragover.jstree', function (e) {
6819
- e.preventDefault();
6820
- $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6821
- return false;
6822
- })
6823
- //.on('dragenter.jstree', this.settings.dnd.large_drop_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) {
6824
- // e.preventDefault();
6825
- // $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6826
- // return false;
6827
- // }, this))
6828
- .on('drop.jstree', $.proxy(function (e) {
6829
- e.preventDefault();
6830
- $.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
6831
- return false;
6832
- }, this));
6833
- }
6834
- };
6835
- this.redraw_node = function(obj, deep, callback, force_render) {
6836
- obj = parent.redraw_node.apply(this, arguments);
6837
- if (obj && this.settings.dnd.use_html5) {
6838
- if (this.settings.dnd.large_drag_target) {
6839
- obj.setAttribute('draggable', true);
6840
- } else {
6841
- var i, j, tmp = null;
6842
- for(i = 0, j = obj.childNodes.length; i < j; i++) {
6843
- if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) {
6844
- tmp = obj.childNodes[i];
6845
- break;
6846
- }
6847
- }
6848
- if(tmp) {
6849
- tmp.setAttribute('draggable', true);
6850
- }
6851
- }
6852
- }
6853
- return obj;
6854
- };
6855
- };
6856
-
6857
- $(function() {
6858
- // bind only once for all instances
6859
- var lastmv = false,
6860
- laster = false,
6861
- lastev = false,
6862
- opento = false,
6863
- marker = $('<div id="jstree-marker">&#160;</div>').hide(); //.appendTo('body');
6864
-
6865
- $(document)
6866
- .on('dragover.vakata.jstree', function (e) {
6867
- if (elm) {
6868
- $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6869
- }
6870
- })
6871
- .on('drop.vakata.jstree', function (e) {
6872
- if (elm) {
6873
- $.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
6874
- elm = null;
6875
- drg = null;
6876
- }
6877
- })
6878
- .on('dnd_start.vakata.jstree', function (e, data) {
6879
- lastmv = false;
6880
- lastev = false;
6881
- if(!data || !data.data || !data.data.jstree) { return; }
6882
- marker.appendTo(document.body); //.show();
6883
- })
6884
- .on('dnd_move.vakata.jstree', function (e, data) {
6885
- var isDifferentNode = data.event.target !== lastev.target;
6886
- if(opento) {
6887
- if (!data.event || data.event.type !== 'dragover' || isDifferentNode) {
6888
- clearTimeout(opento);
6889
- }
6890
- }
6891
- if(!data || !data.data || !data.data.jstree) { return; }
6892
-
6893
- // if we are hovering the marker image do nothing (can happen on "inside" drags)
6894
- if(data.event.target.id && data.event.target.id === 'jstree-marker') {
6895
- return;
6896
- }
6897
- lastev = data.event;
6898
-
6899
- var ins = $.jstree.reference(data.event.target),
6900
- ref = false,
6901
- off = false,
6902
- rel = false,
6903
- tmp, l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm, is_copy, pn, c;
6904
- // if we are over an instance
6905
- if(ins && ins._data && ins._data.dnd) {
6906
- marker.attr('class', 'jstree-' + ins.get_theme() + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ));
6907
- is_copy = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)));
6908
- data.helper
6909
- .children().attr('class', 'jstree-' + ins.get_theme() + ' jstree-' + ins.get_theme() + '-' + ins.get_theme_variant() + ' ' + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ))
6910
- .find('.jstree-copy').first()[ is_copy ? 'show' : 'hide' ]();
6911
-
6912
- // if are hovering the container itself add a new root node
6913
- //console.log(data.event);
6914
- if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) {
6915
- ok = true;
6916
- for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) {
6917
- ok = ok && ins.check( (data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)) ) ? "copy_node" : "move_node"), (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), $.jstree.root, 'last', { 'dnd' : true, 'ref' : ins.get_node($.jstree.root), 'pos' : 'i', 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) });
6918
- if(!ok) { break; }
6919
- }
6920
- if(ok) {
6921
- lastmv = { 'ins' : ins, 'par' : $.jstree.root, 'pos' : 'last' };
6922
- marker.hide();
6923
- data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok');
6924
- if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
6925
- data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move';
6926
- }
6927
- return;
6928
- }
6929
- }
6930
- else {
6931
- // if we are hovering a tree node
6932
- ref = ins.settings.dnd.large_drop_target ? $(data.event.target).closest('.jstree-node').children('.jstree-anchor') : $(data.event.target).closest('.jstree-anchor');
6933
- if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) {
6934
- off = ref.offset();
6935
- rel = (data.event.pageY !== undefined ? data.event.pageY : data.event.originalEvent.pageY) - off.top;
6936
- h = ref.outerHeight();
6937
- if(rel < h / 3) {
6938
- o = ['b', 'i', 'a'];
6939
- }
6940
- else if(rel > h - h / 3) {
6941
- o = ['a', 'i', 'b'];
6942
- }
6943
- else {
6944
- o = rel > h / 2 ? ['i', 'a', 'b'] : ['i', 'b', 'a'];
6945
- }
6946
- $.each(o, function (j, v) {
6947
- switch(v) {
6948
- case 'b':
6949
- l = off.left - 6;
6950
- t = off.top;
6951
- p = ins.get_parent(ref);
6952
- i = ref.parent().index();
6953
- c = 'jstree-below';
6954
- break;
6955
- case 'i':
6956
- ip = ins.settings.dnd.inside_pos;
6957
- tm = ins.get_node(ref.parent());
6958
- l = off.left - 2;
6959
- t = off.top + h / 2 + 1;
6960
- p = tm.id;
6961
- i = ip === 'first' ? 0 : (ip === 'last' ? tm.children.length : Math.min(ip, tm.children.length));
6962
- c = 'jstree-inside';
6963
- break;
6964
- case 'a':
6965
- l = off.left - 6;
6966
- t = off.top + h;
6967
- p = ins.get_parent(ref);
6968
- i = ref.parent().index() + 1;
6969
- c = 'jstree-above';
6970
- break;
6971
- }
6972
- ok = true;
6973
- for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) {
6974
- op = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? "copy_node" : "move_node";
6975
- ps = i;
6976
- if(op === "move_node" && v === 'a' && (data.data.origin && data.data.origin === ins) && p === ins.get_parent(data.data.nodes[t1])) {
6977
- pr = ins.get_node(p);
6978
- if(ps > $.inArray(data.data.nodes[t1], pr.children)) {
6979
- ps -= 1;
6980
- }
6981
- }
6982
- ok = ok && ( (ins && ins.settings && ins.settings.dnd && ins.settings.dnd.check_while_dragging === false) || ins.check(op, (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), p, ps, { 'dnd' : true, 'ref' : ins.get_node(ref.parent()), 'pos' : v, 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }) );
6983
- if(!ok) {
6984
- if(ins && ins.last_error) { laster = ins.last_error(); }
6985
- break;
6986
- }
6987
- }
6988
- if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) {
6989
- if (!data.event || data.event.type !== 'dragover' || isDifferentNode) {
6990
- if (opento) { clearTimeout(opento); }
6991
- opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout);
6992
- }
6993
- }
6994
- if(ok) {
6995
- pn = ins.get_node(p, true);
6996
- if (!pn.hasClass('.jstree-dnd-parent')) {
6997
- $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');
6998
- pn.addClass('jstree-dnd-parent');
6999
- }
7000
- lastmv = { 'ins' : ins, 'par' : p, 'pos' : v === 'i' && ip === 'last' && i === 0 && !ins.is_loaded(tm) ? 'last' : i };
7001
- marker.css({ 'left' : l + 'px', 'top' : t + 'px' }).show();
7002
- marker.removeClass('jstree-above jstree-inside jstree-below').addClass(c);
7003
- data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok');
7004
- if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
7005
- data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move';
7006
- }
7007
- laster = {};
7008
- o = true;
7009
- return false;
7010
- }
7011
- });
7012
- if(o === true) { return; }
7013
- }
7014
- }
7015
- }
7016
- $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');
7017
- lastmv = false;
7018
- data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er');
7019
- if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
7020
- //data.event.originalEvent.dataTransfer.dropEffect = 'none';
7021
- }
7022
- marker.hide();
7023
- })
7024
- .on('dnd_scroll.vakata.jstree', function (e, data) {
7025
- if(!data || !data.data || !data.data.jstree) { return; }
7026
- marker.hide();
7027
- lastmv = false;
7028
- lastev = false;
7029
- data.helper.find('.jstree-icon').first().removeClass('jstree-ok').addClass('jstree-er');
7030
- })
7031
- .on('dnd_stop.vakata.jstree', function (e, data) {
7032
- $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');
7033
- if(opento) { clearTimeout(opento); }
7034
- if(!data || !data.data || !data.data.jstree) { return; }
7035
- marker.hide().detach();
7036
- var i, j, nodes = [];
7037
- if(lastmv) {
7038
- for(i = 0, j = data.data.nodes.length; i < j; i++) {
7039
- nodes[i] = data.data.origin ? data.data.origin.get_node(data.data.nodes[i]) : data.data.nodes[i];
7040
- }
7041
- lastmv.ins[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'copy_node' : 'move_node' ](nodes, lastmv.par, lastmv.pos, false, false, false, data.data.origin);
7042
- }
7043
- else {
7044
- i = $(data.event.target).closest('.jstree');
7045
- if(i.length && laster && laster.error && laster.error === 'check') {
7046
- i = i.jstree(true);
7047
- if(i) {
7048
- i.settings.core.error.call(this, laster);
7049
- }
7050
- }
7051
- }
7052
- lastev = false;
7053
- lastmv = false;
7054
- })
7055
- .on('keyup.jstree keydown.jstree', function (e, data) {
7056
- data = $.vakata.dnd._get();
7057
- if(data && data.data && data.data.jstree) {
7058
- if (e.type === "keyup" && e.which === 27) {
7059
- if (opento) { clearTimeout(opento); }
7060
- lastmv = false;
7061
- laster = false;
7062
- lastev = false;
7063
- opento = false;
7064
- marker.hide().detach();
7065
- $.vakata.dnd._clean();
7066
- } else {
7067
- data.helper.find('.jstree-copy').first()[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (e.metaKey || e.ctrlKey))) ? 'show' : 'hide' ]();
7068
- if(lastev) {
7069
- lastev.metaKey = e.metaKey;
7070
- lastev.ctrlKey = e.ctrlKey;
7071
- $.vakata.dnd._trigger('move', lastev);
7072
- }
7073
- }
7074
- }
7075
- });
7076
- });
7077
-
7078
- // helpers
7079
- (function ($) {
7080
- $.vakata.html = {
7081
- div : $('<div></div>'),
7082
- escape : function (str) {
7083
- return $.vakata.html.div.text(str).html();
7084
- },
7085
- strip : function (str) {
7086
- return $.vakata.html.div.empty().append($.parseHTML(str)).text();
7087
- }
7088
- };
7089
- // private variable
7090
- var vakata_dnd = {
7091
- element : false,
7092
- target : false,
7093
- is_down : false,
7094
- is_drag : false,
7095
- helper : false,
7096
- helper_w: 0,
7097
- data : false,
7098
- init_x : 0,
7099
- init_y : 0,
7100
- scroll_l: 0,
7101
- scroll_t: 0,
7102
- scroll_e: false,
7103
- scroll_i: false,
7104
- is_touch: false
7105
- };
7106
- $.vakata.dnd = {
7107
- settings : {
7108
- scroll_speed : 10,
7109
- scroll_proximity : 20,
7110
- helper_left : 5,
7111
- helper_top : 10,
7112
- threshold : 5,
7113
- threshold_touch : 10
7114
- },
7115
- _trigger : function (event_name, e, data) {
7116
- if (data === undefined) {
7117
- data = $.vakata.dnd._get();
7118
- }
7119
- data.event = e;
7120
- $(document).triggerHandler("dnd_" + event_name + ".vakata", data);
7121
- },
7122
- _get : function () {
7123
- return {
7124
- "data" : vakata_dnd.data,
7125
- "element" : vakata_dnd.element,
7126
- "helper" : vakata_dnd.helper
7127
- };
7128
- },
7129
- _clean : function () {
7130
- if(vakata_dnd.helper) { vakata_dnd.helper.remove(); }
7131
- if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; }
7132
- vakata_dnd = {
7133
- element : false,
7134
- target : false,
7135
- is_down : false,
7136
- is_drag : false,
7137
- helper : false,
7138
- helper_w: 0,
7139
- data : false,
7140
- init_x : 0,
7141
- init_y : 0,
7142
- scroll_l: 0,
7143
- scroll_t: 0,
7144
- scroll_e: false,
7145
- scroll_i: false,
7146
- is_touch: false
7147
- };
7148
- elm = null;
7149
- $(document).off("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag);
7150
- $(document).off("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop);
7151
- },
7152
- _scroll : function (init_only) {
7153
- if(!vakata_dnd.scroll_e || (!vakata_dnd.scroll_l && !vakata_dnd.scroll_t)) {
7154
- if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; }
7155
- return false;
7156
- }
7157
- if(!vakata_dnd.scroll_i) {
7158
- vakata_dnd.scroll_i = setInterval($.vakata.dnd._scroll, 100);
7159
- return false;
7160
- }
7161
- if(init_only === true) { return false; }
7162
-
7163
- var i = vakata_dnd.scroll_e.scrollTop(),
7164
- j = vakata_dnd.scroll_e.scrollLeft();
7165
- vakata_dnd.scroll_e.scrollTop(i + vakata_dnd.scroll_t * $.vakata.dnd.settings.scroll_speed);
7166
- vakata_dnd.scroll_e.scrollLeft(j + vakata_dnd.scroll_l * $.vakata.dnd.settings.scroll_speed);
7167
- if(i !== vakata_dnd.scroll_e.scrollTop() || j !== vakata_dnd.scroll_e.scrollLeft()) {
7168
- /**
7169
- * triggered on the document when a drag causes an element to scroll
7170
- * @event
7171
- * @plugin dnd
7172
- * @name dnd_scroll.vakata
7173
- * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7174
- * @param {DOM} element the DOM element being dragged
7175
- * @param {jQuery} helper the helper shown next to the mouse
7176
- * @param {jQuery} event the element that is scrolling
7177
- */
7178
- $.vakata.dnd._trigger("scroll", vakata_dnd.scroll_e);
7179
- }
7180
- },
7181
- start : function (e, data, html) {
7182
- if(e.type === "touchstart" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) {
7183
- e.pageX = e.originalEvent.changedTouches[0].pageX;
7184
- e.pageY = e.originalEvent.changedTouches[0].pageY;
7185
- e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset);
7186
- }
7187
- if(vakata_dnd.is_drag) { $.vakata.dnd.stop({}); }
7188
- try {
7189
- e.currentTarget.unselectable = "on";
7190
- e.currentTarget.onselectstart = function() { return false; };
7191
- if(e.currentTarget.style) {
7192
- e.currentTarget.style.touchAction = "none";
7193
- e.currentTarget.style.msTouchAction = "none";
7194
- e.currentTarget.style.MozUserSelect = "none";
7195
- }
7196
- } catch(ignore) { }
7197
- vakata_dnd.init_x = e.pageX;
7198
- vakata_dnd.init_y = e.pageY;
7199
- vakata_dnd.data = data;
7200
- vakata_dnd.is_down = true;
7201
- vakata_dnd.element = e.currentTarget;
7202
- vakata_dnd.target = e.target;
7203
- vakata_dnd.is_touch = e.type === "touchstart";
7204
- if(html !== false) {
7205
- vakata_dnd.helper = $("<div id='vakata-dnd'></div>").html(html).css({
7206
- "display" : "block",
7207
- "margin" : "0",
7208
- "padding" : "0",
7209
- "position" : "absolute",
7210
- "top" : "-2000px",
7211
- "lineHeight" : "16px",
7212
- "zIndex" : "10000"
7213
- });
7214
- }
7215
- $(document).on("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag);
7216
- $(document).on("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop);
7217
- return false;
7218
- },
7219
- drag : function (e) {
7220
- if(e.type === "touchmove" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) {
7221
- e.pageX = e.originalEvent.changedTouches[0].pageX;
7222
- e.pageY = e.originalEvent.changedTouches[0].pageY;
7223
- e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset);
7224
- }
7225
- if(!vakata_dnd.is_down) { return; }
7226
- if(!vakata_dnd.is_drag) {
7227
- if(
7228
- Math.abs(e.pageX - vakata_dnd.init_x) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold) ||
7229
- Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold)
7230
- ) {
7231
- if(vakata_dnd.helper) {
7232
- vakata_dnd.helper.appendTo(document.body);
7233
- vakata_dnd.helper_w = vakata_dnd.helper.outerWidth();
7234
- }
7235
- vakata_dnd.is_drag = true;
7236
- $(vakata_dnd.target).one('click.vakata', false);
7237
- /**
7238
- * triggered on the document when a drag starts
7239
- * @event
7240
- * @plugin dnd
7241
- * @name dnd_start.vakata
7242
- * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7243
- * @param {DOM} element the DOM element being dragged
7244
- * @param {jQuery} helper the helper shown next to the mouse
7245
- * @param {Object} event the event that caused the start (probably mousemove)
7246
- */
7247
- $.vakata.dnd._trigger("start", e);
7248
- }
7249
- else { return; }
7250
- }
7251
-
7252
- var d = false, w = false,
7253
- dh = false, wh = false,
7254
- dw = false, ww = false,
7255
- dt = false, dl = false,
7256
- ht = false, hl = false;
7257
-
7258
- vakata_dnd.scroll_t = 0;
7259
- vakata_dnd.scroll_l = 0;
7260
- vakata_dnd.scroll_e = false;
7261
- $($(e.target).parentsUntil("body").addBack().get().reverse())
7262
- .filter(function () {
7263
- return (/^auto|scroll$/).test($(this).css("overflow")) &&
7264
- (this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth);
7265
- })
7266
- .each(function () {
7267
- var t = $(this), o = t.offset();
7268
- if(this.scrollHeight > this.offsetHeight) {
7269
- if(o.top + t.height() - e.pageY < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; }
7270
- if(e.pageY - o.top < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; }
7271
- }
7272
- if(this.scrollWidth > this.offsetWidth) {
7273
- if(o.left + t.width() - e.pageX < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; }
7274
- if(e.pageX - o.left < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; }
7275
- }
7276
- if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) {
7277
- vakata_dnd.scroll_e = $(this);
7278
- return false;
7279
- }
7280
- });
7281
-
7282
- if(!vakata_dnd.scroll_e) {
7283
- d = $(document); w = $(window);
7284
- dh = d.height(); wh = w.height();
7285
- dw = d.width(); ww = w.width();
7286
- dt = d.scrollTop(); dl = d.scrollLeft();
7287
- if(dh > wh && e.pageY - dt < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; }
7288
- if(dh > wh && wh - (e.pageY - dt) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; }
7289
- if(dw > ww && e.pageX - dl < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; }
7290
- if(dw > ww && ww - (e.pageX - dl) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; }
7291
- if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) {
7292
- vakata_dnd.scroll_e = d;
7293
- }
7294
- }
7295
- if(vakata_dnd.scroll_e) { $.vakata.dnd._scroll(true); }
7296
-
7297
- if(vakata_dnd.helper) {
7298
- ht = parseInt(e.pageY + $.vakata.dnd.settings.helper_top, 10);
7299
- hl = parseInt(e.pageX + $.vakata.dnd.settings.helper_left, 10);
7300
- if(dh && ht + 25 > dh) { ht = dh - 50; }
7301
- if(dw && hl + vakata_dnd.helper_w > dw) { hl = dw - (vakata_dnd.helper_w + 2); }
7302
- vakata_dnd.helper.css({
7303
- left : hl + "px",
7304
- top : ht + "px"
7305
- });
7306
- }
7307
- /**
7308
- * triggered on the document when a drag is in progress
7309
- * @event
7310
- * @plugin dnd
7311
- * @name dnd_move.vakata
7312
- * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7313
- * @param {DOM} element the DOM element being dragged
7314
- * @param {jQuery} helper the helper shown next to the mouse
7315
- * @param {Object} event the event that caused this to trigger (most likely mousemove)
7316
- */
7317
- $.vakata.dnd._trigger("move", e);
7318
- return false;
7319
- },
7320
- stop : function (e) {
7321
- if(e.type === "touchend" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) {
7322
- e.pageX = e.originalEvent.changedTouches[0].pageX;
7323
- e.pageY = e.originalEvent.changedTouches[0].pageY;
7324
- e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset);
7325
- }
7326
- if(vakata_dnd.is_drag) {
7327
- /**
7328
- * triggered on the document when a drag stops (the dragged element is dropped)
7329
- * @event
7330
- * @plugin dnd
7331
- * @name dnd_stop.vakata
7332
- * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7333
- * @param {DOM} element the DOM element being dragged
7334
- * @param {jQuery} helper the helper shown next to the mouse
7335
- * @param {Object} event the event that caused the stop
7336
- */
7337
- if (e.target !== vakata_dnd.target) {
7338
- $(vakata_dnd.target).off('click.vakata');
7339
- }
7340
- $.vakata.dnd._trigger("stop", e);
7341
- }
7342
- else {
7343
- if(e.type === "touchend" && e.target === vakata_dnd.target) {
7344
- var to = setTimeout(function () { $(e.target).click(); }, 100);
7345
- $(e.target).one('click', function() { if(to) { clearTimeout(to); } });
7346
- }
7347
- }
7348
- $.vakata.dnd._clean();
7349
- return false;
7350
- }
7351
- };
7352
- }($));
7353
-
7354
- // include the dnd plugin by default
7355
- // $.jstree.defaults.plugins.push("dnd");
7356
-
7357
-
7358
- /**
7359
- * ### Massload plugin
7360
- *
7361
- * Adds massload functionality to jsTree, so that multiple nodes can be loaded in a single request (only useful with lazy loading).
7362
- */
7363
-
7364
- /**
7365
- * massload configuration
7366
- *
7367
- * It is possible to set this to a standard jQuery-like AJAX config.
7368
- * In addition to the standard jQuery ajax options here you can supply functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node IDs need to be loaded, the return value of those functions will be used.
7369
- *
7370
- * You can also set this to a function, that function will receive the node IDs being loaded as argument and a second param which is a function (callback) which should be called with the result.
7371
- *
7372
- * Both the AJAX and the function approach rely on the same return value - an object where the keys are the node IDs, and the value is the children of that node as an array.
7373
- *
7374
- * {
7375
- * "id1" : [{ "text" : "Child of ID1", "id" : "c1" }, { "text" : "Another child of ID1", "id" : "c2" }],
7376
- * "id2" : [{ "text" : "Child of ID2", "id" : "c3" }]
7377
- * }
7378
- *
7379
- * @name $.jstree.defaults.massload
7380
- * @plugin massload
7381
- */
7382
- $.jstree.defaults.massload = null;
7383
- $.jstree.plugins.massload = function (options, parent) {
7384
- this.init = function (el, options) {
7385
- this._data.massload = {};
7386
- parent.init.call(this, el, options);
7387
- };
7388
- this._load_nodes = function (nodes, callback, is_callback, force_reload) {
7389
- var s = this.settings.massload,
7390
- toLoad = [],
7391
- m = this._model.data,
7392
- i, j, dom;
7393
- if (!is_callback) {
7394
- for(i = 0, j = nodes.length; i < j; i++) {
7395
- if(!m[nodes[i]] || ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || force_reload) ) {
7396
- toLoad.push(nodes[i]);
7397
- dom = this.get_node(nodes[i], true);
7398
- if (dom && dom.length) {
7399
- dom.addClass("jstree-loading").attr('aria-busy',true);
7400
- }
7401
- }
7402
- }
7403
- this._data.massload = {};
7404
- if (toLoad.length) {
7405
- if($.isFunction(s)) {
7406
- return s.call(this, toLoad, $.proxy(function (data) {
7407
- var i, j;
7408
- if(data) {
7409
- for(i in data) {
7410
- if(data.hasOwnProperty(i)) {
7411
- this._data.massload[i] = data[i];
7412
- }
7413
- }
7414
- }
7415
- for(i = 0, j = nodes.length; i < j; i++) {
7416
- dom = this.get_node(nodes[i], true);
7417
- if (dom && dom.length) {
7418
- dom.removeClass("jstree-loading").attr('aria-busy',false);
7419
- }
7420
- }
7421
- parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7422
- }, this));
7423
- }
7424
- if(typeof s === 'object' && s && s.url) {
7425
- s = $.extend(true, {}, s);
7426
- if($.isFunction(s.url)) {
7427
- s.url = s.url.call(this, toLoad);
7428
- }
7429
- if($.isFunction(s.data)) {
7430
- s.data = s.data.call(this, toLoad);
7431
- }
7432
- return $.ajax(s)
7433
- .done($.proxy(function (data,t,x) {
7434
- var i, j;
7435
- if(data) {
7436
- for(i in data) {
7437
- if(data.hasOwnProperty(i)) {
7438
- this._data.massload[i] = data[i];
7439
- }
7440
- }
7441
- }
7442
- for(i = 0, j = nodes.length; i < j; i++) {
7443
- dom = this.get_node(nodes[i], true);
7444
- if (dom && dom.length) {
7445
- dom.removeClass("jstree-loading").attr('aria-busy',false);
7446
- }
7447
- }
7448
- parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7449
- }, this))
7450
- .fail($.proxy(function (f) {
7451
- parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7452
- }, this));
7453
- }
7454
- }
7455
- }
7456
- return parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7457
- };
7458
- this._load_node = function (obj, callback) {
7459
- var data = this._data.massload[obj.id],
7460
- rslt = null, dom;
7461
- if(data) {
7462
- rslt = this[typeof data === 'string' ? '_append_html_data' : '_append_json_data'](
7463
- obj,
7464
- typeof data === 'string' ? $($.parseHTML(data)).filter(function () { return this.nodeType !== 3; }) : data,
7465
- function (status) { callback.call(this, status); }
7466
- );
7467
- dom = this.get_node(obj.id, true);
7468
- if (dom && dom.length) {
7469
- dom.removeClass("jstree-loading").attr('aria-busy',false);
7470
- }
7471
- delete this._data.massload[obj.id];
7472
- return rslt;
7473
- }
7474
- return parent._load_node.call(this, obj, callback);
7475
- };
7476
- };
7477
-
7478
-
7479
- /**
7480
- * ### Search plugin
7481
- *
7482
- * Adds search functionality to jsTree.
7483
- */
7484
-
7485
- /**
7486
- * stores all defaults for the search plugin
7487
- * @name $.jstree.defaults.search
7488
- * @plugin search
7489
- */
7490
- $.jstree.defaults.search = {
7491
- /**
7492
- * a jQuery-like AJAX config, which jstree uses if a server should be queried for results.
7493
- *
7494
- * A `str` (which is the search string) parameter will be added with the request, an optional `inside` parameter will be added if the search is limited to a node id. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed.
7495
- * Leave this setting as `false` to not query the server. You can also set this to a function, which will be invoked in the instance's scope and receive 3 parameters - the search string, the callback to call with the array of nodes to load, and the optional node ID to limit the search to
7496
- * @name $.jstree.defaults.search.ajax
7497
- * @plugin search
7498
- */
7499
- ajax : false,
7500
- /**
7501
- * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `false`.
7502
- * @name $.jstree.defaults.search.fuzzy
7503
- * @plugin search
7504
- */
7505
- fuzzy : false,
7506
- /**
7507
- * Indicates if the search should be case sensitive. Default is `false`.
7508
- * @name $.jstree.defaults.search.case_sensitive
7509
- * @plugin search
7510
- */
7511
- case_sensitive : false,
7512
- /**
7513
- * Indicates if the tree should be filtered (by default) to show only matching nodes (keep in mind this can be a heavy on large trees in old browsers).
7514
- * This setting can be changed at runtime when calling the search method. Default is `false`.
7515
- * @name $.jstree.defaults.search.show_only_matches
7516
- * @plugin search
7517
- */
7518
- show_only_matches : false,
7519
- /**
7520
- * Indicates if the children of matched element are shown (when show_only_matches is true)
7521
- * This setting can be changed at runtime when calling the search method. Default is `false`.
7522
- * @name $.jstree.defaults.search.show_only_matches_children
7523
- * @plugin search
7524
- */
7525
- show_only_matches_children : false,
7526
- /**
7527
- * Indicates if all nodes opened to reveal the search result, should be closed when the search is cleared or a new search is performed. Default is `true`.
7528
- * @name $.jstree.defaults.search.close_opened_onclear
7529
- * @plugin search
7530
- */
7531
- close_opened_onclear : true,
7532
- /**
7533
- * Indicates if only leaf nodes should be included in search results. Default is `false`.
7534
- * @name $.jstree.defaults.search.search_leaves_only
7535
- * @plugin search
7536
- */
7537
- search_leaves_only : false,
7538
- /**
7539
- * If set to a function it wil be called in the instance's scope with two arguments - search string and node (where node will be every node in the structure, so use with caution).
7540
- * If the function returns a truthy value the node will be considered a match (it might not be displayed if search_only_leaves is set to true and the node is not a leaf). Default is `false`.
7541
- * @name $.jstree.defaults.search.search_callback
7542
- * @plugin search
7543
- */
7544
- search_callback : false
7545
- };
7546
-
7547
- $.jstree.plugins.search = function (options, parent) {
7548
- this.bind = function () {
7549
- parent.bind.call(this);
7550
-
7551
- this._data.search.str = "";
7552
- this._data.search.dom = $();
7553
- this._data.search.res = [];
7554
- this._data.search.opn = [];
7555
- this._data.search.som = false;
7556
- this._data.search.smc = false;
7557
- this._data.search.hdn = [];
7558
-
7559
- this.element
7560
- .on("search.jstree", $.proxy(function (e, data) {
7561
- if(this._data.search.som && data.res.length) {
7562
- var m = this._model.data, i, j, p = [], k, l;
7563
- for(i = 0, j = data.res.length; i < j; i++) {
7564
- if(m[data.res[i]] && !m[data.res[i]].state.hidden) {
7565
- p.push(data.res[i]);
7566
- p = p.concat(m[data.res[i]].parents);
7567
- if(this._data.search.smc) {
7568
- for (k = 0, l = m[data.res[i]].children_d.length; k < l; k++) {
7569
- if (m[m[data.res[i]].children_d[k]] && !m[m[data.res[i]].children_d[k]].state.hidden) {
7570
- p.push(m[data.res[i]].children_d[k]);
7571
- }
7572
- }
7573
- }
7574
- }
7575
- }
7576
- p = $.vakata.array_remove_item($.vakata.array_unique(p), $.jstree.root);
7577
- this._data.search.hdn = this.hide_all(true);
7578
- this.show_node(p, true);
7579
- this.redraw(true);
7580
- }
7581
- }, this))
7582
- .on("clear_search.jstree", $.proxy(function (e, data) {
7583
- if(this._data.search.som && data.res.length) {
7584
- this.show_node(this._data.search.hdn, true);
7585
- this.redraw(true);
7586
- }
7587
- }, this));
7588
- };
7589
- /**
7590
- * used to search the tree nodes for a given string
7591
- * @name search(str [, skip_async])
7592
- * @param {String} str the search string
7593
- * @param {Boolean} skip_async if set to true server will not be queried even if configured
7594
- * @param {Boolean} show_only_matches if set to true only matching nodes will be shown (keep in mind this can be very slow on large trees or old browsers)
7595
- * @param {mixed} inside an optional node to whose children to limit the search
7596
- * @param {Boolean} append if set to true the results of this search are appended to the previous search
7597
- * @plugin search
7598
- * @trigger search.jstree
7599
- */
7600
- this.search = function (str, skip_async, show_only_matches, inside, append, show_only_matches_children) {
7601
- if(str === false || $.trim(str.toString()) === "") {
7602
- return this.clear_search();
7603
- }
7604
- inside = this.get_node(inside);
7605
- inside = inside && inside.id ? inside.id : null;
7606
- str = str.toString();
7607
- var s = this.settings.search,
7608
- a = s.ajax ? s.ajax : false,
7609
- m = this._model.data,
7610
- f = null,
7611
- r = [],
7612
- p = [], i, j;
7613
- if(this._data.search.res.length && !append) {
7614
- this.clear_search();
7615
- }
7616
- if(show_only_matches === undefined) {
7617
- show_only_matches = s.show_only_matches;
7618
- }
7619
- if(show_only_matches_children === undefined) {
7620
- show_only_matches_children = s.show_only_matches_children;
7621
- }
7622
- if(!skip_async && a !== false) {
7623
- if($.isFunction(a)) {
7624
- return a.call(this, str, $.proxy(function (d) {
7625
- if(d && d.d) { d = d.d; }
7626
- this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
7627
- this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
7628
- });
7629
- }, this), inside);
7630
- }
7631
- else {
7632
- a = $.extend({}, a);
7633
- if(!a.data) { a.data = {}; }
7634
- a.data.str = str;
7635
- if(inside) {
7636
- a.data.inside = inside;
7637
- }
7638
- if (this._data.search.lastRequest) {
7639
- this._data.search.lastRequest.abort();
7640
- }
7641
- this._data.search.lastRequest = $.ajax(a)
7642
- .fail($.proxy(function () {
7643
- this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) };
7644
- this.settings.core.error.call(this, this._data.core.last_error);
7645
- }, this))
7646
- .done($.proxy(function (d) {
7647
- if(d && d.d) { d = d.d; }
7648
- this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
7649
- this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
7650
- });
7651
- }, this));
7652
- return this._data.search.lastRequest;
7653
- }
7654
- }
7655
- if(!append) {
7656
- this._data.search.str = str;
7657
- this._data.search.dom = $();
7658
- this._data.search.res = [];
7659
- this._data.search.opn = [];
7660
- this._data.search.som = show_only_matches;
7661
- this._data.search.smc = show_only_matches_children;
7662
- }
7663
-
7664
- f = new $.vakata.search(str, true, { caseSensitive : s.case_sensitive, fuzzy : s.fuzzy });
7665
- $.each(m[inside ? inside : $.jstree.root].children_d, function (ii, i) {
7666
- var v = m[i];
7667
- if(v.text && !v.state.hidden && (!s.search_leaves_only || (v.state.loaded && v.children.length === 0)) && ( (s.search_callback && s.search_callback.call(this, str, v)) || (!s.search_callback && f.search(v.text).isMatch) ) ) {
7668
- r.push(i);
7669
- p = p.concat(v.parents);
7670
- }
7671
- });
7672
- if(r.length) {
7673
- p = $.vakata.array_unique(p);
7674
- for(i = 0, j = p.length; i < j; i++) {
7675
- if(p[i] !== $.jstree.root && m[p[i]] && this.open_node(p[i], null, 0) === true) {
7676
- this._data.search.opn.push(p[i]);
7677
- }
7678
- }
7679
- if(!append) {
7680
- this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #')));
7681
- this._data.search.res = r;
7682
- }
7683
- else {
7684
- this._data.search.dom = this._data.search.dom.add($(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))));
7685
- this._data.search.res = $.vakata.array_unique(this._data.search.res.concat(r));
7686
- }
7687
- this._data.search.dom.children(".jstree-anchor").addClass('jstree-search');
7688
- }
7689
- /**
7690
- * triggered after search is complete
7691
- * @event
7692
- * @name search.jstree
7693
- * @param {jQuery} nodes a jQuery collection of matching nodes
7694
- * @param {String} str the search string
7695
- * @param {Array} res a collection of objects represeing the matching nodes
7696
- * @plugin search
7697
- */
7698
- this.trigger('search', { nodes : this._data.search.dom, str : str, res : this._data.search.res, show_only_matches : show_only_matches });
7699
- };
7700
- /**
7701
- * used to clear the last search (removes classes and shows all nodes if filtering is on)
7702
- * @name clear_search()
7703
- * @plugin search
7704
- * @trigger clear_search.jstree
7705
- */
7706
- this.clear_search = function () {
7707
- if(this.settings.search.close_opened_onclear) {
7708
- this.close_node(this._data.search.opn, 0);
7709
- }
7710
- /**
7711
- * triggered after search is complete
7712
- * @event
7713
- * @name clear_search.jstree
7714
- * @param {jQuery} nodes a jQuery collection of matching nodes (the result from the last search)
7715
- * @param {String} str the search string (the last search string)
7716
- * @param {Array} res a collection of objects represeing the matching nodes (the result from the last search)
7717
- * @plugin search
7718
- */
7719
- this.trigger('clear_search', { 'nodes' : this._data.search.dom, str : this._data.search.str, res : this._data.search.res });
7720
- if(this._data.search.res.length) {
7721
- this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(this._data.search.res, function (v) {
7722
- return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&');
7723
- }).join(', #')));
7724
- this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search");
7725
- }
7726
- this._data.search.str = "";
7727
- this._data.search.res = [];
7728
- this._data.search.opn = [];
7729
- this._data.search.dom = $();
7730
- };
7731
-
7732
- this.redraw_node = function(obj, deep, callback, force_render) {
7733
- obj = parent.redraw_node.apply(this, arguments);
7734
- if(obj) {
7735
- if($.inArray(obj.id, this._data.search.res) !== -1) {
7736
- var i, j, tmp = null;
7737
- for(i = 0, j = obj.childNodes.length; i < j; i++) {
7738
- if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) {
7739
- tmp = obj.childNodes[i];
7740
- break;
7741
- }
7742
- }
7743
- if(tmp) {
7744
- tmp.className += ' jstree-search';
7745
- }
7746
- }
7747
- }
7748
- return obj;
7749
- };
7750
- };
7751
-
7752
- // helpers
7753
- (function ($) {
7754
- // from http://kiro.me/projects/fuse.html
7755
- $.vakata.search = function(pattern, txt, options) {
7756
- options = options || {};
7757
- options = $.extend({}, $.vakata.search.defaults, options);
7758
- if(options.fuzzy !== false) {
7759
- options.fuzzy = true;
7760
- }
7761
- pattern = options.caseSensitive ? pattern : pattern.toLowerCase();
7762
- var MATCH_LOCATION = options.location,
7763
- MATCH_DISTANCE = options.distance,
7764
- MATCH_THRESHOLD = options.threshold,
7765
- patternLen = pattern.length,
7766
- matchmask, pattern_alphabet, match_bitapScore, search;
7767
- if(patternLen > 32) {
7768
- options.fuzzy = false;
7769
- }
7770
- if(options.fuzzy) {
7771
- matchmask = 1 << (patternLen - 1);
7772
- pattern_alphabet = (function () {
7773
- var mask = {},
7774
- i = 0;
7775
- for (i = 0; i < patternLen; i++) {
7776
- mask[pattern.charAt(i)] = 0;
7777
- }
7778
- for (i = 0; i < patternLen; i++) {
7779
- mask[pattern.charAt(i)] |= 1 << (patternLen - i - 1);
7780
- }
7781
- return mask;
7782
- }());
7783
- match_bitapScore = function (e, x) {
7784
- var accuracy = e / patternLen,
7785
- proximity = Math.abs(MATCH_LOCATION - x);
7786
- if(!MATCH_DISTANCE) {
7787
- return proximity ? 1.0 : accuracy;
7788
- }
7789
- return accuracy + (proximity / MATCH_DISTANCE);
7790
- };
7791
- }
7792
- search = function (text) {
7793
- text = options.caseSensitive ? text : text.toLowerCase();
7794
- if(pattern === text || text.indexOf(pattern) !== -1) {
7795
- return {
7796
- isMatch: true,
7797
- score: 0
7798
- };
7799
- }
7800
- if(!options.fuzzy) {
7801
- return {
7802
- isMatch: false,
7803
- score: 1
7804
- };
7805
- }
7806
- var i, j,
7807
- textLen = text.length,
7808
- scoreThreshold = MATCH_THRESHOLD,
7809
- bestLoc = text.indexOf(pattern, MATCH_LOCATION),
7810
- binMin, binMid,
7811
- binMax = patternLen + textLen,
7812
- lastRd, start, finish, rd, charMatch,
7813
- score = 1,
7814
- locations = [];
7815
- if (bestLoc !== -1) {
7816
- scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold);
7817
- bestLoc = text.lastIndexOf(pattern, MATCH_LOCATION + patternLen);
7818
- if (bestLoc !== -1) {
7819
- scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold);
7820
- }
7821
- }
7822
- bestLoc = -1;
7823
- for (i = 0; i < patternLen; i++) {
7824
- binMin = 0;
7825
- binMid = binMax;
7826
- while (binMin < binMid) {
7827
- if (match_bitapScore(i, MATCH_LOCATION + binMid) <= scoreThreshold) {
7828
- binMin = binMid;
7829
- } else {
7830
- binMax = binMid;
7831
- }
7832
- binMid = Math.floor((binMax - binMin) / 2 + binMin);
7833
- }
7834
- binMax = binMid;
7835
- start = Math.max(1, MATCH_LOCATION - binMid + 1);
7836
- finish = Math.min(MATCH_LOCATION + binMid, textLen) + patternLen;
7837
- rd = new Array(finish + 2);
7838
- rd[finish + 1] = (1 << i) - 1;
7839
- for (j = finish; j >= start; j--) {
7840
- charMatch = pattern_alphabet[text.charAt(j - 1)];
7841
- if (i === 0) {
7842
- rd[j] = ((rd[j + 1] << 1) | 1) & charMatch;
7843
- } else {
7844
- rd[j] = ((rd[j + 1] << 1) | 1) & charMatch | (((lastRd[j + 1] | lastRd[j]) << 1) | 1) | lastRd[j + 1];
7845
- }
7846
- if (rd[j] & matchmask) {
7847
- score = match_bitapScore(i, j - 1);
7848
- if (score <= scoreThreshold) {
7849
- scoreThreshold = score;
7850
- bestLoc = j - 1;
7851
- locations.push(bestLoc);
7852
- if (bestLoc > MATCH_LOCATION) {
7853
- start = Math.max(1, 2 * MATCH_LOCATION - bestLoc);
7854
- } else {
7855
- break;
7856
- }
7857
- }
7858
- }
7859
- }
7860
- if (match_bitapScore(i + 1, MATCH_LOCATION) > scoreThreshold) {
7861
- break;
7862
- }
7863
- lastRd = rd;
7864
- }
7865
- return {
7866
- isMatch: bestLoc >= 0,
7867
- score: score
7868
- };
7869
- };
7870
- return txt === true ? { 'search' : search } : search(txt);
7871
- };
7872
- $.vakata.search.defaults = {
7873
- location : 0,
7874
- distance : 100,
7875
- threshold : 0.6,
7876
- fuzzy : false,
7877
- caseSensitive : false
7878
- };
7879
- }($));
7880
-
7881
- // include the search plugin by default
7882
- // $.jstree.defaults.plugins.push("search");
7883
-
7884
-
7885
- /**
7886
- * ### Sort plugin
7887
- *
7888
- * Automatically sorts all siblings in the tree according to a sorting function.
7889
- */
7890
-
7891
- /**
7892
- * the settings function used to sort the nodes.
7893
- * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`.
7894
- * @name $.jstree.defaults.sort
7895
- * @plugin sort
7896
- */
7897
- $.jstree.defaults.sort = function (a, b) {
7898
- //return this.get_type(a) === this.get_type(b) ? (this.get_text(a) > this.get_text(b) ? 1 : -1) : this.get_type(a) >= this.get_type(b);
7899
- return this.get_text(a) > this.get_text(b) ? 1 : -1;
7900
- };
7901
- $.jstree.plugins.sort = function (options, parent) {
7902
- this.bind = function () {
7903
- parent.bind.call(this);
7904
- this.element
7905
- .on("model.jstree", $.proxy(function (e, data) {
7906
- this.sort(data.parent, true);
7907
- }, this))
7908
- .on("rename_node.jstree create_node.jstree", $.proxy(function (e, data) {
7909
- this.sort(data.parent || data.node.parent, false);
7910
- this.redraw_node(data.parent || data.node.parent, true);
7911
- }, this))
7912
- .on("move_node.jstree copy_node.jstree", $.proxy(function (e, data) {
7913
- this.sort(data.parent, false);
7914
- this.redraw_node(data.parent, true);
7915
- }, this));
7916
- };
7917
- /**
7918
- * used to sort a node's children
7919
- * @private
7920
- * @name sort(obj [, deep])
7921
- * @param {mixed} obj the node
7922
- * @param {Boolean} deep if set to `true` nodes are sorted recursively.
7923
- * @plugin sort
7924
- * @trigger search.jstree
7925
- */
7926
- this.sort = function (obj, deep) {
7927
- var i, j;
7928
- obj = this.get_node(obj);
7929
- if(obj && obj.children && obj.children.length) {
7930
- obj.children.sort($.proxy(this.settings.sort, this));
7931
- if(deep) {
7932
- for(i = 0, j = obj.children_d.length; i < j; i++) {
7933
- this.sort(obj.children_d[i], false);
7934
- }
7935
- }
7936
- }
7937
- };
7938
- };
7939
-
7940
- // include the sort plugin by default
7941
- // $.jstree.defaults.plugins.push("sort");
7942
-
7943
- /**
7944
- * ### State plugin
7945
- *
7946
- * Saves the state of the tree (selected nodes, opened nodes) on the user's computer using available options (localStorage, cookies, etc)
7947
- */
7948
-
7949
- var to = false;
7950
- /**
7951
- * stores all defaults for the state plugin
7952
- * @name $.jstree.defaults.state
7953
- * @plugin state
7954
- */
7955
- $.jstree.defaults.state = {
7956
- /**
7957
- * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`.
7958
- * @name $.jstree.defaults.state.key
7959
- * @plugin state
7960
- */
7961
- key : 'jstree',
7962
- /**
7963
- * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`.
7964
- * @name $.jstree.defaults.state.events
7965
- * @plugin state
7966
- */
7967
- events : 'changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree',
7968
- /**
7969
- * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire.
7970
- * @name $.jstree.defaults.state.ttl
7971
- * @plugin state
7972
- */
7973
- ttl : false,
7974
- /**
7975
- * A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state.
7976
- * @name $.jstree.defaults.state.filter
7977
- * @plugin state
7978
- */
7979
- filter : false,
7980
- /**
7981
- * Should loaded nodes be restored (setting this to true means that it is possible that the whole tree will be loaded for some users - use with caution). Defaults to `false`
7982
- * @name $.jstree.defaults.state.preserve_loaded
7983
- * @plugin state
7984
- */
7985
- preserve_loaded : false
7986
- };
7987
- $.jstree.plugins.state = function (options, parent) {
7988
- this.bind = function () {
7989
- parent.bind.call(this);
7990
- var bind = $.proxy(function () {
7991
- this.element.on(this.settings.state.events, $.proxy(function () {
7992
- if(to) { clearTimeout(to); }
7993
- to = setTimeout($.proxy(function () { this.save_state(); }, this), 100);
7994
- }, this));
7995
- /**
7996
- * triggered when the state plugin is finished restoring the state (and immediately after ready if there is no state to restore).
7997
- * @event
7998
- * @name state_ready.jstree
7999
- * @plugin state
8000
- */
8001
- this.trigger('state_ready');
8002
- }, this);
8003
- this.element
8004
- .on("ready.jstree", $.proxy(function (e, data) {
8005
- this.element.one("restore_state.jstree", bind);
8006
- if(!this.restore_state()) { bind(); }
8007
- }, this));
8008
- };
8009
- /**
8010
- * save the state
8011
- * @name save_state()
8012
- * @plugin state
8013
- */
8014
- this.save_state = function () {
8015
- var tm = this.get_state();
8016
- if (!this.settings.state.preserve_loaded) {
8017
- delete tm.core.loaded;
8018
- }
8019
- var st = { 'state' : tm, 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
8020
- $.vakata.storage.set(this.settings.state.key, JSON.stringify(st));
8021
- };
8022
- /**
8023
- * restore the state from the user's computer
8024
- * @name restore_state()
8025
- * @plugin state
8026
- */
8027
- this.restore_state = function () {
8028
- var k = $.vakata.storage.get(this.settings.state.key);
8029
- if(!!k) { try { k = JSON.parse(k); } catch(ex) { return false; } }
8030
- if(!!k && k.ttl && k.sec && +(new Date()) - k.sec > k.ttl) { return false; }
8031
- if(!!k && k.state) { k = k.state; }
8032
- if(!!k && $.isFunction(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); }
8033
- if(!!k) {
8034
- if (!this.settings.state.preserve_loaded) {
8035
- delete k.core.loaded;
8036
- }
8037
- this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); });
8038
- this.set_state(k);
8039
- return true;
8040
- }
8041
- return false;
8042
- };
8043
- /**
8044
- * clear the state on the user's computer
8045
- * @name clear_state()
8046
- * @plugin state
8047
- */
8048
- this.clear_state = function () {
8049
- return $.vakata.storage.del(this.settings.state.key);
8050
- };
8051
- };
8052
-
8053
- (function ($, undefined) {
8054
- $.vakata.storage = {
8055
- // simply specifying the functions in FF throws an error
8056
- set : function (key, val) { return window.localStorage.setItem(key, val); },
8057
- get : function (key) { return window.localStorage.getItem(key); },
8058
- del : function (key) { return window.localStorage.removeItem(key); }
8059
- };
8060
- }($));
8061
-
8062
- // include the state plugin by default
8063
- // $.jstree.defaults.plugins.push("state");
8064
-
8065
- /**
8066
- * ### Types plugin
8067
- *
8068
- * Makes it possible to add predefined types for groups of nodes, which make it possible to easily control nesting rules and icon for each group.
8069
- */
8070
-
8071
- /**
8072
- * An object storing all types as key value pairs, where the key is the type name and the value is an object that could contain following keys (all optional).
8073
- *
8074
- * * `max_children` the maximum number of immediate children this node type can have. Do not specify or set to `-1` for unlimited.
8075
- * * `max_depth` the maximum number of nesting this node type can have. A value of `1` would mean that the node can have children, but no grandchildren. Do not specify or set to `-1` for unlimited.
8076
- * * `valid_children` an array of node type strings, that nodes of this type can have as children. Do not specify or set to `-1` for no limits.
8077
- * * `icon` a string - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class. Omit to use the default icon from your theme.
8078
- * * `li_attr` an object of values which will be used to add HTML attributes on the resulting LI DOM node (merged with the node's own data)
8079
- * * `a_attr` an object of values which will be used to add HTML attributes on the resulting A DOM node (merged with the node's own data)
8080
- *
8081
- * There are two predefined types:
8082
- *
8083
- * * `#` represents the root of the tree, for example `max_children` would control the maximum number of root nodes.
8084
- * * `default` represents the default node - any settings here will be applied to all nodes that do not have a type specified.
8085
- *
8086
- * @name $.jstree.defaults.types
8087
- * @plugin types
8088
- */
8089
- $.jstree.defaults.types = {
8090
- 'default' : {}
8091
- };
8092
- $.jstree.defaults.types[$.jstree.root] = {};
8093
-
8094
- $.jstree.plugins.types = function (options, parent) {
8095
- this.init = function (el, options) {
8096
- var i, j;
8097
- if(options && options.types && options.types['default']) {
8098
- for(i in options.types) {
8099
- if(i !== "default" && i !== $.jstree.root && options.types.hasOwnProperty(i)) {
8100
- for(j in options.types['default']) {
8101
- if(options.types['default'].hasOwnProperty(j) && options.types[i][j] === undefined) {
8102
- options.types[i][j] = options.types['default'][j];
8103
- }
8104
- }
8105
- }
8106
- }
8107
- }
8108
- parent.init.call(this, el, options);
8109
- this._model.data[$.jstree.root].type = $.jstree.root;
8110
- };
8111
- this.refresh = function (skip_loading, forget_state) {
8112
- parent.refresh.call(this, skip_loading, forget_state);
8113
- this._model.data[$.jstree.root].type = $.jstree.root;
8114
- };
8115
- this.bind = function () {
8116
- this.element
8117
- .on('model.jstree', $.proxy(function (e, data) {
8118
- var m = this._model.data,
8119
- dpc = data.nodes,
8120
- t = this.settings.types,
8121
- i, j, c = 'default', k;
8122
- for(i = 0, j = dpc.length; i < j; i++) {
8123
- c = 'default';
8124
- if(m[dpc[i]].original && m[dpc[i]].original.type && t[m[dpc[i]].original.type]) {
8125
- c = m[dpc[i]].original.type;
8126
- }
8127
- if(m[dpc[i]].data && m[dpc[i]].data.jstree && m[dpc[i]].data.jstree.type && t[m[dpc[i]].data.jstree.type]) {
8128
- c = m[dpc[i]].data.jstree.type;
8129
- }
8130
- m[dpc[i]].type = c;
8131
- if(m[dpc[i]].icon === true && t[c].icon !== undefined) {
8132
- m[dpc[i]].icon = t[c].icon;
8133
- }
8134
- if(t[c].li_attr !== undefined && typeof t[c].li_attr === 'object') {
8135
- for (k in t[c].li_attr) {
8136
- if (t[c].li_attr.hasOwnProperty(k)) {
8137
- if (k === 'id') {
8138
- continue;
8139
- }
8140
- else if (m[dpc[i]].li_attr[k] === undefined) {
8141
- m[dpc[i]].li_attr[k] = t[c].li_attr[k];
8142
- }
8143
- else if (k === 'class') {
8144
- m[dpc[i]].li_attr['class'] = t[c].li_attr['class'] + ' ' + m[dpc[i]].li_attr['class'];
8145
- }
8146
- }
8147
- }
8148
- }
8149
- if(t[c].a_attr !== undefined && typeof t[c].a_attr === 'object') {
8150
- for (k in t[c].a_attr) {
8151
- if (t[c].a_attr.hasOwnProperty(k)) {
8152
- if (k === 'id') {
8153
- continue;
8154
- }
8155
- else if (m[dpc[i]].a_attr[k] === undefined) {
8156
- m[dpc[i]].a_attr[k] = t[c].a_attr[k];
8157
- }
8158
- else if (k === 'href' && m[dpc[i]].a_attr[k] === '#') {
8159
- m[dpc[i]].a_attr['href'] = t[c].a_attr['href'];
8160
- }
8161
- else if (k === 'class') {
8162
- m[dpc[i]].a_attr['class'] = t[c].a_attr['class'] + ' ' + m[dpc[i]].a_attr['class'];
8163
- }
8164
- }
8165
- }
8166
- }
8167
- }
8168
- m[$.jstree.root].type = $.jstree.root;
8169
- }, this));
8170
- parent.bind.call(this);
8171
- };
8172
- this.get_json = function (obj, options, flat) {
8173
- var i, j,
8174
- m = this._model.data,
8175
- opt = options ? $.extend(true, {}, options, {no_id:false}) : {},
8176
- tmp = parent.get_json.call(this, obj, opt, flat);
8177
- if(tmp === false) { return false; }
8178
- if($.isArray(tmp)) {
8179
- for(i = 0, j = tmp.length; i < j; i++) {
8180
- tmp[i].type = tmp[i].id && m[tmp[i].id] && m[tmp[i].id].type ? m[tmp[i].id].type : "default";
8181
- if(options && options.no_id) {
8182
- delete tmp[i].id;
8183
- if(tmp[i].li_attr && tmp[i].li_attr.id) {
8184
- delete tmp[i].li_attr.id;
8185
- }
8186
- if(tmp[i].a_attr && tmp[i].a_attr.id) {
8187
- delete tmp[i].a_attr.id;
8188
- }
8189
- }
8190
- }
8191
- }
8192
- else {
8193
- tmp.type = tmp.id && m[tmp.id] && m[tmp.id].type ? m[tmp.id].type : "default";
8194
- if(options && options.no_id) {
8195
- tmp = this._delete_ids(tmp);
8196
- }
8197
- }
8198
- return tmp;
8199
- };
8200
- this._delete_ids = function (tmp) {
8201
- if($.isArray(tmp)) {
8202
- for(var i = 0, j = tmp.length; i < j; i++) {
8203
- tmp[i] = this._delete_ids(tmp[i]);
8204
- }
8205
- return tmp;
8206
- }
8207
- delete tmp.id;
8208
- if(tmp.li_attr && tmp.li_attr.id) {
8209
- delete tmp.li_attr.id;
8210
- }
8211
- if(tmp.a_attr && tmp.a_attr.id) {
8212
- delete tmp.a_attr.id;
8213
- }
8214
- if(tmp.children && $.isArray(tmp.children)) {
8215
- tmp.children = this._delete_ids(tmp.children);
8216
- }
8217
- return tmp;
8218
- };
8219
- this.check = function (chk, obj, par, pos, more) {
8220
- if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
8221
- obj = obj && obj.id ? obj : this.get_node(obj);
8222
- par = par && par.id ? par : this.get_node(par);
8223
- var m = obj && obj.id ? (more && more.origin ? more.origin : $.jstree.reference(obj.id)) : null, tmp, d, i, j;
8224
- m = m && m._model && m._model.data ? m._model.data : null;
8225
- switch(chk) {
8226
- case "create_node":
8227
- case "move_node":
8228
- case "copy_node":
8229
- if(chk !== 'move_node' || $.inArray(obj.id, par.children) === -1) {
8230
- tmp = this.get_rules(par);
8231
- if(tmp.max_children !== undefined && tmp.max_children !== -1 && tmp.max_children === par.children.length) {
8232
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_01', 'reason' : 'max_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8233
- return false;
8234
- }
8235
- if(tmp.valid_children !== undefined && tmp.valid_children !== -1 && $.inArray((obj.type || 'default'), tmp.valid_children) === -1) {
8236
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_02', 'reason' : 'valid_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8237
- return false;
8238
- }
8239
- if(m && obj.children_d && obj.parents) {
8240
- d = 0;
8241
- for(i = 0, j = obj.children_d.length; i < j; i++) {
8242
- d = Math.max(d, m[obj.children_d[i]].parents.length);
8243
- }
8244
- d = d - obj.parents.length + 1;
8245
- }
8246
- if(d <= 0 || d === undefined) { d = 1; }
8247
- do {
8248
- if(tmp.max_depth !== undefined && tmp.max_depth !== -1 && tmp.max_depth < d) {
8249
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_03', 'reason' : 'max_depth prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8250
- return false;
8251
- }
8252
- par = this.get_node(par.parent);
8253
- tmp = this.get_rules(par);
8254
- d++;
8255
- } while(par);
8256
- }
8257
- break;
8258
- }
8259
- return true;
8260
- };
8261
- /**
8262
- * used to retrieve the type settings object for a node
8263
- * @name get_rules(obj)
8264
- * @param {mixed} obj the node to find the rules for
8265
- * @return {Object}
8266
- * @plugin types
8267
- */
8268
- this.get_rules = function (obj) {
8269
- obj = this.get_node(obj);
8270
- if(!obj) { return false; }
8271
- var tmp = this.get_type(obj, true);
8272
- if(tmp.max_depth === undefined) { tmp.max_depth = -1; }
8273
- if(tmp.max_children === undefined) { tmp.max_children = -1; }
8274
- if(tmp.valid_children === undefined) { tmp.valid_children = -1; }
8275
- return tmp;
8276
- };
8277
- /**
8278
- * used to retrieve the type string or settings object for a node
8279
- * @name get_type(obj [, rules])
8280
- * @param {mixed} obj the node to find the rules for
8281
- * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned
8282
- * @return {String|Object}
8283
- * @plugin types
8284
- */
8285
- this.get_type = function (obj, rules) {
8286
- obj = this.get_node(obj);
8287
- return (!obj) ? false : ( rules ? $.extend({ 'type' : obj.type }, this.settings.types[obj.type]) : obj.type);
8288
- };
8289
- /**
8290
- * used to change a node's type
8291
- * @name set_type(obj, type)
8292
- * @param {mixed} obj the node to change
8293
- * @param {String} type the new type
8294
- * @plugin types
8295
- */
8296
- this.set_type = function (obj, type) {
8297
- var m = this._model.data, t, t1, t2, old_type, old_icon, k, d, a;
8298
- if($.isArray(obj)) {
8299
- obj = obj.slice();
8300
- for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
8301
- this.set_type(obj[t1], type);
8302
- }
8303
- return true;
8304
- }
8305
- t = this.settings.types;
8306
- obj = this.get_node(obj);
8307
- if(!t[type] || !obj) { return false; }
8308
- d = this.get_node(obj, true);
8309
- if (d && d.length) {
8310
- a = d.children('.jstree-anchor');
8311
- }
8312
- old_type = obj.type;
8313
- old_icon = this.get_icon(obj);
8314
- obj.type = type;
8315
- if(old_icon === true || !t[old_type] || (t[old_type].icon !== undefined && old_icon === t[old_type].icon)) {
8316
- this.set_icon(obj, t[type].icon !== undefined ? t[type].icon : true);
8317
- }
8318
-
8319
- // remove old type props
8320
- if(t[old_type] && t[old_type].li_attr !== undefined && typeof t[old_type].li_attr === 'object') {
8321
- for (k in t[old_type].li_attr) {
8322
- if (t[old_type].li_attr.hasOwnProperty(k)) {
8323
- if (k === 'id') {
8324
- continue;
8325
- }
8326
- else if (k === 'class') {
8327
- m[obj.id].li_attr['class'] = (m[obj.id].li_attr['class'] || '').replace(t[old_type].li_attr[k], '');
8328
- if (d) { d.removeClass(t[old_type].li_attr[k]); }
8329
- }
8330
- else if (m[obj.id].li_attr[k] === t[old_type].li_attr[k]) {
8331
- m[obj.id].li_attr[k] = null;
8332
- if (d) { d.removeAttr(k); }
8333
- }
8334
- }
8335
- }
8336
- }
8337
- if(t[old_type] && t[old_type].a_attr !== undefined && typeof t[old_type].a_attr === 'object') {
8338
- for (k in t[old_type].a_attr) {
8339
- if (t[old_type].a_attr.hasOwnProperty(k)) {
8340
- if (k === 'id') {
8341
- continue;
8342
- }
8343
- else if (k === 'class') {
8344
- m[obj.id].a_attr['class'] = (m[obj.id].a_attr['class'] || '').replace(t[old_type].a_attr[k], '');
8345
- if (a) { a.removeClass(t[old_type].a_attr[k]); }
8346
- }
8347
- else if (m[obj.id].a_attr[k] === t[old_type].a_attr[k]) {
8348
- if (k === 'href') {
8349
- m[obj.id].a_attr[k] = '#';
8350
- if (a) { a.attr('href', '#'); }
8351
- }
8352
- else {
8353
- delete m[obj.id].a_attr[k];
8354
- if (a) { a.removeAttr(k); }
8355
- }
8356
- }
8357
- }
8358
- }
8359
- }
8360
-
8361
- // add new props
8362
- if(t[type].li_attr !== undefined && typeof t[type].li_attr === 'object') {
8363
- for (k in t[type].li_attr) {
8364
- if (t[type].li_attr.hasOwnProperty(k)) {
8365
- if (k === 'id') {
8366
- continue;
8367
- }
8368
- else if (m[obj.id].li_attr[k] === undefined) {
8369
- m[obj.id].li_attr[k] = t[type].li_attr[k];
8370
- if (d) {
8371
- if (k === 'class') {
8372
- d.addClass(t[type].li_attr[k]);
8373
- }
8374
- else {
8375
- d.attr(k, t[type].li_attr[k]);
8376
- }
8377
- }
8378
- }
8379
- else if (k === 'class') {
8380
- m[obj.id].li_attr['class'] = t[type].li_attr[k] + ' ' + m[obj.id].li_attr['class'];
8381
- if (d) { d.addClass(t[type].li_attr[k]); }
8382
- }
8383
- }
8384
- }
8385
- }
8386
- if(t[type].a_attr !== undefined && typeof t[type].a_attr === 'object') {
8387
- for (k in t[type].a_attr) {
8388
- if (t[type].a_attr.hasOwnProperty(k)) {
8389
- if (k === 'id') {
8390
- continue;
8391
- }
8392
- else if (m[obj.id].a_attr[k] === undefined) {
8393
- m[obj.id].a_attr[k] = t[type].a_attr[k];
8394
- if (a) {
8395
- if (k === 'class') {
8396
- a.addClass(t[type].a_attr[k]);
8397
- }
8398
- else {
8399
- a.attr(k, t[type].a_attr[k]);
8400
- }
8401
- }
8402
- }
8403
- else if (k === 'href' && m[obj.id].a_attr[k] === '#') {
8404
- m[obj.id].a_attr['href'] = t[type].a_attr['href'];
8405
- if (a) { a.attr('href', t[type].a_attr['href']); }
8406
- }
8407
- else if (k === 'class') {
8408
- m[obj.id].a_attr['class'] = t[type].a_attr['class'] + ' ' + m[obj.id].a_attr['class'];
8409
- if (a) { a.addClass(t[type].a_attr[k]); }
8410
- }
8411
- }
8412
- }
8413
- }
8414
-
8415
- return true;
8416
- };
8417
- };
8418
- // include the types plugin by default
8419
- // $.jstree.defaults.plugins.push("types");
8420
-
8421
-
8422
- /**
8423
- * ### Unique plugin
8424
- *
8425
- * Enforces that no nodes with the same name can coexist as siblings.
8426
- */
8427
-
8428
- /**
8429
- * stores all defaults for the unique plugin
8430
- * @name $.jstree.defaults.unique
8431
- * @plugin unique
8432
- */
8433
- $.jstree.defaults.unique = {
8434
- /**
8435
- * Indicates if the comparison should be case sensitive. Default is `false`.
8436
- * @name $.jstree.defaults.unique.case_sensitive
8437
- * @plugin unique
8438
- */
8439
- case_sensitive : false,
8440
- /**
8441
- * Indicates if white space should be trimmed before the comparison. Default is `false`.
8442
- * @name $.jstree.defaults.unique.trim_whitespace
8443
- * @plugin unique
8444
- */
8445
- trim_whitespace : false,
8446
- /**
8447
- * A callback executed in the instance's scope when a new node is created and the name is already taken, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`.
8448
- * @name $.jstree.defaults.unique.duplicate
8449
- * @plugin unique
8450
- */
8451
- duplicate : function (name, counter) {
8452
- return name + ' (' + counter + ')';
8453
- }
8454
- };
8455
-
8456
- $.jstree.plugins.unique = function (options, parent) {
8457
- this.check = function (chk, obj, par, pos, more) {
8458
- if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
8459
- obj = obj && obj.id ? obj : this.get_node(obj);
8460
- par = par && par.id ? par : this.get_node(par);
8461
- if(!par || !par.children) { return true; }
8462
- var n = chk === "rename_node" ? pos : obj.text,
8463
- c = [],
8464
- s = this.settings.unique.case_sensitive,
8465
- w = this.settings.unique.trim_whitespace,
8466
- m = this._model.data, i, j, t;
8467
- for(i = 0, j = par.children.length; i < j; i++) {
8468
- t = m[par.children[i]].text;
8469
- if (!s) {
8470
- t = t.toLowerCase();
8471
- }
8472
- if (w) {
8473
- t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8474
- }
8475
- c.push(t);
8476
- }
8477
- if(!s) { n = n.toLowerCase(); }
8478
- if (w) { n = n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }
8479
- switch(chk) {
8480
- case "delete_node":
8481
- return true;
8482
- case "rename_node":
8483
- t = obj.text || '';
8484
- if (!s) {
8485
- t = t.toLowerCase();
8486
- }
8487
- if (w) {
8488
- t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8489
- }
8490
- i = ($.inArray(n, c) === -1 || (obj.text && t === n));
8491
- if(!i) {
8492
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8493
- }
8494
- return i;
8495
- case "create_node":
8496
- i = ($.inArray(n, c) === -1);
8497
- if(!i) {
8498
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_04', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8499
- }
8500
- return i;
8501
- case "copy_node":
8502
- i = ($.inArray(n, c) === -1);
8503
- if(!i) {
8504
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_02', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8505
- }
8506
- return i;
8507
- case "move_node":
8508
- i = ( (obj.parent === par.id && (!more || !more.is_multi)) || $.inArray(n, c) === -1);
8509
- if(!i) {
8510
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_03', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8511
- }
8512
- return i;
8513
- }
8514
- return true;
8515
- };
8516
- this.create_node = function (par, node, pos, callback, is_loaded) {
8517
- if(!node || node.text === undefined) {
8518
- if(par === null) {
8519
- par = $.jstree.root;
8520
- }
8521
- par = this.get_node(par);
8522
- if(!par) {
8523
- return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8524
- }
8525
- pos = pos === undefined ? "last" : pos;
8526
- if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
8527
- return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8528
- }
8529
- if(!node) { node = {}; }
8530
- var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, w = this.settings.unique.trim_whitespace, cb = this.settings.unique.duplicate, t;
8531
- n = tmp = this.get_string('New node');
8532
- dpc = [];
8533
- for(i = 0, j = par.children.length; i < j; i++) {
8534
- t = m[par.children[i]].text;
8535
- if (!s) {
8536
- t = t.toLowerCase();
8537
- }
8538
- if (w) {
8539
- t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8540
- }
8541
- dpc.push(t);
8542
- }
8543
- i = 1;
8544
- t = n;
8545
- if (!s) {
8546
- t = t.toLowerCase();
8547
- }
8548
- if (w) {
8549
- t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8550
- }
8551
- while($.inArray(t, dpc) !== -1) {
8552
- n = cb.call(this, tmp, (++i)).toString();
8553
- t = n;
8554
- if (!s) {
8555
- t = t.toLowerCase();
8556
- }
8557
- if (w) {
8558
- t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8559
- }
8560
- }
8561
- node.text = n;
8562
- }
8563
- return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8564
- };
8565
- };
8566
-
8567
- // include the unique plugin by default
8568
- // $.jstree.defaults.plugins.push("unique");
8569
-
8570
-
8571
- /**
8572
- * ### Wholerow plugin
8573
- *
8574
- * Makes each node appear block level. Making selection easier. May cause slow down for large trees in old browsers.
8575
- */
8576
-
8577
- var div = document.createElement('DIV');
8578
- div.setAttribute('unselectable','on');
8579
- div.setAttribute('role','presentation');
8580
- div.className = 'jstree-wholerow';
8581
- div.innerHTML = '&#160;';
8582
- $.jstree.plugins.wholerow = function (options, parent) {
8583
- this.bind = function () {
8584
- parent.bind.call(this);
8585
-
8586
- this.element
8587
- .on('ready.jstree set_state.jstree', $.proxy(function () {
8588
- this.hide_dots();
8589
- }, this))
8590
- .on("init.jstree loading.jstree ready.jstree", $.proxy(function () {
8591
- //div.style.height = this._data.core.li_height + 'px';
8592
- this.get_container_ul().addClass('jstree-wholerow-ul');
8593
- }, this))
8594
- .on("deselect_all.jstree", $.proxy(function (e, data) {
8595
- this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked');
8596
- }, this))
8597
- .on("changed.jstree", $.proxy(function (e, data) {
8598
- this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked');
8599
- var tmp = false, i, j;
8600
- for(i = 0, j = data.selected.length; i < j; i++) {
8601
- tmp = this.get_node(data.selected[i], true);
8602
- if(tmp && tmp.length) {
8603
- tmp.children('.jstree-wholerow').addClass('jstree-wholerow-clicked');
8604
- }
8605
- }
8606
- }, this))
8607
- .on("open_node.jstree", $.proxy(function (e, data) {
8608
- this.get_node(data.node, true).find('.jstree-clicked').parent().children('.jstree-wholerow').addClass('jstree-wholerow-clicked');
8609
- }, this))
8610
- .on("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) {
8611
- if(e.type === "hover_node" && this.is_disabled(data.node)) { return; }
8612
- this.get_node(data.node, true).children('.jstree-wholerow')[e.type === "hover_node"?"addClass":"removeClass"]('jstree-wholerow-hovered');
8613
- }, this))
8614
- .on("contextmenu.jstree", ".jstree-wholerow", $.proxy(function (e) {
8615
- if (this._data.contextmenu) {
8616
- e.preventDefault();
8617
- var tmp = $.Event('contextmenu', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey, pageX : e.pageX, pageY : e.pageY });
8618
- $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp);
8619
- }
8620
- }, this))
8621
- /*!
8622
- .on("mousedown.jstree touchstart.jstree", ".jstree-wholerow", function (e) {
8623
- if(e.target === e.currentTarget) {
8624
- var a = $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor");
8625
- e.target = a[0];
8626
- a.trigger(e);
8627
- }
8628
- })
8629
- */
8630
- .on("click.jstree", ".jstree-wholerow", function (e) {
8631
- e.stopImmediatePropagation();
8632
- var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
8633
- $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
8634
- })
8635
- .on("dblclick.jstree", ".jstree-wholerow", function (e) {
8636
- e.stopImmediatePropagation();
8637
- var tmp = $.Event('dblclick', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
8638
- $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
8639
- })
8640
- .on("click.jstree", ".jstree-leaf > .jstree-ocl", $.proxy(function (e) {
8641
- e.stopImmediatePropagation();
8642
- var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
8643
- $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
8644
- }, this))
8645
- .on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", $.proxy(function (e) {
8646
- e.stopImmediatePropagation();
8647
- if(!this.is_disabled(e.currentTarget)) {
8648
- this.hover_node(e.currentTarget);
8649
- }
8650
- return false;
8651
- }, this))
8652
- .on("mouseleave.jstree", ".jstree-node", $.proxy(function (e) {
8653
- this.dehover_node(e.currentTarget);
8654
- }, this));
8655
- };
8656
- this.teardown = function () {
8657
- if(this.settings.wholerow) {
8658
- this.element.find(".jstree-wholerow").remove();
8659
- }
8660
- parent.teardown.call(this);
8661
- };
8662
- this.redraw_node = function(obj, deep, callback, force_render) {
8663
- obj = parent.redraw_node.apply(this, arguments);
8664
- if(obj) {
8665
- var tmp = div.cloneNode(true);
8666
- //tmp.style.height = this._data.core.li_height + 'px';
8667
- if($.inArray(obj.id, this._data.core.selected) !== -1) { tmp.className += ' jstree-wholerow-clicked'; }
8668
- if(this._data.core.focused && this._data.core.focused === obj.id) { tmp.className += ' jstree-wholerow-hovered'; }
8669
- obj.insertBefore(tmp, obj.childNodes[0]);
8670
- }
8671
- return obj;
8672
- };
8673
- };
8674
- // include the wholerow plugin by default
8675
- // $.jstree.defaults.plugins.push("wholerow");
8676
- if(window.customElements && Object && Object.create) {
8677
- var proto = Object.create(HTMLElement.prototype);
8678
- proto.createdCallback = function () {
8679
- var c = { core : {}, plugins : [] }, i;
8680
- for(i in $.jstree.plugins) {
8681
- if($.jstree.plugins.hasOwnProperty(i) && this.attributes[i]) {
8682
- c.plugins.push(i);
8683
- if(this.getAttribute(i) && JSON.parse(this.getAttribute(i))) {
8684
- c[i] = JSON.parse(this.getAttribute(i));
8685
- }
8686
- }
8687
- }
8688
- for(i in $.jstree.defaults.core) {
8689
- if($.jstree.defaults.core.hasOwnProperty(i) && this.attributes[i]) {
8690
- c.core[i] = JSON.parse(this.getAttribute(i)) || this.getAttribute(i);
8691
- }
8692
- }
8693
- $(this).jstree(c);
8694
- };
8695
- // proto.attributeChangedCallback = function (name, previous, value) { };
8696
- try {
8697
- window.customElements.define("vakata-jstree", function() {}, { prototype: proto });
8698
- } catch (ignore) { }
8699
- }
8700
-
8701
  }));
1
+ /*globals jQuery, define, module, exports, require, window, document, postMessage */
2
+ (function (factory) {
3
+ "use strict";
4
+ if (typeof define === 'function' && define.amd) {
5
+ define(['jquery'], factory);
6
+ }
7
+ else if(typeof module !== 'undefined' && module.exports) {
8
+ module.exports = factory(require('jquery'));
9
+ }
10
+ else {
11
+ factory(jQuery);
12
+ }
13
+ }(function ($, undefined) {
14
+ "use strict";
15
+ /*!
16
+ * jsTree 3.3.10
17
+ * http://jstree.com/
18
+ *
19
+ * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
20
+ *
21
+ * Licensed same as jquery - under the terms of the MIT License
22
+ * http://www.opensource.org/licenses/mit-license.php
23
+ */
24
+ /*!
25
+ * if using jslint please allow for the jQuery global and use following options:
26
+ * jslint: loopfunc: true, browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
27
+ */
28
+ /*jshint -W083 */
29
+
30
+ // prevent another load? maybe there is a better way?
31
+ if($.jstree) {
32
+ return;
33
+ }
34
+
35
+ /**
36
+ * ### jsTree core functionality
37
+ */
38
+
39
+ // internal variables
40
+ var instance_counter = 0,
41
+ ccp_node = false,
42
+ ccp_mode = false,
43
+ ccp_inst = false,
44
+ themes_loaded = [],
45
+ src = $('script:last').attr('src'),
46
+ document = window.document; // local variable is always faster to access then a global
47
+
48
+ var setImmediate = window.setImmediate;
49
+ var Promise = window.Promise;
50
+ if (!setImmediate && Promise) {
51
+ // Good enough approximation of setImmediate
52
+ setImmediate = function (cb, arg) {
53
+ Promise.resolve(arg).then(cb);
54
+ };
55
+ }
56
+
57
+ /**
58
+ * holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances.
59
+ * @name $.jstree
60
+ */
61
+ $.jstree = {
62
+ /**
63
+ * specifies the jstree version in use
64
+ * @name $.jstree.version
65
+ */
66
+ version : '3.3.10',
67
+ /**
68
+ * holds all the default options used when creating new instances
69
+ * @name $.jstree.defaults
70
+ */
71
+ defaults : {
72
+ /**
73
+ * configure which plugins will be active on an instance. Should be an array of strings, where each element is a plugin name. The default is `[]`
74
+ * @name $.jstree.defaults.plugins
75
+ */
76
+ plugins : []
77
+ },
78
+ /**
79
+ * stores all loaded jstree plugins (used internally)
80
+ * @name $.jstree.plugins
81
+ */
82
+ plugins : {},
83
+ path : src && src.indexOf('/') !== -1 ? src.replace(/\/[^\/]+$/,'') : '',
84
+ idregex : /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,
85
+ root : '#'
86
+ };
87
+
88
+ /**
89
+ * creates a jstree instance
90
+ * @name $.jstree.create(el [, options])
91
+ * @param {DOMElement|jQuery|String} el the element to create the instance on, can be jQuery extended or a selector
92
+ * @param {Object} options options for this instance (extends `$.jstree.defaults`)
93
+ * @return {jsTree} the new instance
94
+ */
95
+ $.jstree.create = function (el, options) {
96
+ var tmp = new $.jstree.core(++instance_counter),
97
+ opt = options;
98
+ options = $.extend(true, {}, $.jstree.defaults, options);
99
+ if(opt && opt.plugins) {
100
+ options.plugins = opt.plugins;
101
+ }
102
+ $.each(options.plugins, function (i, k) {
103
+ if(i !== 'core') {
104
+ tmp = tmp.plugin(k, options[k]);
105
+ }
106
+ });
107
+ $(el).data('jstree', tmp);
108
+ tmp.init(el, options);
109
+ return tmp;
110
+ };
111
+ /**
112
+ * remove all traces of jstree from the DOM and destroy all instances
113
+ * @name $.jstree.destroy()
114
+ */
115
+ $.jstree.destroy = function () {
116
+ $('.jstree:jstree').jstree('destroy');
117
+ $(document).off('.jstree');
118
+ };
119
+ /**
120
+ * the jstree class constructor, used only internally
121
+ * @private
122
+ * @name $.jstree.core(id)
123
+ * @param {Number} id this instance's index
124
+ */
125
+ $.jstree.core = function (id) {
126
+ this._id = id;
127
+ this._cnt = 0;
128
+ this._wrk = null;
129
+ this._data = {
130
+ core : {
131
+ themes : {
132
+ name : false,
133
+ dots : false,
134
+ icons : false,
135
+ ellipsis : false
136
+ },
137
+ selected : [],
138
+ last_error : {},
139
+ working : false,
140
+ worker_queue : [],
141
+ focused : null
142
+ }
143
+ };
144
+ };
145
+ /**
146
+ * get a reference to an existing instance
147
+ *
148
+ * __Examples__
149
+ *
150
+ * // provided a container with an ID of "tree", and a nested node with an ID of "branch"
151
+ * // all of there will return the same instance
152
+ * $.jstree.reference('tree');
153
+ * $.jstree.reference('#tree');
154
+ * $.jstree.reference($('#tree'));
155
+ * $.jstree.reference(document.getElementByID('tree'));
156
+ * $.jstree.reference('branch');
157
+ * $.jstree.reference('#branch');
158
+ * $.jstree.reference($('#branch'));
159
+ * $.jstree.reference(document.getElementByID('branch'));
160
+ *
161
+ * @name $.jstree.reference(needle)
162
+ * @param {DOMElement|jQuery|String} needle
163
+ * @return {jsTree|null} the instance or `null` if not found
164
+ */
165
+ $.jstree.reference = function (needle) {
166
+ var tmp = null,
167
+ obj = null;
168
+ if(needle && needle.id && (!needle.tagName || !needle.nodeType)) { needle = needle.id; }
169
+
170
+ if(!obj || !obj.length) {
171
+ try { obj = $(needle); } catch (ignore) { }
172
+ }
173
+ if(!obj || !obj.length) {
174
+ try { obj = $('#' + needle.replace($.jstree.idregex,'\\$&')); } catch (ignore) { }
175
+ }
176
+ if(obj && obj.length && (obj = obj.closest('.jstree')).length && (obj = obj.data('jstree'))) {
177
+ tmp = obj;
178
+ }
179
+ else {
180
+ $('.jstree').each(function () {
181
+ var inst = $(this).data('jstree');
182
+ if(inst && inst._model.data[needle]) {
183
+ tmp = inst;
184
+ return false;
185
+ }
186
+ });
187
+ }
188
+ return tmp;
189
+ };
190
+ /**
191
+ * Create an instance, get an instance or invoke a command on a instance.
192
+ *
193
+ * If there is no instance associated with the current node a new one is created and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken).
194
+ *
195
+ * If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function).
196
+ *
197
+ * If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`).
198
+ *
199
+ * In any other case - nothing is returned and chaining is not broken.
200
+ *
201
+ * __Examples__
202
+ *
203
+ * $('#tree1').jstree(); // creates an instance
204
+ * $('#tree2').jstree({ plugins : [] }); // create an instance with some options
205
+ * $('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments
206
+ * $('#tree2').jstree(); // get an existing instance (or create an instance)
207
+ * $('#tree2').jstree(true); // get an existing instance (will not create new instance)
208
+ * $('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method)
209
+ *
210
+ * @name $().jstree([arg])
211
+ * @param {String|Object} arg
212
+ * @return {Mixed}
213
+ */
214
+ $.fn.jstree = function (arg) {
215
+ // check for string argument
216
+ var is_method = (typeof arg === 'string'),
217
+ args = Array.prototype.slice.call(arguments, 1),
218
+ result = null;
219
+ if(arg === true && !this.length) { return false; }
220
+ this.each(function () {
221
+ // get the instance (if there is one) and method (if it exists)
222
+ var instance = $.jstree.reference(this),
223
+ method = is_method && instance ? instance[arg] : null;
224
+ // if calling a method, and method is available - execute on the instance
225
+ result = is_method && method ?
226
+ method.apply(instance, args) :
227
+ null;
228
+ // if there is no instance and no method is being called - create one
229
+ if(!instance && !is_method && (arg === undefined || $.isPlainObject(arg))) {
230
+ $.jstree.create(this, arg);
231
+ }
232
+ // if there is an instance and no method is called - return the instance
233
+ if( (instance && !is_method) || arg === true ) {
234
+ result = instance || false;
235
+ }
236
+ // if there was a method call which returned a result - break and return the value
237
+ if(result !== null && result !== undefined) {
238
+ return false;
239
+ }
240
+ });
241
+ // if there was a method call with a valid return value - return that, otherwise continue the chain
242
+ return result !== null && result !== undefined ?
243
+ result : this;
244
+ };
245
+ /**
246
+ * used to find elements containing an instance
247
+ *
248
+ * __Examples__
249
+ *
250
+ * $('div:jstree').each(function () {
251
+ * $(this).jstree('destroy');
252
+ * });
253
+ *
254
+ * @name $(':jstree')
255
+ * @return {jQuery}
256
+ */
257
+ $.expr.pseudos.jstree = $.expr.createPseudo(function(search) {
258
+ return function(a) {
259
+ return $(a).hasClass('jstree') &&
260
+ $(a).data('jstree') !== undefined;
261
+ };
262
+ });
263
+
264
+ /**
265
+ * stores all defaults for the core
266
+ * @name $.jstree.defaults.core
267
+ */
268
+ $.jstree.defaults.core = {
269
+ /**
270
+ * data configuration
271
+ *
272
+ * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items).
273
+ *
274
+ * You can also pass in a HTML string or a JSON array here.
275
+ *
276
+ * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree.
277
+ * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used.
278
+ *
279
+ * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result.
280
+ *
281
+ * __Examples__
282
+ *
283
+ * // AJAX
284
+ * $('#tree').jstree({
285
+ * 'core' : {
286
+ * 'data' : {
287
+ * 'url' : '/get/children/',
288
+ * 'data' : function (node) {
289
+ * return { 'id' : node.id };
290
+ * }
291
+ * }
292
+ * });
293
+ *
294
+ * // direct data
295
+ * $('#tree').jstree({
296
+ * 'core' : {
297
+ * 'data' : [
298
+ * 'Simple root node',
299
+ * {
300
+ * 'id' : 'node_2',
301
+ * 'text' : 'Root node with options',
302
+ * 'state' : { 'opened' : true, 'selected' : true },
303
+ * 'children' : [ { 'text' : 'Child 1' }, 'Child 2']
304
+ * }
305
+ * ]
306
+ * }
307
+ * });
308
+ *
309
+ * // function
310
+ * $('#tree').jstree({
311
+ * 'core' : {
312
+ * 'data' : function (obj, callback) {
313
+ * callback.call(this, ['Root 1', 'Root 2']);
314
+ * }
315
+ * });
316
+ *
317
+ * @name $.jstree.defaults.core.data
318
+ */
319
+ data : false,
320
+ /**
321
+ * configure the various strings used throughout the tree
322
+ *
323
+ * You can use an object where the key is the string you need to replace and the value is your replacement.
324
+ * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement.
325
+ * If left as `false` no replacement is made.
326
+ *
327
+ * __Examples__
328
+ *
329
+ * $('#tree').jstree({
330
+ * 'core' : {
331
+ * 'strings' : {
332
+ * 'Loading ...' : 'Please wait ...'
333
+ * }
334
+ * }
335
+ * });
336
+ *
337
+ * @name $.jstree.defaults.core.strings
338
+ */
339
+ strings : false,
340
+ /**
341
+ * determines what happens when a user tries to modify the structure of the tree
342
+ * If left as `false` all operations like create, rename, delete, move or copy are prevented.
343
+ * You can set this to `true` to allow all interactions or use a function to have better control.
344
+ *
345
+ * __Examples__
346
+ *
347
+ * $('#tree').jstree({
348
+ * 'core' : {
349
+ * 'check_callback' : function (operation, node, node_parent, node_position, more) {
350
+ * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit'
351
+ * // in case of 'rename_node' node_position is filled with the new node name
352
+ * return operation === 'rename_node' ? true : false;
353
+ * }
354
+ * }
355
+ * });
356
+ *
357
+ * @name $.jstree.defaults.core.check_callback
358
+ */
359
+ check_callback : false,
360
+ /**
361
+ * a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc)
362
+ * @name $.jstree.defaults.core.error
363
+ */
364
+ error : $.noop,
365
+ /**
366
+ * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`)
367
+ * @name $.jstree.defaults.core.animation
368
+ */
369
+ animation : 200,
370
+ /**
371
+ * a boolean indicating if multiple nodes can be selected
372
+ * @name $.jstree.defaults.core.multiple
373
+ */
374
+ multiple : true,
375
+ /**
376
+ * theme configuration object
377
+ * @name $.jstree.defaults.core.themes
378
+ */
379
+ themes : {
380
+ /**
381
+ * the name of the theme to use (if left as `false` the default theme is used)
382
+ * @name $.jstree.defaults.core.themes.name
383
+ */
384
+ name : false,
385
+ /**
386
+ * the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme.
387
+ * @name $.jstree.defaults.core.themes.url
388
+ */
389
+ url : false,
390
+ /**
391
+ * the location of all jstree themes - only used if `url` is set to `true`
392
+ * @name $.jstree.defaults.core.themes.dir
393
+ */
394
+ dir : false,
395
+ /**
396
+ * a boolean indicating if connecting dots are shown
397
+ * @name $.jstree.defaults.core.themes.dots
398
+ */
399
+ dots : true,
400
+ /**
401
+ * a boolean indicating if node icons are shown
402
+ * @name $.jstree.defaults.core.themes.icons
403
+ */
404
+ icons : true,
405
+ /**
406
+ * a boolean indicating if node ellipsis should be shown - this only works with a fixed with on the container
407
+ * @name $.jstree.defaults.core.themes.ellipsis
408
+ */
409
+ ellipsis : false,
410
+ /**
411
+ * a boolean indicating if the tree background is striped
412
+ * @name $.jstree.defaults.core.themes.stripes
413
+ */
414
+ stripes : false,
415
+ /**
416
+ * a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants)
417
+ * @name $.jstree.defaults.core.themes.variant
418
+ */
419
+ variant : false,
420
+ /**
421
+ * a boolean specifying if a reponsive version of the theme should kick in on smaller screens (if the theme supports it). Defaults to `false`.
422
+ * @name $.jstree.defaults.core.themes.responsive
423
+ */
424
+ responsive : false
425
+ },
426
+ /**
427
+ * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user)
428
+ * @name $.jstree.defaults.core.expand_selected_onload
429
+ */
430
+ expand_selected_onload : true,
431
+ /**
432
+ * if left as `true` web workers will be used to parse incoming JSON data where possible, so that the UI will not be blocked by large requests. Workers are however about 30% slower. Defaults to `true`
433
+ * @name $.jstree.defaults.core.worker
434
+ */
435
+ worker : true,
436
+ /**
437
+ * Force node text to plain text (and escape HTML). Defaults to `false`
438
+ * @name $.jstree.defaults.core.force_text
439
+ */
440
+ force_text : false,
441
+ /**
442
+ * Should the node be toggled if the text is double clicked. Defaults to `true`
443
+ * @name $.jstree.defaults.core.dblclick_toggle
444
+ */
445
+ dblclick_toggle : true,
446
+ /**
447
+ * Should the loaded nodes be part of the state. Defaults to `false`
448
+ * @name $.jstree.defaults.core.loaded_state
449
+ */
450
+ loaded_state : false,
451
+ /**
452
+ * Should the last active node be focused when the tree container is blurred and the focused again. This helps working with screen readers. Defaults to `true`
453
+ * @name $.jstree.defaults.core.restore_focus
454
+ */
455
+ restore_focus : true,
456
+ /**
457
+ * Default keyboard shortcuts (an object where each key is the button name or combo - like 'enter', 'ctrl-space', 'p', etc and the value is the function to execute in the instance's scope)
458
+ * @name $.jstree.defaults.core.keyboard
459
+ */
460
+ keyboard : {
461
+ 'ctrl-space': function (e) {
462
+ // aria defines space only with Ctrl
463
+ e.type = "click";
464
+ $(e.currentTarget).trigger(e);
465
+ },
466
+ 'enter': function (e) {
467
+ // enter
468
+ e.type = "click";
469
+ $(e.currentTarget).trigger(e);
470
+ },
471
+ 'left': function (e) {
472
+ // left
473
+ e.preventDefault();
474
+ if(this.is_open(e.currentTarget)) {
475
+ this.close_node(e.currentTarget);
476
+ }
477
+ else {
478
+ var o = this.get_parent(e.currentTarget);
479
+ if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); }
480
+ }
481
+ },
482
+ 'up': function (e) {
483
+ // up
484
+ e.preventDefault();
485
+ var o = this.get_prev_dom(e.currentTarget);
486
+ if(o && o.length) { o.children('.jstree-anchor').focus(); }
487
+ },
488
+ 'right': function (e) {
489
+ // right
490
+ e.preventDefault();
491
+ if(this.is_closed(e.currentTarget)) {
492
+ this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); });
493
+ }
494
+ else if (this.is_open(e.currentTarget)) {
495
+ var o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
496
+ if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); }
497
+ }
498
+ },
499
+ 'down': function (e) {
500
+ // down
501
+ e.preventDefault();
502
+ var o = this.get_next_dom(e.currentTarget);
503
+ if(o && o.length) { o.children('.jstree-anchor').focus(); }
504
+ },
505
+ '*': function (e) {
506
+ // aria defines * on numpad as open_all - not very common
507
+ this.open_all();
508
+ },
509
+ 'home': function (e) {
510
+ // home
511
+ e.preventDefault();
512
+ var o = this._firstChild(this.get_container_ul()[0]);
513
+ if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); }
514
+ },
515
+ 'end': function (e) {
516
+ // end
517
+ e.preventDefault();
518
+ this.element.find('.jstree-anchor').filter(':visible').last().focus();
519
+ },
520
+ 'f2': function (e) {
521
+ // f2 - safe to include - if check_callback is false it will fail
522
+ e.preventDefault();
523
+ this.edit(e.currentTarget);
524
+ }
525
+ }
526
+ };
527
+ $.jstree.core.prototype = {
528
+ /**
529
+ * used to decorate an instance with a plugin. Used internally.
530
+ * @private
531
+ * @name plugin(deco [, opts])
532
+ * @param {String} deco the plugin to decorate with
533
+ * @param {Object} opts options for the plugin
534
+ * @return {jsTree}
535
+ */
536
+ plugin : function (deco, opts) {
537
+ var Child = $.jstree.plugins[deco];
538
+ if(Child) {
539
+ this._data[deco] = {};
540
+ Child.prototype = this;
541
+ return new Child(opts, this);
542
+ }
543
+ return this;
544
+ },
545
+ /**
546
+ * initialize the instance. Used internally.
547
+ * @private
548
+ * @name init(el, optons)
549
+ * @param {DOMElement|jQuery|String} el the element we are transforming
550
+ * @param {Object} options options for this instance
551
+ * @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree
552
+ */
553
+ init : function (el, options) {
554
+ this._model = {
555
+ data : {},
556
+ changed : [],
557
+ force_full_redraw : false,
558
+ redraw_timeout : false,
559
+ default_state : {
560
+ loaded : true,
561
+ opened : false,
562
+ selected : false,
563
+ disabled : false
564
+ }
565
+ };
566
+ this._model.data[$.jstree.root] = {
567
+ id : $.jstree.root,
568
+ parent : null,
569
+ parents : [],
570
+ children : [],
571
+ children_d : [],
572
+ state : { loaded : false }
573
+ };
574
+
575
+ this.element = $(el).addClass('jstree jstree-' + this._id);
576
+ this.settings = options;
577
+
578
+ this._data.core.ready = false;
579
+ this._data.core.loaded = false;
580
+ this._data.core.rtl = (this.element.css("direction") === "rtl");
581
+ this.element[this._data.core.rtl ? 'addClass' : 'removeClass']("jstree-rtl");
582
+ this.element.attr('role','tree');
583
+ if(this.settings.core.multiple) {
584
+ this.element.attr('aria-multiselectable', true);
585
+ }
586
+ if(!this.element.attr('tabindex')) {
587
+ this.element.attr('tabindex','0');
588
+ }
589
+
590
+ this.bind();
591
+ /**
592
+ * triggered after all events are bound
593
+ * @event
594
+ * @name init.jstree
595
+ */
596
+ this.trigger("init");
597
+
598
+ this._data.core.original_container_html = this.element.find(" > ul > li").clone(true);
599
+ this._data.core.original_container_html
600
+ .find("li").addBack()
601
+ .contents().filter(function() {
602
+ return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue));
603
+ })
604
+ .remove();
605
+ this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='presentation'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden pfolder-folder-close'></i>" + this.get_string("Loading ...") + "</a></li></ul>");
606
+ this.element.attr('aria-activedescendant','j' + this._id + '_loading');
607
+ this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24;
608
+ this._data.core.node = this._create_prototype_node();
609
+ /**
610
+ * triggered after the loading text is shown and before loading starts
611
+ * @event
612
+ * @name loading.jstree
613
+ */
614
+ this.trigger("loading");
615
+ this.load_node($.jstree.root);
616
+ },
617
+ /**
618
+ * destroy an instance
619
+ * @name destroy()
620
+ * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact
621
+ */
622
+ destroy : function (keep_html) {
623
+ /**
624
+ * triggered before the tree is destroyed
625
+ * @event
626
+ * @name destroy.jstree
627
+ */
628
+ this.trigger("destroy");
629
+ if(this._wrk) {
630
+ try {
631
+ window.URL.revokeObjectURL(this._wrk);
632
+ this._wrk = null;
633
+ }
634
+ catch (ignore) { }
635
+ }
636
+ if(!keep_html) { this.element.empty(); }
637
+ this.teardown();
638
+ },
639
+ /**
640
+ * Create a prototype node
641
+ * @name _create_prototype_node()
642
+ * @return {DOMElement}
643
+ */
644
+ _create_prototype_node : function () {
645
+ var _node = document.createElement('LI'), _temp1, _temp2;
646
+ _node.setAttribute('role', 'presentation');
647
+ _temp1 = document.createElement('I');
648
+ _temp1.className = 'jstree-icon jstree-ocl';
649
+ _temp1.setAttribute('role', 'presentation');
650
+ _node.appendChild(_temp1);
651
+ _temp1 = document.createElement('A');
652
+ _temp1.className = 'jstree-anchor';
653
+ _temp1.setAttribute('href','#');
654
+ _temp1.setAttribute('tabindex','-1');
655
+ _temp1.setAttribute('role', 'treeitem');
656
+ _temp2 = document.createElement('I');
657
+ _temp2.className = 'pfolder-folder-close';
658
+ _temp2.setAttribute('role', 'presentation');
659
+ _temp1.appendChild(_temp2);
660
+
661
+ var _tempSpan = document.createElement('span');
662
+ _tempSpan.className = 'folder-checkbox';
663
+ _temp1.appendChild(_tempSpan);
664
+
665
+ var _inputCheck = document.createElement('input');
666
+ _inputCheck.setAttribute('type', 'checkbox');
667
+ _inputCheck.setAttribute('class', 'checkbox');
668
+ _tempSpan.appendChild(_inputCheck);
669
+
670
+ var _temp3 = document.createElement('span');
671
+ _temp3.className = 'folder-actions';
672
+ _temp1.appendChild(_temp3);
673
+
674
+ /* for inline edit */
675
+ var _temp4 = document.createElement('span');
676
+ _temp4.className = 'folder-inline-edit';
677
+ _temp3.appendChild(_temp4);
678
+
679
+ var _temp5 = document.createElement('i');
680
+ _temp5.className = 'pfolder-edit-folder';
681
+ _temp4.appendChild(_temp5);
682
+
683
+ /* for star */
684
+ var _temp6 = document.createElement('span');
685
+ _temp6.className = 'star-icon';
686
+ _temp3.appendChild(_temp6);
687
+
688
+ var _temp7 = document.createElement('i');
689
+ _temp7.className = 'pfolder-star';
690
+ _temp6.appendChild(_temp7);
691
+
692
+ /* for star */
693
+ var _temp8 = document.createElement('span');
694
+ _temp8.className = 'sticky-icon';
695
+ _temp3.appendChild(_temp8);
696
+
697
+ var _temp9 = document.createElement('i');
698
+ _temp9.className = 'pfolder-pin';
699
+ _temp8.appendChild(_temp9);
700
+
701
+ /* for star */
702
+ var _temp10 = document.createElement('span');
703
+ _temp10.className = 'premio-folder-count';
704
+ _temp3.appendChild(_temp10);
705
+
706
+ _node.appendChild(_temp1);
707
+ _temp1 = _temp2 = null;
708
+
709
+ return _node;
710
+ },
711
+ _kbevent_to_func : function (e) {
712
+ var keys = {
713
+ 8: "Backspace", 9: "Tab", 13: "Enter", 19: "Pause", 27: "Esc",
714
+ 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home",
715
+ 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "Print", 45: "Insert",
716
+ 46: "Delete", 96: "Numpad0", 97: "Numpad1", 98: "Numpad2", 99 : "Numpad3",
717
+ 100: "Numpad4", 101: "Numpad5", 102: "Numpad6", 103: "Numpad7",
718
+ 104: "Numpad8", 105: "Numpad9", '-13': "NumpadEnter", 112: "F1",
719
+ 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7",
720
+ 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "Numlock",
721
+ 145: "Scrolllock", 16: 'Shift', 17: 'Ctrl', 18: 'Alt',
722
+ 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
723
+ 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
724
+ 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
725
+ 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
726
+ 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
727
+ 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
728
+ 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
729
+ 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*', 173: '-'
730
+ };
731
+ var parts = [];
732
+ if (e.ctrlKey) { parts.push('ctrl'); }
733
+ if (e.altKey) { parts.push('alt'); }
734
+ if (e.shiftKey) { parts.push('shift'); }
735
+ parts.push(keys[e.which] || e.which);
736
+ parts = parts.sort().join('-').toLowerCase();
737
+ if (parts === 'shift-shift' || parts === 'ctrl-ctrl' || parts === 'alt-alt') {
738
+ return null;
739
+ }
740
+
741
+ var kb = this.settings.core.keyboard, i, tmp;
742
+ for (i in kb) {
743
+ if (kb.hasOwnProperty(i)) {
744
+ tmp = i;
745
+ if (tmp !== '-' && tmp !== '+') {
746
+ tmp = tmp.replace('--', '-MINUS').replace('+-', '-MINUS').replace('++', '-PLUS').replace('-+', '-PLUS');
747
+ tmp = tmp.split(/-|\+/).sort().join('-').replace('MINUS', '-').replace('PLUS', '+').toLowerCase();
748
+ }
749
+ if (tmp === parts) {
750
+ return kb[i];
751
+ }
752
+ }
753
+ }
754
+ return null;
755
+ },
756
+ /**
757
+ * part of the destroying of an instance. Used internally.
758
+ * @private
759
+ * @name teardown()
760
+ */
761
+ teardown : function () {
762
+ this.unbind();
763
+ this.element
764
+ .removeClass('jstree')
765
+ .removeData('jstree')
766
+ .find("[class^='jstree']")
767
+ .addBack()
768
+ .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
769
+ this.element = null;
770
+ },
771
+ /**
772
+ * bind all events. Used internally.
773
+ * @private
774
+ * @name bind()
775
+ */
776
+ bind : function () {
777
+ var word = '',
778
+ tout = null,
779
+ was_click = 0;
780
+ this.element
781
+ .on("dblclick.jstree", function (e) {
782
+ if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
783
+ if(document.selection && document.selection.empty) {
784
+ document.selection.empty();
785
+ }
786
+ else {
787
+ if(window.getSelection) {
788
+ var sel = window.getSelection();
789
+ try {
790
+ sel.removeAllRanges();
791
+ sel.collapse();
792
+ } catch (ignore) { }
793
+ }
794
+ }
795
+ })
796
+ .on("mousedown.jstree", $.proxy(function (e) {
797
+ if(e.target === this.element[0]) {
798
+ e.preventDefault(); // prevent losing focus when clicking scroll arrows (FF, Chrome)
799
+ was_click = +(new Date()); // ie does not allow to prevent losing focus
800
+ }
801
+ }, this))
802
+ .on("mousedown.jstree", ".jstree-ocl", function (e) {
803
+ e.preventDefault(); // prevent any node inside from losing focus when clicking the open/close icon
804
+ })
805
+ .on("click.jstree", ".jstree-ocl", $.proxy(function (e) {
806
+ this.toggle_node(e.target);
807
+ }, this))
808
+ .on("dblclick.jstree", ".jstree-anchor", $.proxy(function (e) {
809
+ if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
810
+ if(this.settings.core.dblclick_toggle) {
811
+ this.toggle_node(e.target);
812
+ }
813
+ }, this))
814
+ .on("click.jstree", ".jstree-anchor", $.proxy(function (e) {
815
+ if(e.target.className != 'pfolder-edit-folder' && e.target.className != 'checkbox') {
816
+ e.preventDefault();
817
+ if(e.currentTarget !== document.activeElement) { $(e.currentTarget).focus(); }
818
+ this.activate_node(e.currentTarget, e);
819
+ }
820
+ }, this))
821
+ .on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) {
822
+ if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
823
+ if(this._data.core.rtl) {
824
+ if(e.which === 37) { e.which = 39; }
825
+ else if(e.which === 39) { e.which = 37; }
826
+ }
827
+ var f = this._kbevent_to_func(e);
828
+ if (f) {
829
+ var r = f.call(this, e);
830
+ if (r === false || r === true) {
831
+ return r;
832
+ }
833
+ }
834
+ }, this))
835
+ .on("load_node.jstree", $.proxy(function (e, data) {
836
+ if(data.status) {
837
+ if(data.node.id === $.jstree.root && !this._data.core.loaded) {
838
+ this._data.core.loaded = true;
839
+ if(this._firstChild(this.get_container_ul()[0])) {
840
+ this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id);
841
+ }
842
+ /**
843
+ * triggered after the root node is loaded for the first time
844
+ * @event
845
+ * @name loaded.jstree
846
+ */
847
+ this.trigger("loaded");
848
+ }
849
+ if(!this._data.core.ready) {
850
+ setTimeout($.proxy(function() {
851
+ if(this.element && !this.get_container_ul().find('.jstree-loading').length) {
852
+ this._data.core.ready = true;
853
+ if(this._data.core.selected.length) {
854
+ if(this.settings.core.expand_selected_onload) {
855
+ var tmp = [], i, j;
856
+ for(i = 0, j = this._data.core.selected.length; i < j; i++) {
857
+ tmp = tmp.concat(this._model.data[this._data.core.selected[i]].parents);
858
+ }
859
+ tmp = $.vakata.array_unique(tmp);
860
+ for(i = 0, j = tmp.length; i < j; i++) {
861
+ this.open_node(tmp[i], false, 0);
862
+ }
863
+ }
864
+ this.trigger('changed', { 'action' : 'ready', 'selected' : this._data.core.selected });
865
+ }
866
+ /**
867
+ * triggered after all nodes are finished loading
868
+ * @event
869
+ * @name ready.jstree
870
+ */
871
+ this.trigger("ready");
872
+ }
873
+ }, this), 0);
874
+ }
875
+ }
876
+ }, this))
877
+ // quick searching when the tree is focused
878
+ .on('keypress.jstree', $.proxy(function (e) {
879
+ if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
880
+ if(tout) { clearTimeout(tout); }
881
+ tout = setTimeout(function () {
882
+ word = '';
883
+ }, 500);
884
+
885
+ var chr = String.fromCharCode(e.which).toLowerCase(),
886
+ col = this.element.find('.jstree-anchor').filter(':visible'),
887
+ ind = col.index(document.activeElement) || 0,
888
+ end = false;
889
+ word += chr;
890
+
891
+ // match for whole word from current node down (including the current node)
892
+ if(word.length > 1) {
893
+ col.slice(ind).each($.proxy(function (i, v) {
894
+ if($(v).text().toLowerCase().indexOf(word) === 0) {
895
+ $(v).focus();
896
+ end = true;
897
+ return false;
898
+ }
899
+ }, this));
900
+ if(end) { return; }
901
+
902
+ // match for whole word from the beginning of the tree
903
+ col.slice(0, ind).each($.proxy(function (i, v) {
904
+ if($(v).text().toLowerCase().indexOf(word) === 0) {
905
+ $(v).focus();
906
+ end = true;
907
+ return false;
908
+ }
909
+ }, this));
910
+ if(end) { return; }
911
+ }
912
+ // list nodes that start with that letter (only if word consists of a single char)
913
+ if(new RegExp('^' + chr.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '+$').test(word)) {
914
+ // search for the next node starting with that letter
915
+ col.slice(ind + 1).each($.proxy(function (i, v) {
916
+ if($(v).text().toLowerCase().charAt(0) === chr) {
917
+ $(v).focus();
918
+ end = true;
919
+ return false;
920
+ }
921
+ }, this));
922
+ if(end) { return; }
923
+
924
+ // search from the beginning
925
+ col.slice(0, ind + 1).each($.proxy(function (i, v) {
926
+ if($(v).text().toLowerCase().charAt(0) === chr) {
927
+ $(v).focus();
928
+ end = true;
929
+ return false;
930
+ }
931
+ }, this));
932
+ if(end) { return; }
933
+ }
934
+ }, this))
935
+ // THEME RELATED
936
+ .on("init.jstree", $.proxy(function () {
937
+ var s = this.settings.core.themes;
938
+ this._data.core.themes.dots = s.dots;
939
+ this._data.core.themes.stripes = s.stripes;
940
+ this._data.core.themes.icons = s.icons;
941
+ this._data.core.themes.ellipsis = s.ellipsis;
942
+ this.set_theme(s.name || "default", s.url);
943
+ this.set_theme_variant(s.variant);
944
+ }, this))
945
+ .on("loading.jstree", $.proxy(function () {
946
+ this[ this._data.core.themes.dots ? "show_dots" : "hide_dots" ]();
947
+ this[ this._data.core.themes.icons ? "show_icons" : "hide_icons" ]();
948
+ this[ this._data.core.themes.stripes ? "show_stripes" : "hide_stripes" ]();
949
+ this[ this._data.core.themes.ellipsis ? "show_ellipsis" : "hide_ellipsis" ]();
950
+ }, this))
951
+ .on('blur.jstree', '.jstree-anchor', $.proxy(function (e) {
952
+ this._data.core.focused = null;
953
+ $(e.currentTarget).filter('.jstree-hovered').trigger('mouseleave');
954
+ this.element.attr('tabindex', '0');
955
+ }, this))
956
+ .on('focus.jstree', '.jstree-anchor', $.proxy(function (e) {
957
+ var tmp = this.get_node(e.currentTarget);
958
+ if(tmp && tmp.id) {
959
+ this._data.core.focused = tmp.id;
960
+ }
961
+ this.element.find('.jstree-hovered').not(e.currentTarget).trigger('mouseleave');
962
+ $(e.currentTarget).trigger('mouseenter');
963
+ this.element.attr('tabindex', '-1');
964
+ }, this))
965
+ .on('focus.jstree', $.proxy(function () {
966
+ if(+(new Date()) - was_click > 500 && !this._data.core.focused && this.settings.core.restore_focus) {
967
+ was_click = 0;
968
+ var act = this.get_node(this.element.attr('aria-activedescendant'), true);
969
+ if(act) {
970
+ act.find('> .jstree-anchor').focus();
971
+ }
972
+ }
973
+ }, this))
974
+ .on('mouseenter.jstree', '.jstree-anchor', $.proxy(function (e) {
975
+ this.hover_node(e.currentTarget);
976
+ }, this))
977
+ .on('mouseleave.jstree', '.jstree-anchor', $.proxy(function (e) {
978
+ this.dehover_node(e.currentTarget);
979
+ }, this));
980
+ },
981
+ /**
982
+ * part of the destroying of an instance. Used internally.
983
+ * @private
984
+ * @name unbind()
985
+ */
986
+ unbind : function () {
987
+ this.element.off('.jstree');
988
+ $(document).off('.jstree-' + this._id);
989
+ },
990
+ /**
991
+ * trigger an event. Used internally.
992
+ * @private
993
+ * @name trigger(ev [, data])
994
+ * @param {String} ev the name of the event to trigger
995
+ * @param {Object} data additional data to pass with the event
996
+ */
997
+ trigger : function (ev, data) {
998
+ if(!data) {
999
+ data = {};
1000
+ }
1001
+ data.instance = this;
1002
+ this.element.triggerHandler(ev.replace('.jstree','') + '.jstree', data);
1003
+ },
1004
+ /**
1005
+ * returns the jQuery extended instance container
1006
+ * @name get_container()
1007
+ * @return {jQuery}
1008
+ */
1009
+ get_container : function () {
1010
+ return this.element;
1011
+ },
1012
+ /**
1013
+ * returns the jQuery extended main UL node inside the instance container. Used internally.
1014
+ * @private
1015
+ * @name get_container_ul()
1016
+ * @return {jQuery}
1017
+ */
1018
+ get_container_ul : function () {
1019
+ return this.element.children(".jstree-children").first();
1020
+ },
1021
+ /**
1022
+ * gets string replacements (localization). Used internally.
1023
+ * @private
1024
+ * @name get_string(key)
1025
+ * @param {String} key
1026
+ * @return {String}
1027
+ */
1028
+ get_string : function (key) {
1029
+ var a = this.settings.core.strings;
1030
+ if($.isFunction(a)) { return a.call(this, key); }
1031
+ if(a && a[key]) { return a[key]; }
1032
+ return key;
1033
+ },
1034
+ /**
1035
+ * gets the first child of a DOM node. Used internally.
1036
+ * @private
1037
+ * @name _firstChild(dom)
1038
+ * @param {DOMElement} dom
1039
+ * @return {DOMElement}
1040
+ */
1041
+ _firstChild : function (dom) {
1042
+ dom = dom ? dom.firstChild : null;
1043
+ while(dom !== null && dom.nodeType !== 1) {
1044
+ dom = dom.nextSibling;
1045
+ }
1046
+ return dom;
1047
+ },
1048
+ /**
1049
+ * gets the next sibling of a DOM node. Used internally.
1050
+ * @private
1051
+ * @name _nextSibling(dom)
1052
+ * @param {DOMElement} dom
1053
+ * @return {DOMElement}
1054
+ */
1055
+ _nextSibling : function (dom) {
1056
+ dom = dom ? dom.nextSibling : null;
1057
+ while(dom !== null && dom.nodeType !== 1) {
1058
+ dom = dom.nextSibling;
1059
+ }
1060
+ return dom;
1061
+ },
1062
+ /**
1063
+ * gets the previous sibling of a DOM node. Used internally.
1064
+ * @private
1065
+ * @name _previousSibling(dom)
1066
+ * @param {DOMElement} dom
1067
+ * @return {DOMElement}
1068
+ */
1069
+ _previousSibling : function (dom) {
1070
+ dom = dom ? dom.previousSibling : null;
1071
+ while(dom !== null && dom.nodeType !== 1) {
1072
+ dom = dom.previousSibling;
1073
+ }
1074
+ return dom;
1075
+ },
1076
+ /**
1077
+ * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc)
1078
+ * @name get_node(obj [, as_dom])
1079
+ * @param {mixed} obj
1080
+ * @param {Boolean} as_dom
1081
+ * @return {Object|jQuery}
1082
+ */
1083
+ get_node : function (obj, as_dom) {
1084
+ if(obj && obj.id) {
1085
+ obj = obj.id;
1086
+ }
1087
+ if (obj instanceof $ && obj.length && obj[0].id) {
1088
+ obj = obj[0].id;
1089
+ }
1090
+ var dom;
1091
+ try {
1092
+ if(this._model.data[obj]) {
1093
+ obj = this._model.data[obj];
1094
+ }
1095
+ else if(typeof obj === "string" && this._model.data[obj.replace(/^#/, '')]) {
1096
+ obj = this._model.data[obj.replace(/^#/, '')];
1097
+ }
1098
+ else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
1099
+ obj = this._model.data[dom.closest('.jstree-node').attr('id')];
1100
+ }
1101
+ else if((dom = this.element.find(obj)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
1102
+ obj = this._model.data[dom.closest('.jstree-node').attr('id')];
1103
+ }
1104
+ else if((dom = this.element.find(obj)).length && dom.hasClass('jstree')) {
1105
+ obj = this._model.data[$.jstree.root];
1106
+ }
1107
+ else {
1108
+ return false;
1109
+ }
1110
+
1111
+ if(as_dom) {
1112
+ obj = obj.id === $.jstree.root ? this.element : $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element);
1113
+ }
1114
+ return obj;
1115
+ } catch (ex) { return false; }
1116
+ },
1117
+ /**
1118
+ * get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array)
1119
+ * @name get_path(obj [, glue, ids])
1120
+ * @param {mixed} obj the node
1121
+ * @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned
1122
+ * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used
1123
+ * @return {mixed}
1124
+ */
1125
+ get_path : function (obj, glue, ids) {
1126
+ obj = obj.parents ? obj : this.get_node(obj);
1127
+ if(!obj || obj.id === $.jstree.root || !obj.parents) {
1128
+ return false;
1129
+ }
1130
+ var i, j, p = [];
1131
+ p.push(ids ? obj.id : obj.text);
1132
+ for(i = 0, j = obj.parents.length; i < j; i++) {
1133
+ p.push(ids ? obj.parents[i] : this.get_text(obj.parents[i]));
1134
+ }
1135
+ p = p.reverse().slice(1);
1136
+ return glue ? p.join(glue) : p;
1137
+ },
1138
+ /**
1139
+ * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
1140
+ * @name get_next_dom(obj [, strict])
1141
+ * @param {mixed} obj
1142
+ * @param {Boolean} strict
1143
+ * @return {jQuery}
1144
+ */
1145
+ get_next_dom : function (obj, strict) {
1146
+ var tmp;
1147
+ obj = this.get_node(obj, true);
1148
+ if(obj[0] === this.element[0]) {
1149
+ tmp = this._firstChild(this.get_container_ul()[0]);
1150
+ while (tmp && tmp.offsetHeight === 0) {
1151
+ tmp = this._nextSibling(tmp);
1152
+ }
1153
+ return tmp ? $(tmp) : false;
1154
+ }
1155
+ if(!obj || !obj.length) {
1156
+ return false;
1157
+ }
1158
+ if(strict) {
1159
+ tmp = obj[0];
1160
+ do {
1161
+ tmp = this._nextSibling(tmp);
1162
+ } while (tmp && tmp.offsetHeight === 0);
1163
+ return tmp ? $(tmp) : false;
1164
+ }
1165
+ if(obj.hasClass("jstree-open")) {
1166
+ tmp = this._firstChild(obj.children('.jstree-children')[0]);
1167
+ while (tmp && tmp.offsetHeight === 0) {
1168
+ tmp = this._nextSibling(tmp);
1169
+ }
1170
+ if(tmp !== null) {
1171
+ return $(tmp);
1172
+ }
1173
+ }
1174
+ tmp = obj[0];
1175
+ do {
1176
+ tmp = this._nextSibling(tmp);
1177
+ } while (tmp && tmp.offsetHeight === 0);
1178
+ if(tmp !== null) {
1179
+ return $(tmp);
1180
+ }
1181
+ return obj.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first();
1182
+ },
1183
+ /**
1184
+ * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
1185
+ * @name get_prev_dom(obj [, strict])
1186
+ * @param {mixed} obj
1187
+ * @param {Boolean} strict
1188
+ * @return {jQuery}
1189
+ */
1190
+ get_prev_dom : function (obj, strict) {
1191
+ var tmp;
1192
+ obj = this.get_node(obj, true);
1193
+ if(obj[0] === this.element[0]) {
1194
+ tmp = this.get_container_ul()[0].lastChild;
1195
+ while (tmp && tmp.offsetHeight === 0) {
1196
+ tmp = this._previousSibling(tmp);
1197
+ }
1198
+ return tmp ? $(tmp) : false;
1199
+ }
1200
+ if(!obj || !obj.length) {
1201
+ return false;
1202
+ }
1203
+ if(strict) {
1204
+ tmp = obj[0];
1205
+ do {
1206
+ tmp = this._previousSibling(tmp);
1207
+ } while (tmp && tmp.offsetHeight === 0);
1208
+ return tmp ? $(tmp) : false;
1209
+ }
1210
+ tmp = obj[0];
1211
+ do {
1212
+ tmp = this._previousSibling(tmp);
1213
+ } while (tmp && tmp.offsetHeight === 0);
1214
+ if(tmp !== null) {
1215
+ obj = $(tmp);
1216
+ while(obj.hasClass("jstree-open")) {
1217
+ obj = obj.children(".jstree-children").first().children(".jstree-node:visible:last");
1218
+ }
1219
+ return obj;
1220
+ }
1221
+ tmp = obj[0].parentNode.parentNode;
1222
+ return tmp && tmp.className && tmp.className.indexOf('jstree-node') !== -1 ? $(tmp) : false;
1223
+ },
1224
+ /**
1225
+ * get the parent ID of a node
1226
+ * @name get_parent(obj)
1227
+ * @param {mixed} obj
1228
+ * @return {String}
1229
+ */
1230
+ get_parent : function (obj) {
1231
+ obj = this.get_node(obj);
1232
+ if(!obj || obj.id === $.jstree.root) {
1233
+ return false;
1234
+ }
1235
+ return obj.parent;
1236
+ },
1237
+ /**
1238
+ * get a jQuery collection of all the children of a node (node must be rendered), returns false on error
1239
+ * @name get_children_dom(obj)
1240
+ * @param {mixed} obj
1241
+ * @return {jQuery}
1242
+ */
1243
+ get_children_dom : function (obj) {
1244
+ obj = this.get_node(obj, true);
1245
+ if(obj[0] === this.element[0]) {
1246
+ return this.get_container_ul().children(".jstree-node");
1247
+ }
1248
+ if(!obj || !obj.length) {
1249
+ return false;
1250
+ }
1251
+ return obj.children(".jstree-children").children(".jstree-node");
1252
+ },
1253
+ /**
1254
+ * checks if a node has children
1255
+ * @name is_parent(obj)
1256
+ * @param {mixed} obj
1257
+ * @return {Boolean}
1258
+ */
1259
+ is_parent : function (obj) {
1260
+ obj = this.get_node(obj);
1261
+ return obj && (obj.state.loaded === false || obj.children.length > 0);
1262
+ },
1263
+ /**
1264
+ * checks if a node is loaded (its children are available)
1265
+ * @name is_loaded(obj)
1266
+ * @param {mixed} obj
1267
+ * @return {Boolean}
1268
+ */
1269
+ is_loaded : function (obj) {
1270
+ obj = this.get_node(obj);
1271
+ return obj && obj.state.loaded;
1272
+ },
1273
+ /**
1274
+ * check if a node is currently loading (fetching children)
1275
+ * @name is_loading(obj)
1276
+ * @param {mixed} obj
1277
+ * @return {Boolean}
1278
+ */
1279
+ is_loading : function (obj) {
1280
+ obj = this.get_node(obj);
1281
+ return obj && obj.state && obj.state.loading;
1282
+ },
1283
+ /**
1284
+ * check if a node is opened
1285
+ * @name is_open(obj)
1286
+ * @param {mixed} obj
1287
+ * @return {Boolean}
1288
+ */
1289
+ is_open : function (obj) {
1290
+ obj = this.get_node(obj);
1291
+ return obj && obj.state.opened;
1292
+ },
1293
+ /**
1294
+ * check if a node is in a closed state
1295
+ * @name is_closed(obj)
1296
+ * @param {mixed} obj
1297
+ * @return {Boolean}
1298
+ */
1299
+ is_closed : function (obj) {
1300
+ obj = this.get_node(obj);
1301
+ return obj && this.is_parent(obj) && !obj.state.opened;
1302
+ },
1303
+ /**
1304
+ * check if a node has no children
1305
+ * @name is_leaf(obj)
1306
+ * @param {mixed} obj
1307
+ * @return {Boolean}
1308
+ */
1309
+ is_leaf : function (obj) {
1310
+ return !this.is_parent(obj);
1311
+ },
1312
+ /**
1313
+ * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array.
1314
+ * @name load_node(obj [, callback])
1315
+ * @param {mixed} obj
1316
+ * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives two arguments - the node and a boolean status
1317
+ * @return {Boolean}
1318
+ * @trigger load_node.jstree
1319
+ */
1320
+ load_node : function (obj, callback) {
1321
+ var k, l, i, j, c;
1322
+ if($.isArray(obj)) {
1323
+ this._load_nodes(obj.slice(), callback);
1324
+ return true;
1325
+ }
1326
+ obj = this.get_node(obj);
1327
+ if(!obj) {
1328
+ if(callback) { callback.call(this, obj, false); }
1329
+ return false;
1330
+ }
1331
+ // if(obj.state.loading) { } // the node is already loading - just wait for it to load and invoke callback? but if called implicitly it should be loaded again?
1332
+ if(obj.state.loaded) {
1333
+ obj.state.loaded = false;
1334
+ for(i = 0, j = obj.parents.length; i < j; i++) {
1335
+ this._model.data[obj.parents[i]].children_d = $.vakata.array_filter(this._model.data[obj.parents[i]].children_d, function (v) {
1336
+ return $.inArray(v, obj.children_d) === -1;
1337
+ });
1338
+ }
1339
+ for(k = 0, l = obj.children_d.length; k < l; k++) {
1340
+ if(this._model.data[obj.children_d[k]].state.selected) {
1341
+ c = true;
1342
+ }
1343
+ delete this._model.data[obj.children_d[k]];
1344
+ }
1345
+ if (c) {
1346
+ this._data.core.selected = $.vakata.array_filter(this._data.core.selected, function (v) {
1347
+ return $.inArray(v, obj.children_d) === -1;
1348
+ });
1349
+ }
1350
+ obj.children = [];
1351
+ obj.children_d = [];
1352
+ if(c) {
1353
+ this.trigger('changed', { 'action' : 'load_node', 'node' : obj, 'selected' : this._data.core.selected });
1354
+ }
1355
+ }
1356
+ obj.state.failed = false;
1357
+ obj.state.loading = true;
1358
+ this.get_node(obj, true).addClass("jstree-loading").attr('aria-busy',true);
1359
+ this._load_node(obj, $.proxy(function (status) {
1360
+ obj = this._model.data[obj.id];
1361
+ obj.state.loading = false;
1362
+ obj.state.loaded = status;
1363
+ obj.state.failed = !obj.state.loaded;
1364
+ var dom = this.get_node(obj, true), i = 0, j = 0, m = this._model.data, has_children = false;
1365
+ for(i = 0, j = obj.children.length; i < j; i++) {
1366
+ if(m[obj.children[i]] && !m[obj.children[i]].state.hidden) {
1367
+ has_children = true;
1368
+ break;
1369
+ }
1370
+ }
1371
+ if(obj.state.loaded && dom && dom.length) {
1372
+ dom.removeClass('jstree-closed jstree-open jstree-leaf');
1373
+ if (!has_children) {
1374
+ dom.addClass('jstree-leaf');
1375
+ }
1376
+ else {
1377
+ if (obj.id !== '#') {
1378
+ dom.addClass(obj.state.opened ? 'jstree-open' : 'jstree-closed');
1379
+ }
1380
+ }
1381
+ }
1382
+ dom.removeClass("jstree-loading").attr('aria-busy',false);
1383
+ /**
1384
+ * triggered after a node is loaded
1385
+ * @event
1386
+ * @name load_node.jstree
1387
+ * @param {Object} node the node that was loading
1388
+ * @param {Boolean} status was the node loaded successfully
1389
+ */
1390
+ this.trigger('load_node', { "node" : obj, "status" : status });
1391
+ if(callback) {
1392
+ callback.call(this, obj, status);
1393
+ }
1394
+ }, this));
1395
+ return true;
1396
+ },
1397
+ /**
1398
+ * load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
1399
+ * @private
1400
+ * @name _load_nodes(nodes [, callback])
1401
+ * @param {array} nodes
1402
+ * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes
1403
+ */
1404
+ _load_nodes : function (nodes, callback, is_callback, force_reload) {
1405
+ var r = true,
1406
+ c = function () { this._load_nodes(nodes, callback, true); },
1407
+ m = this._model.data, i, j, tmp = [];
1408
+ for(i = 0, j = nodes.length; i < j; i++) {
1409
+ if(m[nodes[i]] && ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || (!is_callback && force_reload) )) {
1410
+ if(!this.is_loading(nodes[i])) {
1411
+ this.load_node(nodes[i], c);
1412
+ }
1413
+ r = false;
1414
+ }
1415
+ }
1416
+ if(r) {
1417
+ for(i = 0, j = nodes.length; i < j; i++) {
1418
+ if(m[nodes[i]] && m[nodes[i]].state.loaded) {
1419
+ tmp.push(nodes[i]);
1420
+ }
1421
+ }
1422
+ if(callback && !callback.done) {
1423
+ callback.call(this, tmp);
1424
+ callback.done = true;
1425
+ }
1426
+ }
1427
+ },
1428
+ /**
1429
+ * loads all unloaded nodes
1430
+ * @name load_all([obj, callback])
1431
+ * @param {mixed} obj the node to load recursively, omit to load all nodes in the tree
1432
+ * @param {function} callback a function to be executed once loading all the nodes is complete,
1433
+ * @trigger load_all.jstree
1434
+ */
1435
+ load_all : function (obj, callback) {
1436
+ if(!obj) { obj = $.jstree.root; }
1437
+ obj = this.get_node(obj);
1438
+ if(!obj) { return false; }
1439
+ var to_load = [],
1440
+ m = this._model.data,
1441
+ c = m[obj.id].children_d,
1442
+ i, j;
1443
+ if(obj.state && !obj.state.loaded) {
1444
+ to_load.push(obj.id);
1445
+ }
1446
+ for(i = 0, j = c.length; i < j; i++) {
1447
+ if(m[c[i]] && m[c[i]].state && !m[c[i]].state.loaded) {
1448
+ to_load.push(c[i]);
1449
+ }
1450
+ }
1451
+ if(to_load.length) {
1452
+ this._load_nodes(to_load, function () {
1453
+ this.load_all(obj, callback);
1454
+ });
1455
+ }
1456
+ else {
1457
+ /**
1458
+ * triggered after a load_all call completes
1459
+ * @event
1460
+ * @name load_all.jstree
1461
+ * @param {Object} node the recursively loaded node
1462
+ */
1463
+ if(callback) { callback.call(this, obj); }
1464
+ this.trigger('load_all', { "node" : obj });
1465
+ }
1466
+ },
1467
+ /**
1468
+ * handles the actual loading of a node. Used only internally.
1469
+ * @private
1470
+ * @name _load_node(obj [, callback])
1471
+ * @param {mixed} obj
1472
+ * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status
1473
+ * @return {Boolean}
1474
+ */
1475
+ _load_node : function (obj, callback) {
1476
+ var s = this.settings.core.data, t;
1477
+ var notTextOrCommentNode = function notTextOrCommentNode () {
1478
+ return this.nodeType !== 3 && this.nodeType !== 8;
1479
+ };
1480
+ // use original HTML
1481
+ if(!s) {
1482
+ if(obj.id === $.jstree.root) {
1483
+ return this._append_html_data(obj, this._data.core.original_container_html.clone(true), function (status) {
1484
+ callback.call(this, status);
1485
+ });
1486
+ }
1487
+ else {
1488
+ return callback.call(this, false);
1489
+ }
1490
+ // return callback.call(this, obj.id === $.jstree.root ? this._append_html_data(obj, this._data.core.original_container_html.clone(true)) : false);
1491
+ }
1492
+ if($.isFunction(s)) {
1493
+ return s.call(this, obj, $.proxy(function (d) {
1494
+ if(d === false) {
1495
+ callback.call(this, false);
1496
+ }
1497
+ else {
1498
+ this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $($.parseHTML(d)).filter(notTextOrCommentNode) : d, function (status) {
1499
+ callback.call(this, status);
1500
+ });
1501
+ }
1502
+ // return d === false ? callback.call(this, false) : callback.call(this, this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d));
1503
+ }, this));
1504
+ }
1505
+ if(typeof s === 'object') {
1506
+ if(s.url) {
1507
+ s = $.extend(true, {}, s);
1508
+ if($.isFunction(s.url)) {
1509
+ s.url = s.url.call(this, obj);
1510
+ }
1511
+ if($.isFunction(s.data)) {
1512
+ s.data = s.data.call(this, obj);
1513
+ }
1514
+ return $.ajax(s)
1515
+ .done($.proxy(function (d,t,x) {
1516
+ var type = x.getResponseHeader('Content-Type');
1517
+ if((type && type.indexOf('json') !== -1) || typeof d === "object") {
1518
+ return this._append_json_data(obj, d, function (status) { callback.call(this, status); });
1519
+ //return callback.call(this, this._append_json_data(obj, d));
1520
+ }
1521
+ if((type && type.indexOf('html') !== -1) || typeof d === "string") {
1522
+ return this._append_html_data(obj, $($.parseHTML(d)).filter(notTextOrCommentNode), function (status) { callback.call(this, status); });
1523
+ // return callback.call(this, this._append_html_data(obj, $(d)));
1524
+ }
1525
+ this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : x }) };
1526
+ this.settings.core.error.call(this, this._data.core.last_error);
1527
+ return callback.call(this, false);
1528
+ }, this))
1529
+ .fail($.proxy(function (f) {
1530
+ this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : f }) };
1531
+ callback.call(this, false);
1532
+ this.settings.core.error.call(this, this._data.core.last_error);
1533
+ }, this));
1534
+ }
1535
+ if ($.isArray(s)) {
1536
+ t = $.extend(true, [], s);
1537
+ } else if ($.isPlainObject(s)) {
1538
+ t = $.extend(true, {}, s);
1539
+ } else {
1540
+ t = s;
1541
+ }
1542
+ if(obj.id === $.jstree.root) {
1543
+ return this._append_json_data(obj, t, function (status) {
1544
+ callback.call(this, status);
1545
+ });
1546
+ }
1547
+ else {
1548
+ this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_05', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) };
1549
+ this.settings.core.error.call(this, this._data.core.last_error);
1550
+ return callback.call(this, false);
1551
+ }
1552
+ //return callback.call(this, (obj.id === $.jstree.root ? this._append_json_data(obj, t) : false) );
1553
+ }
1554
+ if(typeof s === 'string') {
1555
+ if(obj.id === $.jstree.root) {
1556
+ return this._append_html_data(obj, $($.parseHTML(s)).filter(notTextOrCommentNode), function (status) {
1557
+ callback.call(this, status);
1558
+ });
1559
+ }
1560
+ else {
1561
+ this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_06', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) };
1562
+ this.settings.core.error.call(this, this._data.core.last_error);
1563
+ return callback.call(this, false);
1564
+ }
1565
+ //return callback.call(this, (obj.id === $.jstree.root ? this._append_html_data(obj, $(s)) : false) );
1566
+ }
1567
+ return callback.call(this, false);
1568
+ },
1569
+ /**
1570
+ * adds a node to the list of nodes to redraw. Used only internally.
1571
+ * @private
1572
+ * @name _node_changed(obj [, callback])
1573
+ * @param {mixed} obj
1574
+ */
1575
+ _node_changed : function (obj) {
1576
+ obj = this.get_node(obj);
1577
+ if (obj && $.inArray(obj.id, this._model.changed) === -1) {
1578
+ this._model.changed.push(obj.id);
1579
+ }
1580
+ },
1581
+ /**
1582
+ * appends HTML content to the tree. Used internally.
1583
+ * @private
1584
+ * @name _append_html_data(obj, data)
1585
+ * @param {mixed} obj the node to append to
1586
+ * @param {String} data the HTML string to parse and append
1587
+ * @trigger model.jstree, changed.jstree
1588
+ */
1589
+ _append_html_data : function (dom, data, cb) {
1590
+ dom = this.get_node(dom);
1591
+ dom.children = [];
1592
+ dom.children_d = [];
1593
+ var dat = data.is('ul') ? data.children() : data,
1594
+ par = dom.id,
1595
+ chd = [],
1596
+ dpc = [],
1597
+ m = this._model.data,
1598
+ p = m[par],
1599
+ s = this._data.core.selected.length,
1600
+ tmp, i, j;
1601
+ dat.each($.proxy(function (i, v) {
1602
+ tmp = this._parse_model_from_html($(v), par, p.parents.concat());
1603
+ if(tmp) {
1604
+ chd.push(tmp);
1605
+ dpc.push(tmp);
1606
+ if(m[tmp].children_d.length) {
1607
+ dpc = dpc.concat(m[tmp].children_d);
1608
+ }
1609
+ }
1610
+ }, this));
1611
+ p.children = chd;
1612
+ p.children_d = dpc;
1613
+ for(i = 0, j = p.parents.length; i < j; i++) {
1614
+ m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
1615
+ }
1616
+ /**
1617
+ * triggered when new data is inserted to the tree model
1618
+ * @event
1619
+ * @name model.jstree
1620
+ * @param {Array} nodes an array of node IDs
1621
+ * @param {String} parent the parent ID of the nodes
1622
+ */
1623
+ this.trigger('model', { "nodes" : dpc, 'parent' : par });
1624
+ if(par !== $.jstree.root) {
1625
+ this._node_changed(par);
1626
+ this.redraw();
1627
+ }
1628
+ else {
1629
+ this.get_container_ul().children('.jstree-initial-node').remove();
1630
+ this.redraw(true);
1631
+ }
1632
+ if(this._data.core.selected.length !== s) {
1633
+ this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected });
1634
+ }
1635
+ cb.call(this, true);
1636
+ },
1637
+ /**
1638
+ * appends JSON content to the tree. Used internally.
1639
+ * @private
1640
+ * @name _append_json_data(obj, data)
1641
+ * @param {mixed} obj the node to append to
1642
+ * @param {String} data the JSON object to parse and append
1643
+ * @param {Boolean} force_processing internal param - do not set
1644
+ * @trigger model.jstree, changed.jstree
1645
+ */
1646
+ _append_json_data : function (dom, data, cb, force_processing) {
1647
+ if(this.element === null) { return; }
1648
+ dom = this.get_node(dom);
1649
+ dom.children = [];
1650
+ dom.children_d = [];
1651
+ // *%$@!!!
1652
+ if(data.d) {
1653
+ data = data.d;
1654
+ if(typeof data === "string") {
1655
+ data = JSON.parse(data);
1656
+ }
1657
+ }
1658
+ if(!$.isArray(data)) { data = [data]; }
1659
+ var w = null,
1660
+ args = {
1661
+ 'df' : this._model.default_state,
1662
+ 'dat' : data,
1663
+ 'par' : dom.id,
1664
+ 'm' : this._model.data,
1665
+ 't_id' : this._id,
1666
+ 't_cnt' : this._cnt,
1667
+ 'sel' : this._data.core.selected
1668
+ },
1669
+ inst = this,
1670
+ func = function (data, undefined) {
1671
+ if(data.data) { data = data.data; }
1672
+ var dat = data.dat,
1673
+ par = data.par,
1674
+ chd = [],
1675
+ dpc = [],
1676
+ add = [],
1677
+ df = data.df,
1678
+ t_id = data.t_id,
1679
+ t_cnt = data.t_cnt,
1680
+ m = data.m,
1681
+ p = m[par],
1682
+ sel = data.sel,
1683
+ tmp, i, j, rslt,
1684
+ parse_flat = function (d, p, ps) {
1685
+ if(!ps) { ps = []; }
1686
+ else { ps = ps.concat(); }
1687
+ if(p) { ps.unshift(p); }
1688
+ var tid = d.id.toString(),
1689
+ i, j, c, e,
1690
+ tmp = {
1691
+ id : tid,
1692
+ text : d.text || '',
1693
+ icon : d.icon !== undefined ? d.icon : true,
1694
+ parent : p,
1695
+ parents : ps,
1696
+ children : d.children || [],
1697
+ children_d : d.children_d || [],
1698
+ data : d.data,
1699
+ state : { },
1700
+ li_attr : { id : false },
1701
+ a_attr : { href : '#' },
1702
+ original : false
1703
+ };
1704
+ for(i in df) {
1705
+ if(df.hasOwnProperty(i)) {
1706
+ tmp.state[i] = df[i];
1707
+ }
1708
+ }
1709
+ if(d && d.data && d.data.jstree && d.data.jstree.icon) {
1710
+ tmp.icon = d.data.jstree.icon;
1711
+ }
1712
+ if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
1713
+ tmp.icon = true;
1714
+ }
1715
+ if(d && d.data) {
1716
+ tmp.data = d.data;
1717
+ if(d.data.jstree) {
1718
+ for(i in d.data.jstree) {
1719
+ if(d.data.jstree.hasOwnProperty(i)) {
1720
+ tmp.state[i] = d.data.jstree[i];
1721
+ }
1722
+ }
1723
+ }
1724
+ }
1725
+ if(d && typeof d.state === 'object') {
1726
+ for (i in d.state) {
1727
+ if(d.state.hasOwnProperty(i)) {
1728
+ tmp.state[i] = d.state[i];
1729
+ }
1730
+ }
1731
+ }
1732
+ if(d && typeof d.li_attr === 'object') {
1733
+ for (i in d.li_attr) {
1734
+ if(d.li_attr.hasOwnProperty(i)) {
1735
+ tmp.li_attr[i] = d.li_attr[i];
1736
+ }
1737
+ }
1738
+ }
1739
+ if(!tmp.li_attr.id) {
1740
+ tmp.li_attr.id = tid;
1741
+ }
1742
+ if(d && typeof d.a_attr === 'object') {
1743
+ for (i in d.a_attr) {
1744
+ if(d.a_attr.hasOwnProperty(i)) {
1745
+ tmp.a_attr[i] = d.a_attr[i];
1746
+ }
1747
+ }
1748
+ }
1749
+ if(d && d.children && d.children === true) {
1750
+ tmp.state.loaded = false;
1751
+ tmp.children = [];
1752
+ tmp.children_d = [];
1753
+ }
1754
+ m[tmp.id] = tmp;
1755
+ for(i = 0, j = tmp.children.length; i < j; i++) {
1756
+ c = parse_flat(m[tmp.children[i]], tmp.id, ps);
1757
+ e = m[c];
1758
+ tmp.children_d.push(c);
1759
+ if(e.children_d.length) {
1760
+ tmp.children_d = tmp.children_d.concat(e.children_d);
1761
+ }
1762
+ }
1763
+ delete d.data;
1764
+ delete d.children;
1765
+ m[tmp.id].original = d;
1766
+ if(tmp.state.selected) {
1767
+ add.push(tmp.id);
1768
+ }
1769
+ return tmp.id;
1770
+ },
1771
+ parse_nest = function (d, p, ps) {
1772
+ if(!ps) { ps = []; }
1773
+ else { ps = ps.concat(); }
1774
+ if(p) { ps.unshift(p); }
1775
+ var tid = false, i, j, c, e, tmp;
1776
+ do {
1777
+ tid = 'j' + t_id + '_' + (++t_cnt);
1778
+ } while(m[tid]);
1779
+
1780
+ tmp = {
1781
+ id : false,
1782
+ text : typeof d === 'string' ? d : '',
1783
+ icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
1784
+ parent : p,
1785
+ parents : ps,
1786
+ children : [],
1787
+ children_d : [],
1788
+ data : null,
1789
+ state : { },
1790
+ li_attr : { id : false },
1791
+ a_attr : { href : '#' },
1792
+ original : false
1793
+ };
1794
+ for(i in df) {
1795
+ if(df.hasOwnProperty(i)) {
1796
+ tmp.state[i] = df[i];
1797
+ }
1798
+ }
1799
+ if(d && d.id) { tmp.id = d.id.toString(); }
1800
+ if(d && d.text) { tmp.text = d.text; }
1801
+ if(d && d.data && d.data.jstree && d.data.jstree.icon) {
1802
+ tmp.icon = d.data.jstree.icon;
1803
+ }
1804
+ if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
1805
+ tmp.icon = true;
1806
+ }
1807
+ if(d && d.data) {
1808
+ tmp.data = d.data;
1809
+ if(d.data.jstree) {
1810
+ for(i in d.data.jstree) {
1811
+ if(d.data.jstree.hasOwnProperty(i)) {
1812
+ tmp.state[i] = d.data.jstree[i];
1813
+ }
1814
+ }
1815
+ }
1816
+ }
1817
+ if(d && typeof d.state === 'object') {
1818
+ for (i in d.state) {
1819
+ if(d.state.hasOwnProperty(i)) {
1820
+ tmp.state[i] = d.state[i];
1821
+ }
1822
+ }
1823
+ }
1824
+ if(d && typeof d.li_attr === 'object') {
1825
+ for (i in d.li_attr) {
1826
+ if(d.li_attr.hasOwnProperty(i)) {
1827
+ tmp.li_attr[i] = d.li_attr[i];
1828
+ }
1829
+ }
1830
+ }
1831
+ if(tmp.li_attr.id && !tmp.id) {
1832
+ tmp.id = tmp.li_attr.id.toString();
1833
+ }
1834
+ if(!tmp.id) {
1835
+ tmp.id = tid;
1836
+ }
1837
+ if(!tmp.li_attr.id) {
1838
+ tmp.li_attr.id = tmp.id;
1839
+ }
1840
+ if(d && typeof d.a_attr === 'object') {
1841
+ for (i in d.a_attr) {
1842
+ if(d.a_attr.hasOwnProperty(i)) {
1843
+ tmp.a_attr[i] = d.a_attr[i];
1844
+ }
1845
+ }
1846
+ }
1847
+ if(d && d.children && d.children.length) {
1848
+ for(i = 0, j = d.children.length; i < j; i++) {
1849
+ c = parse_nest(d.children[i], tmp.id, ps);
1850
+ e = m[c];
1851
+ tmp.children.push(c);
1852
+ if(e.children_d.length) {
1853
+ tmp.children_d = tmp.children_d.concat(e.children_d);
1854
+ }
1855
+ }
1856
+ tmp.children_d = tmp.children_d.concat(tmp.children);
1857
+ }
1858
+ if(d && d.children && d.children === true) {
1859
+ tmp.state.loaded = false;
1860
+ tmp.children = [];
1861
+ tmp.children_d = [];
1862
+ }
1863
+ delete d.data;
1864
+ delete d.children;
1865
+ tmp.original = d;
1866
+ m[tmp.id] = tmp;
1867
+ if(tmp.state.selected) {
1868
+ add.push(tmp.id);
1869
+ }
1870
+ return tmp.id;
1871
+ };
1872
+
1873
+ if(dat.length && dat[0].id !== undefined && dat[0].parent !== undefined) {
1874
+ // Flat JSON support (for easy import from DB):
1875
+ // 1) convert to object (foreach)
1876
+ for(i = 0, j = dat.length; i < j; i++) {
1877
+ if(!dat[i].children) {
1878
+ dat[i].children = [];
1879
+ }
1880
+ if(!dat[i].state) {
1881
+ dat[i].state = {};
1882
+ }
1883
+ m[dat[i].id.toString()] = dat[i];
1884
+ }
1885
+ // 2) populate children (foreach)
1886
+ for(i = 0, j = dat.length; i < j; i++) {
1887
+ if (!m[dat[i].parent.toString()]) {
1888
+ if (typeof inst !== "undefined") {
1889
+ inst._data.core.last_error = { 'error' : 'parse', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Node with invalid parent', 'data' : JSON.stringify({ 'id' : dat[i].id.toString(), 'parent' : dat[i].parent.toString() }) };
1890
+ inst.settings.core.error.call(inst, inst._data.core.last_error);
1891
+ }
1892
+ continue;
1893
+ }
1894
+
1895
+ m[dat[i].parent.toString()].children.push(dat[i].id.toString());
1896
+ // populate parent.children_d
1897
+ p.children_d.push(dat[i].id.toString());
1898
+ }
1899
+ // 3) normalize && populate parents and children_d with recursion
1900
+ for(i = 0, j = p.children.length; i < j; i++) {
1901
+ tmp = parse_flat(m[p.children[i]], par, p.parents.concat());
1902
+ dpc.push(tmp);
1903
+ if(m[tmp].children_d.length) {
1904
+ dpc = dpc.concat(m[tmp].children_d);
1905
+ }
1906
+ }
1907
+ for(i = 0, j = p.parents.length; i < j; i++) {
1908
+ m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
1909
+ }
1910
+ // ?) three_state selection - p.state.selected && t - (if three_state foreach(dat => ch) -> foreach(parents) if(parent.selected) child.selected = true;
1911
+ rslt = {
1912
+ 'cnt' : t_cnt,
1913
+ 'mod' : m,
1914
+ 'sel' : sel,
1915
+ 'par' : par,
1916
+ 'dpc' : dpc,
1917
+ 'add' : add
1918
+ };
1919
+ }
1920
+ else {
1921
+ for(i = 0, j = dat.length; i < j; i++) {
1922
+ tmp = parse_nest(dat[i], par, p.parents.concat());
1923
+ if(tmp) {
1924
+ chd.push(tmp);
1925
+ dpc.push(tmp);
1926
+ if(m[tmp].children_d.length) {
1927
+ dpc = dpc.concat(m[tmp].children_d);
1928
+ }
1929
+ }
1930
+ }
1931
+ p.children = chd;
1932
+ p.children_d = dpc;
1933
+ for(i = 0, j = p.parents.length; i < j; i++) {
1934
+ m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
1935
+ }
1936
+ rslt = {
1937
+ 'cnt' : t_cnt,
1938
+ 'mod' : m,
1939
+ 'sel' : sel,
1940
+ 'par' : par,
1941
+ 'dpc' : dpc,
1942
+ 'add' : add
1943
+ };
1944
+ }
1945
+ if(typeof window === 'undefined' || typeof window.document === 'undefined') {
1946
+ postMessage(rslt);
1947
+ }
1948
+ else {
1949
+ return rslt;
1950
+ }
1951
+ },
1952
+ rslt = function (rslt, worker) {
1953
+ if(this.element === null) { return; }
1954
+ this._cnt = rslt.cnt;
1955
+ var i, m = this._model.data;
1956
+ for (i in m) {
1957
+ if (m.hasOwnProperty(i) && m[i].state && m[i].state.loading && rslt.mod[i]) {
1958
+ rslt.mod[i].state.loading = true;
1959
+ }
1960
+ }
1961
+ this._model.data = rslt.mod; // breaks the reference in load_node - careful
1962
+
1963
+ if(worker) {
1964
+ var j, a = rslt.add, r = rslt.sel, s = this._data.core.selected.slice();
1965
+ m = this._model.data;
1966
+ // if selection was changed while calculating in worker
1967
+ if(r.length !== s.length || $.vakata.array_unique(r.concat(s)).length !== r.length) {
1968
+ // deselect nodes that are no longer selected
1969
+ for(i = 0, j = r.length; i < j; i++) {
1970
+ if($.inArray(r[i], a) === -1 && $.inArray(r[i], s) === -1) {
1971
+ m[r[i]].state.selected = false;
1972
+ }
1973
+ }
1974
+ // select nodes that were selected in the mean time
1975
+ for(i = 0, j = s.length; i < j; i++) {
1976
+ if($.inArray(s[i], r) === -1) {
1977
+ m[s[i]].state.selected = true;
1978
+ }
1979
+ }
1980
+ }
1981
+ }
1982
+ if(rslt.add.length) {
1983
+ this._data.core.selected = this._data.core.selected.concat(rslt.add);
1984
+ }
1985
+
1986
+ this.trigger('model', { "nodes" : rslt.dpc, 'parent' : rslt.par });
1987
+
1988
+ if(rslt.par !== $.jstree.root) {
1989
+ this._node_changed(rslt.par);
1990
+ this.redraw();
1991
+ }
1992
+ else {
1993
+ // this.get_container_ul().children('.jstree-initial-node').remove();
1994
+ this.redraw(true);
1995
+ }
1996
+ if(rslt.add.length) {
1997
+ this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected });
1998
+ }
1999
+
2000
+ // If no worker, try to mimic worker behavioour, by invoking cb asynchronously
2001
+ if (!worker && setImmediate) {
2002
+ setImmediate(function(){
2003
+ cb.call(inst, true);
2004
+ });
2005
+ }
2006
+ else {
2007
+ cb.call(inst, true);
2008
+ }
2009
+ };
2010
+ if(this.settings.core.worker && window.Blob && window.URL && window.Worker) {
2011
+ try {
2012
+ if(this._wrk === null) {
2013
+ this._wrk = window.URL.createObjectURL(
2014
+ new window.Blob(
2015
+ ['self.onmessage = ' + func.toString()],
2016
+ {type:"text/javascript"}
2017
+ )
2018
+ );
2019
+ }
2020
+ if(!this._data.core.working || force_processing) {
2021
+ this._data.core.working = true;
2022
+ w = new window.Worker(this._wrk);
2023
+ w.onmessage = $.proxy(function (e) {
2024
+ rslt.call(this, e.data, true);
2025
+ try { w.terminate(); w = null; } catch(ignore) { }
2026
+ if(this._data.core.worker_queue.length) {
2027
+ this._append_json_data.apply(this, this._data.core.worker_queue.shift());
2028
+ }
2029
+ else {
2030
+ this._data.core.working = false;
2031
+ }
2032
+ }, this);
2033
+ if(!args.par) {
2034
+ if(this._data.core.worker_queue.length) {
2035
+ this._append_json_data.apply(this, this._data.core.worker_queue.shift());
2036
+ }
2037
+ else {
2038
+ this._data.core.working = false;
2039
+ }
2040
+ }
2041
+ else {
2042
+ w.postMessage(args);
2043
+ }
2044
+ }
2045
+ else {
2046
+ this._data.core.worker_queue.push([dom, data, cb, true]);
2047
+ }
2048
+ }
2049
+ catch(e) {
2050
+ rslt.call(this, func(args), false);
2051
+ if(this._data.core.worker_queue.length) {
2052
+ this._append_json_data.apply(this, this._data.core.worker_queue.shift());
2053
+ }
2054
+ else {
2055
+ this._data.core.working = false;
2056
+ }
2057
+ }
2058
+ }
2059
+ else {
2060
+ rslt.call(this, func(args), false);
2061
+ }
2062
+ },
2063
+ /**
2064
+ * parses a node from a jQuery object and appends them to the in memory tree model. Used internally.
2065
+ * @private
2066
+ * @name _parse_model_from_html(d [, p, ps])
2067
+ * @param {jQuery} d the jQuery object to parse
2068
+ * @param {String} p the parent ID
2069
+ * @param {Array} ps list of all parents
2070
+ * @return {String} the ID of the object added to the model
2071
+ */
2072
+ _parse_model_from_html : function (d, p, ps) {
2073
+ if(!ps) { ps = []; }
2074
+ else { ps = [].concat(ps); }
2075
+ if(p) { ps.unshift(p); }
2076
+ var c, e, m = this._model.data,
2077
+ data = {
2078
+ id : false,
2079
+ text : false,
2080
+ icon : true,
2081
+ parent : p,
2082
+ parents : ps,
2083
+ children : [],
2084
+ children_d : [],
2085
+ data : null,
2086
+ state : { },
2087
+ li_attr : { id : false },
2088
+ a_attr : { href : '#' },
2089
+ original : false
2090
+ }, i, tmp, tid;
2091
+ for(i in this._model.default_state) {
2092
+ if(this._model.default_state.hasOwnProperty(i)) {
2093
+ data.state[i] = this._model.default_state[i];
2094
+ }
2095
+ }
2096
+ tmp = $.vakata.attributes(d, true);
2097
+ $.each(tmp, function (i, v) {
2098
+ v = $.trim(v);
2099
+ if(!v.length) { return true; }
2100
+ data.li_attr[i] = v;
2101
+ if(i === 'id') {
2102
+ data.id = v.toString();
2103
+ }
2104
+ });
2105
+ tmp = d.children('a').first();
2106
+ if(tmp.length) {
2107
+ tmp = $.vakata.attributes(tmp, true);
2108
+ $.each(tmp, function (i, v) {
2109
+ v = $.trim(v);
2110
+ if(v.length) {
2111
+ data.a_attr[i] = v;
2112
+ }
2113
+ });
2114
+ }
2115
+ tmp = d.children("a").first().length ? d.children("a").first().clone() : d.clone();
2116
+ tmp.children("ins, i, ul").remove();
2117
+ tmp = tmp.html();
2118
+ tmp = $('<div></div>').html(tmp);
2119
+ data.text = this.settings.core.force_text ? tmp.text() : tmp.html();
2120
+ tmp = d.data();
2121
+ data.data = tmp ? $.extend(true, {}, tmp) : null;
2122
+ data.state.opened = d.hasClass('jstree-open');
2123
+ data.state.selected = d.children('a').hasClass('jstree-clicked');
2124
+ data.state.disabled = d.children('a').hasClass('jstree-disabled');
2125
+ if(data.data && data.data.jstree) {
2126
+ for(i in data.data.jstree) {
2127
+ if(data.data.jstree.hasOwnProperty(i)) {
2128
+ data.state[i] = data.data.jstree[i];
2129
+ }
2130
+ }
2131
+ }
2132
+ tmp = d.children("a").children(".jstree-themeicon");
2133
+ if(tmp.length) {
2134
+ data.icon = tmp.hasClass('jstree-themeicon-hidden') ? false : tmp.attr('rel');
2135
+ }
2136
+ if(data.state.icon !== undefined) {
2137
+ data.icon = data.state.icon;
2138
+ }
2139
+ if(data.icon === undefined || data.icon === null || data.icon === "") {
2140
+ data.icon = true;
2141
+ }
2142
+ tmp = d.children("ul").children("li");
2143
+ do {
2144
+ tid = 'j' + this._id + '_' + (++this._cnt);
2145
+ } while(m[tid]);
2146
+ data.id = data.li_attr.id ? data.li_attr.id.toString() : tid;
2147
+ if(tmp.length) {
2148
+ tmp.each($.proxy(function (i, v) {
2149
+ c = this._parse_model_from_html($(v), data.id, ps);
2150
+ e = this._model.data[c];
2151
+ data.children.push(c);
2152
+ if(e.children_d.length) {
2153
+ data.children_d = data.children_d.concat(e.children_d);
2154
+ }
2155
+ }, this));
2156
+ data.children_d = data.children_d.concat(data.children);
2157
+ }
2158
+ else {
2159
+ if(d.hasClass('jstree-closed')) {
2160
+ data.state.loaded = false;
2161
+ }
2162
+ }
2163
+ if(data.li_attr['class']) {
2164
+ data.li_attr['class'] = data.li_attr['class'].replace('jstree-closed','').replace('jstree-open','');
2165
+ }
2166
+ if(data.a_attr['class']) {
2167
+ data.a_attr['class'] = data.a_attr['class'].replace('jstree-clicked','').replace('jstree-disabled','');
2168
+ }
2169
+ m[data.id] = data;
2170
+ if(data.state.selected) {
2171
+ this._data.core.selected.push(data.id);
2172
+ }
2173
+ return data.id;
2174
+ },
2175
+ /**
2176
+ * parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally.
2177
+ * @private
2178
+ * @name _parse_model_from_flat_json(d [, p, ps])
2179
+ * @param {Object} d the JSON object to parse
2180
+ * @param {String} p the parent ID
2181
+ * @param {Array} ps list of all parents
2182
+ * @return {String} the ID of the object added to the model
2183
+ */
2184
+ _parse_model_from_flat_json : function (d, p, ps) {
2185
+ if(!ps) { ps = []; }
2186
+ else { ps = ps.concat(); }
2187
+ if(p) { ps.unshift(p); }
2188
+ var tid = d.id.toString(),
2189
+ m = this._model.data,
2190
+ df = this._model.default_state,
2191
+ i, j, c, e,
2192
+ tmp = {
2193
+ id : tid,
2194
+ text : d.text || '',
2195
+ icon : d.icon !== undefined ? d.icon : true,
2196
+ parent : p,
2197
+ parents : ps,
2198
+ children : d.children || [],
2199
+ children_d : d.children_d || [],
2200
+ data : d.data,
2201
+ state : { },
2202
+ li_attr : { id : false },
2203
+ a_attr : { href : '#' },
2204
+ original : false
2205
+ };
2206
+ for(i in df) {
2207
+ if(df.hasOwnProperty(i)) {
2208
+ tmp.state[i] = df[i];
2209
+ }
2210
+ }
2211
+ if(d && d.data && d.data.jstree && d.data.jstree.icon) {
2212
+ tmp.icon = d.data.jstree.icon;
2213
+ }
2214
+ if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
2215
+ tmp.icon = true;
2216
+ }
2217
+ if(d && d.data) {
2218
+ tmp.data = d.data;
2219
+ if(d.data.jstree) {
2220
+ for(i in d.data.jstree) {
2221
+ if(d.data.jstree.hasOwnProperty(i)) {
2222
+ tmp.state[i] = d.data.jstree[i];
2223
+ }
2224
+ }
2225
+ }
2226
+ }
2227
+ if(d && typeof d.state === 'object') {
2228
+ for (i in d.state) {
2229
+ if(d.state.hasOwnProperty(i)) {
2230
+ tmp.state[i] = d.state[i];
2231
+ }
2232
+ }
2233
+ }
2234
+ if(d && typeof d.li_attr === 'object') {
2235
+ for (i in d.li_attr) {
2236
+ if(d.li_attr.hasOwnProperty(i)) {
2237
+ tmp.li_attr[i] = d.li_attr[i];
2238
+ }
2239
+ }
2240
+ }
2241
+ if(!tmp.li_attr.id) {
2242
+ tmp.li_attr.id = tid;
2243
+ }
2244
+ if(d && typeof d.a_attr === 'object') {
2245
+ for (i in d.a_attr) {
2246
+ if(d.a_attr.hasOwnProperty(i)) {
2247
+ tmp.a_attr[i] = d.a_attr[i];
2248
+ }
2249
+ }
2250
+ }
2251
+ if(d && d.children && d.children === true) {
2252
+ tmp.state.loaded = false;
2253
+ tmp.children = [];
2254
+ tmp.children_d = [];
2255
+ }
2256
+ m[tmp.id] = tmp;
2257
+ for(i = 0, j = tmp.children.length; i < j; i++) {
2258
+ c = this._parse_model_from_flat_json(m[tmp.children[i]], tmp.id, ps);
2259
+ e = m[c];
2260
+ tmp.children_d.push(c);
2261
+ if(e.children_d.length) {
2262
+ tmp.children_d = tmp.children_d.concat(e.children_d);
2263
+ }
2264
+ }
2265
+ delete d.data;
2266
+ delete d.children;
2267
+ m[tmp.id].original = d;
2268
+ if(tmp.state.selected) {
2269
+ this._data.core.selected.push(tmp.id);
2270
+ }
2271
+ return tmp.id;
2272
+ },
2273
+ /**
2274
+ * parses a node from a JSON object and appends it to the in memory tree model. Used internally.
2275
+ * @private
2276
+ * @name _parse_model_from_json(d [, p, ps])
2277
+ * @param {Object} d the JSON object to parse
2278
+ * @param {String} p the parent ID
2279
+ * @param {Array} ps list of all parents
2280
+ * @return {String} the ID of the object added to the model
2281
+ */
2282
+ _parse_model_from_json : function (d, p, ps) {
2283
+ if(!ps) { ps = []; }
2284
+ else { ps = ps.concat(); }
2285
+ if(p) { ps.unshift(p); }
2286
+ var tid = false, i, j, c, e, m = this._model.data, df = this._model.default_state, tmp;
2287
+ do {
2288
+ tid = 'j' + this._id + '_' + (++this._cnt);
2289
+ } while(m[tid]);
2290
+
2291
+ tmp = {
2292
+ id : false,
2293
+ text : typeof d === 'string' ? d : '',
2294
+ icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
2295
+ parent : p,
2296
+ parents : ps,
2297
+ children : [],
2298
+ children_d : [],
2299
+ data : null,
2300
+ state : { },
2301
+ li_attr : { id : false },
2302
+ a_attr : { href : '#' },
2303
+ original : false
2304
+ };
2305
+ for(i in df) {
2306
+ if(df.hasOwnProperty(i)) {
2307
+ tmp.state[i] = df[i];
2308
+ }
2309
+ }
2310
+ if(d && d.id) { tmp.id = d.id.toString(); }
2311
+ if(d && d.text) { tmp.text = d.text; }
2312
+ if(d && d.data && d.data.jstree && d.data.jstree.icon) {
2313
+ tmp.icon = d.data.jstree.icon;
2314
+ }
2315
+ if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
2316
+ tmp.icon = true;
2317
+ }
2318
+ if(d && d.data) {
2319
+ tmp.data = d.data;
2320
+ if(d.data.jstree) {
2321
+ for(i in d.data.jstree) {
2322
+ if(d.data.jstree.hasOwnProperty(i)) {
2323
+ tmp.state[i] = d.data.jstree[i];
2324
+ }
2325
+ }
2326
+ }
2327
+ }
2328
+ if(d && typeof d.state === 'object') {
2329
+ for (i in d.state) {
2330
+ if(d.state.hasOwnProperty(i)) {
2331
+ tmp.state[i] = d.state[i];
2332
+ }
2333
+ }
2334
+ }
2335
+ if(d && typeof d.li_attr === 'object') {
2336
+ for (i in d.li_attr) {
2337
+ if(d.li_attr.hasOwnProperty(i)) {
2338
+ tmp.li_attr[i] = d.li_attr[i];
2339
+ }
2340
+ }
2341
+ }
2342
+ if(tmp.li_attr.id && !tmp.id) {
2343
+ tmp.id = tmp.li_attr.id.toString();
2344
+ }
2345
+ if(!tmp.id) {
2346
+ tmp.id = tid;
2347
+ }
2348
+ if(!tmp.li_attr.id) {
2349
+ tmp.li_attr.id = tmp.id;
2350
+ }
2351
+ if(d && typeof d.a_attr === 'object') {
2352
+ for (i in d.a_attr) {
2353
+ if(d.a_attr.hasOwnProperty(i)) {
2354
+ tmp.a_attr[i] = d.a_attr[i];
2355
+ }
2356
+ }
2357
+ }
2358
+ if(d && d.children && d.children.length) {
2359
+ for(i = 0, j = d.children.length; i < j; i++) {
2360
+ c = this._parse_model_from_json(d.children[i], tmp.id, ps);
2361
+ e = m[c];
2362
+ tmp.children.push(c);
2363
+ if(e.children_d.length) {
2364
+ tmp.children_d = tmp.children_d.concat(e.children_d);
2365
+ }
2366
+ }
2367
+ tmp.children_d = tmp.children.concat(tmp.children_d);
2368
+ }
2369
+ if(d && d.children && d.children === true) {
2370
+ tmp.state.loaded = false;
2371
+ tmp.children = [];
2372
+ tmp.children_d = [];
2373
+ }
2374
+ delete d.data;
2375
+ delete d.children;
2376
+ tmp.original = d;
2377
+ m[tmp.id] = tmp;
2378
+ if(tmp.state.selected) {
2379
+ this._data.core.selected.push(tmp.id);
2380
+ }
2381
+ return tmp.id;
2382
+ },
2383
+ /**
2384
+ * redraws all nodes that need to be redrawn. Used internally.
2385
+ * @private
2386
+ * @name _redraw()
2387
+ * @trigger redraw.jstree
2388
+ */
2389
+ _redraw : function () {
2390
+ var nodes = this._model.force_full_redraw ? this._model.data[$.jstree.root].children.concat([]) : this._model.changed.concat([]),
2391
+ f = document.createElement('UL'), tmp, i, j, fe = this._data.core.focused;
2392
+ for(i = 0, j = nodes.length; i < j; i++) {
2393
+ tmp = this.redraw_node(nodes[i], true, this._model.force_full_redraw);
2394
+ if(tmp && this._model.force_full_redraw) {
2395
+ f.appendChild(tmp);
2396
+ }
2397
+ }
2398
+ if(this._model.force_full_redraw) {
2399
+ f.className = this.get_container_ul()[0].className;
2400
+ f.setAttribute('role','group');
2401
+ this.element.empty().append(f);
2402
+ //this.get_container_ul()[0].appendChild(f);
2403
+ }
2404
+ if(fe !== null && this.settings.core.restore_focus) {
2405
+ tmp = this.get_node(fe, true);
2406
+ if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) {
2407
+ tmp.children('.jstree-anchor').focus();
2408
+ }
2409
+ else {
2410
+ this._data.core.focused = null;
2411
+ }
2412
+ }
2413
+ this._model.force_full_redraw = false;
2414
+ this._model.changed = [];
2415
+ /**
2416
+ * triggered after nodes are redrawn
2417
+ * @event
2418
+ * @name redraw.jstree
2419
+ * @param {array} nodes the redrawn nodes
2420
+ */
2421
+ this.trigger('redraw', { "nodes" : nodes });
2422
+ },
2423
+ /**
2424
+ * redraws all nodes that need to be redrawn or optionally - the whole tree
2425
+ * @name redraw([full])
2426
+ * @param {Boolean} full if set to `true` all nodes are redrawn.
2427
+ */
2428
+ redraw : function (full) {
2429
+ if(full) {
2430
+ this._model.force_full_redraw = true;
2431
+ }
2432
+ //if(this._model.redraw_timeout) {
2433
+ // clearTimeout(this._model.redraw_timeout);
2434
+ //}
2435
+ //this._model.redraw_timeout = setTimeout($.proxy(this._redraw, this),0);
2436
+ this._redraw();
2437
+ },
2438
+ /**
2439
+ * redraws a single node's children. Used internally.
2440
+ * @private
2441
+ * @name draw_children(node)
2442
+ * @param {mixed} node the node whose children will be redrawn
2443
+ */
2444
+ draw_children : function (node) {
2445
+ var obj = this.get_node(node),
2446
+ i = false,
2447
+ j = false,
2448
+ k = false,
2449
+ d = document;
2450
+ if(!obj) { return false; }
2451
+ if(obj.id === $.jstree.root) { return this.redraw(true); }
2452
+ node = this.get_node(node, true);
2453
+ if(!node || !node.length) { return false; } // TODO: quick toggle
2454
+
2455
+ node.children('.jstree-children').remove();
2456
+ node = node[0];
2457
+ if(obj.children.length && obj.state.loaded) {
2458
+ k = d.createElement('UL');
2459
+ k.setAttribute('role', 'group');
2460
+ k.className = 'jstree-children';
2461
+ for(i = 0, j = obj.children.length; i < j; i++) {
2462
+ k.appendChild(this.redraw_node(obj.children[i], true, true));
2463
+ }
2464
+ node.appendChild(k);
2465
+ }
2466
+ },
2467
+ /**
2468
+ * redraws a single node. Used internally.
2469
+ * @private
2470
+ * @name redraw_node(node, deep, is_callback, force_render)
2471
+ * @param {mixed} node the node to redraw
2472
+ * @param {Boolean} deep should child nodes be redrawn too
2473
+ * @param {Boolean} is_callback is this a recursion call
2474
+ * @param {Boolean} force_render should children of closed parents be drawn anyway
2475
+ */
2476
+ redraw_node : function (node, deep, is_callback, force_render) {
2477
+ var obj = this.get_node(node),
2478
+ par = false,
2479
+ ind = false,
2480
+ old = false,
2481
+ i = false,
2482
+ j = false,
2483
+ k = false,
2484
+ c = '',
2485
+ d = document,
2486
+ m = this._model.data,
2487
+ f = false,
2488
+ s = false,
2489
+ tmp = null,
2490
+ t = 0,
2491
+ l = 0,
2492
+ has_children = false,
2493
+ last_sibling = false;
2494
+ if(!obj) { return false; }
2495
+ if(obj.id === $.jstree.root) { return this.redraw(true); }
2496
+ deep = deep || obj.children.length === 0;
2497
+ node = !document.querySelector ? document.getElementById(obj.id) : this.element[0].querySelector('#' + ("0123456789".indexOf(obj.id[0]) !== -1 ? '\\3' + obj.id[0] + ' ' + obj.id.substr(1).replace($.jstree.idregex,'\\$&') : obj.id.replace($.jstree.idregex,'\\$&')) ); //, this.element);
2498
+ if(!node) {
2499
+ deep = true;
2500
+ //node = d.createElement('LI');
2501
+ if(!is_callback) {
2502
+ par = obj.parent !== $.jstree.root ? $('#' + obj.parent.replace($.jstree.idregex,'\\$&'), this.element)[0] : null;
2503
+ if(par !== null && (!par || !m[obj.parent].state.opened)) {
2504
+ return false;
2505
+ }
2506
+ ind = $.inArray(obj.id, par === null ? m[$.jstree.root].children : m[obj.parent].children);
2507
+ }
2508
+ }
2509
+ else {
2510
+ node = $(node);
2511
+ if(!is_callback) {
2512
+ par = node.parent().parent()[0];
2513
+ if(par === this.element[0]) {
2514
+ par = null;
2515
+ }
2516
+ ind = node.index();
2517
+ }
2518
+ // m[obj.id].data = node.data(); // use only node's data, no need to touch jquery storage
2519
+ if(!deep && obj.children.length && !node.children('.jstree-children').length) {
2520
+ deep = true;
2521
+ }
2522
+ if(!deep) {
2523
+ old = node.children('.jstree-children')[0];
2524
+ }
2525
+ f = node.children('.jstree-anchor')[0] === document.activeElement;
2526
+ node.remove();
2527
+ //node = d.createElement('LI');
2528
+ //node = node[0];
2529
+ }
2530
+ node = this._data.core.node.cloneNode(true);
2531
+ // node is DOM, deep is boolean
2532
+
2533
+ c = 'jstree-node ';
2534
+ for(i in obj.li_attr) {
2535
+ if(obj.li_attr.hasOwnProperty(i)) {
2536
+ if(i === 'id') { continue; }
2537
+ if(i !== 'class') {
2538
+ node.setAttribute(i, obj.li_attr[i]);
2539
+ }
2540
+ else {
2541
+ c += obj.li_attr[i];
2542
+ }
2543
+ }
2544
+ }
2545
+ if(!obj.a_attr.id) {
2546
+ obj.a_attr.id = obj.id + '_anchor';
2547
+ }
2548
+ node.setAttribute('aria-selected', !!obj.state.selected);
2549
+ node.childNodes[1].setAttribute('aria-selected', !!obj.state.selected);
2550
+ node.setAttribute('aria-level', obj.parents.length);
2551
+ node.childNodes[1].setAttribute('aria-level', obj.parents.length);
2552
+
2553
+ node.setAttribute('aria-labelledby', obj.a_attr.id);
2554
+ node.setAttribute('data-folder', obj.id);
2555
+ if(obj.state.disabled) {
2556
+ node.setAttribute('aria-disabled', true);
2557
+ node.childNodes[1].setAttribute('aria-disabled', true);
2558
+ }
2559
+
2560
+ for(i = 0, j = obj.children.length; i < j; i++) {
2561
+ if(!m[obj.children[i]].state.hidden) {
2562
+ has_children = true;
2563
+ break;
2564
+ }
2565
+ }
2566
+ if(obj.parent !== null && m[obj.parent] && !obj.state.hidden) {
2567
+ i = $.inArray(obj.id, m[obj.parent].children);
2568
+ last_sibling = obj.id;
2569
+ if(i !== -1) {
2570
+ i++;
2571
+ for(j = m[obj.parent].children.length; i < j; i++) {
2572
+ if(!m[m[obj.parent].children[i]].state.hidden) {
2573
+ last_sibling = m[obj.parent].children[i];
2574
+ }
2575
+ if(last_sibling !== obj.id) {
2576
+ break;
2577
+ }
2578
+ }
2579
+ }
2580
+ }
2581
+
2582
+ if(obj.state.hidden) {
2583
+ c += ' jstree-hidden';
2584
+ }
2585
+ if (obj.state.loading) {
2586
+ c += ' jstree-loading';
2587
+ }
2588
+ if(obj.state.loaded && !has_children) {
2589
+ c += ' jstree-leaf';
2590
+ }
2591
+ else {
2592
+ c += obj.state.opened && obj.state.loaded ? ' jstree-open' : ' jstree-closed';
2593
+ node.setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) );
2594
+ node.childNodes[1].setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) );
2595
+ }
2596
+ if(last_sibling === obj.id) {
2597
+ c += ' jstree-last';
2598
+ }
2599
+ node.id = obj.id;
2600
+ node.className = c;
2601
+ c = ( obj.state.selected ? ' jstree-clicked' : '') + ( obj.state.disabled ? ' jstree-disabled' : '');
2602
+ for(j in obj.a_attr) {
2603
+ if(obj.a_attr.hasOwnProperty(j)) {
2604
+ if(j === 'href' && obj.a_attr[j] === '#') { continue; }
2605
+ if(j !== 'class') {
2606
+ node.childNodes[1].setAttribute(j, obj.a_attr[j]);
2607
+ }
2608
+ else {
2609
+ c += ' ' + obj.a_attr[j];
2610
+ }
2611
+ }
2612
+ }
2613
+ if(c.length) {
2614
+ node.childNodes[1].className = 'jstree-anchor ' + c;
2615
+ }
2616
+ if((obj.icon && obj.icon !== true) || obj.icon === false) {
2617
+ if(obj.icon === false) {
2618
+ node.childNodes[1].childNodes[0].className += ' jstree-themeicon-hidden';
2619
+ }
2620
+ else if(obj.icon.indexOf('/') === -1 && obj.icon.indexOf('.') === -1) {
2621
+ node.childNodes[1].childNodes[0].className += ' ' + obj.icon + ' jstree-themeicon-custom';
2622
+ }
2623
+ else {
2624
+ node.childNodes[1].childNodes[0].style.backgroundImage = 'url("'+obj.icon+'")';
2625
+ node.childNodes[1].childNodes[0].style.backgroundPosition = 'center center';
2626
+ node.childNodes[1].childNodes[0].style.backgroundSize = 'auto';
2627
+ node.childNodes[1].childNodes[0].className += ' jstree-themeicon-custom';
2628
+ }
2629
+ }
2630
+
2631
+ if(this.settings.core.force_text) {
2632
+ node.childNodes[1].appendChild(d.createTextNode(obj.text));
2633
+ }
2634
+ else {
2635
+ node.childNodes[1].innerHTML += obj.text;
2636
+ }
2637
+
2638
+
2639
+ if(deep && obj.children.length && (obj.state.opened || force_render) && obj.state.loaded) {
2640
+ k = d.createElement('UL');
2641
+ k.setAttribute('role', 'group');
2642
+ k.className = 'jstree-children';
2643
+ for(i = 0, j = obj.children.length; i < j; i++) {
2644
+ k.appendChild(this.redraw_node(obj.children[i], deep, true));
2645
+ }
2646
+ node.appendChild(k);
2647
+ }
2648
+ if(old) {
2649
+ node.appendChild(old);
2650
+ }
2651
+ if(!is_callback) {
2652
+ // append back using par / ind
2653
+ if(!par) {
2654
+ par = this.element[0];
2655
+ }
2656
+ for(i = 0, j = par.childNodes.length; i < j; i++) {
2657
+ if(par.childNodes[i] && par.childNodes[i].className && par.childNodes[i].className.indexOf('jstree-children') !== -1) {
2658
+ tmp = par.childNodes[i];
2659
+ break;
2660
+ }
2661
+ }
2662
+ if(!tmp) {
2663
+ tmp = d.createElement('UL');
2664
+ tmp.setAttribute('role', 'group');
2665
+ tmp.className = 'jstree-children';
2666
+ par.appendChild(tmp);
2667
+ }
2668
+ par = tmp;
2669
+
2670
+ if(ind < par.childNodes.length) {
2671
+ par.insertBefore(node, par.childNodes[ind]);
2672
+ }
2673
+ else {
2674
+ par.appendChild(node);
2675
+ }
2676
+ if(f) {
2677
+ t = this.element[0].scrollTop;
2678
+ l = this.element[0].scrollLeft;
2679
+ node.childNodes[1].focus();
2680
+ this.element[0].scrollTop = t;
2681
+ this.element[0].scrollLeft = l;
2682
+ }
2683
+ }
2684
+ if(obj.state.opened && !obj.state.loaded) {
2685
+ obj.state.opened = false;
2686
+ setTimeout($.proxy(function () {
2687
+ this.open_node(obj.id, false, 0);
2688
+ }, this), 0);
2689
+ }
2690
+ return node;
2691
+ },
2692
+ /**
2693
+ * opens a node, revealing its children. If the node is not loaded it will be loaded and opened once ready.
2694
+ * @name open_node(obj [, callback, animation])
2695
+ * @param {mixed} obj the node to open
2696
+ * @param {Function} callback a function to execute once the node is opened
2697
+ * @param {Number} animation the animation duration in milliseconds when opening the node (overrides the `core.animation` setting). Use `false` for no animation.
2698
+ * @trigger open_node.jstree, after_open.jstree, before_open.jstree
2699
+ */
2700
+ open_node : function (obj, callback, animation) {
2701
+ var t1, t2, d, t;
2702
+ if($.isArray(obj)) {
2703
+ obj = obj.slice();
2704
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2705
+ this.open_node(obj[t1], callback, animation);
2706
+ }
2707
+ return true;
2708
+ }
2709
+ obj = this.get_node(obj);
2710
+ if(!obj || obj.id === $.jstree.root) {
2711
+ return false;
2712
+ }
2713
+ animation = animation === undefined ? this.settings.core.animation : animation;
2714
+ if(!this.is_closed(obj)) {
2715
+ if(callback) {
2716
+ callback.call(this, obj, false);
2717
+ }
2718
+ return false;
2719
+ }
2720
+ if(!this.is_loaded(obj)) {
2721
+ if(this.is_loading(obj)) {
2722
+ return setTimeout($.proxy(function () {
2723
+ this.open_node(obj, callback, animation);
2724
+ }, this), 500);
2725
+ }
2726
+ this.load_node(obj, function (o, ok) {
2727
+ return ok ? this.open_node(o, callback, animation) : (callback ? callback.call(this, o, false) : false);
2728
+ });
2729
+ }
2730
+ else {
2731
+ d = this.get_node(obj, true);
2732
+ t = this;
2733
+ if(d.length) {
2734
+ if(animation && d.children(".jstree-children").length) {
2735
+ d.children(".jstree-children").stop(true, true);
2736
+ }
2737
+ if(obj.children.length && !this._firstChild(d.children('.jstree-children')[0])) {
2738
+ this.draw_children(obj);
2739
+ //d = this.get_node(obj, true);
2740
+ }
2741
+ if(!animation) {
2742
+ this.trigger('before_open', { "node" : obj });
2743
+ d[0].className = d[0].className.replace('jstree-closed', 'jstree-open');
2744
+ d[0].setAttribute("aria-expanded", true);
2745
+ d[0].childNodes[1].setAttribute("aria-expanded", true);
2746
+ }
2747
+ else {
2748
+ this.trigger('before_open', { "node" : obj });
2749
+ d
2750
+ .children(".jstree-children").css("display","none").end()
2751
+ .removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded", true)
2752
+ .children('.jstree-anchor').attr("aria-expanded", true).end()
2753
+ .children(".jstree-children").stop(true, true)
2754
+ .slideDown(animation, function () {
2755
+ this.style.display = "";
2756
+ if (t.element) {
2757
+ t.trigger("after_open", { "node" : obj });
2758
+ }
2759
+ });
2760
+ }
2761
+ }
2762
+ obj.state.opened = true;
2763
+ if(callback) {
2764
+ callback.call(this, obj, true);
2765
+ }
2766
+ if(!d.length) {
2767
+ /**
2768
+ * triggered when a node is about to be opened (if the node is supposed to be in the DOM, it will be, but it won't be visible yet)
2769
+ * @event
2770
+ * @name before_open.jstree
2771
+ * @param {Object} node the opened node
2772
+ */
2773
+ this.trigger('before_open', { "node" : obj });
2774
+ }
2775
+ /**
2776
+ * triggered when a node is opened (if there is an animation it will not be completed yet)
2777
+ * @event
2778
+ * @name open_node.jstree
2779
+ * @param {Object} node the opened node
2780
+ */
2781
+ this.trigger('open_node', { "node" : obj });
2782
+ if(!animation || !d.length) {
2783
+ /**
2784
+ * triggered when a node is opened and the animation is complete
2785
+ * @event
2786
+ * @name after_open.jstree
2787
+ * @param {Object} node the opened node
2788
+ */
2789
+ this.trigger("after_open", { "node" : obj });
2790
+ }
2791
+ return true;
2792
+ }
2793
+ },
2794
+ /**
2795
+ * opens every parent of a node (node should be loaded)
2796
+ * @name _open_to(obj)
2797
+ * @param {mixed} obj the node to reveal
2798
+ * @private
2799
+ */
2800
+ _open_to : function (obj) {
2801
+ obj = this.get_node(obj);
2802
+ if(!obj || obj.id === $.jstree.root) {
2803
+ return false;
2804
+ }
2805
+ var i, j, p = obj.parents;
2806
+ for(i = 0, j = p.length; i < j; i+=1) {
2807
+ if(i !== $.jstree.root) {
2808
+ this.open_node(p[i], false, 0);
2809
+ }
2810
+ }
2811
+ return $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element);
2812
+ },
2813
+ /**
2814
+ * closes a node, hiding its children
2815
+ * @name close_node(obj [, animation])
2816
+ * @param {mixed} obj the node to close
2817
+ * @param {Number} animation the animation duration in milliseconds when closing the node (overrides the `core.animation` setting). Use `false` for no animation.
2818
+ * @trigger close_node.jstree, after_close.jstree
2819
+ */
2820
+ close_node : function (obj, animation) {
2821
+ var t1, t2, t, d;
2822
+ if($.isArray(obj)) {
2823
+ obj = obj.slice();
2824
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2825
+ this.close_node(obj[t1], animation);
2826
+ }
2827
+ return true;
2828
+ }
2829
+ obj = this.get_node(obj);
2830
+ if(!obj || obj.id === $.jstree.root) {
2831
+ return false;
2832
+ }
2833
+ if(this.is_closed(obj)) {
2834
+ return false;
2835
+ }
2836
+ animation = animation === undefined ? this.settings.core.animation : animation;
2837
+ t = this;
2838
+ d = this.get_node(obj, true);
2839
+
2840
+ obj.state.opened = false;
2841
+ /**
2842
+ * triggered when a node is closed (if there is an animation it will not be complete yet)
2843
+ * @event
2844
+ * @name close_node.jstree
2845
+ * @param {Object} node the closed node
2846
+ */
2847
+ this.trigger('close_node',{ "node" : obj });
2848
+ if(!d.length) {
2849
+ /**
2850
+ * triggered when a node is closed and the animation is complete
2851
+ * @event
2852
+ * @name after_close.jstree
2853
+ * @param {Object} node the closed node
2854
+ */
2855
+ this.trigger("after_close", { "node" : obj });
2856
+ }
2857
+ else {
2858
+ if(!animation) {
2859
+ d[0].className = d[0].className.replace('jstree-open', 'jstree-closed');
2860
+ d.children('.jstree-anchor').attr("aria-expanded", false);
2861
+ d.attr("aria-expanded", false).children('.jstree-children').remove();
2862
+ this.trigger("after_close", { "node" : obj });
2863
+ }
2864
+ else {
2865
+ d
2866
+ .children(".jstree-children").attr("style","display:block !important").end()
2867
+ .removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded", false)
2868
+ .children('.jstree-anchor').attr("aria-expanded", false).end()
2869
+ .children(".jstree-children").stop(true, true).slideUp(animation, function () {
2870
+ this.style.display = "";
2871
+ d.children('.jstree-children').remove();
2872
+ if (t.element) {
2873
+ t.trigger("after_close", { "node" : obj });
2874
+ }
2875
+ });
2876
+ }
2877
+ }
2878
+ },
2879
+ /**
2880
+ * toggles a node - closing it if it is open, opening it if it is closed
2881
+ * @name toggle_node(obj)
2882
+ * @param {mixed} obj the node to toggle
2883
+ */
2884
+ toggle_node : function (obj) {
2885
+ var t1, t2;
2886
+ if($.isArray(obj)) {
2887
+ obj = obj.slice();
2888
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2889
+ this.toggle_node(obj[t1]);
2890
+ }
2891
+ return true;
2892
+ }
2893
+ if(this.is_closed(obj)) {
2894
+ return this.open_node(obj);
2895
+ }
2896
+ if(this.is_open(obj)) {
2897
+ return this.close_node(obj);
2898
+ }
2899
+ },
2900
+ /**
2901
+ * opens all nodes within a node (or the tree), revealing their children. If the node is not loaded it will be loaded and opened once ready.
2902
+ * @name open_all([obj, animation, original_obj])
2903
+ * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree
2904
+ * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation
2905
+ * @param {jQuery} reference to the node that started the process (internal use)
2906
+ * @trigger open_all.jstree
2907
+ */
2908
+ open_all : function (obj, animation, original_obj) {
2909
+ if(!obj) { obj = $.jstree.root; }
2910
+ obj = this.get_node(obj);
2911
+ if(!obj) { return false; }
2912
+ var dom = obj.id === $.jstree.root ? this.get_container_ul() : this.get_node(obj, true), i, j, _this;
2913
+ if(!dom.length) {
2914
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
2915
+ if(this.is_closed(this._model.data[obj.children_d[i]])) {
2916
+ this._model.data[obj.children_d[i]].state.opened = true;
2917
+ }
2918
+ }
2919
+ return this.trigger('open_all', { "node" : obj });
2920
+ }
2921
+ original_obj = original_obj || dom;
2922
+ _this = this;
2923
+ dom = this.is_closed(obj) ? dom.find('.jstree-closed').addBack() : dom.find('.jstree-closed');
2924
+ dom.each(function () {
2925
+ _this.open_node(
2926
+ this,
2927
+ function(node, status) { if(status && this.is_parent(node)) { this.open_all(node, animation, original_obj); } },
2928
+ animation || 0
2929
+ );
2930
+ });
2931
+ if(original_obj.find('.jstree-closed').length === 0) {
2932
+ /**
2933
+ * triggered when an `open_all` call completes
2934
+ * @event
2935
+ * @name open_all.jstree
2936
+ * @param {Object} node the opened node
2937
+ */
2938
+ this.trigger('open_all', { "node" : this.get_node(original_obj) });
2939
+ }
2940
+ },
2941
+ /**
2942
+ * closes all nodes within a node (or the tree), revealing their children
2943
+ * @name close_all([obj, animation])
2944
+ * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree
2945
+ * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation
2946
+ * @trigger close_all.jstree
2947
+ */
2948
+ close_all : function (obj, animation) {
2949
+ if(!obj) { obj = $.jstree.root; }
2950
+ obj = this.get_node(obj);
2951
+ if(!obj) { return false; }
2952
+ var dom = obj.id === $.jstree.root ? this.get_container_ul() : this.get_node(obj, true),
2953
+ _this = this, i, j;
2954
+ if(dom.length) {
2955
+ dom = this.is_open(obj) ? dom.find('.jstree-open').addBack() : dom.find('.jstree-open');
2956
+ $(dom.get().reverse()).each(function () { _this.close_node(this, animation || 0); });
2957
+ }
2958
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
2959
+ this._model.data[obj.children_d[i]].state.opened = false;
2960
+ }
2961
+ /**
2962
+ * triggered when an `close_all` call completes
2963
+ * @event
2964
+ * @name close_all.jstree
2965
+ * @param {Object} node the closed node
2966
+ */
2967
+ this.trigger('close_all', { "node" : obj });
2968
+ },
2969
+ /**
2970
+ * checks if a node is disabled (not selectable)
2971
+ * @name is_disabled(obj)
2972
+ * @param {mixed} obj
2973
+ * @return {Boolean}
2974
+ */
2975
+ is_disabled : function (obj) {
2976
+ obj = this.get_node(obj);
2977
+ return obj && obj.state && obj.state.disabled;
2978
+ },
2979
+ /**
2980
+ * enables a node - so that it can be selected
2981
+ * @name enable_node(obj)
2982
+ * @param {mixed} obj the node to enable
2983
+ * @trigger enable_node.jstree
2984
+ */
2985
+ enable_node : function (obj) {
2986
+ var t1, t2;
2987
+ if($.isArray(obj)) {
2988
+ obj = obj.slice();
2989
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
2990
+ this.enable_node(obj[t1]);
2991
+ }
2992
+ return true;
2993
+ }
2994
+ obj = this.get_node(obj);
2995
+ if(!obj || obj.id === $.jstree.root) {
2996
+ return false;
2997
+ }
2998
+ obj.state.disabled = false;
2999
+ this.get_node(obj,true).children('.jstree-anchor').removeClass('jstree-disabled').attr('aria-disabled', false);
3000
+ /**
3001
+ * triggered when an node is enabled
3002
+ * @event
3003
+ * @name enable_node.jstree
3004
+ * @param {Object} node the enabled node
3005
+ */
3006
+ this.trigger('enable_node', { 'node' : obj });
3007
+ },
3008
+ /**
3009
+ * disables a node - so that it can not be selected
3010
+ * @name disable_node(obj)
3011
+ * @param {mixed} obj the node to disable
3012
+ * @trigger disable_node.jstree
3013
+ */
3014
+ disable_node : function (obj) {
3015
+ var t1, t2;
3016
+ if($.isArray(obj)) {
3017
+ obj = obj.slice();
3018
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3019
+ this.disable_node(obj[t1]);
3020
+ }
3021
+ return true;
3022
+ }
3023
+ obj = this.get_node(obj);
3024
+ if(!obj || obj.id === $.jstree.root) {
3025
+ return false;
3026
+ }
3027
+ obj.state.disabled = true;
3028
+ this.get_node(obj,true).children('.jstree-anchor').addClass('jstree-disabled').attr('aria-disabled', true);
3029
+ /**
3030
+ * triggered when an node is disabled
3031
+ * @event
3032
+ * @name disable_node.jstree
3033
+ * @param {Object} node the disabled node
3034
+ */
3035
+ this.trigger('disable_node', { 'node' : obj });
3036
+ },
3037
+ /**
3038
+ * determines if a node is hidden
3039
+ * @name is_hidden(obj)
3040
+ * @param {mixed} obj the node
3041
+ */
3042
+ is_hidden : function (obj) {
3043
+ obj = this.get_node(obj);
3044
+ return obj.state.hidden === true;
3045
+ },
3046
+ /**
3047
+ * hides a node - it is still in the structure but will not be visible
3048
+ * @name hide_node(obj)
3049
+ * @param {mixed} obj the node to hide
3050
+ * @param {Boolean} skip_redraw internal parameter controlling if redraw is called
3051
+ * @trigger hide_node.jstree
3052
+ */
3053
+ hide_node : function (obj, skip_redraw) {
3054
+ var t1, t2;
3055
+ if($.isArray(obj)) {
3056
+ obj = obj.slice();
3057
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3058
+ this.hide_node(obj[t1], true);
3059
+ }
3060
+ if (!skip_redraw) {
3061
+ this.redraw();
3062
+ }
3063
+ return true;
3064
+ }
3065
+ obj = this.get_node(obj);
3066
+ if(!obj || obj.id === $.jstree.root) {
3067
+ return false;
3068
+ }
3069
+ if(!obj.state.hidden) {
3070
+ obj.state.hidden = true;
3071
+ this._node_changed(obj.parent);
3072
+ if(!skip_redraw) {
3073
+ this.redraw();
3074
+ }
3075
+ /**
3076
+ * triggered when an node is hidden
3077
+ * @event
3078
+ * @name hide_node.jstree
3079
+ * @param {Object} node the hidden node
3080
+ */
3081
+ this.trigger('hide_node', { 'node' : obj });
3082
+ }
3083
+ },
3084
+ /**
3085
+ * shows a node
3086
+ * @name show_node(obj)
3087
+ * @param {mixed} obj the node to show
3088
+ * @param {Boolean} skip_redraw internal parameter controlling if redraw is called
3089
+ * @trigger show_node.jstree
3090
+ */
3091
+ show_node : function (obj, skip_redraw) {
3092
+ var t1, t2;
3093
+ if($.isArray(obj)) {
3094
+ obj = obj.slice();
3095
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3096
+ this.show_node(obj[t1], true);
3097
+ }
3098
+ if (!skip_redraw) {
3099
+ this.redraw();
3100
+ }
3101
+ return true;
3102
+ }
3103
+ obj = this.get_node(obj);
3104
+ if(!obj || obj.id === $.jstree.root) {
3105
+ return false;
3106
+ }
3107
+ if(obj.state.hidden) {
3108
+ obj.state.hidden = false;
3109
+ this._node_changed(obj.parent);
3110
+ if(!skip_redraw) {
3111
+ this.redraw();
3112
+ }
3113
+ /**
3114
+ * triggered when an node is shown
3115
+ * @event
3116
+ * @name show_node.jstree
3117
+ * @param {Object} node the shown node
3118
+ */
3119
+ this.trigger('show_node', { 'node' : obj });
3120
+ }
3121
+ },
3122
+ /**
3123
+ * hides all nodes
3124
+ * @name hide_all()
3125
+ * @trigger hide_all.jstree
3126
+ */
3127
+ hide_all : function (skip_redraw) {
3128
+ var i, m = this._model.data, ids = [];
3129
+ for(i in m) {
3130
+ if(m.hasOwnProperty(i) && i !== $.jstree.root && !m[i].state.hidden) {
3131
+ m[i].state.hidden = true;
3132
+ ids.push(i);
3133
+ }
3134
+ }
3135
+ this._model.force_full_redraw = true;
3136
+ if(!skip_redraw) {
3137
+ this.redraw();
3138
+ }
3139
+ /**
3140
+ * triggered when all nodes are hidden
3141
+ * @event
3142
+ * @name hide_all.jstree
3143
+ * @param {Array} nodes the IDs of all hidden nodes
3144
+ */
3145
+ this.trigger('hide_all', { 'nodes' : ids });
3146
+ return ids;
3147
+ },
3148
+ /**
3149
+ * shows all nodes
3150
+ * @name show_all()
3151
+ * @trigger show_all.jstree
3152
+ */
3153
+ show_all : function (skip_redraw) {
3154
+ var i, m = this._model.data, ids = [];
3155
+ for(i in m) {
3156
+ if(m.hasOwnProperty(i) && i !== $.jstree.root && m[i].state.hidden) {
3157
+ m[i].state.hidden = false;
3158
+ ids.push(i);
3159
+ }
3160
+ }
3161
+ this._model.force_full_redraw = true;
3162
+ if(!skip_redraw) {
3163
+ this.redraw();
3164
+ }
3165
+ /**
3166
+ * triggered when all nodes are shown
3167
+ * @event
3168
+ * @name show_all.jstree
3169
+ * @param {Array} nodes the IDs of all shown nodes
3170
+ */
3171
+ this.trigger('show_all', { 'nodes' : ids });
3172
+ return ids;
3173
+ },
3174
+ /**
3175
+ * called when a node is selected by the user. Used internally.
3176
+ * @private
3177
+ * @name activate_node(obj, e)
3178
+ * @param {mixed} obj the node
3179
+ * @param {Object} e the related event
3180
+ * @trigger activate_node.jstree, changed.jstree
3181
+ */
3182
+ activate_node : function (obj, e) {
3183
+ if(typeof e.isTrigger !== "undefined" && e.isTrigger >0) {
3184
+ return false;
3185
+ }
3186
+ if(this.is_disabled(obj)) {
3187
+ return false;
3188
+ }
3189
+ if(!e || typeof e !== 'object') {
3190
+ e = {};
3191
+ }
3192
+
3193
+ // ensure last_clicked is still in the DOM, make it fresh (maybe it was moved?) and make sure it is still selected, if not - make last_clicked the last selected node
3194
+ this._data.core.last_clicked = this._data.core.last_clicked && this._data.core.last_clicked.id !== undefined ? this.get_node(this._data.core.last_clicked.id) : null;
3195
+ if(this._data.core.last_clicked && !this._data.core.last_clicked.state.selected) { this._data.core.last_clicked = null; }
3196
+ if(!this._data.core.last_clicked && this._data.core.selected.length) { this._data.core.last_clicked = this.get_node(this._data.core.selected[this._data.core.selected.length - 1]); }
3197
+
3198
+ if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {
3199
+ if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
3200
+ this.deselect_node(obj, false, e);
3201
+ }
3202
+ else {
3203
+ this.deselect_all(true);
3204
+ this.select_node(obj, false, false, e);
3205
+ this._data.core.last_clicked = this.get_node(obj);
3206
+ }
3207
+ }
3208
+ else {
3209
+ if(e.shiftKey) {
3210
+ var o = this.get_node(obj).id,
3211
+ l = this._data.core.last_clicked.id,
3212
+ p = this.get_node(this._data.core.last_clicked.parent).children,
3213
+ c = false,
3214
+ i, j;
3215
+ for(i = 0, j = p.length; i < j; i += 1) {
3216
+ // separate IFs work whem o and l are the same
3217
+ if(p[i] === o) {
3218
+ c = !c;
3219
+ }
3220
+ if(p[i] === l) {
3221
+ c = !c;
3222
+ }
3223
+ if(!this.is_disabled(p[i]) && (c || p[i] === o || p[i] === l)) {
3224
+ if (!this.is_hidden(p[i])) {
3225
+ this.select_node(p[i], true, false, e);
3226
+ }
3227
+ }
3228
+ else {
3229
+ this.deselect_node(p[i], true, e);
3230
+ }
3231
+ }
3232
+ this.trigger('changed', { 'action' : 'select_node', 'node' : this.get_node(obj), 'selected' : this._data.core.selected, 'event' : e });
3233
+ }
3234
+ else {
3235
+ if(!this.is_selected(obj)) {
3236
+ this.select_node(obj, false, false, e);
3237
+ }
3238
+ else {
3239
+ this.deselect_node(obj, false, e);
3240
+ }
3241
+ }
3242
+ }
3243
+ /**
3244
+ * triggered when an node is clicked or intercated with by the user
3245
+ * @event
3246
+ * @name activate_node.jstree
3247
+ * @param {Object} node
3248
+ * @param {Object} event the ooriginal event (if any) which triggered the call (may be an empty object)
3249
+ */
3250
+ this.trigger('activate_node', { 'node' : this.get_node(obj), 'event' : e });
3251
+ },
3252
+ /**
3253
+ * applies the hover state on a node, called when a node is hovered by the user. Used internally.
3254
+ * @private
3255
+ * @name hover_node(obj)
3256
+ * @param {mixed} obj
3257
+ * @trigger hover_node.jstree
3258
+ */
3259
+ hover_node : function (obj) {
3260
+ obj = this.get_node(obj, true);
3261
+ if(!obj || !obj.length || obj.children('.jstree-hovered').length) {
3262
+ return false;
3263
+ }
3264
+ var o = this.element.find('.jstree-hovered'), t = this.element;
3265
+ if(o && o.length) { this.dehover_node(o); }
3266
+
3267
+ obj.children('.jstree-anchor').addClass('jstree-hovered');
3268
+ /**
3269
+ * triggered when an node is hovered
3270
+ * @event
3271
+ * @name hover_node.jstree
3272
+ * @param {Object} node
3273
+ */
3274
+ this.trigger('hover_node', { 'node' : this.get_node(obj) });
3275
+ setTimeout(function () { t.attr('aria-activedescendant', obj[0].id); }, 0);
3276
+ },
3277
+ /**
3278
+ * removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally.
3279
+ * @private
3280
+ * @name dehover_node(obj)
3281
+ * @param {mixed} obj
3282
+ * @trigger dehover_node.jstree
3283
+ */
3284
+ dehover_node : function (obj) {
3285
+ obj = this.get_node(obj, true);
3286
+ if(!obj || !obj.length || !obj.children('.jstree-hovered').length) {
3287
+ return false;
3288
+ }
3289
+ obj.children('.jstree-anchor').removeClass('jstree-hovered');
3290
+ /**
3291
+ * triggered when an node is no longer hovered
3292
+ * @event
3293
+ * @name dehover_node.jstree
3294
+ * @param {Object} node
3295
+ */
3296
+ this.trigger('dehover_node', { 'node' : this.get_node(obj) });
3297
+ },
3298
+ /**
3299
+ * select a node
3300
+ * @name select_node(obj [, supress_event, prevent_open])
3301
+ * @param {mixed} obj an array can be used to select multiple nodes
3302
+ * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3303
+ * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened
3304
+ * @trigger select_node.jstree, changed.jstree
3305
+ */
3306
+ select_node : function (obj, supress_event, prevent_open, e) {
3307
+ var dom, t1, t2, th;
3308
+ if($.isArray(obj)) {
3309
+ obj = obj.slice();
3310
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3311
+ this.select_node(obj[t1], supress_event, prevent_open, e);
3312
+ }
3313
+ return true;
3314
+ }
3315
+ obj = this.get_node(obj);
3316
+ if(!obj || obj.id === $.jstree.root) {
3317
+ return false;
3318
+ }
3319
+ dom = this.get_node(obj, true);
3320
+ if(!obj.state.selected) {
3321
+ obj.state.selected = true;
3322
+ this._data.core.selected.push(obj.id);
3323
+ if(!prevent_open) {
3324
+ dom = this._open_to(obj);
3325
+ }
3326
+ if(dom && dom.length) {
3327
+ dom.attr('aria-selected', true).children('.jstree-anchor').addClass('jstree-clicked').attr('aria-selected', true);
3328
+ }
3329
+ /**
3330
+ * triggered when an node is selected
3331
+ * @event
3332
+ * @name select_node.jstree
3333
+ * @param {Object} node
3334
+ * @param {Array} selected the current selection
3335
+ * @param {Object} event the event (if any) that triggered this select_node
3336
+ */
3337
+ this.trigger('select_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3338
+ if(!supress_event) {
3339
+ /**
3340
+ * triggered when selection changes
3341
+ * @event
3342
+ * @name changed.jstree
3343
+ * @param {Object} node
3344
+ * @param {Object} action the action that caused the selection to change
3345
+ * @param {Array} selected the current selection
3346
+ * @param {Object} event the event (if any) that triggered this changed event
3347
+ */
3348
+ this.trigger('changed', { 'action' : 'select_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3349
+ }
3350
+ }
3351
+ },
3352
+ /**
3353
+ * deselect a node
3354
+ * @name deselect_node(obj [, supress_event])
3355
+ * @param {mixed} obj an array can be used to deselect multiple nodes
3356
+ * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3357
+ * @trigger deselect_node.jstree, changed.jstree
3358
+ */
3359
+ deselect_node : function (obj, supress_event, e) {
3360
+ var t1, t2, dom;
3361
+ if($.isArray(obj)) {
3362
+ obj = obj.slice();
3363
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3364
+ this.deselect_node(obj[t1], supress_event, e);
3365
+ }
3366
+ return true;
3367
+ }
3368
+ obj = this.get_node(obj);
3369
+ if(!obj || obj.id === $.jstree.root) {
3370
+ return false;
3371
+ }
3372
+ dom = this.get_node(obj, true);
3373
+ if(obj.state.selected) {
3374
+ obj.state.selected = false;
3375
+ this._data.core.selected = $.vakata.array_remove_item(this._data.core.selected, obj.id);
3376
+ if(dom.length) {
3377
+ dom.attr('aria-selected', false).children('.jstree-anchor').removeClass('jstree-clicked').attr('aria-selected', false);
3378
+ }
3379
+ /**
3380
+ * triggered when an node is deselected
3381
+ * @event
3382
+ * @name deselect_node.jstree
3383
+ * @param {Object} node
3384
+ * @param {Array} selected the current selection
3385
+ * @param {Object} event the event (if any) that triggered this deselect_node
3386
+ */
3387
+ this.trigger('deselect_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3388
+ if(!supress_event) {
3389
+ this.trigger('changed', { 'action' : 'deselect_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e });
3390
+ }
3391
+ }
3392
+ },
3393
+ /**
3394
+ * select all nodes in the tree
3395
+ * @name select_all([supress_event])
3396
+ * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3397
+ * @trigger select_all.jstree, changed.jstree
3398
+ */
3399
+ select_all : function (supress_event) {
3400
+ var tmp = this._data.core.selected.concat([]), i, j;
3401
+ this._data.core.selected = this._model.data[$.jstree.root].children_d.concat();
3402
+ for(i = 0, j = this._data.core.selected.length; i < j; i++) {
3403
+ if(this._model.data[this._data.core.selected[i]]) {
3404
+ this._model.data[this._data.core.selected[i]].state.selected = true;
3405
+ }
3406
+ }
3407
+ this.redraw(true);
3408
+ /**
3409
+ * triggered when all nodes are selected
3410
+ * @event
3411
+ * @name select_all.jstree
3412
+ * @param {Array} selected the current selection
3413
+ */
3414
+ this.trigger('select_all', { 'selected' : this._data.core.selected });
3415
+ if(!supress_event) {
3416
+ this.trigger('changed', { 'action' : 'select_all', 'selected' : this._data.core.selected, 'old_selection' : tmp });
3417
+ }
3418
+ },
3419
+ /**
3420
+ * deselect all selected nodes
3421
+ * @name deselect_all([supress_event])
3422
+ * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
3423
+ * @trigger deselect_all.jstree, changed.jstree
3424
+ */
3425
+ deselect_all : function (supress_event) {
3426
+ var tmp = this._data.core.selected.concat([]), i, j;
3427
+ for(i = 0, j = this._data.core.selected.length; i < j; i++) {
3428
+ if(this._model.data[this._data.core.selected[i]]) {
3429
+ this._model.data[this._data.core.selected[i]].state.selected = false;
3430
+ }
3431
+ }
3432
+ this._data.core.selected = [];
3433
+ this.element.find('.jstree-clicked').removeClass('jstree-clicked').attr('aria-selected', false).parent().attr('aria-selected', false);
3434
+ /**
3435
+ * triggered when all nodes are deselected
3436
+ * @event
3437
+ * @name deselect_all.jstree
3438
+ * @param {Object} node the previous selection
3439
+ * @param {Array} selected the current selection
3440
+ */
3441
+ this.trigger('deselect_all', { 'selected' : this._data.core.selected, 'node' : tmp });
3442
+ if(!supress_event) {
3443
+ this.trigger('changed', { 'action' : 'deselect_all', 'selected' : this._data.core.selected, 'old_selection' : tmp });
3444
+ }
3445
+ },
3446
+ /**
3447
+ * checks if a node is selected
3448
+ * @name is_selected(obj)
3449
+ * @param {mixed} obj
3450
+ * @return {Boolean}
3451
+ */
3452
+ is_selected : function (obj) {
3453
+ obj = this.get_node(obj);
3454
+ if(!obj || obj.id === $.jstree.root) {
3455
+ return false;
3456
+ }
3457
+ return obj.state.selected;
3458
+ },
3459
+ /**
3460
+ * get an array of all selected nodes
3461
+ * @name get_selected([full])
3462
+ * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
3463
+ * @return {Array}
3464
+ */
3465
+ get_selected : function (full) {
3466
+ return full ? $.map(this._data.core.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.core.selected.slice();
3467
+ },
3468
+ /**
3469
+ * get an array of all top level selected nodes (ignoring children of selected nodes)
3470
+ * @name get_top_selected([full])
3471
+ * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
3472
+ * @return {Array}
3473
+ */
3474
+ get_top_selected : function (full) {
3475
+ var tmp = this.get_selected(true),
3476
+ obj = {}, i, j, k, l;
3477
+ for(i = 0, j = tmp.length; i < j; i++) {
3478
+ obj[tmp[i].id] = tmp[i];
3479
+ }
3480
+ for(i = 0, j = tmp.length; i < j; i++) {
3481
+ for(k = 0, l = tmp[i].children_d.length; k < l; k++) {
3482
+ if(obj[tmp[i].children_d[k]]) {
3483
+ delete obj[tmp[i].children_d[k]];
3484
+ }
3485
+ }
3486
+ }
3487
+ tmp = [];
3488
+ for(i in obj) {
3489
+ if(obj.hasOwnProperty(i)) {
3490
+ tmp.push(i);
3491
+ }
3492
+ }
3493
+ return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp;
3494
+ },
3495
+ /**
3496
+ * get an array of all bottom level selected nodes (ignoring selected parents)
3497
+ * @name get_bottom_selected([full])
3498
+ * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
3499
+ * @return {Array}
3500
+ */
3501
+ get_bottom_selected : function (full) {
3502
+ var tmp = this.get_selected(true),
3503
+ obj = [], i, j;
3504
+ for(i = 0, j = tmp.length; i < j; i++) {
3505
+ if(!tmp[i].children.length) {
3506
+ obj.push(tmp[i].id);
3507
+ }
3508
+ }
3509
+ return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj;
3510
+ },
3511
+ /**
3512
+ * gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally.
3513
+ * @name get_state()
3514
+ * @private
3515
+ * @return {Object}
3516
+ */
3517
+ get_state : function () {
3518
+ var state = {
3519
+ 'core' : {
3520
+ 'open' : [],
3521
+ 'loaded' : [],
3522
+ 'scroll' : {
3523
+ 'left' : this.element.scrollLeft(),
3524
+ 'top' : this.element.scrollTop()
3525
+ },
3526
+ /*!
3527
+ 'themes' : {
3528
+ 'name' : this.get_theme(),
3529
+ 'icons' : this._data.core.themes.icons,
3530
+ 'dots' : this._data.core.themes.dots
3531
+ },
3532
+ */
3533
+ 'selected' : []
3534
+ }
3535
+ }, i;
3536
+ for(i in this._model.data) {
3537
+ if(this._model.data.hasOwnProperty(i)) {
3538
+ if(i !== $.jstree.root) {
3539
+ if(this._model.data[i].state.loaded && this.settings.core.loaded_state) {
3540
+ state.core.loaded.push(i);
3541
+ }
3542
+ if(this._model.data[i].state.opened) {
3543
+ state.core.open.push(i);
3544
+ }
3545
+ if(this._model.data[i].state.selected) {
3546
+ state.core.selected.push(i);
3547
+ }
3548
+ }
3549
+ }
3550
+ }
3551
+ return state;
3552
+ },
3553
+ /**
3554
+ * sets the state of the tree. Used internally.
3555
+ * @name set_state(state [, callback])
3556
+ * @private
3557
+ * @param {Object} state the state to restore. Keep in mind this object is passed by reference and jstree will modify it.
3558
+ * @param {Function} callback an optional function to execute once the state is restored.
3559
+ * @trigger set_state.jstree
3560
+ */
3561
+ set_state : function (state, callback) {
3562
+ if(state) {
3563
+ if(state.core && state.core.selected && state.core.initial_selection === undefined) {
3564
+ state.core.initial_selection = this._data.core.selected.concat([]).sort().join(',');
3565
+ }
3566
+ if(state.core) {
3567
+ var res, n, t, _this, i;
3568
+ if(state.core.loaded) {
3569
+ if(!this.settings.core.loaded_state || !$.isArray(state.core.loaded) || !state.core.loaded.length) {
3570
+ delete state.core.loaded;
3571
+ this.set_state(state, callback);
3572
+ }
3573
+ else {
3574
+ this._load_nodes(state.core.loaded, function (nodes) {
3575
+ delete state.core.loaded;
3576
+ this.set_state(state, callback);
3577
+ });
3578
+ }
3579
+ return false;
3580
+ }
3581
+ if(state.core.open) {
3582
+ if(!$.isArray(state.core.open) || !state.core.open.length) {
3583
+ delete state.core.open;
3584
+ this.set_state(state, callback);
3585
+ }
3586
+ else {
3587
+ this._load_nodes(state.core.open, function (nodes) {
3588
+ this.open_node(nodes, false, 0);
3589
+ delete state.core.open;
3590
+ this.set_state(state, callback);
3591
+ });
3592
+ }
3593
+ return false;
3594
+ }
3595
+ if(state.core.scroll) {
3596
+ if(state.core.scroll && state.core.scroll.left !== undefined) {
3597
+ this.element.scrollLeft(state.core.scroll.left);
3598
+ }
3599
+ if(state.core.scroll && state.core.scroll.top !== undefined) {
3600
+ this.element.scrollTop(state.core.scroll.top);
3601
+ }
3602
+ delete state.core.scroll;
3603
+ this.set_state(state, callback);
3604
+ return false;
3605
+ }
3606
+ if(state.core.selected) {
3607
+ _this = this;
3608
+ if (state.core.initial_selection === undefined ||
3609
+ state.core.initial_selection === this._data.core.selected.concat([]).sort().join(',')
3610
+ ) {
3611
+ this.deselect_all();
3612
+ $.each(state.core.selected, function (i, v) {
3613
+ _this.select_node(v, false, true);
3614
+ });
3615
+ }
3616
+ delete state.core.initial_selection;
3617
+ delete state.core.selected;
3618
+ this.set_state(state, callback);
3619
+ return false;
3620
+ }
3621
+ for(i in state) {
3622
+ if(state.hasOwnProperty(i) && i !== "core" && $.inArray(i, this.settings.plugins) === -1) {
3623
+ delete state[i];
3624
+ }
3625
+ }
3626
+ if($.isEmptyObject(state.core)) {
3627
+ delete state.core;
3628
+ this.set_state(state, callback);
3629
+ return false;
3630
+ }
3631
+ }
3632
+ if($.isEmptyObject(state)) {
3633
+ state = null;
3634
+ if(callback) { callback.call(this); }
3635
+ /**
3636
+ * triggered when a `set_state` call completes
3637
+ * @event
3638
+ * @name set_state.jstree
3639
+ */
3640
+ this.trigger('set_state');
3641
+ return false;
3642
+ }
3643
+ return true;
3644
+ }
3645
+ return false;
3646
+ },
3647
+ /**
3648
+ * refreshes the tree - all nodes are reloaded with calls to `load_node`.
3649
+ * @name refresh()
3650
+ * @param {Boolean} skip_loading an option to skip showing the loading indicator
3651
+ * @param {Mixed} forget_state if set to `true` state will not be reapplied, if set to a function (receiving the current state as argument) the result of that function will be used as state
3652
+ * @trigger refresh.jstree
3653
+ */
3654
+ refresh : function (skip_loading, forget_state) {
3655
+ this._data.core.state = forget_state === true ? {} : this.get_state();
3656
+ if(forget_state && $.isFunction(forget_state)) { this._data.core.state = forget_state.call(this, this._data.core.state); }
3657
+ this._cnt = 0;
3658
+ this._model.data = {};
3659
+ this._model.data[$.jstree.root] = {
3660
+ id : $.jstree.root,
3661
+ parent : null,
3662
+ parents : [],
3663
+ children : [],
3664
+ children_d : [],
3665
+ state : { loaded : false }
3666
+ };
3667
+ this._data.core.selected = [];
3668
+ this._data.core.last_clicked = null;
3669
+ this._data.core.focused = null;
3670
+
3671
+ var c = this.get_container_ul()[0].className;
3672
+ if(!skip_loading) {
3673
+ this.element.html("<"+"ul class='"+c+"' role='group'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='presentation' id='j"+this._id+"_loading'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden pfolder-folder-close'></i>" + this.get_string("Loading ...") + "</a></li></ul>");
3674
+ this.element.attr('aria-activedescendant','j'+this._id+'_loading');
3675
+ }
3676
+ this.load_node($.jstree.root, function (o, s) {
3677
+ if(s) {
3678
+ this.get_container_ul()[0].className = c;
3679
+ if(this._firstChild(this.get_container_ul()[0])) {
3680
+ this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id);
3681
+ }
3682
+ this.set_state($.extend(true, {}, this._data.core.state), function () {
3683
+ /**
3684
+ * triggered when a `refresh` call completes
3685
+ * @event
3686
+ * @name refresh.jstree
3687
+ */
3688
+ this.trigger('refresh');
3689
+ });
3690
+ }
3691
+ this._data.core.state = null;
3692
+ });
3693
+ },
3694
+ /**
3695
+ * refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`.
3696
+ * @name refresh_node(obj)
3697
+ * @param {mixed} obj the node
3698
+ * @trigger refresh_node.jstree
3699
+ */
3700
+ refresh_node : function (obj) {
3701
+ obj = this.get_node(obj);
3702
+ if(!obj || obj.id === $.jstree.root) { return false; }
3703
+ var opened = [], to_load = [], s = this._data.core.selected.concat([]);
3704
+ to_load.push(obj.id);
3705
+ if(obj.state.opened === true) { opened.push(obj.id); }
3706
+ this.get_node(obj, true).find('.jstree-open').each(function() { to_load.push(this.id); opened.push(this.id); });
3707
+ this._load_nodes(to_load, $.proxy(function (nodes) {
3708
+ this.open_node(opened, false, 0);
3709
+ this.select_node(s);
3710
+ /**
3711
+ * triggered when a node is refreshed
3712
+ * @event
3713
+ * @name refresh_node.jstree
3714
+ * @param {Object} node - the refreshed node
3715
+ * @param {Array} nodes - an array of the IDs of the nodes that were reloaded
3716
+ */
3717
+ this.trigger('refresh_node', { 'node' : obj, 'nodes' : nodes });
3718
+ }, this), false, true);
3719
+ },
3720
+ /**
3721
+ * set (change) the ID of a node
3722
+ * @name set_id(obj, id)
3723
+ * @param {mixed} obj the node
3724
+ * @param {String} id the new ID
3725
+ * @return {Boolean}
3726
+ * @trigger set_id.jstree
3727
+ */
3728
+ set_id : function (obj, id) {
3729
+ obj = this.get_node(obj);
3730
+ if(!obj || obj.id === $.jstree.root) { return false; }
3731
+ var i, j, m = this._model.data, old = obj.id;
3732
+ id = id.toString();
3733
+ // update parents (replace current ID with new one in children and children_d)
3734
+ m[obj.parent].children[$.inArray(obj.id, m[obj.parent].children)] = id;
3735
+ for(i = 0, j = obj.parents.length; i < j; i++) {
3736
+ m[obj.parents[i]].children_d[$.inArray(obj.id, m[obj.parents[i]].children_d)] = id;
3737
+ }
3738
+ // update children (replace current ID with new one in parent and parents)
3739
+ for(i = 0, j = obj.children.length; i < j; i++) {
3740
+ m[obj.children[i]].parent = id;
3741
+ }
3742
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
3743
+ m[obj.children_d[i]].parents[$.inArray(obj.id, m[obj.children_d[i]].parents)] = id;
3744
+ }
3745
+ i = $.inArray(obj.id, this._data.core.selected);
3746
+ if(i !== -1) { this._data.core.selected[i] = id; }
3747
+ // update model and obj itself (obj.id, this._model.data[KEY])
3748
+ i = this.get_node(obj.id, true);
3749
+ if(i) {
3750
+ i.attr('id', id); //.children('.jstree-anchor').attr('id', id + '_anchor').end().attr('aria-labelledby', id + '_anchor');
3751
+ if(this.element.attr('aria-activedescendant') === obj.id) {
3752
+ this.element.attr('aria-activedescendant', id);
3753
+ }
3754
+ }
3755
+ delete m[obj.id];
3756
+ obj.id = id;
3757
+ obj.li_attr.id = id;
3758
+ m[id] = obj;
3759
+ /**
3760
+ * triggered when a node id value is changed
3761
+ * @event
3762
+ * @name set_id.jstree
3763
+ * @param {Object} node
3764
+ * @param {String} old the old id
3765
+ */
3766
+ this.trigger('set_id',{ "node" : obj, "new" : obj.id, "old" : old });
3767
+ return true;
3768
+ },
3769
+ /**
3770
+ * get the text value of a node
3771
+ * @name get_text(obj)
3772
+ * @param {mixed} obj the node
3773
+ * @return {String}
3774
+ */
3775
+ get_text : function (obj) {
3776
+ obj = this.get_node(obj);
3777
+ return (!obj || obj.id === $.jstree.root) ? false : obj.text;
3778
+ },
3779
+ /**
3780
+ * set the text value of a node. Used internally, please use `rename_node(obj, val)`.
3781
+ * @private
3782
+ * @name set_text(obj, val)
3783
+ * @param {mixed} obj the node, you can pass an array to set the text on multiple nodes
3784
+ * @param {String} val the new text value
3785
+ * @return {Boolean}
3786
+ * @trigger set_text.jstree
3787
+ */
3788
+ set_text : function (obj, val) {
3789
+ var t1, t2;
3790
+ if($.isArray(obj)) {
3791
+ obj = obj.slice();
3792
+ console.log(obj);
3793
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3794
+ this.set_text(obj[t1], val);
3795
+ }
3796
+ return true;
3797
+ }
3798
+ obj = this.get_node(obj);
3799
+ if(!obj || obj.id === $.jstree.root) { return false; }
3800
+ obj.text = val;
3801
+ if(this.get_node(obj, true).length) {
3802
+ this.redraw_node(obj.id);
3803
+ }
3804
+ /**
3805
+ * triggered when a node text value is changed
3806
+ * @event
3807
+ * @name set_text.jstree
3808
+ * @param {Object} obj
3809
+ * @param {String} text the new value
3810
+ */
3811
+ this.trigger('set_text',{ "obj" : obj, "text" : val });
3812
+ return true;
3813
+ },
3814
+ /**
3815
+ * gets a JSON representation of a node (or the whole tree)
3816
+ * @name get_json([obj, options])
3817
+ * @param {mixed} obj
3818
+ * @param {Object} options
3819
+ * @param {Boolean} options.no_state do not return state information
3820
+ * @param {Boolean} options.no_id do not return ID
3821
+ * @param {Boolean} options.no_children do not include children
3822
+ * @param {Boolean} options.no_data do not include node data
3823
+ * @param {Boolean} options.no_li_attr do not include LI attributes
3824
+ * @param {Boolean} options.no_a_attr do not include A attributes
3825
+ * @param {Boolean} options.flat return flat JSON instead of nested
3826
+ * @return {Object}
3827
+ */
3828
+ get_json : function (obj, options, flat) {
3829
+ obj = this.get_node(obj || $.jstree.root);
3830
+ if(!obj) { return false; }
3831
+ if(options && options.flat && !flat) { flat = []; }
3832
+ var tmp = {
3833
+ 'id' : obj.id,
3834
+ 'text' : obj.text,
3835
+ 'icon' : this.get_icon(obj),
3836
+ 'li_attr' : $.extend(true, {}, obj.li_attr),
3837
+ 'a_attr' : $.extend(true, {}, obj.a_attr),
3838
+ 'state' : {},
3839
+ 'data' : options && options.no_data ? false : $.extend(true, $.isArray(obj.data)?[]:{}, obj.data)
3840
+ //( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ),
3841
+ }, i, j;
3842
+ if(options && options.flat) {
3843
+ tmp.parent = obj.parent;
3844
+ }
3845
+ else {
3846
+ tmp.children = [];
3847
+ }
3848
+ if(!options || !options.no_state) {
3849
+ for(i in obj.state) {
3850
+ if(obj.state.hasOwnProperty(i)) {
3851
+ tmp.state[i] = obj.state[i];
3852
+ }
3853
+ }
3854
+ } else {
3855
+ delete tmp.state;
3856
+ }
3857
+ if(options && options.no_li_attr) {
3858
+ delete tmp.li_attr;
3859
+ }
3860
+ if(options && options.no_a_attr) {
3861
+ delete tmp.a_attr;
3862
+ }
3863
+ if(options && options.no_id) {
3864
+ delete tmp.id;
3865
+ if(tmp.li_attr && tmp.li_attr.id) {
3866
+ delete tmp.li_attr.id;
3867
+ }
3868
+ if(tmp.a_attr && tmp.a_attr.id) {
3869
+ delete tmp.a_attr.id;
3870
+ }
3871
+ }
3872
+ if(options && options.flat && obj.id !== $.jstree.root) {
3873
+ flat.push(tmp);
3874
+ }
3875
+ if(!options || !options.no_children) {
3876
+ for(i = 0, j = obj.children.length; i < j; i++) {
3877
+ if(options && options.flat) {
3878
+ this.get_json(obj.children[i], options, flat);
3879
+ }
3880
+ else {
3881
+ tmp.children.push(this.get_json(obj.children[i], options));
3882
+ }
3883
+ }
3884
+ }
3885
+ return options && options.flat ? flat : (obj.id === $.jstree.root ? tmp.children : tmp);
3886
+ },
3887
+ /**
3888
+ * create a new node (do not confuse with load_node)
3889
+ * @name create_node([par, node, pos, callback, is_loaded])
3890
+ * @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`)
3891
+ * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name)
3892
+ * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last"
3893
+ * @param {Function} callback a function to be called once the node is created
3894
+ * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded
3895
+ * @return {String} the ID of the newly create node
3896
+ * @trigger model.jstree, create_node.jstree
3897
+ */
3898
+ create_node : function (par, node, pos, callback, is_loaded) {
3899
+ if(par === null) { par = $.jstree.root; }
3900
+ par = this.get_node(par);
3901
+ if(!par) { return false; }
3902
+ pos = pos === undefined ? "last" : pos;
3903
+ if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
3904
+ return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); });
3905
+ }
3906
+ if(!node) { node = { "text" : this.get_string('New node') }; }
3907
+ if(typeof node === "string") {
3908
+ node = { "text" : node };
3909
+ } else {
3910
+ node = $.extend(true, {}, node);
3911
+ }
3912
+ if(node.text === undefined) { node.text = this.get_string('New node'); }
3913
+ var tmp, dpc, i, j;
3914
+
3915
+ if(par.id === $.jstree.root) {
3916
+ if(pos === "before") { pos = "first"; }
3917
+ if(pos === "after") { pos = "last"; }
3918
+ }
3919
+ switch(pos) {
3920
+ case "before":
3921
+ tmp = this.get_node(par.parent);
3922
+ pos = $.inArray(par.id, tmp.children);
3923
+ par = tmp;
3924
+ break;
3925
+ case "after" :
3926
+ tmp = this.get_node(par.parent);
3927
+ pos = $.inArray(par.id, tmp.children) + 1;
3928
+ par = tmp;
3929
+ break;
3930
+ case "inside":
3931
+ case "first":
3932
+ pos = 0;
3933
+ break;
3934
+ case "last":
3935
+ pos = par.children.length;
3936
+ break;
3937
+ default:
3938
+ if(!pos) { pos = 0; }
3939
+ break;
3940
+ }
3941
+ if(pos > par.children.length) { pos = par.children.length; }
3942
+ if(!node.id) { node.id = true; }
3943
+ if(!this.check("create_node", node, par, pos)) {
3944
+ this.settings.core.error.call(this, this._data.core.last_error);
3945
+ return false;
3946
+ }
3947
+ if(node.id === true) { delete node.id; }
3948
+ node = this._parse_model_from_json(node, par.id, par.parents.concat());
3949
+ if(!node) { return false; }
3950
+ tmp = this.get_node(node);
3951
+ dpc = [];
3952
+ dpc.push(node);
3953
+ dpc = dpc.concat(tmp.children_d);
3954
+ this.trigger('model', { "nodes" : dpc, "parent" : par.id });
3955
+
3956
+ par.children_d = par.children_d.concat(dpc);
3957
+ for(i = 0, j = par.parents.length; i < j; i++) {
3958
+ this._model.data[par.parents[i]].children_d = this._model.data[par.parents[i]].children_d.concat(dpc);
3959
+ }
3960
+ node = tmp;
3961
+ tmp = [];
3962
+ for(i = 0, j = par.children.length; i < j; i++) {
3963
+ tmp[i >= pos ? i+1 : i] = par.children[i];
3964
+ }
3965
+ tmp[pos] = node.id;
3966
+ par.children = tmp;
3967
+
3968
+ this.redraw_node(par, true);
3969
+ /**
3970
+ * triggered when a node is created
3971
+ * @event
3972
+ * @name create_node.jstree
3973
+ * @param {Object} node
3974
+ * @param {String} parent the parent's ID
3975
+ * @param {Number} position the position of the new node among the parent's children
3976
+ */
3977
+ this.trigger('create_node', { "node" : this.get_node(node), "parent" : par.id, "position" : pos });
3978
+ if(callback) { callback.call(this, this.get_node(node)); }
3979
+ return node.id;
3980
+ },
3981
+ /**
3982
+ * set the text value of a node
3983
+ * @name rename_node(obj, val)
3984
+ * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name
3985
+ * @param {String} val the new text value
3986
+ * @return {Boolean}
3987
+ * @trigger rename_node.jstree
3988
+ */
3989
+ rename_node : function (obj, val) {
3990
+ var t1, t2, old;
3991
+ if($.isArray(obj)) {
3992
+ obj = obj.slice();
3993
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
3994
+ this.rename_node(obj[t1], val);
3995
+ }
3996
+ return true;
3997
+ }
3998
+ obj = this.get_node(obj);
3999
+ if(!obj || obj.id === $.jstree.root) { return false; }
4000
+ old = obj.text;
4001
+ if(!this.check("rename_node", obj, this.get_parent(obj), val)) {
4002
+ this.settings.core.error.call(this, this._data.core.last_error);
4003
+ return false;
4004
+ }
4005
+ this.set_text(obj, val); // .apply(this, Array.prototype.slice.call(arguments))
4006
+ /**
4007
+ * triggered when a node is renamed
4008
+ * @event
4009
+ * @name rename_node.jstree
4010
+ * @param {Object} node
4011
+ * @param {String} text the new value
4012
+ * @param {String} old the old value
4013
+ */
4014
+ this.trigger('rename_node', { "node" : obj, "text" : val, "old" : old });
4015
+ return true;
4016
+ },
4017
+ /**
4018
+ * remove a node
4019
+ * @name delete_node(obj)
4020
+ * @param {mixed} obj the node, you can pass an array to delete multiple nodes
4021
+ * @return {Boolean}
4022
+ * @trigger delete_node.jstree, changed.jstree
4023
+ */
4024
+ delete_node : function (obj) {
4025
+ var t1, t2, par, pos, tmp, i, j, k, l, c, top, lft;
4026
+ if($.isArray(obj)) {
4027
+ obj = obj.slice();
4028
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4029
+ this.delete_node(obj[t1]);
4030
+ }
4031
+ return true;
4032
+ }
4033
+ obj = this.get_node(obj);
4034
+ if(!obj || obj.id === $.jstree.root) { return false; }
4035
+ par = this.get_node(obj.parent);
4036
+ pos = $.inArray(obj.id, par.children);
4037
+ c = false;
4038
+ if(!this.check("delete_node", obj, par, pos)) {
4039
+ this.settings.core.error.call(this, this._data.core.last_error);
4040
+ return false;
4041
+ }
4042
+ if(pos !== -1) {
4043
+ par.children = $.vakata.array_remove(par.children, pos);
4044
+ }
4045
+ tmp = obj.children_d.concat([]);
4046
+ tmp.push(obj.id);
4047
+ for(i = 0, j = obj.parents.length; i < j; i++) {
4048
+ this._model.data[obj.parents[i]].children_d = $.vakata.array_filter(this._model.data[obj.parents[i]].children_d, function (v) {
4049
+ return $.inArray(v, tmp) === -1;
4050
+ });
4051
+ }
4052
+ for(k = 0, l = tmp.length; k < l; k++) {
4053
+ if(this._model.data[tmp[k]].state.selected) {
4054
+ c = true;
4055
+ break;
4056
+ }
4057
+ }
4058
+ if (c) {
4059
+ this._data.core.selected = $.vakata.array_filter(this._data.core.selected, function (v) {
4060
+ return $.inArray(v, tmp) === -1;
4061
+ });
4062
+ }
4063
+ /**
4064
+ * triggered when a node is deleted
4065
+ * @event
4066
+ * @name delete_node.jstree
4067
+ * @param {Object} node
4068
+ * @param {String} parent the parent's ID
4069
+ */
4070
+ this.trigger('delete_node', { "node" : obj, "parent" : par.id });
4071
+ if(c) {
4072
+ this.trigger('changed', { 'action' : 'delete_node', 'node' : obj, 'selected' : this._data.core.selected, 'parent' : par.id });
4073
+ }
4074
+ for(k = 0, l = tmp.length; k < l; k++) {
4075
+ delete this._model.data[tmp[k]];
4076
+ }
4077
+ if($.inArray(this._data.core.focused, tmp) !== -1) {
4078
+ this._data.core.focused = null;
4079
+ top = this.element[0].scrollTop;
4080
+ lft = this.element[0].scrollLeft;
4081
+ if(par.id === $.jstree.root) {
4082
+ if (this._model.data[$.jstree.root].children[0]) {
4083
+ this.get_node(this._model.data[$.jstree.root].children[0], true).children('.jstree-anchor').focus();
4084
+ }
4085
+ }
4086
+ else {
4087
+ this.get_node(par, true).children('.jstree-anchor').focus();
4088
+ }
4089
+ this.element[0].scrollTop = top;
4090
+ this.element[0].scrollLeft = lft;
4091
+ }
4092
+ this.redraw_node(par, true);
4093
+ return true;
4094
+ },
4095
+ /**
4096
+ * check if an operation is premitted on the tree. Used internally.
4097
+ * @private
4098
+ * @name check(chk, obj, par, pos)
4099
+ * @param {String} chk the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node"
4100
+ * @param {mixed} obj the node
4101
+ * @param {mixed} par the parent
4102
+ * @param {mixed} pos the position to insert at, or if "rename_node" - the new name
4103
+ * @param {mixed} more some various additional information, for example if a "move_node" operations is triggered by DND this will be the hovered node
4104
+ * @return {Boolean}
4105
+ */
4106
+ check : function (chk, obj, par, pos, more) {
4107
+ obj = obj && obj.id ? obj : this.get_node(obj);
4108
+ par = par && par.id ? par : this.get_node(par);
4109
+ var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj,
4110
+ chc = this.settings.core.check_callback;
4111
+ if(chk === "move_node" || chk === "copy_node") {
4112
+ if((!more || !more.is_multi) && (chk === "move_node" && $.inArray(obj.id, par.children) === pos)) {
4113
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_08', 'reason' : 'Moving node to its current position', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4114
+ return false;
4115
+ }
4116
+ if((!more || !more.is_multi) && (obj.id === par.id || (chk === "move_node" && $.inArray(obj.id, par.children) === pos) || $.inArray(par.id, obj.children_d) !== -1)) {
4117
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_01', 'reason' : 'Moving parent inside child', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4118
+ return false;
4119
+ }
4120
+ }
4121
+ if(tmp && tmp.data) { tmp = tmp.data; }
4122
+ if(tmp && tmp.functions && (tmp.functions[chk] === false || tmp.functions[chk] === true)) {
4123
+ if(tmp.functions[chk] === false) {
4124
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_02', 'reason' : 'Node data prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4125
+ }
4126
+ return tmp.functions[chk];
4127
+ }
4128
+ if(chc === false || ($.isFunction(chc) && chc.call(this, chk, obj, par, pos, more) === false) || (chc && chc[chk] === false)) {
4129
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_03', 'reason' : 'User config for core.check_callback prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
4130
+ return false;
4131
+ }
4132
+ return true;
4133
+ },
4134
+ /**
4135
+ * get the last error
4136
+ * @name last_error()
4137
+ * @return {Object}
4138
+ */
4139
+ last_error : function () {
4140
+ return this._data.core.last_error;
4141
+ },
4142
+ /**
4143
+ * move a node to a new parent
4144
+ * @name move_node(obj, par [, pos, callback, is_loaded])
4145
+ * @param {mixed} obj the node to move, pass an array to move multiple nodes
4146
+ * @param {mixed} par the new parent
4147
+ * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
4148
+ * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
4149
+ * @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
4150
+ * @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
4151
+ * @param {Boolean} instance internal parameter indicating if the node comes from another instance
4152
+ * @trigger move_node.jstree
4153
+ */
4154
+ move_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) {
4155
+ var t1, t2, old_par, old_pos, new_par, old_ins, is_multi, dpc, tmp, i, j, k, l, p;
4156
+
4157
+ par = this.get_node(par);
4158
+ pos = pos === undefined ? 0 : pos;
4159
+ if(!par) { return false; }
4160
+ if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
4161
+ return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true, false, origin); });
4162
+ }
4163
+
4164
+ if($.isArray(obj)) {
4165
+ if(obj.length === 1) {
4166
+ obj = obj[0];
4167
+ }
4168
+ else {
4169
+ //obj = obj.slice();
4170
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4171
+ if((tmp = this.move_node(obj[t1], par, pos, callback, is_loaded, false, origin))) {
4172
+ par = tmp;
4173
+ pos = "after";
4174
+ }
4175
+ }
4176
+ this.redraw();
4177
+ return true;
4178
+ }
4179
+ }
4180
+ obj = obj && obj.id ? obj : this.get_node(obj);
4181
+
4182
+ if(!obj || obj.id === $.jstree.root) { return false; }
4183
+
4184
+ old_par = (obj.parent || $.jstree.root).toString();
4185
+ new_par = (!pos.toString().match(/^(before|after)$/) || par.id === $.jstree.root) ? par : this.get_node(par.parent);
4186
+ old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id));
4187
+ is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id);
4188
+ old_pos = old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1;
4189
+ if(old_ins && old_ins._id) {
4190
+ obj = old_ins._model.data[obj.id];
4191
+ }
4192
+
4193
+ if(is_multi) {
4194
+ if((tmp = this.copy_node(obj, par, pos, callback, is_loaded, false, origin))) {
4195
+ if(old_ins) { old_ins.delete_node(obj); }
4196
+ return tmp;
4197
+ }
4198
+ return false;
4199
+ }
4200
+ //var m = this._model.data;
4201
+ if(par.id === $.jstree.root) {
4202
+ if(pos === "before") { pos = "first"; }
4203
+ if(pos === "after") { pos = "last"; }
4204
+ }
4205
+ switch(pos) {
4206
+ case "before":
4207
+ pos = $.inArray(par.id, new_par.children);
4208
+ break;
4209
+ case "after" :
4210
+ pos = $.inArray(par.id, new_par.children) + 1;
4211
+ break;
4212
+ case "inside":
4213
+ case "first":
4214
+ pos = 0;
4215
+ break;
4216
+ case "last":
4217
+ pos = new_par.children.length;
4218
+ break;
4219
+ default:
4220
+ if(!pos) { pos = 0; }
4221
+ break;
4222
+ }
4223
+ if(pos > new_par.children.length) { pos = new_par.children.length; }
4224
+ if(!this.check("move_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
4225
+ this.settings.core.error.call(this, this._data.core.last_error);
4226
+ return false;
4227
+ }
4228
+ if(obj.parent === new_par.id) {
4229
+ dpc = new_par.children.concat();
4230
+ tmp = $.inArray(obj.id, dpc);
4231
+ if(tmp !== -1) {
4232
+ dpc = $.vakata.array_remove(dpc, tmp);
4233
+ if(pos > tmp) { pos--; }
4234
+ }
4235
+ tmp = [];
4236
+ for(i = 0, j = dpc.length; i < j; i++) {
4237
+ tmp[i >= pos ? i+1 : i] = dpc[i];
4238
+ }
4239
+ tmp[pos] = obj.id;
4240
+ new_par.children = tmp;
4241
+ this._node_changed(new_par.id);
4242
+ this.redraw(new_par.id === $.jstree.root);
4243
+ }
4244
+ else {
4245
+ // clean old parent and up
4246
+ tmp = obj.children_d.concat();
4247
+ tmp.push(obj.id);
4248
+ for(i = 0, j = obj.parents.length; i < j; i++) {
4249
+ dpc = [];
4250
+ p = old_ins._model.data[obj.parents[i]].children_d;
4251
+ for(k = 0, l = p.length; k < l; k++) {
4252
+ if($.inArray(p[k], tmp) === -1) {
4253
+ dpc.push(p[k]);
4254
+ }
4255
+ }
4256
+ old_ins._model.data[obj.parents[i]].children_d = dpc;
4257
+ }
4258
+ old_ins._model.data[old_par].children = $.vakata.array_remove_item(old_ins._model.data[old_par].children, obj.id);
4259
+
4260
+ // insert into new parent and up
4261
+ for(i = 0, j = new_par.parents.length; i < j; i++) {
4262
+ this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(tmp);
4263
+ }
4264
+ dpc = [];
4265
+ for(i = 0, j = new_par.children.length; i < j; i++) {
4266
+ dpc[i >= pos ? i+1 : i] = new_par.children[i];
4267
+ }
4268
+ dpc[pos] = obj.id;
4269
+ new_par.children = dpc;
4270
+ new_par.children_d.push(obj.id);
4271
+ new_par.children_d = new_par.children_d.concat(obj.children_d);
4272
+
4273
+ // update object
4274
+ obj.parent = new_par.id;
4275
+ tmp = new_par.parents.concat();
4276
+ tmp.unshift(new_par.id);
4277
+ p = obj.parents.length;
4278
+ obj.parents = tmp;
4279
+
4280
+ // update object children
4281
+ tmp = tmp.concat();
4282
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
4283
+ this._model.data[obj.children_d[i]].parents = this._model.data[obj.children_d[i]].parents.slice(0,p*-1);
4284
+ Array.prototype.push.apply(this._model.data[obj.children_d[i]].parents, tmp);
4285
+ }
4286
+
4287
+ if(old_par === $.jstree.root || new_par.id === $.jstree.root) {
4288
+ this._model.force_full_redraw = true;
4289
+ }
4290
+ if(!this._model.force_full_redraw) {
4291
+ this._node_changed(old_par);
4292
+ this._node_changed(new_par.id);
4293
+ }
4294
+ if(!skip_redraw) {
4295
+ this.redraw();
4296
+ }
4297
+ }
4298
+ if(callback) { callback.call(this, obj, new_par, pos); }
4299
+ /**
4300
+ * triggered when a node is moved
4301
+ * @event
4302
+ * @name move_node.jstree
4303
+ * @param {Object} node
4304
+ * @param {String} parent the parent's ID
4305
+ * @param {Number} position the position of the node among the parent's children
4306
+ * @param {String} old_parent the old parent of the node
4307
+ * @param {Number} old_position the old position of the node
4308
+ * @param {Boolean} is_multi do the node and new parent belong to different instances
4309
+ * @param {jsTree} old_instance the instance the node came from
4310
+ * @param {jsTree} new_instance the instance of the new parent
4311
+ */
4312
+ this.trigger('move_node', { "node" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_pos, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this });
4313
+ return obj.id;
4314
+ },
4315
+ /**
4316
+ * copy a node to a new parent
4317
+ * @name copy_node(obj, par [, pos, callback, is_loaded])
4318
+ * @param {mixed} obj the node to copy, pass an array to copy multiple nodes
4319
+ * @param {mixed} par the new parent
4320
+ * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
4321
+ * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
4322
+ * @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
4323
+ * @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
4324
+ * @param {Boolean} instance internal parameter indicating if the node comes from another instance
4325
+ * @trigger model.jstree copy_node.jstree
4326
+ */
4327
+ copy_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) {
4328
+ var t1, t2, dpc, tmp, i, j, node, old_par, new_par, old_ins, is_multi;
4329
+
4330
+ par = this.get_node(par);
4331
+ pos = pos === undefined ? 0 : pos;
4332
+ if(!par) { return false; }
4333
+ if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
4334
+ return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true, false, origin); });
4335
+ }
4336
+
4337
+ if($.isArray(obj)) {
4338
+ if(obj.length === 1) {
4339
+ obj = obj[0];
4340
+ }
4341
+ else {
4342
+ //obj = obj.slice();
4343
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4344
+ if((tmp = this.copy_node(obj[t1], par, pos, callback, is_loaded, true, origin))) {
4345
+ par = tmp;
4346
+ pos = "after";
4347
+ }
4348
+ }
4349
+ this.redraw();
4350
+ return true;
4351
+ }
4352
+ }
4353
+ obj = obj && obj.id ? obj : this.get_node(obj);
4354
+ if(!obj || obj.id === $.jstree.root) { return false; }
4355
+
4356
+ old_par = (obj.parent || $.jstree.root).toString();
4357
+ new_par = (!pos.toString().match(/^(before|after)$/) || par.id === $.jstree.root) ? par : this.get_node(par.parent);
4358
+ old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id));
4359
+ is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id);
4360
+
4361
+ if(old_ins && old_ins._id) {
4362
+ obj = old_ins._model.data[obj.id];
4363
+ }
4364
+
4365
+ if(par.id === $.jstree.root) {
4366
+ if(pos === "before") { pos = "first"; }
4367
+ if(pos === "after") { pos = "last"; }
4368
+ }
4369
+ switch(pos) {
4370
+ case "before":
4371
+ pos = $.inArray(par.id, new_par.children);
4372
+ break;
4373
+ case "after" :
4374
+ pos = $.inArray(par.id, new_par.children) + 1;
4375
+ break;
4376
+ case "inside":
4377
+ case "first":
4378
+ pos = 0;
4379
+ break;
4380
+ case "last":
4381
+ pos = new_par.children.length;
4382
+ break;
4383
+ default:
4384
+ if(!pos) { pos = 0; }
4385
+ break;
4386
+ }
4387
+ if(pos > new_par.children.length) { pos = new_par.children.length; }
4388
+ if(!this.check("copy_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
4389
+ this.settings.core.error.call(this, this._data.core.last_error);
4390
+ return false;
4391
+ }
4392
+ node = old_ins ? old_ins.get_json(obj, { no_id : true, no_data : true, no_state : true }) : obj;
4393
+ if(!node) { return false; }
4394
+ if(node.id === true) { delete node.id; }
4395
+ node = this._parse_model_from_json(node, new_par.id, new_par.parents.concat());
4396
+ if(!node) { return false; }
4397
+ tmp = this.get_node(node);
4398
+ if(obj && obj.state && obj.state.loaded === false) { tmp.state.loaded = false; }
4399
+ dpc = [];
4400
+ dpc.push(node);
4401
+ dpc = dpc.concat(tmp.children_d);
4402
+ this.trigger('model', { "nodes" : dpc, "parent" : new_par.id });
4403
+
4404
+ // insert into new parent and up
4405
+ for(i = 0, j = new_par.parents.length; i < j; i++) {
4406
+ this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(dpc);
4407
+ }
4408
+ dpc = [];
4409
+ for(i = 0, j = new_par.children.length; i < j; i++) {
4410
+ dpc[i >= pos ? i+1 : i] = new_par.children[i];
4411
+ }
4412
+ dpc[pos] = tmp.id;
4413
+ new_par.children = dpc;
4414
+ new_par.children_d.push(tmp.id);
4415
+ new_par.children_d = new_par.children_d.concat(tmp.children_d);
4416
+
4417
+ if(new_par.id === $.jstree.root) {
4418
+ this._model.force_full_redraw = true;
4419
+ }
4420
+ if(!this._model.force_full_redraw) {
4421
+ this._node_changed(new_par.id);
4422
+ }
4423
+ if(!skip_redraw) {
4424
+ this.redraw(new_par.id === $.jstree.root);
4425
+ }
4426
+ if(callback) { callback.call(this, tmp, new_par, pos); }
4427
+ /**
4428
+ * triggered when a node is copied
4429
+ * @event
4430
+ * @name copy_node.jstree
4431
+ * @param {Object} node the copied node
4432
+ * @param {Object} original the original node
4433
+ * @param {String} parent the parent's ID
4434
+ * @param {Number} position the position of the node among the parent's children
4435
+ * @param {String} old_parent the old parent of the node
4436
+ * @param {Number} old_position the position of the original node
4437
+ * @param {Boolean} is_multi do the node and new parent belong to different instances
4438
+ * @param {jsTree} old_instance the instance the node came from
4439
+ * @param {jsTree} new_instance the instance of the new parent
4440
+ */
4441
+ this.trigger('copy_node', { "node" : tmp, "original" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1,'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this });
4442
+ return tmp.id;
4443
+ },
4444
+ /**
4445
+ * cut a node (a later call to `paste(obj)` would move the node)
4446
+ * @name cut(obj)
4447
+ * @param {mixed} obj multiple objects can be passed using an array
4448
+ * @trigger cut.jstree
4449
+ */
4450
+ cut : function (obj) {
4451
+ if(!obj) { obj = this._data.core.selected.concat(); }
4452
+ if(!$.isArray(obj)) { obj = [obj]; }
4453
+ if(!obj.length) { return false; }
4454
+ var tmp = [], o, t1, t2;
4455
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4456
+ o = this.get_node(obj[t1]);
4457
+ if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); }
4458
+ }
4459
+ if(!tmp.length) { return false; }
4460
+ ccp_node = tmp;
4461
+ ccp_inst = this;
4462
+ ccp_mode = 'move_node';
4463
+ /**
4464
+ * triggered when nodes are added to the buffer for moving
4465
+ * @event
4466
+ * @name cut.jstree
4467
+ * @param {Array} node
4468
+ */
4469
+ this.trigger('cut', { "node" : obj });
4470
+ },
4471
+ /**
4472
+ * copy a node (a later call to `paste(obj)` would copy the node)
4473
+ * @name copy(obj)
4474
+ * @param {mixed} obj multiple objects can be passed using an array
4475
+ * @trigger copy.jstree
4476
+ */
4477
+ copy : function (obj) {
4478
+ if(!obj) { obj = this._data.core.selected.concat(); }
4479
+ if(!$.isArray(obj)) { obj = [obj]; }
4480
+ if(!obj.length) { return false; }
4481
+ var tmp = [], o, t1, t2;
4482
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4483
+ o = this.get_node(obj[t1]);
4484
+ if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); }
4485
+ }
4486
+ if(!tmp.length) { return false; }
4487
+ ccp_node = tmp;
4488
+ ccp_inst = this;
4489
+ ccp_mode = 'copy_node';
4490
+ /**
4491
+ * triggered when nodes are added to the buffer for copying
4492
+ * @event
4493
+ * @name copy.jstree
4494
+ * @param {Array} node
4495
+ */
4496
+ this.trigger('copy', { "node" : obj });
4497
+ },
4498
+ /**
4499
+ * get the current buffer (any nodes that are waiting for a paste operation)
4500
+ * @name get_buffer()
4501
+ * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance)
4502
+ */
4503
+ get_buffer : function () {
4504
+ return { 'mode' : ccp_mode, 'node' : ccp_node, 'inst' : ccp_inst };
4505
+ },
4506
+ /**
4507
+ * check if there is something in the buffer to paste
4508
+ * @name can_paste()
4509
+ * @return {Boolean}
4510
+ */
4511
+ can_paste : function () {
4512
+ return ccp_mode !== false && ccp_node !== false; // && ccp_inst._model.data[ccp_node];
4513
+ },
4514
+ /**
4515
+ * copy or move the previously cut or copied nodes to a new parent
4516
+ * @name paste(obj [, pos])
4517
+ * @param {mixed} obj the new parent
4518
+ * @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0`
4519
+ * @trigger paste.jstree
4520
+ */
4521
+ paste : function (obj, pos) {
4522
+ obj = this.get_node(obj);
4523
+ if(!obj || !ccp_mode || !ccp_mode.match(/^(copy_node|move_node)$/) || !ccp_node) { return false; }
4524
+ if(this[ccp_mode](ccp_node, obj, pos, false, false, false, ccp_inst)) {
4525
+ /**
4526
+ * triggered when paste is invoked
4527
+ * @event
4528
+ * @name paste.jstree
4529
+ * @param {String} parent the ID of the receiving node
4530
+ * @param {Array} node the nodes in the buffer
4531
+ * @param {String} mode the performed operation - "copy_node" or "move_node"
4532
+ */
4533
+ this.trigger('paste', { "parent" : obj.id, "node" : ccp_node, "mode" : ccp_mode });
4534
+ }
4535
+ ccp_node = false;
4536
+ ccp_mode = false;
4537
+ ccp_inst = false;
4538
+ },
4539
+ /**
4540
+ * clear the buffer of previously copied or cut nodes
4541
+ * @name clear_buffer()
4542
+ * @trigger clear_buffer.jstree
4543
+ */
4544
+ clear_buffer : function () {
4545
+ ccp_node = false;
4546
+ ccp_mode = false;
4547
+ ccp_inst = false;
4548
+ /**
4549
+ * triggered when the copy / cut buffer is cleared
4550
+ * @event
4551
+ * @name clear_buffer.jstree
4552
+ */
4553
+ this.trigger('clear_buffer');
4554
+ },
4555
+ /**
4556
+ * put a node in edit mode (input field to rename the node)
4557
+ * @name edit(obj [, default_text, callback])
4558
+ * @param {mixed} obj
4559
+ * @param {String} default_text the text to populate the input with (if omitted or set to a non-string value the node's text value is used)
4560
+ * @param {Function} callback a function to be called once the text box is blurred, it is called in the instance's scope and receives the node, a status parameter (true if the rename is successful, false otherwise) and a boolean indicating if the user cancelled the edit. You can access the node's title using .text
4561
+ */
4562
+ edit : function (obj, default_text, callback) {
4563
+ var rtl, w, a, s, t, h1, h2, fn, tmp, cancel = false;
4564
+ obj = this.get_node(obj);
4565
+ if(!obj) { return false; }
4566
+ if(!this.check("edit", obj, this.get_parent(obj))) {
4567
+ this.settings.core.error.call(this, this._data.core.last_error);
4568
+ return false;
4569
+ }
4570
+ tmp = obj;
4571
+ default_text = typeof default_text === 'string' ? default_text : obj.text;
4572
+ this.set_text(obj, "");
4573
+ obj = this._open_to(obj);
4574
+ tmp.text = default_text;
4575
+
4576
+ rtl = this._data.core.rtl;
4577
+ w = this.element.width();
4578
+ this._data.core.focused = tmp.id;
4579
+ a = obj.children('.jstree-anchor').focus();
4580
+ s = $('<span></span>');
4581
+ /*!
4582
+ oi = obj.children("i:visible"),
4583
+ ai = a.children("i:visible"),
4584
+ w1 = oi.width() * oi.length,
4585
+ w2 = ai.width() * ai.length,
4586
+ */
4587
+ t = default_text;
4588
+ h1 = $("<"+"div></div>", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo(document.body);
4589
+ h2 = $("<"+"input />", {
4590
+ "value" : t,
4591
+ "class" : "jstree-rename-input",
4592
+ // "size" : t.length,
4593
+ "css" : {
4594
+ "padding" : "0",
4595
+ "border" : "1px solid silver",
4596
+ "box-sizing" : "border-box",
4597
+ "display" : "inline-block",
4598
+ "height" : (this._data.core.li_height) + "px",
4599
+ "lineHeight" : (this._data.core.li_height) + "px",
4600
+ "width" : "150px" // will be set a bit further down
4601
+ },
4602
+ "blur" : $.proxy(function (e) {
4603
+ e.stopImmediatePropagation();
4604
+ e.preventDefault();
4605
+ var i = s.children(".jstree-rename-input"),
4606
+ v = i.val(),
4607
+ f = this.settings.core.force_text,
4608
+ nv;
4609
+ if(v === "") { v = t; }
4610
+ h1.remove();
4611
+ s.replaceWith(a);
4612
+ s.remove();
4613
+ t = f ? t : $('<div></div>').append($.parseHTML(t)).html();
4614
+ obj = this.get_node(obj);
4615
+ this.set_text(obj, t);
4616
+ nv = !!this.rename_node(obj, f ? $('<div></div>').text(v).text() : $('<div></div>').append($.parseHTML(v)).html());
4617
+ if(!nv) {
4618
+ this.set_text(obj, t); // move this up? and fix #483
4619
+ }
4620
+ this._data.core.focused = tmp.id;
4621
+ setTimeout($.proxy(function () {
4622
+ var node = this.get_node(tmp.id, true);
4623
+ if(node.length) {
4624
+ this._data.core.focused = tmp.id;
4625
+ node.children('.jstree-anchor').focus();
4626
+ }
4627
+ }, this), 0);
4628
+ if(callback) {
4629
+ callback.call(this, tmp, nv, cancel);
4630
+ }
4631
+ h2 = null;
4632
+ }, this),
4633
+ "keydown" : function (e) {
4634
+ var key = e.which;
4635
+ if(key === 27) {
4636
+ cancel = true;
4637
+ this.value = t;
4638
+ }
4639
+ if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) {
4640
+ e.stopImmediatePropagation();
4641
+ }
4642
+ if(key === 27 || key === 13) {
4643
+ e.preventDefault();
4644
+ this.blur();
4645
+ }
4646
+ },
4647
+ "click" : function (e) { e.stopImmediatePropagation(); },
4648
+ "mousedown" : function (e) { e.stopImmediatePropagation(); },
4649
+ "keyup" : function (e) {
4650
+ h2.width(Math.min(h1.text("pW" + this.value).width(),w));
4651
+ },
4652
+ "keypress" : function(e) {
4653
+ if(e.which === 13) { return false; }
4654
+ }
4655
+ });
4656
+ fn = {
4657
+ fontFamily : a.css('fontFamily') || '',
4658
+ fontSize : a.css('fontSize') || '',
4659
+ fontWeight : a.css('fontWeight') || '',
4660
+ fontStyle : a.css('fontStyle') || '',
4661
+ fontStretch : a.css('fontStretch') || '',
4662
+ fontVariant : a.css('fontVariant') || '',
4663
+ letterSpacing : a.css('letterSpacing') || '',
4664
+ wordSpacing : a.css('wordSpacing') || ''
4665
+ };
4666
+ s.attr('class', a.attr('class')).append(a.contents().clone()).append(h2);
4667
+ a.replaceWith(s);
4668
+ h1.css(fn);
4669
+ h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
4670
+ $(document).one('mousedown.jstree touchstart.jstree dnd_start.vakata', function (e) {
4671
+ if (h2 && e.target !== h2) {
4672
+ $(h2).blur();
4673
+ }
4674
+ });
4675
+ },
4676
+
4677
+
4678
+ /**
4679
+ * changes the theme
4680
+ * @name set_theme(theme_name [, theme_url])
4681
+ * @param {String} theme_name the name of the new theme to apply
4682
+ * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory.
4683
+ * @trigger set_theme.jstree
4684
+ */
4685
+ set_theme : function (theme_name, theme_url) {
4686
+ if(!theme_name) { return false; }
4687
+ if(theme_url === true) {
4688
+ var dir = this.settings.core.themes.dir;
4689
+ if(!dir) { dir = $.jstree.path + '/themes'; }
4690
+ theme_url = dir + '/' + theme_name + '/style.css';
4691
+ }
4692
+ if(theme_url && $.inArray(theme_url, themes_loaded) === -1) {
4693
+ $('head').append('<'+'link rel="stylesheet" href="' + theme_url + '" type="text/css" />');
4694
+ themes_loaded.push(theme_url);
4695
+ }
4696
+ if(this._data.core.themes.name) {
4697
+ this.element.removeClass('jstree-' + this._data.core.themes.name);
4698
+ }
4699
+ this._data.core.themes.name = theme_name;
4700
+ this.element.addClass('jstree-' + theme_name);
4701
+ this.element[this.settings.core.themes.responsive ? 'addClass' : 'removeClass' ]('jstree-' + theme_name + '-responsive');
4702
+ /**
4703
+ * triggered when a theme is set
4704
+ * @event
4705
+ * @name set_theme.jstree
4706
+ * @param {String} theme the new theme
4707
+ */
4708
+ this.trigger('set_theme', { 'theme' : theme_name });
4709
+ },
4710
+ /**
4711
+ * gets the name of the currently applied theme name
4712
+ * @name get_theme()
4713
+ * @return {String}
4714
+ */
4715
+ get_theme : function () { return this._data.core.themes.name; },
4716
+ /**
4717
+ * changes the theme variant (if the theme has variants)
4718
+ * @name set_theme_variant(variant_name)
4719
+ * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed)
4720
+ */
4721
+ set_theme_variant : function (variant_name) {
4722
+ if(this._data.core.themes.variant) {
4723
+ this.element.removeClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant);
4724
+ }
4725
+ this._data.core.themes.variant = variant_name;
4726
+ if(variant_name) {
4727
+ this.element.addClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant);
4728
+ }
4729
+ },
4730
+ /**
4731
+ * gets the name of the currently applied theme variant
4732
+ * @name get_theme()
4733
+ * @return {String}
4734
+ */
4735
+ get_theme_variant : function () { return this._data.core.themes.variant; },
4736
+ /**
4737
+ * shows a striped background on the container (if the theme supports it)
4738
+ * @name show_stripes()
4739
+ */
4740
+ show_stripes : function () {
4741
+ this._data.core.themes.stripes = true;
4742
+ this.get_container_ul().addClass("jstree-striped");
4743
+ /**
4744
+ * triggered when stripes are shown
4745
+ * @event
4746
+ * @name show_stripes.jstree
4747
+ */
4748
+ this.trigger('show_stripes');
4749
+ },
4750
+ /**
4751
+ * hides the striped background on the container
4752
+ * @name hide_stripes()
4753
+ */
4754
+ hide_stripes : function () {
4755
+ this._data.core.themes.stripes = false;
4756
+ this.get_container_ul().removeClass("jstree-striped");
4757
+ /**
4758
+ * triggered when stripes are hidden
4759
+ * @event
4760
+ * @name hide_stripes.jstree
4761
+ */
4762
+ this.trigger('hide_stripes');
4763
+ },
4764
+ /**
4765
+ * toggles the striped background on the container
4766
+ * @name toggle_stripes()
4767
+ */
4768
+ toggle_stripes : function () { if(this._data.core.themes.stripes) { this.hide_stripes(); } else { this.show_stripes(); } },
4769
+ /**
4770
+ * shows the connecting dots (if the theme supports it)
4771
+ * @name show_dots()
4772
+ */
4773
+ show_dots : function () {
4774
+ this._data.core.themes.dots = true;
4775
+ this.get_container_ul().removeClass("jstree-no-dots");
4776
+ /**
4777
+ * triggered when dots are shown
4778
+ * @event
4779
+ * @name show_dots.jstree
4780
+ */
4781
+ this.trigger('show_dots');
4782
+ },
4783
+ /**
4784
+ * hides the connecting dots
4785
+ * @name hide_dots()
4786
+ */
4787
+ hide_dots : function () {
4788
+ this._data.core.themes.dots = false;
4789
+ this.get_container_ul().addClass("jstree-no-dots");
4790
+ /**
4791
+ * triggered when dots are hidden
4792
+ * @event
4793
+ * @name hide_dots.jstree
4794
+ */
4795
+ this.trigger('hide_dots');
4796
+ },
4797
+ /**
4798
+ * toggles the connecting dots
4799
+ * @name toggle_dots()
4800
+ */
4801
+ toggle_dots : function () { if(this._data.core.themes.dots) { this.hide_dots(); } else { this.show_dots(); } },
4802
+ /**
4803
+ * show the node icons
4804
+ * @name show_icons()
4805
+ */
4806
+ show_icons : function () {
4807
+ this._data.core.themes.icons = true;
4808
+ this.get_container_ul().removeClass("jstree-no-icons");
4809
+ /**
4810
+ * triggered when icons are shown
4811
+ * @event
4812
+ * @name show_icons.jstree
4813
+ */
4814
+ this.trigger('show_icons');
4815
+ },
4816
+ /**
4817
+ * hide the node icons
4818
+ * @name hide_icons()
4819
+ */
4820
+ hide_icons : function () {
4821
+ this._data.core.themes.icons = false;
4822
+ this.get_container_ul().addClass("jstree-no-icons");
4823
+ /**
4824
+ * triggered when icons are hidden
4825
+ * @event
4826
+ * @name hide_icons.jstree
4827
+ */
4828
+ this.trigger('hide_icons');
4829
+ },
4830
+ /**
4831
+ * toggle the node icons
4832
+ * @name toggle_icons()
4833
+ */
4834
+ toggle_icons : function () { if(this._data.core.themes.icons) { this.hide_icons(); } else { this.show_icons(); } },
4835
+ /**
4836
+ * show the node ellipsis
4837
+ * @name show_icons()
4838
+ */
4839
+ show_ellipsis : function () {
4840
+ this._data.core.themes.ellipsis = true;
4841
+ this.get_container_ul().addClass("jstree-ellipsis");
4842
+ /**
4843
+ * triggered when ellisis is shown
4844
+ * @event
4845
+ * @name show_ellipsis.jstree
4846
+ */
4847
+ this.trigger('show_ellipsis');
4848
+ },
4849
+ /**
4850
+ * hide the node ellipsis
4851
+ * @name hide_ellipsis()
4852
+ */
4853
+ hide_ellipsis : function () {
4854
+ this._data.core.themes.ellipsis = false;
4855
+ this.get_container_ul().removeClass("jstree-ellipsis");
4856
+ /**
4857
+ * triggered when ellisis is hidden
4858
+ * @event
4859
+ * @name hide_ellipsis.jstree
4860
+ */
4861
+ this.trigger('hide_ellipsis');
4862
+ },
4863
+ /**
4864
+ * toggle the node ellipsis
4865
+ * @name toggle_icons()
4866
+ */
4867
+ toggle_ellipsis : function () { if(this._data.core.themes.ellipsis) { this.hide_ellipsis(); } else { this.show_ellipsis(); } },
4868
+ /**
4869
+ * set the node icon for a node
4870
+ * @name set_icon(obj, icon)
4871
+ * @param {mixed} obj
4872
+ * @param {String} icon the new icon - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
4873
+ */
4874
+ set_icon : function (obj, icon) {
4875
+ var t1, t2, dom, old;
4876
+ if($.isArray(obj)) {
4877
+ obj = obj.slice();
4878
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4879
+ this.set_icon(obj[t1], icon);
4880
+ }
4881
+ return true;
4882
+ }
4883
+ obj = this.get_node(obj);
4884
+ if(!obj || obj.id === $.jstree.root) { return false; }
4885
+ old = obj.icon;
4886
+ obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon;
4887
+ dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon");
4888
+ if(icon === false) {
4889
+ dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
4890
+ this.hide_icon(obj);
4891
+ }
4892
+ else if(icon === true || icon === null || icon === undefined || icon === '') {
4893
+ dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
4894
+ if(old === false) { this.show_icon(obj); }
4895
+ }
4896
+ else if(icon.indexOf("/") === -1 && icon.indexOf(".") === -1) {
4897
+ dom.removeClass(old).css("background","");
4898
+ dom.addClass(icon + ' jstree-themeicon-custom').attr("rel",icon);
4899
+ if(old === false) { this.show_icon(obj); }
4900
+ }
4901
+ else {
4902
+ dom.removeClass(old).css("background","");
4903
+ dom.addClass('jstree-themeicon-custom').css("background", "url('" + icon + "') center center no-repeat").attr("rel",icon);
4904
+ if(old === false) { this.show_icon(obj); }
4905
+ }
4906
+ return true;
4907
+ },
4908
+ /**
4909
+ * get the node icon for a node
4910
+ * @name get_icon(obj)
4911
+ * @param {mixed} obj
4912
+ * @return {String}
4913
+ */
4914
+ get_icon : function (obj) {
4915
+ obj = this.get_node(obj);
4916
+ return (!obj || obj.id === $.jstree.root) ? false : obj.icon;
4917
+ },
4918
+ /**
4919
+ * hide the icon on an individual node
4920
+ * @name hide_icon(obj)
4921
+ * @param {mixed} obj
4922
+ */
4923
+ hide_icon : function (obj) {
4924
+ var t1, t2;
4925
+ if($.isArray(obj)) {
4926
+ obj = obj.slice();
4927
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4928
+ this.hide_icon(obj[t1]);
4929
+ }
4930
+ return true;
4931
+ }
4932
+ obj = this.get_node(obj);
4933
+ if(!obj || obj === $.jstree.root) { return false; }
4934
+ obj.icon = false;
4935
+ this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon").addClass('jstree-themeicon-hidden');
4936
+ return true;
4937
+ },
4938
+ /**
4939
+ * show the icon on an individual node
4940
+ * @name show_icon(obj)
4941
+ * @param {mixed} obj
4942
+ */
4943
+ show_icon : function (obj) {
4944
+ var t1, t2, dom;
4945
+ if($.isArray(obj)) {
4946
+ obj = obj.slice();
4947
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
4948
+ this.show_icon(obj[t1]);
4949
+ }
4950
+ return true;
4951
+ }
4952
+ obj = this.get_node(obj);
4953
+ if(!obj || obj === $.jstree.root) { return false; }
4954
+ dom = this.get_node(obj, true);
4955
+ obj.icon = dom.length ? dom.children(".jstree-anchor").children(".jstree-themeicon").attr('rel') : true;
4956
+ if(!obj.icon) { obj.icon = true; }
4957
+ dom.children(".jstree-anchor").children(".jstree-themeicon").removeClass('jstree-themeicon-hidden');
4958
+ return true;
4959
+ }
4960
+ };
4961
+
4962
+ // helpers
4963
+ $.vakata = {};
4964
+ // collect attributes
4965
+ $.vakata.attributes = function(node, with_values) {
4966
+ node = $(node)[0];
4967
+ var attr = with_values ? {} : [];
4968
+ if(node && node.attributes) {
4969
+ $.each(node.attributes, function (i, v) {
4970
+ if($.inArray(v.name.toLowerCase(),['style','contenteditable','hasfocus','tabindex']) !== -1) { return; }
4971
+ if(v.value !== null && $.trim(v.value) !== '') {
4972
+ if(with_values) { attr[v.name] = v.value; }
4973
+ else { attr.push(v.name); }
4974
+ }
4975
+ });
4976
+ }
4977
+ return attr;
4978
+ };
4979
+ $.vakata.array_unique = function(array) {
4980
+ var a = [], i, j, l, o = {};
4981
+ for(i = 0, l = array.length; i < l; i++) {
4982
+ if(o[array[i]] === undefined) {
4983
+ a.push(array[i]);
4984
+ o[array[i]] = true;
4985
+ }
4986
+ }
4987
+ return a;
4988
+ };
4989
+ // remove item from array
4990
+ $.vakata.array_remove = function(array, from) {
4991
+ array.splice(from, 1);
4992
+ return array;
4993
+ //var rest = array.slice((to || from) + 1 || array.length);
4994
+ //array.length = from < 0 ? array.length + from : from;
4995
+ //array.push.apply(array, rest);
4996
+ //return array;
4997
+ };
4998
+ // remove item from array
4999
+ $.vakata.array_remove_item = function(array, item) {
5000
+ var tmp = $.inArray(item, array);
5001
+ return tmp !== -1 ? $.vakata.array_remove(array, tmp) : array;
5002
+ };
5003
+ $.vakata.array_filter = function(c,a,b,d,e) {
5004
+ if (c.filter) {
5005
+ return c.filter(a, b);
5006
+ }
5007
+ d=[];
5008
+ for (e in c) {
5009
+ if (~~e+''===e+'' && e>=0 && a.call(b,c[e],+e,c)) {
5010
+ d.push(c[e]);
5011
+ }
5012
+ }
5013
+ return d;
5014
+ };
5015
+
5016
+
5017
+ /**
5018
+ * ### Changed plugin
5019
+ *
5020
+ * This plugin adds more information to the `changed.jstree` event. The new data is contained in the `changed` event data property, and contains a lists of `selected` and `deselected` nodes.
5021
+ */
5022
+
5023
+ $.jstree.plugins.changed = function (options, parent) {
5024
+ var last = [];
5025
+ this.trigger = function (ev, data) {
5026
+ var i, j;
5027
+ if(!data) {
5028
+ data = {};
5029
+ }
5030
+ if(ev.replace('.jstree','') === 'changed') {
5031
+ data.changed = { selected : [], deselected : [] };
5032
+ var tmp = {};
5033
+ for(i = 0, j = last.length; i < j; i++) {
5034
+ tmp[last[i]] = 1;
5035
+ }
5036
+ for(i = 0, j = data.selected.length; i < j; i++) {
5037
+ if(!tmp[data.selected[i]]) {
5038
+ data.changed.selected.push(data.selected[i]);
5039
+ }
5040
+ else {
5041
+ tmp[data.selected[i]] = 2;
5042
+ }
5043
+ }
5044
+ for(i = 0, j = last.length; i < j; i++) {
5045
+ if(tmp[last[i]] === 1) {
5046
+ data.changed.deselected.push(last[i]);
5047
+ }
5048
+ }
5049
+ last = data.selected.slice();
5050
+ }
5051
+ /**
5052
+ * triggered when selection changes (the "changed" plugin enhances the original event with more data)
5053
+ * @event
5054
+ * @name changed.jstree
5055
+ * @param {Object} node
5056
+ * @param {Object} action the action that caused the selection to change
5057
+ * @param {Array} selected the current selection
5058
+ * @param {Object} changed an object containing two properties `selected` and `deselected` - both arrays of node IDs, which were selected or deselected since the last changed event
5059
+ * @param {Object} event the event (if any) that triggered this changed event
5060
+ * @plugin changed
5061
+ */
5062
+ parent.trigger.call(this, ev, data);
5063
+ };
5064
+ this.refresh = function (skip_loading, forget_state) {
5065
+ last = [];
5066
+ return parent.refresh.apply(this, arguments);
5067
+ };
5068
+ };
5069
+
5070
+ /**
5071
+ * ### Checkbox plugin
5072
+ *
5073
+ * This plugin renders checkbox icons in front of each node, making multiple selection much easier.
5074
+ * It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up.
5075
+ */
5076
+
5077
+ var _i = document.createElement('I');
5078
+ _i.className = 'jstree-icon jstree-checkbox';
5079
+ _i.setAttribute('role', 'presentation');
5080
+ /**
5081
+ * stores all defaults for the checkbox plugin
5082
+ * @name $.jstree.defaults.checkbox
5083
+ * @plugin checkbox
5084
+ */
5085
+ $.jstree.defaults.checkbox = {
5086
+ /**
5087
+ * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`.
5088
+ * @name $.jstree.defaults.checkbox.visible
5089
+ * @plugin checkbox
5090
+ */
5091
+ visible : true,
5092
+ /**
5093
+ * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`.
5094
+ * @name $.jstree.defaults.checkbox.three_state
5095
+ * @plugin checkbox
5096
+ */
5097
+ three_state : true,
5098
+ /**
5099
+ * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`.
5100
+ * @name $.jstree.defaults.checkbox.whole_node
5101
+ * @plugin checkbox
5102
+ */
5103
+ whole_node : true,
5104
+ /**
5105
+ * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`.
5106
+ * @name $.jstree.defaults.checkbox.keep_selected_style
5107
+ * @plugin checkbox
5108
+ */
5109
+ keep_selected_style : true,
5110
+ /**
5111
+ * This setting controls how cascading and undetermined nodes are applied.
5112
+ * If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used.
5113
+ * If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''.
5114
+ * @name $.jstree.defaults.checkbox.cascade
5115
+ * @plugin checkbox
5116
+ */
5117
+ cascade : '',
5118
+ /**
5119
+ * This setting controls if checkbox are bound to the general tree selection or to an internal array maintained by the checkbox plugin. Defaults to `true`, only set to `false` if you know exactly what you are doing.
5120
+ * @name $.jstree.defaults.checkbox.tie_selection
5121
+ * @plugin checkbox
5122
+ */
5123
+ tie_selection : true,
5124
+
5125
+ /**
5126
+ * This setting controls if cascading down affects disabled checkboxes
5127
+ * @name $.jstree.defaults.checkbox.cascade_to_disabled
5128
+ * @plugin checkbox
5129
+ */
5130
+ cascade_to_disabled : true,
5131
+
5132
+ /**
5133
+ * This setting controls if cascading down affects hidden checkboxes
5134
+ * @name $.jstree.defaults.checkbox.cascade_to_hidden
5135
+ * @plugin checkbox
5136
+ */
5137
+ cascade_to_hidden : true
5138
+ };
5139
+ $.jstree.plugins.checkbox = function (options, parent) {
5140
+ this.bind = function () {
5141
+ parent.bind.call(this);
5142
+ this._data.checkbox.uto = false;
5143
+ this._data.checkbox.selected = [];
5144
+ if(this.settings.checkbox.three_state) {
5145
+ this.settings.checkbox.cascade = 'up+down+undetermined';
5146
+ }
5147
+ this.element
5148
+ .on("init.jstree", $.proxy(function () {
5149
+ this._data.checkbox.visible = this.settings.checkbox.visible;
5150
+ if(!this.settings.checkbox.keep_selected_style) {
5151
+ this.element.addClass('jstree-checkbox-no-clicked');
5152
+ }
5153
+ if(this.settings.checkbox.tie_selection) {
5154
+ this.element.addClass('jstree-checkbox-selection');
5155
+ }
5156
+ }, this))
5157
+ .on("loading.jstree", $.proxy(function () {
5158
+ this[ this._data.checkbox.visible ? 'show_checkboxes' : 'hide_checkboxes' ]();
5159
+ }, this));
5160
+ if(this.settings.checkbox.cascade.indexOf('undetermined') !== -1) {
5161
+ this.element
5162
+ .on('changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree', $.proxy(function () {
5163
+ // only if undetermined is in setting
5164
+ if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); }
5165
+ this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50);
5166
+ }, this));
5167
+ }
5168
+ if(!this.settings.checkbox.tie_selection) {
5169
+ this.element
5170
+ .on('model.jstree', $.proxy(function (e, data) {
5171
+ var m = this._model.data,
5172
+ p = m[data.parent],
5173
+ dpc = data.nodes,
5174
+ i, j;
5175
+ for(i = 0, j = dpc.length; i < j; i++) {
5176
+ m[dpc[i]].state.checked = m[dpc[i]].state.checked || (m[dpc[i]].original && m[dpc[i]].original.state && m[dpc[i]].original.state.checked);
5177
+ if(m[dpc[i]].state.checked) {
5178
+ this._data.checkbox.selected.push(dpc[i]);
5179
+ }
5180
+ }
5181
+ }, this));
5182
+ }
5183
+ if(this.settings.checkbox.cascade.indexOf('up') !== -1 || this.settings.checkbox.cascade.indexOf('down') !== -1) {
5184
+ this.element
5185
+ .on('model.jstree', $.proxy(function (e, data) {
5186
+ var m = this._model.data,
5187
+ p = m[data.parent],
5188
+ dpc = data.nodes,
5189
+ chd = [],
5190
+ c, i, j, k, l, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection;
5191
+
5192
+ if(s.indexOf('down') !== -1) {
5193
+ // apply down
5194
+ if(p.state[ t ? 'selected' : 'checked' ]) {
5195
+ for(i = 0, j = dpc.length; i < j; i++) {
5196
+ m[dpc[i]].state[ t ? 'selected' : 'checked' ] = true;
5197
+ }
5198
+
5199
+ this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(dpc);
5200
+ }
5201
+ else {
5202
+ for(i = 0, j = dpc.length; i < j; i++) {
5203
+ if(m[dpc[i]].state[ t ? 'selected' : 'checked' ]) {
5204
+ for(k = 0, l = m[dpc[i]].children_d.length; k < l; k++) {
5205
+ m[m[dpc[i]].children_d[k]].state[ t ? 'selected' : 'checked' ] = true;
5206
+ }
5207
+ this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(m[dpc[i]].children_d);
5208
+ }
5209
+ }
5210
+ }
5211
+ }
5212
+
5213
+ if(s.indexOf('up') !== -1) {
5214
+ // apply up
5215
+ for(i = 0, j = p.children_d.length; i < j; i++) {
5216
+ if(!m[p.children_d[i]].children.length) {
5217
+ chd.push(m[p.children_d[i]].parent);
5218
+ }
5219
+ }
5220
+ chd = $.vakata.array_unique(chd);
5221
+ for(k = 0, l = chd.length; k < l; k++) {
5222
+ p = m[chd[k]];
5223
+ while(p && p.id !== $.jstree.root) {
5224
+ c = 0;
5225
+ for(i = 0, j = p.children.length; i < j; i++) {
5226
+ c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5227
+ }
5228
+ if(c === j) {
5229
+ p.state[ t ? 'selected' : 'checked' ] = true;
5230
+ this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5231
+ tmp = this.get_node(p, true);
5232
+ if(tmp && tmp.length) {
5233
+ tmp.attr('aria-selected', true).children('.jstree-anchor').addClass( t ? 'jstree-clicked' : 'jstree-checked');
5234
+ }
5235
+ }
5236
+ else {
5237
+ break;
5238
+ }
5239
+ p = this.get_node(p.parent);
5240
+ }
5241
+ }
5242
+ }
5243
+
5244
+ this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected);
5245
+ }, this))
5246
+ .on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', $.proxy(function (e, data) {
5247
+ var self = this,
5248
+ obj = data.node,
5249
+ m = this._model.data,
5250
+ par = this.get_node(obj.parent),
5251
+ i, j, c, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection,
5252
+ sel = {}, cur = this._data[ t ? 'core' : 'checkbox' ].selected;
5253
+
5254
+ for (i = 0, j = cur.length; i < j; i++) {
5255
+ sel[cur[i]] = true;
5256
+ }
5257
+
5258
+ // apply down
5259
+ if(s.indexOf('down') !== -1) {
5260
+ //this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d));
5261
+ var selectedIds = this._cascade_new_checked_state(obj.id, true);
5262
+ var temp = obj.children_d.concat(obj.id);
5263
+ for (i = 0, j = temp.length; i < j; i++) {
5264
+ if (selectedIds.indexOf(temp[i]) > -1) {
5265
+ sel[temp[i]] = true;
5266
+ }
5267
+ else {
5268
+ delete sel[temp[i]];
5269
+ }
5270
+ }
5271
+ }
5272
+
5273
+ // apply up
5274
+ if(s.indexOf('up') !== -1) {
5275
+ while(par && par.id !== $.jstree.root) {
5276
+ c = 0;
5277
+ for(i = 0, j = par.children.length; i < j; i++) {
5278
+ c += m[par.children[i]].state[ t ? 'selected' : 'checked' ];
5279
+ }
5280
+ if(c === j) {
5281
+ par.state[ t ? 'selected' : 'checked' ] = true;
5282
+ sel[par.id] = true;
5283
+ //this._data[ t ? 'core' : 'checkbox' ].selected.push(par.id);
5284
+ tmp = this.get_node(par, true);
5285
+ if(tmp && tmp.length) {
5286
+ tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5287
+ }
5288
+ }
5289
+ else {
5290
+ break;
5291
+ }
5292
+ par = this.get_node(par.parent);
5293
+ }
5294
+ }
5295
+
5296
+ cur = [];
5297
+ for (i in sel) {
5298
+ if (sel.hasOwnProperty(i)) {
5299
+ cur.push(i);
5300
+ }
5301
+ }
5302
+ this._data[ t ? 'core' : 'checkbox' ].selected = cur;
5303
+ }, this))
5304
+ .on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', $.proxy(function (e, data) {
5305
+ var obj = this.get_node($.jstree.root),
5306
+ m = this._model.data,
5307
+ i, j, tmp;
5308
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
5309
+ tmp = m[obj.children_d[i]];
5310
+ if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) {
5311
+ tmp.original.state.undetermined = false;
5312
+ }
5313
+ }
5314
+ }, this))
5315
+ .on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', $.proxy(function (e, data) {
5316
+ var self = this,
5317
+ obj = data.node,
5318
+ dom = this.get_node(obj, true),
5319
+ i, j, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection,
5320
+ cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {},
5321
+ stillSelectedIds = [],
5322
+ allIds = obj.children_d.concat(obj.id);
5323
+
5324
+ // apply down
5325
+ if(s.indexOf('down') !== -1) {
5326
+ var selectedIds = this._cascade_new_checked_state(obj.id, false);
5327
+
5328
+ cur = $.vakata.array_filter(cur, function(id) {
5329
+ return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1;
5330
+ });
5331
+ }
5332
+
5333
+ // only apply up if cascade up is enabled and if this node is not selected
5334
+ // (if all child nodes are disabled and cascade_to_disabled === false then this node will till be selected).
5335
+ if(s.indexOf('up') !== -1 && cur.indexOf(obj.id) === -1) {
5336
+ for(i = 0, j = obj.parents.length; i < j; i++) {
5337
+ tmp = this._model.data[obj.parents[i]];
5338
+ tmp.state[ t ? 'selected' : 'checked' ] = false;
5339
+ if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) {
5340
+ tmp.original.state.undetermined = false;
5341
+ }
5342
+ tmp = this.get_node(obj.parents[i], true);
5343
+ if(tmp && tmp.length) {
5344
+ tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5345
+ }
5346
+ }
5347
+
5348
+ cur = $.vakata.array_filter(cur, function(id) {
5349
+ return obj.parents.indexOf(id) === -1;
5350
+ });
5351
+ }
5352
+
5353
+ this._data[ t ? 'core' : 'checkbox' ].selected = cur;
5354
+ }, this));
5355
+ }
5356
+ if(this.settings.checkbox.cascade.indexOf('up') !== -1) {
5357
+ this.element
5358
+ .on('delete_node.jstree', $.proxy(function (e, data) {
5359
+ // apply up (whole handler)
5360
+ var p = this.get_node(data.parent),
5361
+ m = this._model.data,
5362
+ i, j, c, tmp, t = this.settings.checkbox.tie_selection;
5363
+ while(p && p.id !== $.jstree.root && !p.state[ t ? 'selected' : 'checked' ]) {
5364
+ c = 0;
5365
+ for(i = 0, j = p.children.length; i < j; i++) {
5366
+ c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5367
+ }
5368
+ if(j > 0 && c === j) {
5369
+ p.state[ t ? 'selected' : 'checked' ] = true;
5370
+ this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5371
+ tmp = this.get_node(p, true);
5372
+ if(tmp && tmp.length) {
5373
+ tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5374
+ }
5375
+ }
5376
+ else {
5377
+ break;
5378
+ }
5379
+ p = this.get_node(p.parent);
5380
+ }
5381
+ }, this))
5382
+ .on('move_node.jstree', $.proxy(function (e, data) {
5383
+ // apply up (whole handler)
5384
+ var is_multi = data.is_multi,
5385
+ old_par = data.old_parent,
5386
+ new_par = this.get_node(data.parent),
5387
+ m = this._model.data,
5388
+ p, c, i, j, tmp, t = this.settings.checkbox.tie_selection;
5389
+ if(!is_multi) {
5390
+ p = this.get_node(old_par);
5391
+ while(p && p.id !== $.jstree.root && !p.state[ t ? 'selected' : 'checked' ]) {
5392
+ c = 0;
5393
+ for(i = 0, j = p.children.length; i < j; i++) {
5394
+ c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5395
+ }
5396
+ if(j > 0 && c === j) {
5397
+ p.state[ t ? 'selected' : 'checked' ] = true;
5398
+ this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5399
+ tmp = this.get_node(p, true);
5400
+ if(tmp && tmp.length) {
5401
+ tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5402
+ }
5403
+ }
5404
+ else {
5405
+ break;
5406
+ }
5407
+ p = this.get_node(p.parent);
5408
+ }
5409
+ }
5410
+ p = new_par;
5411
+ while(p && p.id !== $.jstree.root) {
5412
+ c = 0;
5413
+ for(i = 0, j = p.children.length; i < j; i++) {
5414
+ c += m[p.children[i]].state[ t ? 'selected' : 'checked' ];
5415
+ }
5416
+ if(c === j) {
5417
+ if(!p.state[ t ? 'selected' : 'checked' ]) {
5418
+ p.state[ t ? 'selected' : 'checked' ] = true;
5419
+ this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
5420
+ tmp = this.get_node(p, true);
5421
+ if(tmp && tmp.length) {
5422
+ tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5423
+ }
5424
+ }
5425
+ }
5426
+ else {
5427
+ if(p.state[ t ? 'selected' : 'checked' ]) {
5428
+ p.state[ t ? 'selected' : 'checked' ] = false;
5429
+ this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_remove_item(this._data[ t ? 'core' : 'checkbox' ].selected, p.id);
5430
+ tmp = this.get_node(p, true);
5431
+ if(tmp && tmp.length) {
5432
+ tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5433
+ }
5434
+ }
5435
+ else {
5436
+ break;
5437
+ }
5438
+ }
5439
+ p = this.get_node(p.parent);
5440
+ }
5441
+ }, this));
5442
+ }
5443
+ };
5444
+ /**
5445
+ * get an array of all nodes whose state is "undetermined"
5446
+ * @name get_undetermined([full])
5447
+ * @param {boolean} full: if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5448
+ * @return {Array}
5449
+ * @plugin checkbox
5450
+ */
5451
+ this.get_undetermined = function (full) {
5452
+ if (this.settings.checkbox.cascade.indexOf('undetermined') === -1) {
5453
+ return [];
5454
+ }
5455
+ var i, j, k, l, o = {}, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this, r = [];
5456
+ for(i = 0, j = s.length; i < j; i++) {
5457
+ if(m[s[i]] && m[s[i]].parents) {
5458
+ for(k = 0, l = m[s[i]].parents.length; k < l; k++) {
5459
+ if(o[m[s[i]].parents[k]] !== undefined) {
5460
+ break;
5461
+ }
5462
+ if(m[s[i]].parents[k] !== $.jstree.root) {
5463
+ o[m[s[i]].parents[k]] = true;
5464
+ p.push(m[s[i]].parents[k]);
5465
+ }
5466
+ }
5467
+ }
5468
+ }
5469
+ // attempt for server side undetermined state
5470
+ this.element.find('.jstree-closed').not(':has(.jstree-children)')
5471
+ .each(function () {
5472
+ var tmp = tt.get_node(this), tmp2;
5473
+
5474
+ if(!tmp) { return; }
5475
+
5476
+ if(!tmp.state.loaded) {
5477
+ if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) {
5478
+ if(o[tmp.id] === undefined && tmp.id !== $.jstree.root) {
5479
+ o[tmp.id] = true;
5480
+ p.push(tmp.id);
5481
+ }
5482
+ for(k = 0, l = tmp.parents.length; k < l; k++) {
5483
+ if(o[tmp.parents[k]] === undefined && tmp.parents[k] !== $.jstree.root) {
5484
+ o[tmp.parents[k]] = true;
5485
+ p.push(tmp.parents[k]);
5486
+ }
5487
+ }
5488
+ }
5489
+ }
5490
+ else {
5491
+ for(i = 0, j = tmp.children_d.length; i < j; i++) {
5492
+ tmp2 = m[tmp.children_d[i]];
5493
+ if(!tmp2.state.loaded && tmp2.original && tmp2.original.state && tmp2.original.state.undetermined && tmp2.original.state.undetermined === true) {
5494
+ if(o[tmp2.id] === undefined && tmp2.id !== $.jstree.root) {
5495
+ o[tmp2.id] = true;
5496
+ p.push(tmp2.id);
5497
+ }
5498
+ for(k = 0, l = tmp2.parents.length; k < l; k++) {
5499
+ if(o[tmp2.parents[k]] === undefined && tmp2.parents[k] !== $.jstree.root) {
5500
+ o[tmp2.parents[k]] = true;
5501
+ p.push(tmp2.parents[k]);
5502
+ }
5503
+ }
5504
+ }
5505
+ }
5506
+ }
5507
+ });
5508
+ for (i = 0, j = p.length; i < j; i++) {
5509
+ if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
5510
+ r.push(full ? m[p[i]] : p[i]);
5511
+ }
5512
+ }
5513
+ return r;
5514
+ };
5515
+ /**
5516
+ * set the undetermined state where and if necessary. Used internally.
5517
+ * @private
5518
+ * @name _undetermined()
5519
+ * @plugin checkbox
5520
+ */
5521
+ this._undetermined = function () {
5522
+ if(this.element === null) { return; }
5523
+ var p = this.get_undetermined(false), i, j, s;
5524
+
5525
+ this.element.find('.jstree-undetermined').removeClass('jstree-undetermined');
5526
+ for (i = 0, j = p.length; i < j; i++) {
5527
+ s = this.get_node(p[i], true);
5528
+ if(s && s.length) {
5529
+ s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
5530
+ }
5531
+ }
5532
+ };
5533
+ this.redraw_node = function(obj, deep, is_callback, force_render) {
5534
+ obj = parent.redraw_node.apply(this, arguments);
5535
+ if(obj) {
5536
+ var i, j, tmp = null, icon = null;
5537
+ for(i = 0, j = obj.childNodes.length; i < j; i++) {
5538
+ if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) {
5539
+ tmp = obj.childNodes[i];
5540
+ break;
5541
+ }
5542
+ }
5543
+ if(tmp) {
5544
+ if(!this.settings.checkbox.tie_selection && this._model.data[obj.id].state.checked) { tmp.className += ' jstree-checked'; }
5545
+ icon = _i.cloneNode(false);
5546
+ if(this._model.data[obj.id].state.checkbox_disabled) { icon.className += ' jstree-checkbox-disabled'; }
5547
+ tmp.insertBefore(icon, tmp.childNodes[0]);
5548
+ }
5549
+ }
5550
+ if(!is_callback && this.settings.checkbox.cascade.indexOf('undetermined') !== -1) {
5551
+ if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); }
5552
+ this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50);
5553
+ }
5554
+ return obj;
5555
+ };
5556
+ /**
5557
+ * show the node checkbox icons
5558
+ * @name show_checkboxes()
5559
+ * @plugin checkbox
5560
+ */
5561
+ this.show_checkboxes = function () { this._data.core.themes.checkboxes = true; this.get_container_ul().removeClass("jstree-no-checkboxes"); };
5562
+ /**
5563
+ * hide the node checkbox icons
5564
+ * @name hide_checkboxes()
5565
+ * @plugin checkbox
5566
+ */
5567
+ this.hide_checkboxes = function () { this._data.core.themes.checkboxes = false; this.get_container_ul().addClass("jstree-no-checkboxes"); };
5568
+ /**
5569
+ * toggle the node icons
5570
+ * @name toggle_checkboxes()
5571
+ * @plugin checkbox
5572
+ */
5573
+ this.toggle_checkboxes = function () { if(this._data.core.themes.checkboxes) { this.hide_checkboxes(); } else { this.show_checkboxes(); } };
5574
+ /**
5575
+ * checks if a node is in an undetermined state
5576
+ * @name is_undetermined(obj)
5577
+ * @param {mixed} obj
5578
+ * @return {Boolean}
5579
+ */
5580
+ this.is_undetermined = function (obj) {
5581
+ obj = this.get_node(obj);
5582
+ var s = this.settings.checkbox.cascade, i, j, t = this.settings.checkbox.tie_selection, d = this._data[ t ? 'core' : 'checkbox' ].selected, m = this._model.data;
5583
+ if(!obj || obj.state[ t ? 'selected' : 'checked' ] === true || s.indexOf('undetermined') === -1 || (s.indexOf('down') === -1 && s.indexOf('up') === -1)) {
5584
+ return false;
5585
+ }
5586
+ if(!obj.state.loaded && obj.original.state.undetermined === true) {
5587
+ return true;
5588
+ }
5589
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
5590
+ if($.inArray(obj.children_d[i], d) !== -1 || (!m[obj.children_d[i]].state.loaded && m[obj.children_d[i]].original.state.undetermined)) {
5591
+ return true;
5592
+ }
5593
+ }
5594
+ return false;
5595
+ };
5596
+ /**
5597
+ * disable a node's checkbox
5598
+ * @name disable_checkbox(obj)
5599
+ * @param {mixed} obj an array can be used too
5600
+ * @trigger disable_checkbox.jstree
5601
+ * @plugin checkbox
5602
+ */
5603
+ this.disable_checkbox = function (obj) {
5604
+ var t1, t2, dom;
5605
+ if($.isArray(obj)) {
5606
+ obj = obj.slice();
5607
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5608
+ this.disable_checkbox(obj[t1]);
5609
+ }
5610
+ return true;
5611
+ }
5612
+ obj = this.get_node(obj);
5613
+ if(!obj || obj.id === $.jstree.root) {
5614
+ return false;
5615
+ }
5616
+ dom = this.get_node(obj, true);
5617
+ if(!obj.state.checkbox_disabled) {
5618
+ obj.state.checkbox_disabled = true;
5619
+ if(dom && dom.length) {
5620
+ dom.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-checkbox-disabled');
5621
+ }
5622
+ /**
5623
+ * triggered when an node's checkbox is disabled
5624
+ * @event
5625
+ * @name disable_checkbox.jstree
5626
+ * @param {Object} node
5627
+ * @plugin checkbox
5628
+ */
5629
+ this.trigger('disable_checkbox', { 'node' : obj });
5630
+ }
5631
+ };
5632
+ /**
5633
+ * enable a node's checkbox
5634
+ * @name enable_checkbox(obj)
5635
+ * @param {mixed} obj an array can be used too
5636
+ * @trigger enable_checkbox.jstree
5637
+ * @plugin checkbox
5638
+ */
5639
+ this.enable_checkbox = function (obj) {
5640
+ var t1, t2, dom;
5641
+ if($.isArray(obj)) {
5642
+ obj = obj.slice();
5643
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5644
+ this.enable_checkbox(obj[t1]);
5645
+ }
5646
+ return true;
5647
+ }
5648
+ obj = this.get_node(obj);
5649
+ if(!obj || obj.id === $.jstree.root) {
5650
+ return false;
5651
+ }
5652
+ dom = this.get_node(obj, true);
5653
+ if(obj.state.checkbox_disabled) {
5654
+ obj.state.checkbox_disabled = false;
5655
+ if(dom && dom.length) {
5656
+ dom.children('.jstree-anchor').children('.jstree-checkbox').removeClass('jstree-checkbox-disabled');
5657
+ }
5658
+ /**
5659
+ * triggered when an node's checkbox is enabled
5660
+ * @event
5661
+ * @name enable_checkbox.jstree
5662
+ * @param {Object} node
5663
+ * @plugin checkbox
5664
+ */
5665
+ this.trigger('enable_checkbox', { 'node' : obj });
5666
+ }
5667
+ };
5668
+
5669
+ this.activate_node = function (obj, e) {
5670
+ if($(e.target).hasClass('jstree-checkbox-disabled')) {
5671
+ return false;
5672
+ }
5673
+ if(this.settings.checkbox.tie_selection && (this.settings.checkbox.whole_node || $(e.target).hasClass('jstree-checkbox'))) {
5674
+ e.ctrlKey = true;
5675
+ }
5676
+ if(this.settings.checkbox.tie_selection || (!this.settings.checkbox.whole_node && !$(e.target).hasClass('jstree-checkbox'))) {
5677
+ return parent.activate_node.call(this, obj, e);
5678
+ }
5679
+ if(this.is_disabled(obj)) {
5680
+ return false;
5681
+ }
5682
+ if(this.is_checked(obj)) {
5683
+ this.uncheck_node(obj, e);
5684
+ }
5685
+ else {
5686
+ this.check_node(obj, e);
5687
+ }
5688
+ this.trigger('activate_node', { 'node' : this.get_node(obj) });
5689
+ };
5690
+
5691
+ /**
5692
+ * Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
5693
+ * However if these unaffected nodes are already selected their ids will be included in the returned array.
5694
+ * @private
5695
+ * @param {string} id the node ID
5696
+ * @param {bool} checkedState should the nodes be checked or not
5697
+ * @returns {Array} Array of all node id's (in this tree branch) that are checked.
5698
+ */
5699
+ this._cascade_new_checked_state = function (id, checkedState) {
5700
+ var self = this;
5701
+ var t = this.settings.checkbox.tie_selection;
5702
+ var node = this._model.data[id];
5703
+ var selectedNodeIds = [];
5704
+ var selectedChildrenIds = [], i, j, selectedChildIds;
5705
+
5706
+ if (
5707
+ (this.settings.checkbox.cascade_to_disabled || !node.state.disabled) &&
5708
+ (this.settings.checkbox.cascade_to_hidden || !node.state.hidden)
5709
+ ) {
5710
+ //First try and check/uncheck the children
5711
+ if (node.children) {
5712
+ for (i = 0, j = node.children.length; i < j; i++) {
5713
+ var childId = node.children[i];
5714
+ selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
5715
+ selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5716
+ if (selectedChildIds.indexOf(childId) > -1) {
5717
+ selectedChildrenIds.push(childId);
5718
+ }
5719
+ }
5720
+ }
5721
+
5722
+ var dom = self.get_node(node, true);
5723
+
5724
+ //A node's state is undetermined if some but not all of it's children are checked/selected .
5725
+ var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length;
5726
+
5727
+ if(node.original && node.original.state && node.original.state.undetermined) {
5728
+ node.original.state.undetermined = undetermined;
5729
+ }
5730
+
5731
+ //If a node is undetermined then remove selected class
5732
+ if (undetermined) {
5733
+ node.state[ t ? 'selected' : 'checked' ] = false;
5734
+ dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5735
+ }
5736
+ //Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children),
5737
+ //check the node and style it correctly.
5738
+ else if (checkedState && selectedChildrenIds.length === node.children.length) {
5739
+ node.state[ t ? 'selected' : 'checked' ] = checkedState;
5740
+ selectedNodeIds.push(node.id);
5741
+
5742
+ dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5743
+ }
5744
+ else {
5745
+ node.state[ t ? 'selected' : 'checked' ] = false;
5746
+ dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5747
+ }
5748
+ }
5749
+ else {
5750
+ selectedChildIds = this.get_checked_descendants(id);
5751
+
5752
+ if (node.state[ t ? 'selected' : 'checked' ]) {
5753
+ selectedChildIds.push(node.id);
5754
+ }
5755
+
5756
+ selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5757
+ }
5758
+
5759
+ return selectedNodeIds;
5760
+ };
5761
+
5762
+ /**
5763
+ * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id)
5764
+ * @name get_checked_descendants(obj)
5765
+ * @param {string} id the node ID
5766
+ * @return {Array} array of IDs
5767
+ * @plugin checkbox
5768
+ */
5769
+ this.get_checked_descendants = function (id) {
5770
+ var self = this;
5771
+ var t = self.settings.checkbox.tie_selection;
5772
+ var node = self._model.data[id];
5773
+
5774
+ return $.vakata.array_filter(node.children_d, function(_id) {
5775
+ return self._model.data[_id].state[ t ? 'selected' : 'checked' ];
5776
+ });
5777
+ };
5778
+
5779
+ /**
5780
+ * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally)
5781
+ * @name check_node(obj)
5782
+ * @param {mixed} obj an array can be used to check multiple nodes
5783
+ * @trigger check_node.jstree
5784
+ * @plugin checkbox
5785
+ */
5786
+ this.check_node = function (obj, e) {
5787
+ if(this.settings.checkbox.tie_selection) { return this.select_node(obj, false, true, e); }
5788
+ var dom, t1, t2, th;
5789
+ if($.isArray(obj)) {
5790
+ obj = obj.slice();
5791
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5792
+ this.check_node(obj[t1], e);
5793
+ }
5794
+ return true;
5795
+ }
5796
+ obj = this.get_node(obj);
5797
+ if(!obj || obj.id === $.jstree.root) {
5798
+ return false;
5799
+ }
5800
+ dom = this.get_node(obj, true);
5801
+ if(!obj.state.checked) {
5802
+ obj.state.checked = true;
5803
+ this._data.checkbox.selected.push(obj.id);
5804
+ if(dom && dom.length) {
5805
+ dom.children('.jstree-anchor').addClass('jstree-checked');
5806
+ }
5807
+ /**
5808
+ * triggered when an node is checked (only if tie_selection in checkbox settings is false)
5809
+ * @event
5810
+ * @name check_node.jstree
5811
+ * @param {Object} node
5812
+ * @param {Array} selected the current selection
5813
+ * @param {Object} event the event (if any) that triggered this check_node
5814
+ * @plugin checkbox
5815
+ */
5816
+ this.trigger('check_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e });
5817
+ }
5818
+ };
5819
+ /**
5820
+ * uncheck a node (only if tie_selection in checkbox settings is false, otherwise deselect_node will be called internally)
5821
+ * @name uncheck_node(obj)
5822
+ * @param {mixed} obj an array can be used to uncheck multiple nodes
5823
+ * @trigger uncheck_node.jstree
5824
+ * @plugin checkbox
5825
+ */
5826
+ this.uncheck_node = function (obj, e) {
5827
+ if(this.settings.checkbox.tie_selection) { return this.deselect_node(obj, false, e); }
5828
+ var t1, t2, dom;
5829
+ if($.isArray(obj)) {
5830
+ obj = obj.slice();
5831
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
5832
+ this.uncheck_node(obj[t1], e);
5833
+ }
5834
+ return true;
5835
+ }
5836
+ obj = this.get_node(obj);
5837
+ if(!obj || obj.id === $.jstree.root) {
5838
+ return false;
5839
+ }
5840
+ dom = this.get_node(obj, true);
5841
+ if(obj.state.checked) {
5842
+ obj.state.checked = false;
5843
+ this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, obj.id);
5844
+ if(dom.length) {
5845
+ dom.children('.jstree-anchor').removeClass('jstree-checked');
5846
+ }
5847
+ /**
5848
+ * triggered when an node is unchecked (only if tie_selection in checkbox settings is false)
5849
+ * @event
5850
+ * @name uncheck_node.jstree
5851
+ * @param {Object} node
5852
+ * @param {Array} selected the current selection
5853
+ * @param {Object} event the event (if any) that triggered this uncheck_node
5854
+ * @plugin checkbox
5855
+ */
5856
+ this.trigger('uncheck_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e });
5857
+ }
5858
+ };
5859
+
5860
+ /**
5861
+ * checks all nodes in the tree (only if tie_selection in checkbox settings is false, otherwise select_all will be called internally)
5862
+ * @name check_all()
5863
+ * @trigger check_all.jstree, changed.jstree
5864
+ * @plugin checkbox
5865
+ */
5866
+ this.check_all = function () {
5867
+ if(this.settings.checkbox.tie_selection) { return this.select_all(); }
5868
+ var tmp = this._data.checkbox.selected.concat([]), i, j;
5869
+ this._data.checkbox.selected = this._model.data[$.jstree.root].children_d.concat();
5870
+ for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) {
5871
+ if(this._model.data[this._data.checkbox.selected[i]]) {
5872
+ this._model.data[this._data.checkbox.selected[i]].state.checked = true;
5873
+ }
5874
+ }
5875
+ this.redraw(true);
5876
+ /**
5877
+ * triggered when all nodes are checked (only if tie_selection in checkbox settings is false)
5878
+ * @event
5879
+ * @name check_all.jstree
5880
+ * @param {Array} selected the current selection
5881
+ * @plugin checkbox
5882
+ */
5883
+ this.trigger('check_all', { 'selected' : this._data.checkbox.selected });
5884
+ };
5885
+ /**
5886
+ * uncheck all checked nodes (only if tie_selection in checkbox settings is false, otherwise deselect_all will be called internally)
5887
+ * @name uncheck_all()
5888
+ * @trigger uncheck_all.jstree
5889
+ * @plugin checkbox
5890
+ */
5891
+ this.uncheck_all = function () {
5892
+ if(this.settings.checkbox.tie_selection) { return this.deselect_all(); }
5893
+ var tmp = this._data.checkbox.selected.concat([]), i, j;
5894
+ for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) {
5895
+ if(this._model.data[this._data.checkbox.selected[i]]) {
5896
+ this._model.data[this._data.checkbox.selected[i]].state.checked = false;
5897
+ }
5898
+ }
5899
+ this._data.checkbox.selected = [];
5900
+ this.element.find('.jstree-checked').removeClass('jstree-checked');
5901
+ /**
5902
+ * triggered when all nodes are unchecked (only if tie_selection in checkbox settings is false)
5903
+ * @event
5904
+ * @name uncheck_all.jstree
5905
+ * @param {Object} node the previous selection
5906
+ * @param {Array} selected the current selection
5907
+ * @plugin checkbox
5908
+ */
5909
+ this.trigger('uncheck_all', { 'selected' : this._data.checkbox.selected, 'node' : tmp });
5910
+ };
5911
+ /**
5912
+ * checks if a node is checked (if tie_selection is on in the settings this function will return the same as is_selected)
5913
+ * @name is_checked(obj)
5914
+ * @param {mixed} obj
5915
+ * @return {Boolean}
5916
+ * @plugin checkbox
5917
+ */
5918
+ this.is_checked = function (obj) {
5919
+ if(this.settings.checkbox.tie_selection) { return this.is_selected(obj); }
5920
+ obj = this.get_node(obj);
5921
+ if(!obj || obj.id === $.jstree.root) { return false; }
5922
+ return obj.state.checked;
5923
+ };
5924
+ /**
5925
+ * get an array of all checked nodes (if tie_selection is on in the settings this function will return the same as get_selected)
5926
+ * @name get_checked([full])
5927
+ * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5928
+ * @return {Array}
5929
+ * @plugin checkbox
5930
+ */
5931
+ this.get_checked = function (full) {
5932
+ if(this.settings.checkbox.tie_selection) { return this.get_selected(full); }
5933
+ return full ? $.map(this._data.checkbox.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.checkbox.selected.slice();
5934
+ };
5935
+ /**
5936
+ * get an array of all top level checked nodes (ignoring children of checked nodes) (if tie_selection is on in the settings this function will return the same as get_top_selected)
5937
+ * @name get_top_checked([full])
5938
+ * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5939
+ * @return {Array}
5940
+ * @plugin checkbox
5941
+ */
5942
+ this.get_top_checked = function (full) {
5943
+ if(this.settings.checkbox.tie_selection) { return this.get_top_selected(full); }
5944
+ var tmp = this.get_checked(true),
5945
+ obj = {}, i, j, k, l;
5946
+ for(i = 0, j = tmp.length; i < j; i++) {
5947
+ obj[tmp[i].id] = tmp[i];
5948
+ }
5949
+ for(i = 0, j = tmp.length; i < j; i++) {
5950
+ for(k = 0, l = tmp[i].children_d.length; k < l; k++) {
5951
+ if(obj[tmp[i].children_d[k]]) {
5952
+ delete obj[tmp[i].children_d[k]];
5953
+ }
5954
+ }
5955
+ }
5956
+ tmp = [];
5957
+ for(i in obj) {
5958
+ if(obj.hasOwnProperty(i)) {
5959
+ tmp.push(i);
5960
+ }
5961
+ }
5962
+ return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp;
5963
+ };
5964
+ /**
5965
+ * get an array of all bottom level checked nodes (ignoring selected parents) (if tie_selection is on in the settings this function will return the same as get_bottom_selected)
5966
+ * @name get_bottom_checked([full])
5967
+ * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5968
+ * @return {Array}
5969
+ * @plugin checkbox
5970
+ */
5971
+ this.get_bottom_checked = function (full) {
5972
+ if(this.settings.checkbox.tie_selection) { return this.get_bottom_selected(full); }
5973
+ var tmp = this.get_checked(true),
5974
+ obj = [], i, j;
5975
+ for(i = 0, j = tmp.length; i < j; i++) {
5976
+ if(!tmp[i].children.length) {
5977
+ obj.push(tmp[i].id);
5978
+ }
5979
+ }
5980
+ return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj;
5981
+ };
5982
+ this.load_node = function (obj, callback) {
5983
+ var k, l, i, j, c, tmp;
5984
+ if(!$.isArray(obj) && !this.settings.checkbox.tie_selection) {
5985
+ tmp = this.get_node(obj);
5986
+ if(tmp && tmp.state.loaded) {
5987
+ for(k = 0, l = tmp.children_d.length; k < l; k++) {
5988
+ if(this._model.data[tmp.children_d[k]].state.checked) {
5989
+ c = true;
5990
+ this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, tmp.children_d[k]);
5991
+ }
5992
+ }
5993
+ }
5994
+ }
5995
+ return parent.load_node.apply(this, arguments);
5996
+ };
5997
+ this.get_state = function () {
5998
+ var state = parent.get_state.apply(this, arguments);
5999
+ if(this.settings.checkbox.tie_selection) { return state; }
6000
+ state.checkbox = this._data.checkbox.selected.slice();
6001
+ return state;
6002
+ };
6003
+ this.set_state = function (state, callback) {
6004
+ var res = parent.set_state.apply(this, arguments);
6005
+ if(res && state.checkbox) {
6006
+ if(!this.settings.checkbox.tie_selection) {
6007
+ this.uncheck_all();
6008
+ var _this = this;
6009
+ $.each(state.checkbox, function (i, v) {
6010
+ _this.check_node(v);
6011
+ });
6012
+ }
6013
+ delete state.checkbox;
6014
+ this.set_state(state, callback);
6015
+ return false;
6016
+ }
6017
+ return res;
6018
+ };
6019
+ this.refresh = function (skip_loading, forget_state) {
6020
+ if(this.settings.checkbox.tie_selection) {
6021
+ this._data.checkbox.selected = [];
6022
+ }
6023
+ return parent.refresh.apply(this, arguments);
6024
+ };
6025
+ };
6026
+
6027
+ // include the checkbox plugin by default
6028
+ // $.jstree.defaults.plugins.push("checkbox");
6029
+
6030
+
6031
+ /**
6032
+ * ### Conditionalselect plugin
6033
+ *
6034
+ * This plugin allows defining a callback to allow or deny node selection by user input (activate node method).
6035
+ */
6036
+
6037
+ /**
6038
+ * a callback (function) which is invoked in the instance's scope and receives two arguments - the node and the event that triggered the `activate_node` call. Returning false prevents working with the node, returning true allows invoking activate_node. Defaults to returning `true`.
6039
+ * @name $.jstree.defaults.checkbox.visible
6040
+ * @plugin checkbox
6041
+ */
6042
+ $.jstree.defaults.conditionalselect = function () { return true; };
6043
+ $.jstree.plugins.conditionalselect = function (options, parent) {
6044
+ // own function
6045
+ this.activate_node = function (obj, e) {
6046
+ if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) {
6047
+ return parent.activate_node.call(this, obj, e);
6048
+ }
6049
+ };
6050
+ };
6051
+
6052
+
6053
+ /**
6054
+ * ### Contextmenu plugin
6055
+ *
6056
+ * Shows a context menu when a node is right-clicked.
6057
+ */
6058
+
6059
+ /**
6060
+ * stores all defaults for the contextmenu plugin
6061
+ * @name $.jstree.defaults.contextmenu
6062
+ * @plugin contextmenu
6063
+ */
6064
+ $.jstree.defaults.contextmenu = {
6065
+ /**
6066
+ * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`.
6067
+ * @name $.jstree.defaults.contextmenu.select_node
6068
+ * @plugin contextmenu
6069
+ */
6070
+ select_node : true,
6071
+ /**
6072
+ * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used.
6073
+ * @name $.jstree.defaults.contextmenu.show_at_node
6074
+ * @plugin contextmenu
6075
+ */
6076
+ show_at_node : true,
6077
+ /**
6078
+ * an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too).
6079
+ *
6080
+ * Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required). Once a menu item is activated the `action` function will be invoked with an object containing the following keys: item - the contextmenu item definition as seen below, reference - the DOM node that was used (the tree node), element - the contextmenu DOM element, position - an object with x/y properties indicating the position of the menu.
6081
+ *
6082
+ * * `separator_before` - a boolean indicating if there should be a separator before this item
6083
+ * * `separator_after` - a boolean indicating if there should be a separator after this item
6084
+ * * `_disabled` - a boolean indicating if this action should be disabled
6085
+ * * `label` - a string - the name of the action (could be a function returning a string)
6086
+ * * `title` - a string - an optional tooltip for the item
6087
+ * * `action` - a function to be executed if this item is chosen, the function will receive
6088
+ * * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
6089
+ * * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2)
6090
+ * * `shortcut_label` - shortcut label (like for example `F2` for rename)
6091
+ * * `submenu` - an object with the same structure as $.jstree.defaults.contextmenu.items which can be used to create a submenu - each key will be rendered as a separate option in a submenu that will appear once the current item is hovered
6092
+ *
6093
+ * @name $.jstree.defaults.contextmenu.items
6094
+ * @plugin contextmenu
6095
+ */
6096
+ items : function (o, cb) { // Could be an object directly
6097
+ return {
6098
+ "create" : {
6099
+ "separator_before" : false,
6100
+ "separator_after" : true,
6101
+ "_disabled" : false, //(this.check("create_node", data.reference, {}, "last")),
6102
+ "label" : "Create",
6103
+ "action" : function (data) {
6104
+ var inst = $.jstree.reference(data.reference),
6105
+ obj = inst.get_node(data.reference);
6106
+ inst.create_node(obj, {}, "last", function (new_node) {
6107
+ try {
6108
+ inst.edit(new_node);
6109
+ } catch (ex) {
6110
+ setTimeout(function () { inst.edit(new_node); },0);
6111
+ }
6112
+ });
6113
+ }
6114
+ },
6115
+ "rename" : {
6116
+ "separator_before" : false,
6117
+ "separator_after" : false,
6118
+ "_disabled" : false, //(this.check("rename_node", data.reference, this.get_parent(data.reference), "")),
6119
+ "label" : "Rename",
6120
+ /*!
6121
+ "shortcut" : 113,
6122
+ "shortcut_label" : 'F2',
6123
+ "icon" : "glyphicon glyphicon-leaf",
6124
+ */
6125
+ "action" : function (data) {
6126
+ var inst = $.jstree.reference(data.reference),
6127
+ obj = inst.get_node(data.reference);
6128
+ inst.edit(obj);
6129
+ }
6130
+ },
6131
+ "remove" : {
6132
+ "separator_before" : false,
6133
+ "icon" : false,
6134
+ "separator_after" : false,
6135
+ "_disabled" : false, //(this.check("delete_node", data.reference, this.get_parent(data.reference), "")),
6136
+ "label" : "Delete",
6137
+ "action" : function (data) {
6138
+ var inst = $.jstree.reference(data.reference),
6139
+ obj = inst.get_node(data.reference);
6140
+ if(inst.is_selected(obj)) {
6141
+ inst.delete_node(inst.get_selected());
6142
+ }
6143
+ else {
6144
+ inst.delete_node(obj);
6145
+ }
6146
+ }
6147
+ },
6148
+ "ccp" : {
6149
+ "separator_before" : true,
6150
+ "icon" : false,
6151
+ "separator_after" : false,
6152
+ "label" : "Edit",
6153
+ "action" : false,
6154
+ "submenu" : {
6155
+ "cut" : {
6156
+ "separator_before" : false,
6157
+ "separator_after" : false,
6158
+ "label" : "Cut",
6159
+ "action" : function (data) {
6160
+ var inst = $.jstree.reference(data.reference),
6161
+ obj = inst.get_node(data.reference);
6162
+ if(inst.is_selected(obj)) {
6163
+ inst.cut(inst.get_top_selected());
6164
+ }
6165
+ else {
6166
+ inst.cut(obj);
6167
+ }
6168
+ }
6169
+ },
6170
+ "copy" : {
6171
+ "separator_before" : false,
6172
+ "icon" : false,
6173
+ "separator_after" : false,
6174
+ "label" : "Copy",
6175
+ "action" : function (data) {
6176
+ var inst = $.jstree.reference(data.reference),
6177
+ obj = inst.get_node(data.reference);
6178
+ if(inst.is_selected(obj)) {
6179
+ inst.copy(inst.get_top_selected());
6180
+ }
6181
+ else {
6182
+ inst.copy(obj);
6183
+ }
6184
+ }
6185
+ },
6186
+ "paste" : {
6187
+ "separator_before" : false,
6188
+ "icon" : false,
6189
+ "_disabled" : function (data) {
6190
+ return !$.jstree.reference(data.reference).can_paste();
6191
+ },
6192
+ "separator_after" : false,
6193
+ "label" : "Paste",
6194
+ "action" : function (data) {
6195
+ var inst = $.jstree.reference(data.reference),
6196
+ obj = inst.get_node(data.reference);
6197
+ inst.paste(obj);
6198
+ }
6199
+ }
6200
+ }
6201
+ }
6202
+ };
6203
+ }
6204
+ };
6205
+
6206
+ $.jstree.plugins.contextmenu = function (options, parent) {
6207
+ this.bind = function () {
6208
+ parent.bind.call(this);
6209
+
6210
+ var last_ts = 0, cto = null, ex, ey;
6211
+ this.element
6212
+ .on("init.jstree loading.jstree ready.jstree", $.proxy(function () {
6213
+ this.get_container_ul().addClass('jstree-contextmenu');
6214
+ }, this))
6215
+ .on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) {
6216
+ if (e.target.tagName.toLowerCase() === 'input') {
6217
+ return;
6218
+ }
6219
+ e.preventDefault();
6220
+ last_ts = e.ctrlKey ? +new Date() : 0;
6221
+ if(data || cto) {
6222
+ last_ts = (+new Date()) + 10000;
6223
+ }
6224
+ if(cto) {
6225
+ clearTimeout(cto);
6226
+ }
6227
+ if(!this.is_loading(e.currentTarget)) {
6228
+ this.show_contextmenu(e.currentTarget, e.pageX, e.pageY, e);
6229
+ }
6230
+ }, this))
6231
+ .on("click.jstree", ".jstree-anchor", $.proxy(function (e) {
6232
+ if(this._data.contextmenu.visible && (!last_ts || (+new Date()) - last_ts > 250)) { // work around safari & macOS ctrl+click
6233
+ $.vakata.context.hide();
6234
+ }
6235
+ last_ts = 0;
6236
+ }, this))
6237
+ .on("touchstart.jstree", ".jstree-anchor", function (e) {
6238
+ if(!e.originalEvent || !e.originalEvent.changedTouches || !e.originalEvent.changedTouches[0]) {
6239
+ return;
6240
+ }
6241
+ ex = e.originalEvent.changedTouches[0].clientX;
6242
+ ey = e.originalEvent.changedTouches[0].clientY;
6243
+ cto = setTimeout(function () {
6244
+ $(e.currentTarget).trigger('contextmenu', true);
6245
+ }, 750);
6246
+ })
6247
+ .on('touchmove.vakata.jstree', function (e) {
6248
+ if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) > 10 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 10)) {
6249
+ clearTimeout(cto);
6250
+ $.vakata.context.hide();
6251
+ }
6252
+ })
6253
+ .on('touchend.vakata.jstree', function (e) {
6254
+ if(cto) {
6255
+ clearTimeout(cto);
6256
+ }
6257
+ });
6258
+
6259
+ /*!
6260
+ if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) {
6261
+ var el = null, tm = null;
6262
+ this.element
6263
+ .on("touchstart", ".jstree-anchor", function (e) {
6264
+ el = e.currentTarget;
6265
+ tm = +new Date();
6266
+ $(document).one("touchend", function (e) {
6267
+ e.target = document.elementFromPoint(e.originalEvent.targetTouches[0].pageX - window.pageXOffset, e.originalEvent.targetTouches[0].pageY - window.pageYOffset);
6268
+ e.currentTarget = e.target;
6269
+ tm = ((+(new Date())) - tm);
6270
+ if(e.target === el && tm > 600 && tm < 1000) {
6271
+ e.preventDefault();
6272
+ $(el).trigger('contextmenu', e);
6273
+ }
6274
+ el = null;
6275
+ tm = null;
6276
+ });
6277
+ });
6278
+ }
6279
+ */
6280
+ $(document).on("context_hide.vakata.jstree", $.proxy(function (e, data) {
6281
+ this._data.contextmenu.visible = false;
6282
+ $(data.reference).removeClass('jstree-context');
6283
+ }, this));
6284
+ };
6285
+ this.teardown = function () {
6286
+ if(this._data.contextmenu.visible) {
6287
+ $.vakata.context.hide();
6288
+ }
6289
+ parent.teardown.call(this);
6290
+ };
6291
+
6292
+ /**
6293
+ * prepare and show the context menu for a node
6294
+ * @name show_contextmenu(obj [, x, y])
6295
+ * @param {mixed} obj the node
6296
+ * @param {Number} x the x-coordinate relative to the document to show the menu at
6297
+ * @param {Number} y the y-coordinate relative to the document to show the menu at
6298
+ * @param {Object} e the event if available that triggered the contextmenu
6299
+ * @plugin contextmenu
6300
+ * @trigger show_contextmenu.jstree
6301
+ */
6302
+ this.show_contextmenu = function (obj, x, y, e) {
6303
+ obj = this.get_node(obj);
6304
+ if(!obj || obj.id === $.jstree.root) { return false; }
6305
+ var s = this.settings.contextmenu,
6306
+ d = this.get_node(obj, true),
6307
+ a = d.children(".jstree-anchor"),
6308
+ o = false,
6309
+ i = false;
6310
+ if(s.show_at_node || x === undefined || y === undefined) {
6311
+ o = a.offset();
6312
+ x = o.left;
6313
+ y = o.top + this._data.core.li_height;
6314
+ }
6315
+ if(this.settings.contextmenu.select_node && !this.is_selected(obj)) {
6316
+ this.activate_node(obj, e);
6317
+ }
6318
+
6319
+ i = s.items;
6320
+ if($.isFunction(i)) {
6321
+ i = i.call(this, obj, $.proxy(function (i) {
6322
+ this._show_contextmenu(obj, x, y, i);
6323
+ }, this));
6324
+ }
6325
+ if($.isPlainObject(i)) {
6326
+ this._show_contextmenu(obj, x, y, i);
6327
+ }
6328
+ };
6329
+ /**
6330
+ * show the prepared context menu for a node
6331
+ * @name _show_contextmenu(obj, x, y, i)
6332
+ * @param {mixed} obj the node
6333
+ * @param {Number} x the x-coordinate relative to the document to show the menu at
6334
+ * @param {Number} y the y-coordinate relative to the document to show the menu at
6335
+ * @param {Number} i the object of items to show
6336
+ * @plugin contextmenu
6337
+ * @trigger show_contextmenu.jstree
6338
+ * @private
6339
+ */
6340
+ this._show_contextmenu = function (obj, x, y, i) {
6341
+ var d = this.get_node(obj, true),
6342
+ a = d.children(".jstree-anchor");
6343
+ $(document).one("context_show.vakata.jstree", $.proxy(function (e, data) {
6344
+ var cls = 'jstree-contextmenu jstree-' + this.get_theme() + '-contextmenu';
6345
+ $(data.element).addClass(cls);
6346
+ a.addClass('jstree-context');
6347
+ }, this));
6348
+ this._data.contextmenu.visible = true;
6349
+ $.vakata.context.show(a, { 'x' : x, 'y' : y }, i);
6350
+ /**
6351
+ * triggered when the contextmenu is shown for a node
6352
+ * @event
6353
+ * @name show_contextmenu.jstree
6354
+ * @param {Object} node the node
6355
+ * @param {Number} x the x-coordinate of the menu relative to the document
6356
+ * @param {Number} y the y-coordinate of the menu relative to the document
6357
+ * @plugin contextmenu
6358
+ */
6359
+ this.trigger('show_contextmenu', { "node" : obj, "x" : x, "y" : y });
6360
+ };
6361
+ };
6362
+
6363
+ // contextmenu helper
6364
+ (function ($) {
6365
+ var right_to_left = false,
6366
+ vakata_context = {
6367
+ element : false,
6368
+ reference : false,
6369
+ position_x : 0,
6370
+ position_y : 0,
6371
+ items : [],
6372
+ html : "",
6373
+ is_visible : false
6374
+ };
6375
+
6376
+ $.vakata.context = {
6377
+ settings : {
6378
+ hide_onmouseleave : 0,
6379
+ icons : true
6380
+ },
6381
+ _trigger : function (event_name) {
6382
+ $(document).triggerHandler("context_" + event_name + ".vakata", {
6383
+ "reference" : vakata_context.reference,
6384
+ "element" : vakata_context.element,
6385
+ "position" : {
6386
+ "x" : vakata_context.position_x,
6387
+ "y" : vakata_context.position_y
6388
+ }
6389
+ });
6390
+ },
6391
+ _execute : function (i) {
6392
+ i = vakata_context.items[i];
6393
+ return i && (!i._disabled || ($.isFunction(i._disabled) && !i._disabled({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }))) && i.action ? i.action.call(null, {
6394
+ "item" : i,
6395
+ "reference" : vakata_context.reference,
6396
+ "element" : vakata_context.element,
6397
+ "position" : {
6398
+ "x" : vakata_context.position_x,
6399
+ "y" : vakata_context.position_y
6400
+ }
6401
+ }) : false;
6402
+ },
6403
+ _parse : function (o, is_callback) {
6404
+ if(!o) { return false; }
6405
+ if(!is_callback) {
6406
+ vakata_context.html = "";
6407
+ vakata_context.items = [];
6408
+ }
6409
+ var str = "",
6410
+ sep = false,
6411
+ tmp;
6412
+
6413
+ if(is_callback) { str += "<"+"ul>"; }
6414
+ $.each(o, function (i, val) {
6415
+ if(!val) { return true; }
6416
+ vakata_context.items.push(val);
6417
+ if(!sep && val.separator_before) {
6418
+ str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;<"+"/a><"+"/li>";
6419
+ }
6420
+ sep = false;
6421
+ str += "<"+"li class='" + (val._class || "") + (val._disabled === true || ($.isFunction(val._disabled) && val._disabled({ "item" : val, "reference" : vakata_context.reference, "element" : vakata_context.element })) ? " vakata-contextmenu-disabled " : "") + "' "+(val.shortcut?" data-shortcut='"+val.shortcut+"' ":'')+">";
6422
+ str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "' " + (val.title ? "title='" + val.title + "'" : "") + ">";
6423
+ if($.vakata.context.settings.icons) {
6424
+ str += "<"+"i ";
6425
+ if(val.icon) {
6426
+ if(val.icon.indexOf("/") !== -1 || val.icon.indexOf(".") !== -1) { str += " style='background:url(\"" + val.icon + "\") center center no-repeat' "; }
6427
+ else { str += " class='" + val.icon + "' "; }
6428
+ }
6429
+ str += "><"+"/i><"+"span class='vakata-contextmenu-sep'>&#160;<"+"/span>";
6430
+ }
6431
+ str += ($.isFunction(val.label) ? val.label({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }) : val.label) + (val.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+val.shortcut+'">'+ (val.shortcut_label || '') +'</span>':'') + "<"+"/a>";
6432
+ if(val.submenu) {
6433
+ tmp = $.vakata.context._parse(val.submenu, true);
6434
+ if(tmp) { str += tmp; }
6435
+ }
6436
+ str += "<"+"/li>";
6437
+ if(val.separator_after) {
6438
+ str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;<"+"/a><"+"/li>";
6439
+ sep = true;
6440
+ }
6441
+ });
6442
+ str = str.replace(/<li class\='vakata-context-separator'\><\/li\>$/,"");
6443
+ if(is_callback) { str += "</ul>"; }
6444
+ /**
6445
+ * triggered on the document when the contextmenu is parsed (HTML is built)
6446
+ * @event
6447
+ * @plugin contextmenu
6448
+ * @name context_parse.vakata
6449
+ * @param {jQuery} reference the element that was right clicked
6450
+ * @param {jQuery} element the DOM element of the menu itself
6451
+ * @param {Object} position the x & y coordinates of the menu
6452
+ */
6453
+ if(!is_callback) { vakata_context.html = str; $.vakata.context._trigger("parse"); }
6454
+ return str.length > 10 ? str : false;
6455
+ },
6456
+ _show_submenu : function (o) {
6457
+ o = $(o);
6458
+ if(!o.length || !o.children("ul").length) { return; }
6459
+ var e = o.children("ul"),
6460
+ xl = o.offset().left,
6461
+ x = xl + o.outerWidth(),
6462
+ y = o.offset().top,
6463
+ w = e.width(),
6464
+ h = e.height(),
6465
+ dw = $(window).width() + $(window).scrollLeft(),
6466
+ dh = $(window).height() + $(window).scrollTop();
6467
+ // може да се спести е една проверка - дали няма някой от класовете вече нагоре
6468
+ if(right_to_left) {
6469
+ o[x - (w + 10 + o.outerWidth()) < 0 ? "addClass" : "removeClass"]("vakata-context-left");
6470
+ }
6471
+ else {
6472
+ o[x + w > dw && xl > dw - x ? "addClass" : "removeClass"]("vakata-context-right");
6473
+ }
6474
+ if(y + h + 10 > dh) {
6475
+ e.css("bottom","-1px");
6476
+ }
6477
+
6478
+ //if does not fit - stick it to the side
6479
+ if (o.hasClass('vakata-context-right')) {
6480
+ if (xl < w) {
6481
+ e.css("margin-right", xl - w);
6482
+ }
6483
+ } else {
6484
+ if (dw - x < w) {
6485
+ e.css("margin-left", dw - x - w);
6486
+ }
6487
+ }
6488
+
6489
+ e.show();
6490
+ },
6491
+ show : function (reference, position, data) {
6492
+ var o, e, x, y, w, h, dw, dh, cond = true;
6493
+ if(vakata_context.element && vakata_context.element.length) {
6494
+ vakata_context.element.width('');
6495
+ }
6496
+ switch(cond) {
6497
+ case (!position && !reference):
6498
+ return false;
6499
+ case (!!position && !!reference):
6500
+ vakata_context.reference = reference;
6501
+ vakata_context.position_x = position.x;
6502
+ vakata_context.position_y = position.y;
6503
+ break;
6504
+ case (!position && !!reference):
6505
+ vakata_context.reference = reference;
6506
+ o = reference.offset();
6507
+ vakata_context.position_x = o.left + reference.outerHeight();
6508
+ vakata_context.position_y = o.top;
6509
+ break;
6510
+ case (!!position && !reference):
6511
+ vakata_context.position_x = position.x;
6512
+ vakata_context.position_y = position.y;
6513
+ break;
6514
+ }
6515
+ if(!!reference && !data && $(reference).data('vakata_contextmenu')) {
6516
+ data = $(reference).data('vakata_contextmenu');
6517
+ }
6518
+ if($.vakata.context._parse(data)) {
6519
+ vakata_context.element.html(vakata_context.html);
6520
+ }
6521
+ if(vakata_context.items.length) {
6522
+ vakata_context.element.appendTo(document.body);
6523
+ e = vakata_context.element;
6524
+ x = vakata_context.position_x;
6525
+ y = vakata_context.position_y;
6526
+ w = e.width();
6527
+ h = e.height();
6528
+ dw = $(window).width() + $(window).scrollLeft();
6529
+ dh = $(window).height() + $(window).scrollTop();
6530
+ if(right_to_left) {
6531
+ x -= (e.outerWidth() - $(reference).outerWidth());
6532
+ if(x < $(window).scrollLeft() + 20) {
6533
+ x = $(window).scrollLeft() + 20;
6534
+ }
6535
+ }
6536
+ if(x + w + 20 > dw) {
6537
+ x = dw - (w + 20);
6538
+ }
6539
+ if(y + h + 20 > dh) {
6540
+ y = dh - (h + 20);
6541
+ }
6542
+
6543
+ vakata_context.element
6544
+ .css({ "left" : x, "top" : y })
6545
+ .show()
6546
+ .find('a').first().focus().parent().addClass("vakata-context-hover");
6547
+ vakata_context.is_visible = true;
6548
+ /**
6549
+ * triggered on the document when the contextmenu is shown
6550
+ * @event
6551
+ * @plugin contextmenu
6552
+ * @name context_show.vakata
6553
+ * @param {jQuery} reference the element that was right clicked
6554
+ * @param {jQuery} element the DOM element of the menu itself
6555
+ * @param {Object} position the x & y coordinates of the menu
6556
+ */
6557
+ $.vakata.context._trigger("show");
6558
+ }
6559
+ },
6560
+ hide : function () {
6561
+ if(vakata_context.is_visible) {
6562
+ vakata_context.element.hide().find("ul").hide().end().find(':focus').blur().end().detach();
6563
+ vakata_context.is_visible = false;
6564
+ /**
6565
+ * triggered on the document when the contextmenu is hidden
6566
+ * @event
6567
+ * @plugin contextmenu
6568
+ * @name context_hide.vakata
6569
+ * @param {jQuery} reference the element that was right clicked
6570
+ * @param {jQuery} element the DOM element of the menu itself
6571
+ * @param {Object} position the x & y coordinates of the menu
6572
+ */
6573
+ $.vakata.context._trigger("hide");
6574
+ }
6575
+ }
6576
+ };
6577
+ $(function () {
6578
+ right_to_left = $(document.body).css("direction") === "rtl";
6579
+ var to = false;
6580
+
6581
+ vakata_context.element = $("<ul class='vakata-context'></ul>");
6582
+ vakata_context.element
6583
+ .on("mouseenter", "li", function (e) {
6584
+ e.stopImmediatePropagation();
6585
+
6586
+ if($.contains(this, e.relatedTarget)) {
6587
+ // премахнато заради delegate mouseleave по-долу
6588
+ // $(this).find(".vakata-context-hover").removeClass("vakata-context-hover");
6589
+ return;
6590
+ }
6591
+
6592
+ if(to) { clearTimeout(to); }
6593
+ vakata_context.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end();
6594
+
6595
+ $(this)
6596
+ .siblings().find("ul").hide().end().end()
6597
+ .parentsUntil(".vakata-context", "li").addBack().addClass("vakata-context-hover");
6598
+ $.vakata.context._show_submenu(this);
6599
+ })
6600
+ // тестово - дали не натоварва?
6601
+ .on("mouseleave", "li", function (e) {
6602
+ if($.contains(this, e.relatedTarget)) { return; }
6603
+ $(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover");
6604
+ })
6605
+ .on("mouseleave", function (e) {
6606
+ $(this).find(".vakata-context-hover").removeClass("vakata-context-hover");
6607
+ if($.vakata.context.settings.hide_onmouseleave) {
6608
+ to = setTimeout(
6609
+ (function (t) {
6610
+ return function () { $.vakata.context.hide(); };
6611
+ }(this)), $.vakata.context.settings.hide_onmouseleave);
6612
+ }
6613
+ })
6614
+ .on("click", "a", function (e) {
6615
+ e.preventDefault();
6616
+ //})
6617
+ //.on("mouseup", "a", function (e) {
6618
+ if(!$(this).blur().parent().hasClass("vakata-context-disabled") && $.vakata.context._execute($(this).attr("rel")) !== false) {
6619
+ $.vakata.context.hide();
6620
+ }
6621
+ })
6622
+ .on('keydown', 'a', function (e) {
6623
+ var o = null;
6624
+ switch(e.which) {
6625
+ case 13:
6626
+ case 32:
6627
+ e.type = "click";
6628
+ e.preventDefault();
6629
+ $(e.currentTarget).trigger(e);
6630
+ break;
6631
+ case 37:
6632
+ if(vakata_context.is_visible) {
6633
+ vakata_context.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children('a').focus();
6634
+ e.stopImmediatePropagation();
6635
+ e.preventDefault();
6636
+ }
6637
+ break;
6638
+ case 38:
6639
+ if(vakata_context.is_visible) {
6640
+ o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();
6641
+ if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last(); }
6642
+ o.addClass("vakata-context-hover").children('a').focus();
6643
+ e.stopImmediatePropagation();
6644
+ e.preventDefault();
6645
+ }
6646
+ break;
6647
+ case 39:
6648
+ if(vakata_context.is_visible) {
6649
+ vakata_context.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children('a').focus();
6650
+ e.stopImmediatePropagation();
6651
+ e.preventDefault();
6652
+ }
6653
+ break;
6654
+ case 40:
6655
+ if(vakata_context.is_visible) {
6656
+ o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();
6657
+ if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first(); }
6658
+ o.addClass("vakata-context-hover").children('a').focus();
6659
+ e.stopImmediatePropagation();
6660
+ e.preventDefault();
6661
+ }
6662
+ break;
6663
+ case 27:
6664
+ $.vakata.context.hide();
6665
+ e.preventDefault();
6666
+ break;
6667
+ default:
6668
+ //console.log(e.which);
6669
+ break;
6670
+ }
6671
+ })
6672
+ .on('keydown', function (e) {
6673
+ e.preventDefault();
6674
+ var a = vakata_context.element.find('.vakata-contextmenu-shortcut-' + e.which).parent();
6675
+ if(a.parent().not('.vakata-context-disabled')) {
6676
+ a.click();
6677
+ }
6678
+ });
6679
+
6680
+ $(document)
6681
+ .on("mousedown.vakata.jstree", function (e) {
6682
+ if(vakata_context.is_visible && vakata_context.element[0] !== e.target && !$.contains(vakata_context.element[0], e.target)) {
6683
+ $.vakata.context.hide();
6684
+ }
6685
+ })
6686
+ .on("context_show.vakata.jstree", function (e, data) {
6687
+ vakata_context.element.find("li:has(ul)").children("a").addClass("vakata-context-parent");
6688
+ if(right_to_left) {
6689
+ vakata_context.element.addClass("vakata-context-rtl").css("direction", "rtl");
6690
+ }
6691
+ // also apply a RTL class?
6692
+ vakata_context.element.find("ul").hide().end();
6693
+ });
6694
+ });
6695
+ }($));
6696
+ // $.jstree.defaults.plugins.push("contextmenu");
6697
+
6698
+
6699
+ /**
6700
+ * ### Drag'n'drop plugin
6701
+ *
6702
+ * Enables dragging and dropping of nodes in the tree, resulting in a move or copy operations.
6703
+ */
6704
+
6705
+ /**
6706
+ * stores all defaults for the drag'n'drop plugin
6707
+ * @name $.jstree.defaults.dnd
6708
+ * @plugin dnd
6709
+ */
6710
+ $.jstree.defaults.dnd = {
6711
+ /**
6712
+ * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`.
6713
+ * @name $.jstree.defaults.dnd.copy
6714
+ * @plugin dnd
6715
+ */
6716
+ copy : true,
6717
+ /**
6718
+ * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`.
6719
+ * @name $.jstree.defaults.dnd.open_timeout
6720
+ * @plugin dnd
6721
+ */
6722
+ open_timeout : 500,
6723
+ /**
6724
+ * a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) and the event that started the drag - return `false` to prevent dragging
6725
+ * @name $.jstree.defaults.dnd.is_draggable
6726
+ * @plugin dnd
6727
+ */
6728
+ is_draggable : true,
6729
+ /**
6730
+ * a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true`
6731
+ * @name $.jstree.defaults.dnd.check_while_dragging
6732
+ * @plugin dnd
6733
+ */
6734
+ check_while_dragging : true,
6735
+ /**
6736
+ * a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false`
6737
+ * @name $.jstree.defaults.dnd.always_copy
6738
+ * @plugin dnd
6739
+ */
6740
+ always_copy : false,
6741
+ /**
6742
+ * when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0`
6743
+ * @name $.jstree.defaults.dnd.inside_pos
6744
+ * @plugin dnd
6745
+ */
6746
+ inside_pos : 0,
6747
+ /**
6748
+ * when starting the drag on a node that is selected this setting controls if all selected nodes are dragged or only the single node, default is `true`, which means all selected nodes are dragged when the drag is started on a selected node
6749
+ * @name $.jstree.defaults.dnd.drag_selection
6750
+ * @plugin dnd
6751
+ */
6752
+ drag_selection : true,
6753
+ /**
6754
+ * controls whether dnd works on touch devices. If left as boolean true dnd will work the same as in desktop browsers, which in some cases may impair scrolling. If set to boolean false dnd will not work on touch devices. There is a special third option - string "selected" which means only selected nodes can be dragged on touch devices.
6755
+ * @name $.jstree.defaults.dnd.touch
6756
+ * @plugin dnd
6757
+ */
6758
+ touch : true,
6759
+ /**
6760
+ * controls whether items can be dropped anywhere on the node, not just on the anchor, by default only the node anchor is a valid drop target. Works best with the wholerow plugin. If enabled on mobile depending on the interface it might be hard for the user to cancel the drop, since the whole tree container will be a valid drop target.
6761
+ * @name $.jstree.defaults.dnd.large_drop_target
6762
+ * @plugin dnd
6763
+ */
6764
+ large_drop_target : false,
6765
+ /**
6766
+ * controls whether a drag can be initiated from any part of the node and not just the text/icon part, works best with the wholerow plugin. Keep in mind it can cause problems with tree scrolling on mobile depending on the interface - in that case set the touch option to "selected".
6767
+ * @name $.jstree.defaults.dnd.large_drag_target
6768
+ * @plugin dnd
6769
+ */
6770
+ large_drag_target : false,
6771
+ /**
6772
+ * controls whether use HTML5 dnd api instead of classical. That will allow better integration of dnd events with other HTML5 controls.
6773
+ * @reference http://caniuse.com/#feat=dragndrop
6774
+ * @name $.jstree.defaults.dnd.use_html5
6775
+ * @plugin dnd
6776
+ */
6777
+ use_html5: false
6778
+ };
6779
+ var drg, elm;
6780
+ // TODO: now check works by checking for each node individually, how about max_children, unique, etc?
6781
+ $.jstree.plugins.dnd = function (options, parent) {
6782
+ this.init = function (el, options) {
6783
+ parent.init.call(this, el, options);
6784
+ this.settings.dnd.use_html5 = this.settings.dnd.use_html5 && ('draggable' in document.createElement('span'));
6785
+ };
6786
+ this.bind = function () {
6787
+ parent.bind.call(this);
6788
+
6789
+ this.element
6790
+ .on(this.settings.dnd.use_html5 ? 'dragstart.jstree' : 'mousedown.jstree touchstart.jstree', this.settings.dnd.large_drag_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) {
6791
+ if(this.settings.dnd.large_drag_target && $(e.target).closest('.jstree-node')[0] !== e.currentTarget) {
6792
+ return true;
6793
+ }
6794
+ if(e.type === "touchstart" && (!this.settings.dnd.touch || (this.settings.dnd.touch === 'selected' && !$(e.currentTarget).closest('.jstree-node').children('.jstree-anchor').hasClass('jstree-clicked')))) {
6795
+ return true;
6796
+ }
6797
+ var obj = this.get_node(e.target),
6798
+ mlt = this.is_selected(obj) && this.settings.dnd.drag_selection ? this.get_top_selected().length : 1,
6799
+ txt = (mlt > 1 ? mlt + ' ' + this.get_string('nodes') : this.get_text(e.currentTarget));
6800
+ if(this.settings.core.force_text) {
6801
+ txt = $.vakata.html.escape(txt);
6802
+ }
6803
+ if(obj && obj.id && obj.id !== $.jstree.root && (e.which === 1 || e.type === "touchstart" || e.type === "dragstart") &&
6804
+ (this.settings.dnd.is_draggable === true || ($.isFunction(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.get_top_selected(true) : [obj]), e)))
6805
+ ) {
6806
+ drg = { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_top_selected() : [obj.id] };
6807
+ elm = e.currentTarget;
6808
+ if (this.settings.dnd.use_html5) {
6809
+ $.vakata.dnd._trigger('start', e, { 'helper': $(), 'element': elm, 'data': drg });
6810
+ } else {
6811
+ this.element.trigger('mousedown.jstree');
6812
+ return $.vakata.dnd.start(e, drg, '<div id="jstree-dnd" data-txt="'+txt+'" class="jstree-' + this.get_theme() + ' jstree-' + this.get_theme() + '-' + this.get_theme_variant() + ' ' + ( this.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ) + '">'+txt+'</div>');
6813
+ }
6814
+ }
6815
+ }, this));
6816
+ if (this.settings.dnd.use_html5) {
6817
+ this.element
6818
+ .on('dragover.jstree', function (e) {
6819
+ e.preventDefault();
6820
+ $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6821
+ return false;
6822
+ })
6823
+ //.on('dragenter.jstree', this.settings.dnd.large_drop_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) {
6824
+ // e.preventDefault();
6825
+ // $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6826
+ // return false;
6827
+ // }, this))
6828
+ .on('drop.jstree', $.proxy(function (e) {
6829
+ e.preventDefault();
6830
+ $.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
6831
+ return false;
6832
+ }, this));
6833
+ }
6834
+ };
6835
+ this.redraw_node = function(obj, deep, callback, force_render) {
6836
+ obj = parent.redraw_node.apply(this, arguments);
6837
+ if (obj && this.settings.dnd.use_html5) {
6838
+ if (this.settings.dnd.large_drag_target) {
6839
+ obj.setAttribute('draggable', true);
6840
+ } else {
6841
+ var i, j, tmp = null;
6842
+ for(i = 0, j = obj.childNodes.length; i < j; i++) {
6843
+ if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) {
6844
+ tmp = obj.childNodes[i];
6845
+ break;
6846
+ }
6847
+ }
6848
+ if(tmp) {
6849
+ tmp.setAttribute('draggable', true);
6850
+ }
6851
+ }
6852
+ }
6853
+ return obj;
6854
+ };
6855
+ };
6856
+
6857
+ $(function() {
6858
+ // bind only once for all instances
6859
+ var lastmv = false,
6860
+ laster = false,
6861
+ lastev = false,
6862
+ opento = false,
6863
+ marker = $('<div id="jstree-marker">&#160;</div>').hide(); //.appendTo('body');
6864
+
6865
+ $(document)
6866
+ .on('dragover.vakata.jstree', function (e) {
6867
+ if (elm) {
6868
+ $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6869
+ }
6870
+ })
6871
+ .on('drop.vakata.jstree', function (e) {
6872
+ if (elm) {
6873
+ $.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
6874
+ elm = null;
6875
+ drg = null;
6876
+ }
6877
+ })
6878
+ .on('dnd_start.vakata.jstree', function (e, data) {
6879
+ lastmv = false;
6880
+ lastev = false;
6881
+ if(!data || !data.data || !data.data.jstree) { return; }
6882
+ marker.appendTo(document.body); //.show();
6883
+ })
6884
+ .on('dnd_move.vakata.jstree', function (e, data) {
6885
+ var isDifferentNode = data.event.target !== lastev.target;
6886
+ if(opento) {
6887
+ if (!data.event || data.event.type !== 'dragover' || isDifferentNode) {
6888
+ clearTimeout(opento);
6889
+ }
6890
+ }
6891
+ if(!data || !data.data || !data.data.jstree) { return; }
6892
+
6893
+ // if we are hovering the marker image do nothing (can happen on "inside" drags)
6894
+ if(data.event.target.id && data.event.target.id === 'jstree-marker') {
6895
+ return;
6896
+ }
6897
+ lastev = data.event;
6898
+
6899
+ var ins = $.jstree.reference(data.event.target),
6900
+ ref = false,
6901
+ off = false,
6902
+ rel = false,
6903
+ tmp, l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm, is_copy, pn, c;
6904
+ // if we are over an instance
6905
+ if(ins && ins._data && ins._data.dnd) {
6906
+ marker.attr('class', 'jstree-' + ins.get_theme() + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ));
6907
+ is_copy = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)));
6908
+ data.helper
6909
+ .children().attr('class', 'jstree-' + ins.get_theme() + ' jstree-' + ins.get_theme() + '-' + ins.get_theme_variant() + ' ' + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ))
6910
+ .find('.jstree-copy').first()[ is_copy ? 'show' : 'hide' ]();
6911
+
6912
+ // if are hovering the container itself add a new root node
6913
+ //console.log(data.event);
6914
+ if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) {
6915
+ ok = true;
6916
+ for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) {
6917
+ ok = ok && ins.check( (data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)) ) ? "copy_node" : "move_node"), (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), $.jstree.root, 'last', { 'dnd' : true, 'ref' : ins.get_node($.jstree.root), 'pos' : 'i', 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) });
6918
+ if(!ok) { break; }
6919
+ }
6920
+ if(ok) {
6921
+ lastmv = { 'ins' : ins, 'par' : $.jstree.root, 'pos' : 'last' };
6922
+ marker.hide();
6923
+ data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok');
6924
+ if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
6925
+ data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move';
6926
+ }
6927
+ return;
6928
+ }
6929
+ }
6930
+ else {
6931
+ // if we are hovering a tree node
6932
+ ref = ins.settings.dnd.large_drop_target ? $(data.event.target).closest('.jstree-node').children('.jstree-anchor') : $(data.event.target).closest('.jstree-anchor');
6933
+ if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) {
6934
+ off = ref.offset();
6935
+ rel = (data.event.pageY !== undefined ? data.event.pageY : data.event.originalEvent.pageY) - off.top;
6936
+ h = ref.outerHeight();
6937
+ if(rel < h / 3) {
6938
+ o = ['b', 'i', 'a'];
6939
+ }
6940
+ else if(rel > h - h / 3) {
6941
+ o = ['a', 'i', 'b'];
6942
+ }
6943
+ else {
6944
+ o = rel > h / 2 ? ['i', 'a', 'b'] : ['i', 'b', 'a'];
6945
+ }
6946
+ $.each(o, function (j, v) {
6947
+ switch(v) {
6948
+ case 'b':
6949
+ l = off.left - 6;
6950
+ t = off.top;
6951
+ p = ins.get_parent(ref);
6952
+ i = ref.parent().index();
6953
+ c = 'jstree-below';
6954
+ break;
6955
+ case 'i':
6956
+ ip = ins.settings.dnd.inside_pos;
6957
+ tm = ins.get_node(ref.parent());
6958
+ l = off.left - 2;
6959
+ t = off.top + h / 2 + 1;
6960
+ p = tm.id;
6961
+ i = ip === 'first' ? 0 : (ip === 'last' ? tm.children.length : Math.min(ip, tm.children.length));
6962
+ c = 'jstree-inside';
6963
+ break;
6964
+ case 'a':
6965
+ l = off.left - 6;
6966
+ t = off.top + h;
6967
+ p = ins.get_parent(ref);
6968
+ i = ref.parent().index() + 1;
6969
+ c = 'jstree-above';
6970
+ break;
6971
+ }
6972
+ ok = true;
6973
+ for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) {
6974
+ op = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? "copy_node" : "move_node";
6975
+ ps = i;
6976
+ if(op === "move_node" && v === 'a' && (data.data.origin && data.data.origin === ins) && p === ins.get_parent(data.data.nodes[t1])) {
6977
+ pr = ins.get_node(p);
6978
+ if(ps > $.inArray(data.data.nodes[t1], pr.children)) {
6979
+ ps -= 1;
6980
+ }
6981
+ }
6982
+ ok = ok && ( (ins && ins.settings && ins.settings.dnd && ins.settings.dnd.check_while_dragging === false) || ins.check(op, (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), p, ps, { 'dnd' : true, 'ref' : ins.get_node(ref.parent()), 'pos' : v, 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }) );
6983
+ if(!ok) {
6984
+ if(ins && ins.last_error) { laster = ins.last_error(); }
6985
+ break;
6986
+ }
6987
+ }
6988
+ if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) {
6989
+ if (!data.event || data.event.type !== 'dragover' || isDifferentNode) {
6990
+ if (opento) { clearTimeout(opento); }
6991
+ opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout);
6992
+ }
6993
+ }
6994
+ if(ok) {
6995
+ pn = ins.get_node(p, true);
6996
+ if (!pn.hasClass('.jstree-dnd-parent')) {
6997
+ $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');
6998
+ pn.addClass('jstree-dnd-parent');
6999
+ }
7000
+ lastmv = { 'ins' : ins, 'par' : p, 'pos' : v === 'i' && ip === 'last' && i === 0 && !ins.is_loaded(tm) ? 'last' : i };
7001
+ marker.css({ 'left' : l + 'px', 'top' : t + 'px' }).show();
7002
+ marker.removeClass('jstree-above jstree-inside jstree-below').addClass(c);
7003
+ data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok');
7004
+ if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
7005
+ data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move';
7006
+ }
7007
+ laster = {};
7008
+ o = true;
7009
+ return false;
7010
+ }
7011
+ });
7012
+ if(o === true) { return; }
7013
+ }
7014
+ }
7015
+ }
7016
+ $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');
7017
+ lastmv = false;
7018
+ data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er');
7019
+ if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
7020
+ //data.event.originalEvent.dataTransfer.dropEffect = 'none';
7021
+ }
7022
+ marker.hide();
7023
+ })
7024
+ .on('dnd_scroll.vakata.jstree', function (e, data) {
7025
+ if(!data || !data.data || !data.data.jstree) { return; }
7026
+ marker.hide();
7027
+ lastmv = false;
7028
+ lastev = false;
7029
+ data.helper.find('.jstree-icon').first().removeClass('jstree-ok').addClass('jstree-er');
7030
+ })
7031
+ .on('dnd_stop.vakata.jstree', function (e, data) {
7032
+ $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');
7033
+ if(opento) { clearTimeout(opento); }
7034
+ if(!data || !data.data || !data.data.jstree) { return; }
7035
+ marker.hide().detach();
7036
+ var i, j, nodes = [];
7037
+ if(lastmv) {
7038
+ for(i = 0, j = data.data.nodes.length; i < j; i++) {
7039
+ nodes[i] = data.data.origin ? data.data.origin.get_node(data.data.nodes[i]) : data.data.nodes[i];
7040
+ }
7041
+ lastmv.ins[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'copy_node' : 'move_node' ](nodes, lastmv.par, lastmv.pos, false, false, false, data.data.origin);
7042
+ }
7043
+ else {
7044
+ i = $(data.event.target).closest('.jstree');
7045
+ if(i.length && laster && laster.error && laster.error === 'check') {
7046
+ i = i.jstree(true);
7047
+ if(i) {
7048
+ i.settings.core.error.call(this, laster);
7049
+ }
7050
+ }
7051
+ }
7052
+ lastev = false;
7053
+ lastmv = false;
7054
+ })
7055
+ .on('keyup.jstree keydown.jstree', function (e, data) {
7056
+ data = $.vakata.dnd._get();
7057
+ if(data && data.data && data.data.jstree) {
7058
+ if (e.type === "keyup" && e.which === 27) {
7059
+ if (opento) { clearTimeout(opento); }
7060
+ lastmv = false;
7061
+ laster = false;
7062
+ lastev = false;
7063
+ opento = false;
7064
+ marker.hide().detach();
7065
+ $.vakata.dnd._clean();
7066
+ } else {
7067
+ data.helper.find('.jstree-copy').first()[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (e.metaKey || e.ctrlKey))) ? 'show' : 'hide' ]();
7068
+ if(lastev) {
7069
+ lastev.metaKey = e.metaKey;
7070
+ lastev.ctrlKey = e.ctrlKey;
7071
+ $.vakata.dnd._trigger('move', lastev);
7072
+ }
7073
+ }
7074
+ }
7075
+ });
7076
+ });
7077
+
7078
+ // helpers
7079
+ (function ($) {
7080
+ $.vakata.html = {
7081
+ div : $('<div></div>'),
7082
+ escape : function (str) {
7083
+ return $.vakata.html.div.text(str).html();
7084
+ },
7085
+ strip : function (str) {
7086
+ return $.vakata.html.div.empty().append($.parseHTML(str)).text();
7087
+ }
7088
+ };
7089
+ // private variable
7090
+ var vakata_dnd = {
7091
+ element : false,
7092
+ target : false,
7093
+ is_down : false,
7094
+ is_drag : false,
7095
+ helper : false,
7096
+ helper_w: 0,
7097
+ data : false,
7098
+ init_x : 0,
7099
+ init_y : 0,
7100
+ scroll_l: 0,
7101
+ scroll_t: 0,
7102
+ scroll_e: false,
7103
+ scroll_i: false,
7104
+ is_touch: false
7105
+ };
7106
+ $.vakata.dnd = {
7107
+ settings : {
7108
+ scroll_speed : 10,
7109
+ scroll_proximity : 20,
7110
+ helper_left : 5,
7111
+ helper_top : 10,
7112
+ threshold : 5,
7113
+ threshold_touch : 10
7114
+ },
7115
+ _trigger : function (event_name, e, data) {
7116
+ if (data === undefined) {
7117
+ data = $.vakata.dnd._get();
7118
+ }
7119
+ data.event = e;
7120
+ $(document).triggerHandler("dnd_" + event_name + ".vakata", data);
7121
+ },
7122
+ _get : function () {
7123
+ return {
7124
+ "data" : vakata_dnd.data,
7125
+ "element" : vakata_dnd.element,
7126
+ "helper" : vakata_dnd.helper
7127
+ };
7128
+ },
7129
+ _clean : function () {
7130
+ if(vakata_dnd.helper) { vakata_dnd.helper.remove(); }
7131
+ if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; }
7132
+ vakata_dnd = {
7133
+ element : false,
7134
+ target : false,
7135
+ is_down : false,
7136
+ is_drag : false,
7137
+ helper : false,
7138
+ helper_w: 0,
7139
+ data : false,
7140
+ init_x : 0,
7141
+ init_y : 0,
7142
+ scroll_l: 0,
7143
+ scroll_t: 0,
7144
+ scroll_e: false,
7145
+ scroll_i: false,
7146
+ is_touch: false
7147
+ };
7148
+ elm = null;
7149
+ $(document).off("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag);
7150
+ $(document).off("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop);
7151
+ },
7152
+ _scroll : function (init_only) {
7153
+ if(!vakata_dnd.scroll_e || (!vakata_dnd.scroll_l && !vakata_dnd.scroll_t)) {
7154
+ if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; }
7155
+ return false;
7156
+ }
7157
+ if(!vakata_dnd.scroll_i) {
7158
+ vakata_dnd.scroll_i = setInterval($.vakata.dnd._scroll, 100);
7159
+ return false;
7160
+ }
7161
+ if(init_only === true) { return false; }
7162
+
7163
+ var i = vakata_dnd.scroll_e.scrollTop(),
7164
+ j = vakata_dnd.scroll_e.scrollLeft();
7165
+ vakata_dnd.scroll_e.scrollTop(i + vakata_dnd.scroll_t * $.vakata.dnd.settings.scroll_speed);
7166
+ vakata_dnd.scroll_e.scrollLeft(j + vakata_dnd.scroll_l * $.vakata.dnd.settings.scroll_speed);
7167
+ if(i !== vakata_dnd.scroll_e.scrollTop() || j !== vakata_dnd.scroll_e.scrollLeft()) {
7168
+ /**
7169
+ * triggered on the document when a drag causes an element to scroll
7170
+ * @event
7171
+ * @plugin dnd
7172
+ * @name dnd_scroll.vakata
7173
+ * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7174
+ * @param {DOM} element the DOM element being dragged
7175
+ * @param {jQuery} helper the helper shown next to the mouse
7176
+ * @param {jQuery} event the element that is scrolling
7177
+ */
7178
+ $.vakata.dnd._trigger("scroll", vakata_dnd.scroll_e);
7179
+ }
7180
+ },
7181
+ start : function (e, data, html) {
7182
+ if(e.type === "touchstart" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) {
7183
+ e.pageX = e.originalEvent.changedTouches[0].pageX;
7184
+ e.pageY = e.originalEvent.changedTouches[0].pageY;
7185
+ e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset);
7186
+ }
7187
+ if(vakata_dnd.is_drag) { $.vakata.dnd.stop({}); }
7188
+ try {
7189
+ e.currentTarget.unselectable = "on";
7190
+ e.currentTarget.onselectstart = function() { return false; };
7191
+ if(e.currentTarget.style) {
7192
+ e.currentTarget.style.touchAction = "none";
7193
+ e.currentTarget.style.msTouchAction = "none";
7194
+ e.currentTarget.style.MozUserSelect = "none";
7195
+ }
7196
+ } catch(ignore) { }
7197
+ vakata_dnd.init_x = e.pageX;
7198
+ vakata_dnd.init_y = e.pageY;
7199
+ vakata_dnd.data = data;
7200
+ vakata_dnd.is_down = true;
7201
+ vakata_dnd.element = e.currentTarget;
7202
+ vakata_dnd.target = e.target;
7203
+ vakata_dnd.is_touch = e.type === "touchstart";
7204
+ if(html !== false) {
7205
+ vakata_dnd.helper = $("<div id='vakata-dnd'></div>").html(html).css({
7206
+ "display" : "block",
7207
+ "margin" : "0",
7208
+ "padding" : "0",
7209
+ "position" : "absolute",
7210
+ "top" : "-2000px",
7211
+ "lineHeight" : "16px",
7212
+ "zIndex" : "10000"
7213
+ });
7214
+ }
7215
+ $(document).on("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag);
7216
+ $(document).on("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop);
7217
+ return false;
7218
+ },
7219
+ drag : function (e) {
7220
+ if(e.type === "touchmove" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) {
7221
+ e.pageX = e.originalEvent.changedTouches[0].pageX;
7222
+ e.pageY = e.originalEvent.changedTouches[0].pageY;
7223
+ e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset);
7224
+ }
7225
+ if(!vakata_dnd.is_down) { return; }
7226
+ if(!vakata_dnd.is_drag) {
7227
+ if(
7228
+ Math.abs(e.pageX - vakata_dnd.init_x) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold) ||
7229
+ Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold)
7230
+ ) {
7231
+ if(vakata_dnd.helper) {
7232
+ vakata_dnd.helper.appendTo(document.body);
7233
+ vakata_dnd.helper_w = vakata_dnd.helper.outerWidth();
7234
+ }
7235
+ vakata_dnd.is_drag = true;
7236
+ $(vakata_dnd.target).one('click.vakata', false);
7237
+ /**
7238
+ * triggered on the document when a drag starts
7239
+ * @event
7240
+ * @plugin dnd
7241
+ * @name dnd_start.vakata
7242
+ * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7243
+ * @param {DOM} element the DOM element being dragged
7244
+ * @param {jQuery} helper the helper shown next to the mouse
7245
+ * @param {Object} event the event that caused the start (probably mousemove)
7246
+ */
7247
+ $.vakata.dnd._trigger("start", e);
7248
+ }
7249
+ else { return; }
7250
+ }
7251
+
7252
+ var d = false, w = false,
7253
+ dh = false, wh = false,
7254
+ dw = false, ww = false,
7255
+ dt = false, dl = false,
7256
+ ht = false, hl = false;
7257
+
7258
+ vakata_dnd.scroll_t = 0;
7259
+ vakata_dnd.scroll_l = 0;
7260
+ vakata_dnd.scroll_e = false;
7261
+ $($(e.target).parentsUntil("body").addBack().get().reverse())
7262
+ .filter(function () {
7263
+ return (/^auto|scroll$/).test($(this).css("overflow")) &&
7264
+ (this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth);
7265
+ })
7266
+ .each(function () {
7267
+ var t = $(this), o = t.offset();
7268
+ if(this.scrollHeight > this.offsetHeight) {
7269
+ if(o.top + t.height() - e.pageY < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; }
7270
+ if(e.pageY - o.top < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; }
7271
+ }
7272
+ if(this.scrollWidth > this.offsetWidth) {
7273
+ if(o.left + t.width() - e.pageX < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; }
7274
+ if(e.pageX - o.left < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; }
7275
+ }
7276
+ if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) {
7277
+ vakata_dnd.scroll_e = $(this);
7278
+ return false;
7279
+ }
7280
+ });
7281
+
7282
+ if(!vakata_dnd.scroll_e) {
7283
+ d = $(document); w = $(window);
7284
+ dh = d.height(); wh = w.height();
7285
+ dw = d.width(); ww = w.width();
7286
+ dt = d.scrollTop(); dl = d.scrollLeft();
7287
+ if(dh > wh && e.pageY - dt < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; }
7288
+ if(dh > wh && wh - (e.pageY - dt) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; }
7289
+ if(dw > ww && e.pageX - dl < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; }
7290
+ if(dw > ww && ww - (e.pageX - dl) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; }
7291
+ if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) {
7292
+ vakata_dnd.scroll_e = d;
7293
+ }
7294
+ }
7295
+ if(vakata_dnd.scroll_e) { $.vakata.dnd._scroll(true); }
7296
+
7297
+ if(vakata_dnd.helper) {
7298
+ ht = parseInt(e.pageY + $.vakata.dnd.settings.helper_top, 10);
7299
+ hl = parseInt(e.pageX + $.vakata.dnd.settings.helper_left, 10);
7300
+ if(dh && ht + 25 > dh) { ht = dh - 50; }
7301
+ if(dw && hl + vakata_dnd.helper_w > dw) { hl = dw - (vakata_dnd.helper_w + 2); }
7302
+ vakata_dnd.helper.css({
7303
+ left : hl + "px",
7304
+ top : ht + "px"
7305
+ });
7306
+ }
7307
+ /**
7308
+ * triggered on the document when a drag is in progress
7309
+ * @event
7310
+ * @plugin dnd
7311
+ * @name dnd_move.vakata
7312
+ * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7313
+ * @param {DOM} element the DOM element being dragged
7314
+ * @param {jQuery} helper the helper shown next to the mouse
7315
+ * @param {Object} event the event that caused this to trigger (most likely mousemove)
7316
+ */
7317
+ $.vakata.dnd._trigger("move", e);
7318
+ return false;
7319
+ },
7320
+ stop : function (e) {
7321
+ if(e.type === "touchend" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) {
7322
+ e.pageX = e.originalEvent.changedTouches[0].pageX;
7323
+ e.pageY = e.originalEvent.changedTouches[0].pageY;
7324
+ e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset);
7325
+ }
7326
+ if(vakata_dnd.is_drag) {
7327
+ /**
7328
+ * triggered on the document when a drag stops (the dragged element is dropped)
7329
+ * @event
7330
+ * @plugin dnd
7331
+ * @name dnd_stop.vakata
7332
+ * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start
7333
+ * @param {DOM} element the DOM element being dragged
7334
+ * @param {jQuery} helper the helper shown next to the mouse
7335
+ * @param {Object} event the event that caused the stop
7336
+ */
7337
+ if (e.target !== vakata_dnd.target) {
7338
+ $(vakata_dnd.target).off('click.vakata');
7339
+ }
7340
+ $.vakata.dnd._trigger("stop", e);
7341
+ }
7342
+ else {
7343
+ if(e.type === "touchend" && e.target === vakata_dnd.target) {
7344
+ var to = setTimeout(function () { $(e.target).click(); }, 100);
7345
+ $(e.target).one('click', function() { if(to) { clearTimeout(to); } });
7346
+ }
7347
+ }
7348
+ $.vakata.dnd._clean();
7349
+ return false;
7350
+ }
7351
+ };
7352
+ }($));
7353
+
7354
+ // include the dnd plugin by default
7355
+ // $.jstree.defaults.plugins.push("dnd");
7356
+
7357
+
7358
+ /**
7359
+ * ### Massload plugin
7360
+ *
7361
+ * Adds massload functionality to jsTree, so that multiple nodes can be loaded in a single request (only useful with lazy loading).
7362
+ */
7363
+
7364
+ /**
7365
+ * massload configuration
7366
+ *
7367
+ * It is possible to set this to a standard jQuery-like AJAX config.
7368
+ * In addition to the standard jQuery ajax options here you can supply functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node IDs need to be loaded, the return value of those functions will be used.
7369
+ *
7370
+ * You can also set this to a function, that function will receive the node IDs being loaded as argument and a second param which is a function (callback) which should be called with the result.
7371
+ *
7372
+ * Both the AJAX and the function approach rely on the same return value - an object where the keys are the node IDs, and the value is the children of that node as an array.
7373
+ *
7374
+ * {
7375
+ * "id1" : [{ "text" : "Child of ID1", "id" : "c1" }, { "text" : "Another child of ID1", "id" : "c2" }],
7376
+ * "id2" : [{ "text" : "Child of ID2", "id" : "c3" }]
7377
+ * }
7378
+ *
7379
+ * @name $.jstree.defaults.massload
7380
+ * @plugin massload
7381
+ */
7382
+ $.jstree.defaults.massload = null;
7383
+ $.jstree.plugins.massload = function (options, parent) {
7384
+ this.init = function (el, options) {
7385
+ this._data.massload = {};
7386
+ parent.init.call(this, el, options);
7387
+ };
7388
+ this._load_nodes = function (nodes, callback, is_callback, force_reload) {
7389
+ var s = this.settings.massload,
7390
+ toLoad = [],
7391
+ m = this._model.data,
7392
+ i, j, dom;
7393
+ if (!is_callback) {
7394
+ for(i = 0, j = nodes.length; i < j; i++) {
7395
+ if(!m[nodes[i]] || ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || force_reload) ) {
7396
+ toLoad.push(nodes[i]);
7397
+ dom = this.get_node(nodes[i], true);
7398
+ if (dom && dom.length) {
7399
+ dom.addClass("jstree-loading").attr('aria-busy',true);
7400
+ }
7401
+ }
7402
+ }
7403
+ this._data.massload = {};
7404
+ if (toLoad.length) {
7405
+ if($.isFunction(s)) {
7406
+ return s.call(this, toLoad, $.proxy(function (data) {
7407
+ var i, j;
7408
+ if(data) {
7409
+ for(i in data) {
7410
+ if(data.hasOwnProperty(i)) {
7411
+ this._data.massload[i] = data[i];
7412
+ }
7413
+ }
7414
+ }
7415
+ for(i = 0, j = nodes.length; i < j; i++) {
7416
+ dom = this.get_node(nodes[i], true);
7417
+ if (dom && dom.length) {
7418
+ dom.removeClass("jstree-loading").attr('aria-busy',false);
7419
+ }
7420
+ }
7421
+ parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7422
+ }, this));
7423
+ }
7424
+ if(typeof s === 'object' && s && s.url) {
7425
+ s = $.extend(true, {}, s);
7426
+ if($.isFunction(s.url)) {
7427
+ s.url = s.url.call(this, toLoad);
7428
+ }
7429
+ if($.isFunction(s.data)) {
7430
+ s.data = s.data.call(this, toLoad);
7431
+ }
7432
+ return $.ajax(s)
7433
+ .done($.proxy(function (data,t,x) {
7434
+ var i, j;
7435
+ if(data) {
7436
+ for(i in data) {
7437
+ if(data.hasOwnProperty(i)) {
7438
+ this._data.massload[i] = data[i];
7439
+ }
7440
+ }
7441
+ }
7442
+ for(i = 0, j = nodes.length; i < j; i++) {
7443
+ dom = this.get_node(nodes[i], true);
7444
+ if (dom && dom.length) {
7445
+ dom.removeClass("jstree-loading").attr('aria-busy',false);
7446
+ }
7447
+ }
7448
+ parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7449
+ }, this))
7450
+ .fail($.proxy(function (f) {
7451
+ parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7452
+ }, this));
7453
+ }
7454
+ }
7455
+ }
7456
+ return parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
7457
+ };
7458
+ this._load_node = function (obj, callback) {
7459
+ var data = this._data.massload[obj.id],
7460
+ rslt = null, dom;
7461
+ if(data) {
7462
+ rslt = this[typeof data === 'string' ? '_append_html_data' : '_append_json_data'](
7463
+ obj,
7464
+ typeof data === 'string' ? $($.parseHTML(data)).filter(function () { return this.nodeType !== 3; }) : data,
7465
+ function (status) { callback.call(this, status); }
7466
+ );
7467
+ dom = this.get_node(obj.id, true);
7468
+ if (dom && dom.length) {
7469
+ dom.removeClass("jstree-loading").attr('aria-busy',false);
7470
+ }
7471
+ delete this._data.massload[obj.id];
7472
+ return rslt;
7473
+ }
7474
+ return parent._load_node.call(this, obj, callback);
7475
+ };
7476
+ };
7477
+
7478
+
7479
+ /**
7480
+ * ### Search plugin
7481
+ *
7482
+ * Adds search functionality to jsTree.
7483
+ */
7484
+
7485
+ /**
7486
+ * stores all defaults for the search plugin
7487
+ * @name $.jstree.defaults.search
7488
+ * @plugin search
7489
+ */
7490
+ $.jstree.defaults.search = {
7491
+ /**
7492
+ * a jQuery-like AJAX config, which jstree uses if a server should be queried for results.
7493
+ *
7494
+ * A `str` (which is the search string) parameter will be added with the request, an optional `inside` parameter will be added if the search is limited to a node id. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed.
7495
+ * Leave this setting as `false` to not query the server. You can also set this to a function, which will be invoked in the instance's scope and receive 3 parameters - the search string, the callback to call with the array of nodes to load, and the optional node ID to limit the search to
7496
+ * @name $.jstree.defaults.search.ajax
7497
+ * @plugin search
7498
+ */
7499
+ ajax : false,
7500
+ /**
7501
+ * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `false`.
7502
+ * @name $.jstree.defaults.search.fuzzy
7503
+ * @plugin search
7504
+ */
7505
+ fuzzy : false,
7506
+ /**
7507
+ * Indicates if the search should be case sensitive. Default is `false`.
7508
+ * @name $.jstree.defaults.search.case_sensitive
7509
+ * @plugin search
7510
+ */
7511
+ case_sensitive : false,
7512
+ /**
7513
+ * Indicates if the tree should be filtered (by default) to show only matching nodes (keep in mind this can be a heavy on large trees in old browsers).
7514
+ * This setting can be changed at runtime when calling the search method. Default is `false`.
7515
+ * @name $.jstree.defaults.search.show_only_matches
7516
+ * @plugin search
7517
+ */
7518
+ show_only_matches : false,
7519
+ /**
7520
+ * Indicates if the children of matched element are shown (when show_only_matches is true)
7521
+ * This setting can be changed at runtime when calling the search method. Default is `false`.
7522
+ * @name $.jstree.defaults.search.show_only_matches_children
7523
+ * @plugin search
7524
+ */
7525
+ show_only_matches_children : false,
7526
+ /**
7527
+ * Indicates if all nodes opened to reveal the search result, should be closed when the search is cleared or a new search is performed. Default is `true`.
7528
+ * @name $.jstree.defaults.search.close_opened_onclear
7529
+ * @plugin search
7530
+ */
7531
+ close_opened_onclear : true,
7532
+ /**
7533
+ * Indicates if only leaf nodes should be included in search results. Default is `false`.
7534
+ * @name $.jstree.defaults.search.search_leaves_only
7535
+ * @plugin search
7536
+ */
7537
+ search_leaves_only : false,
7538
+ /**
7539
+ * If set to a function it wil be called in the instance's scope with two arguments - search string and node (where node will be every node in the structure, so use with caution).
7540
+ * If the function returns a truthy value the node will be considered a match (it might not be displayed if search_only_leaves is set to true and the node is not a leaf). Default is `false`.
7541
+ * @name $.jstree.defaults.search.search_callback
7542
+ * @plugin search
7543
+ */
7544
+ search_callback : false
7545
+ };
7546
+
7547
+ $.jstree.plugins.search = function (options, parent) {
7548
+ this.bind = function () {
7549
+ parent.bind.call(this);
7550
+
7551
+ this._data.search.str = "";
7552
+ this._data.search.dom = $();
7553
+ this._data.search.res = [];
7554
+ this._data.search.opn = [];
7555
+ this._data.search.som = false;
7556
+ this._data.search.smc = false;
7557
+ this._data.search.hdn = [];
7558
+
7559
+ this.element
7560
+ .on("search.jstree", $.proxy(function (e, data) {
7561
+ if(this._data.search.som && data.res.length) {
7562
+ var m = this._model.data, i, j, p = [], k, l;
7563
+ for(i = 0, j = data.res.length; i < j; i++) {
7564
+ if(m[data.res[i]] && !m[data.res[i]].state.hidden) {
7565
+ p.push(data.res[i]);
7566
+ p = p.concat(m[data.res[i]].parents);
7567
+ if(this._data.search.smc) {
7568
+ for (k = 0, l = m[data.res[i]].children_d.length; k < l; k++) {
7569
+ if (m[m[data.res[i]].children_d[k]] && !m[m[data.res[i]].children_d[k]].state.hidden) {
7570
+ p.push(m[data.res[i]].children_d[k]);
7571
+ }
7572
+ }
7573
+ }
7574
+ }
7575
+ }
7576
+ p = $.vakata.array_remove_item($.vakata.array_unique(p), $.jstree.root);
7577
+ this._data.search.hdn = this.hide_all(true);
7578
+ this.show_node(p, true);
7579
+ this.redraw(true);
7580
+ }
7581
+ }, this))
7582
+ .on("clear_search.jstree", $.proxy(function (e, data) {
7583
+ if(this._data.search.som && data.res.length) {
7584
+ this.show_node(this._data.search.hdn, true);
7585
+ this.redraw(true);
7586
+ }
7587
+ }, this));
7588
+ };
7589
+ /**
7590
+ * used to search the tree nodes for a given string
7591
+ * @name search(str [, skip_async])
7592
+ * @param {String} str the search string
7593
+ * @param {Boolean} skip_async if set to true server will not be queried even if configured
7594
+ * @param {Boolean} show_only_matches if set to true only matching nodes will be shown (keep in mind this can be very slow on large trees or old browsers)
7595
+ * @param {mixed} inside an optional node to whose children to limit the search
7596
+ * @param {Boolean} append if set to true the results of this search are appended to the previous search
7597
+ * @plugin search
7598
+ * @trigger search.jstree
7599
+ */
7600
+ this.search = function (str, skip_async, show_only_matches, inside, append, show_only_matches_children) {
7601
+ if(str === false || $.trim(str.toString()) === "") {
7602
+ return this.clear_search();
7603
+ }
7604
+ inside = this.get_node(inside);
7605
+ inside = inside && inside.id ? inside.id : null;
7606
+ str = str.toString();
7607
+ var s = this.settings.search,
7608
+ a = s.ajax ? s.ajax : false,
7609
+ m = this._model.data,
7610
+ f = null,
7611
+ r = [],
7612
+ p = [], i, j;
7613
+ if(this._data.search.res.length && !append) {
7614
+ this.clear_search();
7615
+ }
7616
+ if(show_only_matches === undefined) {
7617
+ show_only_matches = s.show_only_matches;
7618
+ }
7619
+ if(show_only_matches_children === undefined) {
7620
+ show_only_matches_children = s.show_only_matches_children;
7621
+ }
7622
+ if(!skip_async && a !== false) {
7623
+ if($.isFunction(a)) {
7624
+ return a.call(this, str, $.proxy(function (d) {
7625
+ if(d && d.d) { d = d.d; }
7626
+ this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
7627
+ this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
7628
+ });
7629
+ }, this), inside);
7630
+ }
7631
+ else {
7632
+ a = $.extend({}, a);
7633
+ if(!a.data) { a.data = {}; }
7634
+ a.data.str = str;
7635
+ if(inside) {
7636
+ a.data.inside = inside;
7637
+ }
7638
+ if (this._data.search.lastRequest) {
7639
+ this._data.search.lastRequest.abort();
7640
+ }
7641
+ this._data.search.lastRequest = $.ajax(a)
7642
+ .fail($.proxy(function () {
7643
+ this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) };
7644
+ this.settings.core.error.call(this, this._data.core.last_error);
7645
+ }, this))
7646
+ .done($.proxy(function (d) {
7647
+ if(d && d.d) { d = d.d; }
7648
+ this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
7649
+ this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
7650
+ });
7651
+ }, this));
7652
+ return this._data.search.lastRequest;
7653
+ }
7654
+ }
7655
+ if(!append) {
7656
+ this._data.search.str = str;
7657
+ this._data.search.dom = $();
7658
+ this._data.search.res = [];
7659
+ this._data.search.opn = [];
7660
+ this._data.search.som = show_only_matches;
7661
+ this._data.search.smc = show_only_matches_children;
7662
+ }
7663
+
7664
+ f = new $.vakata.search(str, true, { caseSensitive : s.case_sensitive, fuzzy : s.fuzzy });
7665
+ $.each(m[inside ? inside : $.jstree.root].children_d, function (ii, i) {
7666
+ var v = m[i];
7667
+ if(v.text && !v.state.hidden && (!s.search_leaves_only || (v.state.loaded && v.children.length === 0)) && ( (s.search_callback && s.search_callback.call(this, str, v)) || (!s.search_callback && f.search(v.text).isMatch) ) ) {
7668
+ r.push(i);
7669
+ p = p.concat(v.parents);
7670
+ }
7671
+ });
7672
+ if(r.length) {
7673
+ p = $.vakata.array_unique(p);
7674
+ for(i = 0, j = p.length; i < j; i++) {
7675
+ if(p[i] !== $.jstree.root && m[p[i]] && this.open_node(p[i], null, 0) === true) {
7676
+ this._data.search.opn.push(p[i]);
7677
+ }
7678
+ }
7679
+ if(!append) {
7680
+ this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #')));
7681
+ this._data.search.res = r;
7682
+ }
7683
+ else {
7684
+ this._data.search.dom = this._data.search.dom.add($(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))));
7685
+ this._data.search.res = $.vakata.array_unique(this._data.search.res.concat(r));
7686
+ }
7687
+ this._data.search.dom.children(".jstree-anchor").addClass('jstree-search');
7688
+ }
7689
+ /**
7690
+ * triggered after search is complete
7691
+ * @event
7692
+ * @name search.jstree
7693
+ * @param {jQuery} nodes a jQuery collection of matching nodes
7694
+ * @param {String} str the search string
7695
+ * @param {Array} res a collection of objects represeing the matching nodes
7696
+ * @plugin search
7697
+ */
7698
+ this.trigger('search', { nodes : this._data.search.dom, str : str, res : this._data.search.res, show_only_matches : show_only_matches });
7699
+ };
7700
+ /**
7701
+ * used to clear the last search (removes classes and shows all nodes if filtering is on)
7702
+ * @name clear_search()
7703
+ * @plugin search
7704
+ * @trigger clear_search.jstree
7705
+ */
7706
+ this.clear_search = function () {
7707
+ if(this.settings.search.close_opened_onclear) {
7708
+ this.close_node(this._data.search.opn, 0);
7709
+ }
7710
+ /**
7711
+ * triggered after search is complete
7712
+ * @event
7713
+ * @name clear_search.jstree
7714
+ * @param {jQuery} nodes a jQuery collection of matching nodes (the result from the last search)
7715
+ * @param {String} str the search string (the last search string)
7716
+ * @param {Array} res a collection of objects represeing the matching nodes (the result from the last search)
7717
+ * @plugin search
7718
+ */
7719
+ this.trigger('clear_search', { 'nodes' : this._data.search.dom, str : this._data.search.str, res : this._data.search.res });
7720
+ if(this._data.search.res.length) {
7721
+ this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(this._data.search.res, function (v) {
7722
+ return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&');
7723
+ }).join(', #')));
7724
+ this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search");
7725
+ }
7726
+ this._data.search.str = "";
7727
+ this._data.search.res = [];
7728
+ this._data.search.opn = [];
7729
+ this._data.search.dom = $();
7730
+ };
7731
+
7732
+ this.redraw_node = function(obj, deep, callback, force_render) {
7733
+ obj = parent.redraw_node.apply(this, arguments);
7734
+ if(obj) {
7735
+ if($.inArray(obj.id, this._data.search.res) !== -1) {
7736
+ var i, j, tmp = null;
7737
+ for(i = 0, j = obj.childNodes.length; i < j; i++) {
7738
+ if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) {
7739
+ tmp = obj.childNodes[i];
7740
+ break;
7741
+ }
7742
+ }
7743
+ if(tmp) {
7744
+ tmp.className += ' jstree-search';
7745
+ }
7746
+ }
7747
+ }
7748
+ return obj;
7749
+ };
7750
+ };
7751
+
7752
+ // helpers
7753
+ (function ($) {
7754
+ // from http://kiro.me/projects/fuse.html
7755
+ $.vakata.search = function(pattern, txt, options) {
7756
+ options = options || {};
7757
+ options = $.extend({}, $.vakata.search.defaults, options);
7758
+ if(options.fuzzy !== false) {
7759
+ options.fuzzy = true;
7760
+ }
7761
+ pattern = options.caseSensitive ? pattern : pattern.toLowerCase();
7762
+ var MATCH_LOCATION = options.location,
7763
+ MATCH_DISTANCE = options.distance,
7764
+ MATCH_THRESHOLD = options.threshold,
7765
+ patternLen = pattern.length,
7766
+ matchmask, pattern_alphabet, match_bitapScore, search;
7767
+ if(patternLen > 32) {
7768
+ options.fuzzy = false;
7769
+ }
7770
+ if(options.fuzzy) {
7771
+ matchmask = 1 << (patternLen - 1);
7772
+ pattern_alphabet = (function () {
7773
+ var mask = {},
7774
+ i = 0;
7775
+ for (i = 0; i < patternLen; i++) {
7776
+ mask[pattern.charAt(i)] = 0;
7777
+ }
7778
+ for (i = 0; i < patternLen; i++) {
7779
+ mask[pattern.charAt(i)] |= 1 << (patternLen - i - 1);
7780
+ }
7781
+ return mask;
7782
+ }());
7783
+ match_bitapScore = function (e, x) {
7784
+ var accuracy = e / patternLen,
7785
+ proximity = Math.abs(MATCH_LOCATION - x);
7786
+ if(!MATCH_DISTANCE) {
7787
+ return proximity ? 1.0 : accuracy;
7788
+ }
7789
+ return accuracy + (proximity / MATCH_DISTANCE);
7790
+ };
7791
+ }
7792
+ search = function (text) {
7793
+ text = options.caseSensitive ? text : text.toLowerCase();
7794
+ if(pattern === text || text.indexOf(pattern) !== -1) {
7795
+ return {
7796
+ isMatch: true,
7797
+ score: 0
7798
+ };
7799
+ }
7800
+ if(!options.fuzzy) {
7801
+ return {
7802
+ isMatch: false,
7803
+ score: 1
7804
+ };
7805
+ }
7806
+ var i, j,
7807
+ textLen = text.length,
7808
+ scoreThreshold = MATCH_THRESHOLD,
7809
+ bestLoc = text.indexOf(pattern, MATCH_LOCATION),
7810
+ binMin, binMid,
7811
+ binMax = patternLen + textLen,
7812
+ lastRd, start, finish, rd, charMatch,
7813
+ score = 1,
7814
+ locations = [];
7815
+ if (bestLoc !== -1) {
7816
+ scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold);
7817
+ bestLoc = text.lastIndexOf(pattern, MATCH_LOCATION + patternLen);
7818
+ if (bestLoc !== -1) {
7819
+ scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold);
7820
+ }
7821
+ }
7822
+ bestLoc = -1;
7823
+ for (i = 0; i < patternLen; i++) {
7824
+ binMin = 0;
7825
+ binMid = binMax;
7826
+ while (binMin < binMid) {
7827
+ if (match_bitapScore(i, MATCH_LOCATION + binMid) <= scoreThreshold) {
7828
+ binMin = binMid;
7829
+ } else {
7830
+ binMax = binMid;
7831
+ }
7832
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
7833
+ }
7834
+ binMax = binMid;
7835
+ start = Math.max(1, MATCH_LOCATION - binMid + 1);
7836
+ finish = Math.min(MATCH_LOCATION + binMid, textLen) + patternLen;
7837
+ rd = new Array(finish + 2);
7838
+ rd[finish + 1] = (1 << i) - 1;
7839
+ for (j = finish; j >= start; j--) {
7840
+ charMatch = pattern_alphabet[text.charAt(j - 1)];
7841
+ if (i === 0) {
7842
+ rd[j] = ((rd[j + 1] << 1) | 1) & charMatch;
7843
+ } else {
7844
+ rd[j] = ((rd[j + 1] << 1) | 1) & charMatch | (((lastRd[j + 1] | lastRd[j]) << 1) | 1) | lastRd[j + 1];
7845
+ }
7846
+ if (rd[j] & matchmask) {
7847
+ score = match_bitapScore(i, j - 1);
7848
+ if (score <= scoreThreshold) {
7849
+ scoreThreshold = score;
7850
+ bestLoc = j - 1;
7851
+ locations.push(bestLoc);
7852
+ if (bestLoc > MATCH_LOCATION) {
7853
+ start = Math.max(1, 2 * MATCH_LOCATION - bestLoc);
7854
+ } else {
7855
+ break;
7856
+ }
7857
+ }
7858
+ }
7859
+ }
7860
+ if (match_bitapScore(i + 1, MATCH_LOCATION) > scoreThreshold) {
7861
+ break;
7862
+ }
7863
+ lastRd = rd;
7864
+ }
7865
+ return {
7866
+ isMatch: bestLoc >= 0,
7867
+ score: score
7868
+ };
7869
+ };
7870
+ return txt === true ? { 'search' : search } : search(txt);
7871
+ };
7872
+ $.vakata.search.defaults = {
7873
+ location : 0,
7874
+ distance : 100,
7875
+ threshold : 0.6,
7876
+ fuzzy : false,
7877
+ caseSensitive : false
7878
+ };
7879
+ }($));
7880
+
7881
+ // include the search plugin by default
7882
+ // $.jstree.defaults.plugins.push("search");
7883
+
7884
+
7885
+ /**
7886
+ * ### Sort plugin
7887
+ *
7888
+ * Automatically sorts all siblings in the tree according to a sorting function.
7889
+ */
7890
+
7891
+ /**
7892
+ * the settings function used to sort the nodes.
7893
+ * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`.
7894
+ * @name $.jstree.defaults.sort
7895
+ * @plugin sort
7896
+ */
7897
+ $.jstree.defaults.sort = function (a, b) {
7898
+ //return this.get_type(a) === this.get_type(b) ? (this.get_text(a) > this.get_text(b) ? 1 : -1) : this.get_type(a) >= this.get_type(b);
7899
+ return this.get_text(a) > this.get_text(b) ? 1 : -1;
7900
+ };
7901
+ $.jstree.plugins.sort = function (options, parent) {
7902
+ this.bind = function () {
7903
+ parent.bind.call(this);
7904
+ this.element
7905
+ .on("model.jstree", $.proxy(function (e, data) {
7906
+ this.sort(data.parent, true);
7907
+ }, this))
7908
+ .on("rename_node.jstree create_node.jstree", $.proxy(function (e, data) {
7909
+ this.sort(data.parent || data.node.parent, false);
7910
+ this.redraw_node(data.parent || data.node.parent, true);
7911
+ }, this))
7912
+ .on("move_node.jstree copy_node.jstree", $.proxy(function (e, data) {
7913
+ this.sort(data.parent, false);
7914
+ this.redraw_node(data.parent, true);
7915
+ }, this));
7916
+ };
7917
+ /**
7918
+ * used to sort a node's children
7919
+ * @private
7920
+ * @name sort(obj [, deep])
7921
+ * @param {mixed} obj the node
7922
+ * @param {Boolean} deep if set to `true` nodes are sorted recursively.
7923
+ * @plugin sort
7924
+ * @trigger search.jstree
7925
+ */
7926
+ this.sort = function (obj, deep) {
7927
+ var i, j;
7928
+ obj = this.get_node(obj);
7929
+ if(obj && obj.children && obj.children.length) {
7930
+ obj.children.sort($.proxy(this.settings.sort, this));
7931
+ if(deep) {
7932
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
7933
+ this.sort(obj.children_d[i], false);
7934
+ }
7935
+ }
7936
+ }
7937
+ };
7938
+ };
7939
+
7940
+ // include the sort plugin by default
7941
+ // $.jstree.defaults.plugins.push("sort");
7942
+
7943
+ /**
7944
+ * ### State plugin
7945
+ *
7946
+ * Saves the state of the tree (selected nodes, opened nodes) on the user's computer using available options (localStorage, cookies, etc)
7947
+ */
7948
+
7949
+ var to = false;
7950
+ /**
7951
+ * stores all defaults for the state plugin
7952
+ * @name $.jstree.defaults.state
7953
+ * @plugin state
7954
+ */
7955
+ $.jstree.defaults.state = {
7956
+ /**
7957
+ * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`.
7958
+ * @name $.jstree.defaults.state.key
7959
+ * @plugin state
7960
+ */
7961
+ key : 'jstree',
7962
+ /**
7963
+ * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`.
7964
+ * @name $.jstree.defaults.state.events
7965
+ * @plugin state
7966
+ */
7967
+ events : 'changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree',
7968
+ /**
7969
+ * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire.
7970
+ * @name $.jstree.defaults.state.ttl
7971
+ * @plugin state
7972
+ */
7973
+ ttl : false,
7974
+ /**
7975
+ * A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state.
7976
+ * @name $.jstree.defaults.state.filter
7977
+ * @plugin state
7978
+ */
7979
+ filter : false,
7980
+ /**
7981
+ * Should loaded nodes be restored (setting this to true means that it is possible that the whole tree will be loaded for some users - use with caution). Defaults to `false`
7982
+ * @name $.jstree.defaults.state.preserve_loaded
7983
+ * @plugin state
7984
+ */
7985
+ preserve_loaded : false
7986
+ };
7987
+ $.jstree.plugins.state = function (options, parent) {
7988
+ this.bind = function () {
7989
+ parent.bind.call(this);
7990
+ var bind = $.proxy(function () {
7991
+ this.element.on(this.settings.state.events, $.proxy(function () {
7992
+ if(to) { clearTimeout(to); }
7993
+ to = setTimeout($.proxy(function () { this.save_state(); }, this), 100);
7994
+ }, this));
7995
+ /**
7996
+ * triggered when the state plugin is finished restoring the state (and immediately after ready if there is no state to restore).
7997
+ * @event
7998
+ * @name state_ready.jstree
7999
+ * @plugin state
8000
+ */
8001
+ this.trigger('state_ready');
8002
+ }, this);
8003
+ this.element
8004
+ .on("ready.jstree", $.proxy(function (e, data) {
8005
+ this.element.one("restore_state.jstree", bind);
8006
+ if(!this.restore_state()) { bind(); }
8007
+ }, this));
8008
+ };
8009
+ /**
8010
+ * save the state
8011
+ * @name save_state()
8012
+ * @plugin state
8013
+ */
8014
+ this.save_state = function () {
8015
+ var tm = this.get_state();
8016
+ if (!this.settings.state.preserve_loaded) {
8017
+ delete tm.core.loaded;
8018
+ }
8019
+ var st = { 'state' : tm, 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
8020
+ $.vakata.storage.set(this.settings.state.key, JSON.stringify(st));
8021
+ };
8022
+ /**
8023
+ * restore the state from the user's computer
8024
+ * @name restore_state()
8025
+ * @plugin state
8026
+ */
8027
+ this.restore_state = function () {
8028
+ var k = $.vakata.storage.get(this.settings.state.key);
8029
+ if(!!k) { try { k = JSON.parse(k); } catch(ex) { return false; } }
8030
+ if(!!k && k.ttl && k.sec && +(new Date()) - k.sec > k.ttl) { return false; }
8031
+ if(!!k && k.state) { k = k.state; }
8032
+ if(!!k && $.isFunction(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); }
8033
+ if(!!k) {
8034
+ if (!this.settings.state.preserve_loaded) {
8035
+ delete k.core.loaded;
8036
+ }
8037
+ this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); });
8038
+ this.set_state(k);
8039
+ return true;
8040
+ }
8041
+ return false;
8042
+ };
8043
+ /**
8044
+ * clear the state on the user's computer
8045
+ * @name clear_state()
8046
+ * @plugin state
8047
+ */
8048
+ this.clear_state = function () {
8049
+ return $.vakata.storage.del(this.settings.state.key);
8050
+ };
8051
+ };
8052
+
8053
+ (function ($, undefined) {
8054
+ $.vakata.storage = {
8055
+ // simply specifying the functions in FF throws an error
8056
+ set : function (key, val) { return window.localStorage.setItem(key, val); },
8057
+ get : function (key) { return window.localStorage.getItem(key); },
8058
+ del : function (key) { return window.localStorage.removeItem(key); }
8059
+ };
8060
+ }($));
8061
+
8062
+ // include the state plugin by default
8063
+ // $.jstree.defaults.plugins.push("state");
8064
+
8065
+ /**
8066
+ * ### Types plugin
8067
+ *
8068
+ * Makes it possible to add predefined types for groups of nodes, which make it possible to easily control nesting rules and icon for each group.
8069
+ */
8070
+
8071
+ /**
8072
+ * An object storing all types as key value pairs, where the key is the type name and the value is an object that could contain following keys (all optional).
8073
+ *
8074
+ * * `max_children` the maximum number of immediate children this node type can have. Do not specify or set to `-1` for unlimited.
8075
+ * * `max_depth` the maximum number of nesting this node type can have. A value of `1` would mean that the node can have children, but no grandchildren. Do not specify or set to `-1` for unlimited.
8076
+ * * `valid_children` an array of node type strings, that nodes of this type can have as children. Do not specify or set to `-1` for no limits.
8077
+ * * `icon` a string - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class. Omit to use the default icon from your theme.
8078
+ * * `li_attr` an object of values which will be used to add HTML attributes on the resulting LI DOM node (merged with the node's own data)
8079
+ * * `a_attr` an object of values which will be used to add HTML attributes on the resulting A DOM node (merged with the node's own data)
8080
+ *
8081
+ * There are two predefined types:
8082
+ *
8083
+ * * `#` represents the root of the tree, for example `max_children` would control the maximum number of root nodes.
8084
+ * * `default` represents the default node - any settings here will be applied to all nodes that do not have a type specified.
8085
+ *
8086
+ * @name $.jstree.defaults.types
8087
+ * @plugin types
8088
+ */
8089
+ $.jstree.defaults.types = {
8090
+ 'default' : {}
8091
+ };
8092
+ $.jstree.defaults.types[$.jstree.root] = {};
8093
+
8094
+ $.jstree.plugins.types = function (options, parent) {
8095
+ this.init = function (el, options) {
8096
+ var i, j;
8097
+ if(options && options.types && options.types['default']) {
8098
+ for(i in options.types) {
8099
+ if(i !== "default" && i !== $.jstree.root && options.types.hasOwnProperty(i)) {
8100
+ for(j in options.types['default']) {
8101
+ if(options.types['default'].hasOwnProperty(j) && options.types[i][j] === undefined) {
8102
+ options.types[i][j] = options.types['default'][j];
8103
+ }
8104
+ }
8105
+ }
8106
+ }
8107
+ }
8108
+ parent.init.call(this, el, options);
8109
+ this._model.data[$.jstree.root].type = $.jstree.root;
8110
+ };
8111
+ this.refresh = function (skip_loading, forget_state) {
8112
+ parent.refresh.call(this, skip_loading, forget_state);
8113
+ this._model.data[$.jstree.root].type = $.jstree.root;
8114
+ };
8115
+ this.bind = function () {
8116
+ this.element
8117
+ .on('model.jstree', $.proxy(function (e, data) {
8118
+ var m = this._model.data,
8119
+ dpc = data.nodes,
8120
+ t = this.settings.types,
8121
+ i, j, c = 'default', k;
8122
+ for(i = 0, j = dpc.length; i < j; i++) {
8123
+ c = 'default';
8124
+ if(m[dpc[i]].original && m[dpc[i]].original.type && t[m[dpc[i]].original.type]) {
8125
+ c = m[dpc[i]].original.type;
8126
+ }
8127
+ if(m[dpc[i]].data && m[dpc[i]].data.jstree && m[dpc[i]].data.jstree.type && t[m[dpc[i]].data.jstree.type]) {
8128
+ c = m[dpc[i]].data.jstree.type;
8129
+ }
8130
+ m[dpc[i]].type = c;
8131
+ if(m[dpc[i]].icon === true && t[c].icon !== undefined) {
8132
+ m[dpc[i]].icon = t[c].icon;
8133
+ }
8134
+ if(t[c].li_attr !== undefined && typeof t[c].li_attr === 'object') {
8135
+ for (k in t[c].li_attr) {
8136
+ if (t[c].li_attr.hasOwnProperty(k)) {
8137
+ if (k === 'id') {
8138
+ continue;
8139
+ }
8140
+ else if (m[dpc[i]].li_attr[k] === undefined) {
8141
+ m[dpc[i]].li_attr[k] = t[c].li_attr[k];
8142
+ }
8143
+ else if (k === 'class') {
8144
+ m[dpc[i]].li_attr['class'] = t[c].li_attr['class'] + ' ' + m[dpc[i]].li_attr['class'];
8145
+ }
8146
+ }
8147
+ }
8148
+ }
8149
+ if(t[c].a_attr !== undefined && typeof t[c].a_attr === 'object') {
8150
+ for (k in t[c].a_attr) {
8151
+ if (t[c].a_attr.hasOwnProperty(k)) {
8152
+ if (k === 'id') {
8153
+ continue;
8154
+ }
8155
+ else if (m[dpc[i]].a_attr[k] === undefined) {
8156
+ m[dpc[i]].a_attr[k] = t[c].a_attr[k];
8157
+ }
8158
+ else if (k === 'href' && m[dpc[i]].a_attr[k] === '#') {
8159
+ m[dpc[i]].a_attr['href'] = t[c].a_attr['href'];
8160
+ }
8161
+ else if (k === 'class') {
8162
+ m[dpc[i]].a_attr['class'] = t[c].a_attr['class'] + ' ' + m[dpc[i]].a_attr['class'];
8163
+ }
8164
+ }
8165
+ }
8166
+ }
8167
+ }
8168
+ m[$.jstree.root].type = $.jstree.root;
8169
+ }, this));
8170
+ parent.bind.call(this);
8171
+ };
8172
+ this.get_json = function (obj, options, flat) {
8173
+ var i, j,
8174
+ m = this._model.data,
8175
+ opt = options ? $.extend(true, {}, options, {no_id:false}) : {},
8176
+ tmp = parent.get_json.call(this, obj, opt, flat);
8177
+ if(tmp === false) { return false; }
8178
+ if($.isArray(tmp)) {
8179
+ for(i = 0, j = tmp.length; i < j; i++) {
8180
+ tmp[i].type = tmp[i].id && m[tmp[i].id] && m[tmp[i].id].type ? m[tmp[i].id].type : "default";
8181
+ if(options && options.no_id) {
8182
+ delete tmp[i].id;
8183
+ if(tmp[i].li_attr && tmp[i].li_attr.id) {
8184
+ delete tmp[i].li_attr.id;
8185
+ }
8186
+ if(tmp[i].a_attr && tmp[i].a_attr.id) {
8187
+ delete tmp[i].a_attr.id;
8188
+ }
8189
+ }
8190
+ }
8191
+ }
8192
+ else {
8193
+ tmp.type = tmp.id && m[tmp.id] && m[tmp.id].type ? m[tmp.id].type : "default";
8194
+ if(options && options.no_id) {
8195
+ tmp = this._delete_ids(tmp);
8196
+ }
8197
+ }
8198
+ return tmp;
8199
+ };
8200
+ this._delete_ids = function (tmp) {
8201
+ if($.isArray(tmp)) {
8202
+ for(var i = 0, j = tmp.length; i < j; i++) {
8203
+ tmp[i] = this._delete_ids(tmp[i]);
8204
+ }
8205
+ return tmp;
8206
+ }
8207
+ delete tmp.id;
8208
+ if(tmp.li_attr && tmp.li_attr.id) {
8209
+ delete tmp.li_attr.id;
8210
+ }
8211
+ if(tmp.a_attr && tmp.a_attr.id) {
8212
+ delete tmp.a_attr.id;
8213
+ }
8214
+ if(tmp.children && $.isArray(tmp.children)) {
8215
+ tmp.children = this._delete_ids(tmp.children);
8216
+ }
8217
+ return tmp;
8218
+ };
8219
+ this.check = function (chk, obj, par, pos, more) {
8220
+ if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
8221
+ obj = obj && obj.id ? obj : this.get_node(obj);
8222
+ par = par && par.id ? par : this.get_node(par);
8223
+ var m = obj && obj.id ? (more && more.origin ? more.origin : $.jstree.reference(obj.id)) : null, tmp, d, i, j;
8224
+ m = m && m._model && m._model.data ? m._model.data : null;
8225
+ switch(chk) {
8226
+ case "create_node":
8227
+ case "move_node":
8228
+ case "copy_node":
8229
+ if(chk !== 'move_node' || $.inArray(obj.id, par.children) === -1) {
8230
+ tmp = this.get_rules(par);
8231
+ if(tmp.max_children !== undefined && tmp.max_children !== -1 && tmp.max_children === par.children.length) {
8232
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_01', 'reason' : 'max_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8233
+ return false;
8234
+ }
8235
+ if(tmp.valid_children !== undefined && tmp.valid_children !== -1 && $.inArray((obj.type || 'default'), tmp.valid_children) === -1) {
8236
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_02', 'reason' : 'valid_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8237
+ return false;
8238
+ }
8239
+ if(m && obj.children_d && obj.parents) {
8240
+ d = 0;
8241
+ for(i = 0, j = obj.children_d.length; i < j; i++) {
8242
+ d = Math.max(d, m[obj.children_d[i]].parents.length);
8243
+ }
8244
+ d = d - obj.parents.length + 1;
8245
+ }
8246
+ if(d <= 0 || d === undefined) { d = 1; }
8247
+ do {
8248
+ if(tmp.max_depth !== undefined && tmp.max_depth !== -1 && tmp.max_depth < d) {
8249
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_03', 'reason' : 'max_depth prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8250
+ return false;
8251
+ }
8252
+ par = this.get_node(par.parent);
8253
+ tmp = this.get_rules(par);
8254
+ d++;
8255
+ } while(par);
8256
+ }
8257
+ break;
8258
+ }
8259
+ return true;
8260
+ };
8261
+ /**
8262
+ * used to retrieve the type settings object for a node
8263
+ * @name get_rules(obj)
8264
+ * @param {mixed} obj the node to find the rules for
8265
+ * @return {Object}
8266
+ * @plugin types
8267
+ */
8268
+ this.get_rules = function (obj) {
8269
+ obj = this.get_node(obj);
8270
+ if(!obj) { return false; }
8271
+ var tmp = this.get_type(obj, true);
8272
+ if(tmp.max_depth === undefined) { tmp.max_depth = -1; }
8273
+ if(tmp.max_children === undefined) { tmp.max_children = -1; }
8274
+ if(tmp.valid_children === undefined) { tmp.valid_children = -1; }
8275
+ return tmp;
8276
+ };
8277
+ /**
8278
+ * used to retrieve the type string or settings object for a node
8279
+ * @name get_type(obj [, rules])
8280
+ * @param {mixed} obj the node to find the rules for
8281
+ * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned
8282
+ * @return {String|Object}
8283
+ * @plugin types
8284
+ */
8285
+ this.get_type = function (obj, rules) {
8286
+ obj = this.get_node(obj);
8287
+ return (!obj) ? false : ( rules ? $.extend({ 'type' : obj.type }, this.settings.types[obj.type]) : obj.type);
8288
+ };
8289
+ /**
8290
+ * used to change a node's type
8291
+ * @name set_type(obj, type)
8292
+ * @param {mixed} obj the node to change
8293
+ * @param {String} type the new type
8294
+ * @plugin types
8295
+ */
8296
+ this.set_type = function (obj, type) {
8297
+ var m = this._model.data, t, t1, t2, old_type, old_icon, k, d, a;
8298
+ if($.isArray(obj)) {
8299
+ obj = obj.slice();
8300
+ for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
8301
+ this.set_type(obj[t1], type);
8302
+ }
8303
+ return true;
8304
+ }
8305
+ t = this.settings.types;
8306
+ obj = this.get_node(obj);
8307
+ if(!t[type] || !obj) { return false; }
8308
+ d = this.get_node(obj, true);
8309
+ if (d && d.length) {
8310
+ a = d.children('.jstree-anchor');
8311
+ }
8312
+ old_type = obj.type;
8313
+ old_icon = this.get_icon(obj);
8314
+ obj.type = type;
8315
+ if(old_icon === true || !t[old_type] || (t[old_type].icon !== undefined && old_icon === t[old_type].icon)) {
8316
+ this.set_icon(obj, t[type].icon !== undefined ? t[type].icon : true);
8317
+ }
8318
+
8319
+ // remove old type props
8320
+ if(t[old_type] && t[old_type].li_attr !== undefined && typeof t[old_type].li_attr === 'object') {
8321
+ for (k in t[old_type].li_attr) {
8322
+ if (t[old_type].li_attr.hasOwnProperty(k)) {
8323
+ if (k === 'id') {
8324
+ continue;
8325
+ }
8326
+ else if (k === 'class') {
8327
+ m[obj.id].li_attr['class'] = (m[obj.id].li_attr['class'] || '').replace(t[old_type].li_attr[k], '');
8328
+ if (d) { d.removeClass(t[old_type].li_attr[k]); }
8329
+ }
8330
+ else if (m[obj.id].li_attr[k] === t[old_type].li_attr[k]) {
8331
+ m[obj.id].li_attr[k] = null;
8332
+ if (d) { d.removeAttr(k); }
8333
+ }
8334
+ }
8335
+ }
8336
+ }
8337
+ if(t[old_type] && t[old_type].a_attr !== undefined && typeof t[old_type].a_attr === 'object') {
8338
+ for (k in t[old_type].a_attr) {
8339
+ if (t[old_type].a_attr.hasOwnProperty(k)) {
8340
+ if (k === 'id') {
8341
+ continue;
8342
+ }
8343
+ else if (k === 'class') {
8344
+ m[obj.id].a_attr['class'] = (m[obj.id].a_attr['class'] || '').replace(t[old_type].a_attr[k], '');
8345
+ if (a) { a.removeClass(t[old_type].a_attr[k]); }
8346
+ }
8347
+ else if (m[obj.id].a_attr[k] === t[old_type].a_attr[k]) {
8348
+ if (k === 'href') {
8349
+ m[obj.id].a_attr[k] = '#';
8350
+ if (a) { a.attr('href', '#'); }
8351
+ }
8352
+ else {
8353
+ delete m[obj.id].a_attr[k];
8354
+ if (a) { a.removeAttr(k); }
8355
+ }
8356
+ }
8357
+ }
8358
+ }
8359
+ }
8360
+
8361
+ // add new props
8362
+ if(t[type].li_attr !== undefined && typeof t[type].li_attr === 'object') {
8363
+ for (k in t[type].li_attr) {
8364
+ if (t[type].li_attr.hasOwnProperty(k)) {
8365
+ if (k === 'id') {
8366
+ continue;
8367
+ }
8368
+ else if (m[obj.id].li_attr[k] === undefined) {
8369
+ m[obj.id].li_attr[k] = t[type].li_attr[k];
8370
+ if (d) {
8371
+ if (k === 'class') {
8372
+ d.addClass(t[type].li_attr[k]);
8373
+ }
8374
+ else {
8375
+ d.attr(k, t[type].li_attr[k]);
8376
+ }
8377
+ }
8378
+ }
8379
+ else if (k === 'class') {
8380
+ m[obj.id].li_attr['class'] = t[type].li_attr[k] + ' ' + m[obj.id].li_attr['class'];
8381
+ if (d) { d.addClass(t[type].li_attr[k]); }
8382
+ }
8383
+ }
8384
+ }
8385
+ }
8386
+ if(t[type].a_attr !== undefined && typeof t[type].a_attr === 'object') {
8387
+ for (k in t[type].a_attr) {
8388
+ if (t[type].a_attr.hasOwnProperty(k)) {
8389
+ if (k === 'id') {
8390
+ continue;
8391
+ }
8392
+ else if (m[obj.id].a_attr[k] === undefined) {
8393
+ m[obj.id].a_attr[k] = t[type].a_attr[k];
8394
+ if (a) {
8395
+ if (k === 'class') {
8396
+ a.addClass(t[type].a_attr[k]);
8397
+ }
8398
+ else {
8399
+ a.attr(k, t[type].a_attr[k]);
8400
+ }
8401
+ }
8402
+ }
8403
+ else if (k === 'href' && m[obj.id].a_attr[k] === '#') {
8404
+ m[obj.id].a_attr['href'] = t[type].a_attr['href'];
8405
+ if (a) { a.attr('href', t[type].a_attr['href']); }
8406
+ }
8407
+ else if (k === 'class') {
8408
+ m[obj.id].a_attr['class'] = t[type].a_attr['class'] + ' ' + m[obj.id].a_attr['class'];
8409
+ if (a) { a.addClass(t[type].a_attr[k]); }
8410
+ }
8411
+ }
8412
+ }
8413
+ }
8414
+
8415
+ return true;
8416
+ };
8417
+ };
8418
+ // include the types plugin by default
8419
+ // $.jstree.defaults.plugins.push("types");
8420
+
8421
+
8422
+ /**
8423
+ * ### Unique plugin
8424
+ *
8425
+ * Enforces that no nodes with the same name can coexist as siblings.
8426
+ */
8427
+
8428
+ /**
8429
+ * stores all defaults for the unique plugin
8430
+ * @name $.jstree.defaults.unique
8431
+ * @plugin unique
8432
+ */
8433
+ $.jstree.defaults.unique = {
8434
+ /**
8435
+ * Indicates if the comparison should be case sensitive. Default is `false`.
8436
+ * @name $.jstree.defaults.unique.case_sensitive
8437
+ * @plugin unique
8438
+ */
8439
+ case_sensitive : false,
8440
+ /**
8441
+ * Indicates if white space should be trimmed before the comparison. Default is `false`.
8442
+ * @name $.jstree.defaults.unique.trim_whitespace
8443
+ * @plugin unique
8444
+ */
8445
+ trim_whitespace : false,
8446
+ /**
8447
+ * A callback executed in the instance's scope when a new node is created and the name is already taken, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`.
8448
+ * @name $.jstree.defaults.unique.duplicate
8449
+ * @plugin unique
8450
+ */
8451
+ duplicate : function (name, counter) {
8452
+ return name + ' (' + counter + ')';
8453
+ }
8454
+ };
8455
+
8456
+ $.jstree.plugins.unique = function (options, parent) {
8457
+ this.check = function (chk, obj, par, pos, more) {
8458
+ if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
8459
+ obj = obj && obj.id ? obj : this.get_node(obj);
8460
+ par = par && par.id ? par : this.get_node(par);
8461
+ if(!par || !par.children) { return true; }
8462
+ var n = chk === "rename_node" ? pos : obj.text,
8463
+ c = [],
8464
+ s = this.settings.unique.case_sensitive,
8465
+ w = this.settings.unique.trim_whitespace,
8466
+ m = this._model.data, i, j, t;
8467
+ for(i = 0, j = par.children.length; i < j; i++) {
8468
+ t = m[par.children[i]].text;
8469
+ if (!s) {
8470
+ t = t.toLowerCase();
8471
+ }
8472
+ if (w) {
8473
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8474
+ }
8475
+ c.push(t);
8476
+ }
8477
+ if(!s) { n = n.toLowerCase(); }
8478
+ if (w) { n = n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }
8479
+ switch(chk) {
8480
+ case "delete_node":
8481
+ return true;
8482
+ case "rename_node":
8483
+ t = obj.text || '';
8484
+ if (!s) {
8485
+ t = t.toLowerCase();
8486
+ }
8487
+ if (w) {
8488
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8489
+ }
8490
+ i = ($.inArray(n, c) === -1 || (obj.text && t === n));
8491
+ if(!i) {
8492
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8493
+ }
8494
+ return i;
8495
+ case "create_node":
8496
+ i = ($.inArray(n, c) === -1);
8497
+ if(!i) {
8498
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_04', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8499
+ }
8500
+ return i;
8501
+ case "copy_node":
8502
+ i = ($.inArray(n, c) === -1);
8503
+ if(!i) {
8504
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_02', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8505
+ }
8506
+ return i;
8507
+ case "move_node":
8508
+ i = ( (obj.parent === par.id && (!more || !more.is_multi)) || $.inArray(n, c) === -1);
8509
+ if(!i) {
8510
+ this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_03', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
8511
+ }
8512
+ return i;
8513
+ }
8514
+ return true;
8515
+ };
8516
+ this.create_node = function (par, node, pos, callback, is_loaded) {
8517
+ if(!node || node.text === undefined) {
8518
+ if(par === null) {
8519
+ par = $.jstree.root;
8520
+ }
8521
+ par = this.get_node(par);
8522
+ if(!par) {
8523
+ return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8524
+ }
8525
+ pos = pos === undefined ? "last" : pos;
8526
+ if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
8527
+ return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8528
+ }
8529
+ if(!node) { node = {}; }
8530
+ var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, w = this.settings.unique.trim_whitespace, cb = this.settings.unique.duplicate, t;
8531
+ n = tmp = this.get_string('New node');
8532
+ dpc = [];
8533
+ for(i = 0, j = par.children.length; i < j; i++) {
8534
+ t = m[par.children[i]].text;
8535
+ if (!s) {
8536
+ t = t.toLowerCase();
8537
+ }
8538
+ if (w) {
8539
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8540
+ }
8541
+ dpc.push(t);
8542
+ }
8543
+ i = 1;
8544
+ t = n;
8545
+ if (!s) {
8546
+ t = t.toLowerCase();
8547
+ }
8548
+ if (w) {
8549
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8550
+ }
8551
+ while($.inArray(t, dpc) !== -1) {
8552
+ n = cb.call(this, tmp, (++i)).toString();
8553
+ t = n;
8554
+ if (!s) {
8555
+ t = t.toLowerCase();
8556
+ }
8557
+ if (w) {
8558
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8559
+ }
8560
+ }
8561
+ node.text = n;
8562
+ }
8563
+ return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8564
+ };
8565
+ };
8566
+
8567
+ // include the unique plugin by default
8568
+ // $.jstree.defaults.plugins.push("unique");
8569
+
8570
+
8571
+ /**
8572
+ * ### Wholerow plugin
8573
+ *
8574
+ * Makes each node appear block level. Making selection easier. May cause slow down for large trees in old browsers.
8575
+ */
8576
+
8577
+ var div = document.createElement('DIV');
8578
+ div.setAttribute('unselectable','on');
8579
+ div.setAttribute('role','presentation');
8580
+ div.className = 'jstree-wholerow';
8581
+ div.innerHTML = '&#160;';
8582
+ $.jstree.plugins.wholerow = function (options, parent) {
8583
+ this.bind = function () {
8584
+ parent.bind.call(this);
8585
+
8586
+ this.element
8587
+ .on('ready.jstree set_state.jstree', $.proxy(function () {
8588
+ this.hide_dots();
8589
+ }, this))
8590
+ .on("init.jstree loading.jstree ready.jstree", $.proxy(function () {
8591
+ //div.style.height = this._data.core.li_height + 'px';
8592
+ this.get_container_ul().addClass('jstree-wholerow-ul');
8593
+ }, this))
8594
+ .on("deselect_all.jstree", $.proxy(function (e, data) {
8595
+ this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked');
8596
+ }, this))
8597
+ .on("changed.jstree", $.proxy(function (e, data) {
8598
+ this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked');
8599
+ var tmp = false, i, j;
8600
+ for(i = 0, j = data.selected.length; i < j; i++) {
8601
+ tmp = this.get_node(data.selected[i], true);
8602
+ if(tmp && tmp.length) {
8603
+ tmp.children('.jstree-wholerow').addClass('jstree-wholerow-clicked');
8604
+ }
8605
+ }
8606
+ }, this))
8607
+ .on("open_node.jstree", $.proxy(function (e, data) {
8608
+ this.get_node(data.node, true).find('.jstree-clicked').parent().children('.jstree-wholerow').addClass('jstree-wholerow-clicked');
8609
+ }, this))
8610
+ .on("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) {
8611
+ if(e.type === "hover_node" && this.is_disabled(data.node)) { return; }
8612
+ this.get_node(data.node, true).children('.jstree-wholerow')[e.type === "hover_node"?"addClass":"removeClass"]('jstree-wholerow-hovered');
8613
+ }, this))
8614
+ .on("contextmenu.jstree", ".jstree-wholerow", $.proxy(function (e) {
8615
+ if (this._data.contextmenu) {
8616
+ e.preventDefault();
8617
+ var tmp = $.Event('contextmenu', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey, pageX : e.pageX, pageY : e.pageY });
8618
+ $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp);
8619
+ }
8620
+ }, this))
8621
+ /*!
8622
+ .on("mousedown.jstree touchstart.jstree", ".jstree-wholerow", function (e) {
8623
+ if(e.target === e.currentTarget) {
8624
+ var a = $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor");
8625
+ e.target = a[0];
8626
+ a.trigger(e);
8627
+ }
8628
+ })
8629
+ */
8630
+ .on("click.jstree", ".jstree-wholerow", function (e) {
8631
+ e.stopImmediatePropagation();
8632
+ var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
8633
+ $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
8634
+ })
8635
+ .on("dblclick.jstree", ".jstree-wholerow", function (e) {
8636
+ e.stopImmediatePropagation();
8637
+ var tmp = $.Event('dblclick', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
8638
+ $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
8639
+ })
8640
+ .on("click.jstree", ".jstree-leaf > .jstree-ocl", $.proxy(function (e) {
8641
+ e.stopImmediatePropagation();
8642
+ var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
8643
+ $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
8644
+ }, this))
8645
+ .on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", $.proxy(function (e) {
8646
+ e.stopImmediatePropagation();
8647
+ if(!this.is_disabled(e.currentTarget)) {
8648
+ this.hover_node(e.currentTarget);
8649
+ }
8650
+ return false;
8651
+ }, this))
8652
+ .on("mouseleave.jstree", ".jstree-node", $.proxy(function (e) {
8653
+ this.dehover_node(e.currentTarget);
8654
+ }, this));
8655
+ };
8656
+ this.teardown = function () {
8657
+ if(this.settings.wholerow) {
8658
+ this.element.find(".jstree-wholerow").remove();
8659
+ }
8660
+ parent.teardown.call(this);
8661
+ };
8662
+ this.redraw_node = function(obj, deep, callback, force_render) {
8663
+ obj = parent.redraw_node.apply(this, arguments);
8664
+ if(obj) {
8665
+ var tmp = div.cloneNode(true);
8666
+ //tmp.style.height = this._data.core.li_height + 'px';
8667
+ if($.inArray(obj.id, this._data.core.selected) !== -1) { tmp.className += ' jstree-wholerow-clicked'; }
8668
+ if(this._data.core.focused && this._data.core.focused === obj.id) { tmp.className += ' jstree-wholerow-hovered'; }
8669
+ obj.insertBefore(tmp, obj.childNodes[0]);
8670
+ }
8671
+ return obj;
8672
+ };
8673
+ };
8674
+ // include the wholerow plugin by default
8675
+ // $.jstree.defaults.plugins.push("wholerow");
8676
+ if(window.customElements && Object && Object.create) {
8677
+ var proto = Object.create(HTMLElement.prototype);
8678
+ proto.createdCallback = function () {
8679
+ var c = { core : {}, plugins : [] }, i;
8680
+ for(i in $.jstree.plugins) {
8681
+ if($.jstree.plugins.hasOwnProperty(i) && this.attributes[i]) {
8682
+ c.plugins.push(i);
8683
+ if(this.getAttribute(i) && JSON.parse(this.getAttribute(i))) {
8684
+ c[i] = JSON.parse(this.getAttribute(i));
8685
+ }
8686
+ }
8687
+ }
8688
+ for(i in $.jstree.defaults.core) {
8689
+ if($.jstree.defaults.core.hasOwnProperty(i) && this.attributes[i]) {
8690
+ c.core[i] = JSON.parse(this.getAttribute(i)) || this.getAttribute(i);
8691
+ }
8692
+ }
8693
+ $(this).jstree(c);
8694
+ };
8695
+ // proto.attributeChangedCallback = function (name, previous, value) { };
8696
+ try {
8697
+ window.customElements.define("vakata-jstree", function() {}, { prototype: proto });
8698
+ } catch (ignore) { }
8699
+ }
8700
+
8701
  }));
assets/js/page-post-media.js CHANGED
@@ -10,7 +10,7 @@
10
  factory(jQuery);
11
  }
12
  }(function ($, undefined) {
13
- var treeId = "#js-tree-menu";
14
  var folderPropertyArray = [];
15
  var selectedFolderMediaId = -1;
16
  var defaultFolderHtml;
@@ -34,6 +34,7 @@
34
  var lastOrderStatus = "";
35
  var ajaxURL = "";
36
  var folderOrder = 0;
 
37
 
38
  var listFolderString = "<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'>" +
39
  "<div class='folder-item is-folder' data-id='__folder_id__'>" +
@@ -183,7 +184,7 @@
183
  if($("#media-attachment-taxonomy-filter").val() == "all") {
184
  $("#media-attachment-taxonomy-filter option:gt(1)").remove();
185
  _.each(folders_media_options.terms, function(term, index){
186
- $("#media-attachment-taxonomy-filter").append("<option value='" + term.term_id + "'>" + term.name + " (" + term.count + ")</option>")
187
  });
188
  }
189
 
@@ -195,7 +196,7 @@
195
  }
196
  },100);
197
  });
198
- jQuery.extend(wpMediaObj.Uploader.prototype, {
199
  progress: function () {
200
 
201
  },
@@ -274,6 +275,7 @@
274
  $(".folder-modal .media-frame-tab-panel").before("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>");
275
  $(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url + " #wcp-content-resize", function () {
276
  checkForExpandCollapse();
 
277
  initJSTree();
278
  });
279
  }
@@ -283,6 +285,8 @@
283
  $(".folder-modal .media-frame-menu .media-menu").append("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>");
284
  $(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url + " #wcp-content-resize", function () {
285
  checkForExpandCollapse();
 
 
286
  });
287
  }
288
  }
@@ -326,6 +330,7 @@
326
 
327
  $(document).ready(function(){
328
 
 
329
  isKeyActive = parseInt(folders_media_options.is_key_active);
330
  n_o_file = parseInt(folders_media_options.folders);
331
 
@@ -822,13 +827,13 @@
822
  if(folderIDs != "") {
823
  $(".form-loader-count").css("width","100%");
824
  nonce = folders_media_options.nonce;
825
- jQuery.ajax({
826
  url: folders_media_options.ajax_url,
827
  data: "type=" + folders_media_options.post_type + "&action=wcp_change_all_status&status=" + statusType + "&folders="+folderIDs+"&nonce="+nonce,
828
  method: 'post',
829
  success: function (res) {
830
  $(".form-loader-count").css("width","0");
831
- res = jQuery.parseJSON(res);
832
  if(res.status == "0") {
833
  $(".folder-popup-form").hide();
834
  $(".folder-popup-form").removeClass("disabled");
@@ -847,16 +852,18 @@
847
  $(".form-loader-count").css("width", "100%");
848
  $(".folder-order").removeClass("active");
849
  lastOrderStatus = $(this).attr("data-sort");
850
- jQuery.ajax({
851
  url: folders_media_options.ajax_url,
852
  data: "type=" + folders_media_options.post_type + "&action=wcp_folders_by_order&nonce=" + folders_media_options.nonce+"&order="+$(this).attr("data-sort"),
853
  method: 'post',
854
  success: function (res) {
855
- res = jQuery.parseJSON(res);
856
  if(res.status == 1) {
857
  $("#js-tree-menu").jstree().destroy();
858
  $("#js-tree-menu").append("<ul></ul>");
859
  $("#js-tree-menu ul").html(res.data);
 
 
860
  initJSTree();
861
  }
862
  $(".form-loader-count").css("width", "0");
@@ -1169,13 +1176,13 @@
1169
  $(".form-loader-count").css("width","100%");
1170
  nonce = getSettingForPost(folderID, 'nonce');
1171
  checkForExpandCollapse();
1172
- jQuery.ajax({
1173
  url: folders_media_options.ajax_url,
1174
  data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1175
  method: 'post',
1176
  success: function (res) {
1177
  $(".form-loader-count").css("width","0");
1178
- res = jQuery.parseJSON(res);
1179
  if(res.status == "0") {
1180
  // $(".folder-popup-form").hide();
1181
  // $(".folder-popup-form").removeClass("disabled");
@@ -1300,29 +1307,30 @@
1300
  })).bind("move_node.jstree", (function(t, n) {
1301
  folderMoveId = n.node.id;
1302
  orderString = "";
1303
- $(".jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){
1304
  if($(this).attr("id") != 'undefined') {
1305
  orderString += $(this).attr("id") + ",";
1306
  }
1307
  });
1308
- if($("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")) {
1309
  parentID = $("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id");
1310
  } else {
1311
  parentID = 0;
1312
  }
1313
  if(orderString != "") {
1314
  $(".form-loader-count").css("width","100%");
1315
- jQuery.ajax({
1316
  url: folders_media_options.ajax_url,
1317
  data: "term_ids=" + orderString + "&action=wcp_save_folder_order&type=" + folders_media_options.post_type+"&nonce="+folders_media_options.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,
1318
  method: 'post',
1319
  success: function (res) {
1320
- res = jQuery.parseJSON(res);
1321
  if (res.status == '1') {
1322
  $("#wcp_folder_parent").html(res.options);
1323
  $(".form-loader-count").css("width", "0");
1324
  resetMediaAndPosts();
1325
  ajaxAnimation();
 
1326
  } else {
1327
  $(".folder-popup-form").hide();
1328
  $(".folder-popup-form").removeClass("disabled");
@@ -1435,12 +1443,12 @@
1435
 
1436
  function removeMultipleFolderItems() {
1437
  if($("#folder-hide-show-checkbox").is(":checked")) {
1438
- if($("#custom-menu input.checkbox:checked").length > 0) {
1439
  var folderIDs = "";
1440
  var activeItemDeleted = false;
1441
- $("#custom-menu input.checkbox:checked").each(function(){
1442
- folderIDs += $(this).val()+",";
1443
- if($(this).closest("li.route").hasClass("active-item")) {
1444
  activeItemDeleted = true;
1445
  }
1446
  });
@@ -1457,7 +1465,7 @@
1457
  n_o_file = parseInt(res.folders);
1458
  $("#current-folder").text(n_o_file);
1459
  for(i=0; i<res.term_ids.length; i++) {
1460
- $('#js-tree-menu').jstree().delete_node(res.term_ids[i]);
1461
  }
1462
 
1463
  $("#ttl-fldr").text((4*2)+(4/2));
@@ -1470,7 +1478,7 @@
1470
 
1471
  ajaxAnimation();
1472
 
1473
- if(!$("#wcp_folder_"+activeRecordID).length) {
1474
  $(".header-posts a").trigger("click");
1475
  activeRecordID = 0;
1476
  }
@@ -1518,22 +1526,8 @@
1518
  // $("#js-tree-menu > ul#space_0").html(res.data);
1519
  $(".header-posts .total-count").text(res.total_items);
1520
  $(".un-categorised-items .total-count").text(res.empty_items);
1521
-
1522
- for (i = 0; i < res.taxonomies.length; i++) {
1523
- if(!$("#title_"+res.taxonomies[i].term_id+" .total-count").length) {
1524
- $("#title_"+res.taxonomies[i].term_id+" .star-icon").before("<span class='total-count'></span>");
1525
- }
1526
- $("#title_"+res.taxonomies[i].term_id+" .total-count").text(parseInt(res.taxonomies[i].trash_count));
1527
- }
1528
-
1529
- $("span.premio-folder-count").text("");
1530
- $(".folder-count").text("");
1531
- for (i = 0; i < res.taxonomies.length; i++) {
1532
- if(parseInt(res.taxonomies[i].trash_count) != 0) {
1533
- $(".jstree-node[id='" + res.taxonomies[i].term_id + "'] > a.jstree-anchor span.premio-folder-count").text(res.taxonomies[i].trash_count);
1534
- $(".sticky-folder-"+res.taxonomies[i].term_id+" .premio-folder-count").text(res.taxonomies[i].trash_count);
1535
- }
1536
- }
1537
  }
1538
  });
1539
  $(".folder-loader-ajax").addClass("active");
@@ -1548,6 +1542,8 @@
1548
  });
1549
  } else {
1550
  $("#wpbody").load(folderCurrentURL + " #wpbody-content", false, function (res) {
 
 
1551
  if (folders_media_options.show_in_page == "show" && !$(".tree-structure").length) {
1552
  $(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>');
1553
  }
@@ -1558,7 +1554,7 @@
1558
 
1559
  function resetDDCounter() {
1560
  var currentDDVal = $("#media-attachment-taxonomy-filter").val();
1561
- resetMediaFlag = jQuery.ajax({
1562
  url: folders_media_options.ajax_url,
1563
  data: "type=attachment&action=wcp_get_default_list&active_id=0",
1564
  method: 'post',
@@ -1568,40 +1564,54 @@
1568
  }
1569
  },
1570
  success: function(res) {
1571
- var res = jQuery.parseJSON(res);
 
 
 
 
 
1572
 
1573
- if($("#media-attachment-taxonomy-filter").length) {
1574
- $("#media-attachment-taxonomy-filter").each(function(){
1575
- folders_media_options.terms = res.taxonomies;
1576
- var selectedDD = $(this);
1577
- selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
1578
- lastFolderData = res.taxonomies;
1579
- for (var i = 0; i < res.taxonomies.length; i++) {
1580
- selectedDD.append("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name + " (" + res.taxonomies[i].trash_count + ")</option>");
1581
- }
1582
- selectedDD.val(currentDDVal).trigger("change");
1583
- });
1584
- if($("select.folder_for_media").length) {
1585
- var selectedVal = $("select.folder_for_media").val();
1586
- $("select.folder_for_media option:not(:first-child):not(:last-child)").remove();
1587
- for (var i = 0; i < res.taxonomies.length; i++) {
1588
- $("select.folder_for_media option:last-child").before("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name +"</option>");
1589
- }
1590
- if(selectedVal != "") {
1591
- $(".folder_for_media").val(selectedVal);
1592
- }
1593
- }
1594
- $("span.premio-folder-count").text("");
1595
- $(".folder-count").text("");
1596
- for (i = 0; i < res.taxonomies.length; i++) {
1597
- if(parseInt(res.taxonomies[i].trash_count) != 0) {
1598
- $(".jstree-node[id='" + res.taxonomies[i].term_id + "'] > a.jstree-anchor span.premio-folder-count").text(res.taxonomies[i].trash_count);
1599
- $(".sticky-folder-"+res.taxonomies[i].term_id+" .premio-folder-count").text(res.taxonomies[i].trash_count);
1600
- }
1601
- }
1602
  }
1603
  }
1604
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1605
  }
1606
 
1607
  function checkForFolderSearch() {
@@ -1708,7 +1718,6 @@
1708
  data: "type=" + folders_media_options.post_type + "&action=wcp_get_default_list&active_id="+activeRecordID,
1709
  method: 'post',
1710
  beforeSend: function() {
1711
- console.log("changed");
1712
  if(resetMediaFlag != null) {
1713
  resetMediaFlag.abort();
1714
  }
@@ -1731,52 +1740,14 @@
1731
  }
1732
  }
1733
  }
1734
- if(res.taxonomies.length) {
1735
- if($("#media-attachment-taxonomy-filter").length) {
1736
- folders_media_options.terms = res.taxonomies;
1737
- var selectedDD = $("#media-attachment-taxonomy-filter");
1738
- selectedDD.html("<option value='all'>All Folders</option><option value='all'>(Unassigned)</option>");
1739
- $(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>");
1740
- for (i = 0; i < res.taxonomies.length; i++) {
1741
- selectedDD.append("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name + " (" + res.taxonomies[i].trash_count + ")</option>");
1742
- $(".media-select-folder").append("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name + " (" + res.taxonomies[i].trash_count + ")</option>");
1743
- }
1744
- selectedDD.val(selectedVal);
1745
- $(".media-select-folder").val("");
1746
- }
1747
- if($("select.folder_for_media").length) {
1748
- selectedVal = $("select.folder_for_media").val();
1749
- $("select.folder_for_media option:not(:first-child):not(:last-child)").remove();
1750
- for (i = 0; i < res.taxonomies.length; i++) {
1751
- $("select.folder_for_media option:last-child").before("<option value='" + res.taxonomies[i].term_id + "'>" + res.taxonomies[i].name +"</option>");
1752
- }
1753
- if(selectedVal != "") {
1754
- $(".folder_for_media").val(selectedVal);
1755
- }
1756
- }
1757
- $("span.premio-folder-count").text("");
1758
- for (i = 0; i < res.taxonomies.length; i++) {
1759
- if(parseInt(res.taxonomies[i].trash_count) != 0) {
1760
- $(".jstree-node[id='" + res.taxonomies[i].term_id + "'] > a.jstree-anchor span.premio-folder-count").text(res.taxonomies[i].trash_count);
1761
- $(".sticky-folder-"+res.taxonomies[i].term_id+" .premio-folder-count").text(res.taxonomies[i].trash_count);
1762
- }
1763
- }
1764
- }
1765
-
1766
- if(activeRecordID != "") {
1767
- $("#wcp_folder_"+activeRecordID).addClass("active-item");
1768
- }
1769
-
1770
- if(isItFromMedia) {
1771
- $("#title_"+fileFolderID).trigger("click");
1772
- isItFromMedia = false;
1773
- }
1774
  }
1775
  });
1776
  }
1777
 
1778
  function set_default_folders(post_id) {
1779
- jQuery.ajax({
1780
  url: folders_media_options.ajax_url,
1781
  type: 'post',
1782
  data: 'action=save_folder_last_status&post_type='+folders_media_options.post_type+"&post_id="+post_id+"&nonce="+folders_media_options.nonce,
10
  factory(jQuery);
11
  }
12
  }(function ($, undefined) {
13
+ var treeId = ".folder-modal #js-tree-menu";
14
  var folderPropertyArray = [];
15
  var selectedFolderMediaId = -1;
16
  var defaultFolderHtml;
34
  var lastOrderStatus = "";
35
  var ajaxURL = "";
36
  var folderOrder = 0;
37
+ var foldersArray = [];
38
 
39
  var listFolderString = "<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'>" +
40
  "<div class='folder-item is-folder' data-id='__folder_id__'>" +
184
  if($("#media-attachment-taxonomy-filter").val() == "all") {
185
  $("#media-attachment-taxonomy-filter option:gt(1)").remove();
186
  _.each(folders_media_options.terms, function(term, index){
187
+ $("#media-attachment-taxonomy-filter").append("<option value='" + term.term_id + "'>" + term.name + " (" + term.trash_count + ")</option>")
188
  });
189
  }
190
 
196
  }
197
  },100);
198
  });
199
+ $.extend(wpMediaObj.Uploader.prototype, {
200
  progress: function () {
201
 
202
  },
275
  $(".folder-modal .media-frame-tab-panel").before("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>");
276
  $(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url + " #wcp-content-resize", function () {
277
  checkForExpandCollapse();
278
+ setCustomScrollForFolder();
279
  initJSTree();
280
  });
281
  }
285
  $(".folder-modal .media-frame-menu .media-menu").append("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>");
286
  $(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url + " #wcp-content-resize", function () {
287
  checkForExpandCollapse();
288
+ setCustomScrollForFolder();
289
+ initJSTree();
290
  });
291
  }
292
  }
330
 
331
  $(document).ready(function(){
332
 
333
+ foldersArray = folders_media_options.terms;
334
  isKeyActive = parseInt(folders_media_options.is_key_active);
335
  n_o_file = parseInt(folders_media_options.folders);
336
 
827
  if(folderIDs != "") {
828
  $(".form-loader-count").css("width","100%");
829
  nonce = folders_media_options.nonce;
830
+ $.ajax({
831
  url: folders_media_options.ajax_url,
832
  data: "type=" + folders_media_options.post_type + "&action=wcp_change_all_status&status=" + statusType + "&folders="+folderIDs+"&nonce="+nonce,
833
  method: 'post',
834
  success: function (res) {
835
  $(".form-loader-count").css("width","0");
836
+ res = $.parseJSON(res);
837
  if(res.status == "0") {
838
  $(".folder-popup-form").hide();
839
  $(".folder-popup-form").removeClass("disabled");
852
  $(".form-loader-count").css("width", "100%");
853
  $(".folder-order").removeClass("active");
854
  lastOrderStatus = $(this).attr("data-sort");
855
+ $.ajax({
856
  url: folders_media_options.ajax_url,
857
  data: "type=" + folders_media_options.post_type + "&action=wcp_folders_by_order&nonce=" + folders_media_options.nonce+"&order="+$(this).attr("data-sort"),
858
  method: 'post',
859
  success: function (res) {
860
+ res = $.parseJSON(res);
861
  if(res.status == 1) {
862
  $("#js-tree-menu").jstree().destroy();
863
  $("#js-tree-menu").append("<ul></ul>");
864
  $("#js-tree-menu ul").html(res.data);
865
+ foldersArray = res.terms;
866
+ setFolderCountAndDD();
867
  initJSTree();
868
  }
869
  $(".form-loader-count").css("width", "0");
1176
  $(".form-loader-count").css("width","100%");
1177
  nonce = getSettingForPost(folderID, 'nonce');
1178
  checkForExpandCollapse();
1179
+ $.ajax({
1180
  url: folders_media_options.ajax_url,
1181
  data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1182
  method: 'post',
1183
  success: function (res) {
1184
  $(".form-loader-count").css("width","0");
1185
+ res = $.parseJSON(res);
1186
  if(res.status == "0") {
1187
  // $(".folder-popup-form").hide();
1188
  // $(".folder-popup-form").removeClass("disabled");
1307
  })).bind("move_node.jstree", (function(t, n) {
1308
  folderMoveId = n.node.id;
1309
  orderString = "";
1310
+ $(".folder-modal .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){
1311
  if($(this).attr("id") != 'undefined') {
1312
  orderString += $(this).attr("id") + ",";
1313
  }
1314
  });
1315
+ if($(".folder-modal #"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")) {
1316
  parentID = $("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id");
1317
  } else {
1318
  parentID = 0;
1319
  }
1320
  if(orderString != "") {
1321
  $(".form-loader-count").css("width","100%");
1322
+ $.ajax({
1323
  url: folders_media_options.ajax_url,
1324
  data: "term_ids=" + orderString + "&action=wcp_save_folder_order&type=" + folders_media_options.post_type+"&nonce="+folders_media_options.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,
1325
  method: 'post',
1326
  success: function (res) {
1327
+ res = $.parseJSON(res);
1328
  if (res.status == '1') {
1329
  $("#wcp_folder_parent").html(res.options);
1330
  $(".form-loader-count").css("width", "0");
1331
  resetMediaAndPosts();
1332
  ajaxAnimation();
1333
+ setFolderCountAndDD();
1334
  } else {
1335
  $(".folder-popup-form").hide();
1336
  $(".folder-popup-form").removeClass("disabled");
1443
 
1444
  function removeMultipleFolderItems() {
1445
  if($("#folder-hide-show-checkbox").is(":checked")) {
1446
+ if($("#js-tree-menu input.checkbox:checked").length > 0) {
1447
  var folderIDs = "";
1448
  var activeItemDeleted = false;
1449
+ $("#js-tree-menu input.checkbox:checked").each(function(){
1450
+ folderIDs += $(this).closest("li.jstree-node").attr("id")+",";
1451
+ if($(this).closest("li.jstree-node").hasClass("jstree-clicked")) {
1452
  activeItemDeleted = true;
1453
  }
1454
  });
1465
  n_o_file = parseInt(res.folders);
1466
  $("#current-folder").text(n_o_file);
1467
  for(i=0; i<res.term_ids.length; i++) {
1468
+ $('.folder-modal #js-tree-menu').jstree().delete_node(res.term_ids[i]);
1469
  }
1470
 
1471
  $("#ttl-fldr").text((4*2)+(4/2));
1478
 
1479
  ajaxAnimation();
1480
 
1481
+ if(!$(".folder-modal #wcp_folder_"+activeRecordID).length) {
1482
  $(".header-posts a").trigger("click");
1483
  activeRecordID = 0;
1484
  }
1526
  // $("#js-tree-menu > ul#space_0").html(res.data);
1527
  $(".header-posts .total-count").text(res.total_items);
1528
  $(".un-categorised-items .total-count").text(res.empty_items);
1529
+ foldersArray = res.taxonomies;
1530
+ setFolderCountAndDD();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1531
  }
1532
  });
1533
  $(".folder-loader-ajax").addClass("active");
1542
  });
1543
  } else {
1544
  $("#wpbody").load(folderCurrentURL + " #wpbody-content", false, function (res) {
1545
+ var obj = { Title: "", Url: folderCurrentURL };
1546
+ history.pushState(obj, obj.Title, obj.Url);
1547
  if (folders_media_options.show_in_page == "show" && !$(".tree-structure").length) {
1548
  $(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>');
1549
  }
1554
 
1555
  function resetDDCounter() {
1556
  var currentDDVal = $("#media-attachment-taxonomy-filter").val();
1557
+ resetMediaFlag = $.ajax({
1558
  url: folders_media_options.ajax_url,
1559
  data: "type=attachment&action=wcp_get_default_list&active_id=0",
1560
  method: 'post',
1564
  }
1565
  },
1566
  success: function(res) {
1567
+ var res = $.parseJSON(res);
1568
+ foldersArray = res.taxonomies;
1569
+ setFolderCountAndDD();
1570
+ }
1571
+ });
1572
+ }
1573
 
1574
+ function setFolderCountAndDD() {
1575
+ if($("#media-attachment-taxonomy-filter").length) {
1576
+ $("#media-attachment-taxonomy-filter").each(function(){
1577
+ folders_media_options.terms = foldersArray;
1578
+ var selectedDD = $(this);
1579
+ currentDDVal = $(this).val();
1580
+ selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
1581
+ lastFolderData = foldersArray;
1582
+ for (var i = 0; i < foldersArray.length; i++) {
1583
+ selectedDD.append("<option value='" + foldersArray[i].term_id + "'>" + foldersArray[i].name + " (" + foldersArray[i].trash_count + ")</option>");
1584
+ }
1585
+ selectedDD.val(currentDDVal).trigger("change");
1586
+ });
1587
+ if($("select.folder_for_media").length) {
1588
+ var selectedVal = $("select.folder_for_media").val();
1589
+ $("select.folder_for_media option:not(:first-child):not(:last-child)").remove();
1590
+ for (var i = 0; i < foldersArray.length; i++) {
1591
+ $("select.folder_for_media option:last-child").before("<option value='" + foldersArray[i].term_id + "'>" + foldersArray[i].name +"</option>");
1592
+ }
1593
+ if(selectedVal != "") {
1594
+ $(".folder_for_media").val(selectedVal);
 
 
 
 
 
 
 
 
1595
  }
1596
  }
1597
+ }
1598
+ $("span.premio-folder-count").text("");
1599
+ $(".folder-count").text("");
1600
+ for (i = 0; i < foldersArray.length; i++) {
1601
+ if(parseInt(foldersArray[i].trash_count) != 0) {
1602
+ $(".jstree-node[id='" + foldersArray[i].term_id + "'] > a.jstree-anchor span.premio-folder-count").text(foldersArray[i].trash_count);
1603
+ $(".sticky-folder-"+foldersArray[i].term_id+" .premio-folder-count").text(foldersArray[i].trash_count);
1604
+ }
1605
+ }
1606
+
1607
+ if(activeRecordID != "") {
1608
+ $("#wcp_folder_"+activeRecordID).addClass("active-item");
1609
+ }
1610
+
1611
+ if(isItFromMedia) {
1612
+ $("#title_"+fileFolderID).trigger("click");
1613
+ isItFromMedia = false;
1614
+ }
1615
  }
1616
 
1617
  function checkForFolderSearch() {
1718
  data: "type=" + folders_media_options.post_type + "&action=wcp_get_default_list&active_id="+activeRecordID,
1719
  method: 'post',
1720
  beforeSend: function() {
 
1721
  if(resetMediaFlag != null) {
1722
  resetMediaFlag.abort();
1723
  }
1740
  }
1741
  }
1742
  }
1743
+ foldersArray = res.taxonomies;
1744
+ setFolderCountAndDD();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1745
  }
1746
  });
1747
  }
1748
 
1749
  function set_default_folders(post_id) {
1750
+ $.ajax({
1751
  url: folders_media_options.ajax_url,
1752
  type: 'post',
1753
  data: 'action=save_folder_last_status&post_type='+folders_media_options.post_type+"&post_id="+post_id+"&nonce="+folders_media_options.nonce,
assets/js/page-post-media.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e,t){var o="#js-tree-menu",s=[],a=-1,r=0,l=0,d="",n=-1,c=0,m="",p=folders_media_options.page_url,f="",u="",h=!1,v=!1,g=!1,y=0,x=0,j=wp.media.view.AttachmentFilters.extend({id:"media-attachment-taxonomy-filter",createFilters:function(){var e={};folders_media_options.terms.length;_.each(folders_media_options.terms||{},function(t,o){e[t.term_id]={text:t.name+" ("+t.count+")",props:{media_folder:t.slug}}}),e.all={text:"All Folders",props:{media_folder:""},priority:10},e.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10},this.filters=e},change:function(){var e={};_.each(folders_media_options.terms||{},function(t,o){e[t.term_id]={text:t.name+" ("+t.count+")",props:{media_folder:t.slug}}}),e.all={text:"Select a folder >>",props:{media_folder:""},priority:10},e.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10},this.filters=e;var t=this.filters[this.el.value];t&&this.model.set(t.props)}}),w=0,k=0,b=wp.media.view.AttachmentsBrowser;wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({createToolbar:function(){b.prototype.createToolbar.call(this),this.toolbar.set("MediaLibraryOrganizerTaxonomyFilter",new j({controller:this.controller,model:this.collection.props,priority:-75}).render())}});var C,S=wp.media.model.Query;_.extend(S,{get:(C=[],function(e,t){var o,s={},a=S.orderby,r=S.defaultProps;return delete e.query,delete e.cache,_.defaults(e,r),_.each(["include","exclude"],function(t){e[t]&&!_.isArray(e[t])&&(e[t]=[e[t]])}),_.each(e,function(e,t){_.isNull(e)||(s[S.propmap[t]||t]=e)}),_.defaults(s,S.defaultArgs),s.orderby=a.valuemap[e.orderby]||e.orderby,C=[],o||(o=new S([],_.extend(t||{},{props:e,args:s})),C.push(o)),o})});var I=window.wp;void 0!==I&&"function"==typeof I.Uploader&&(I.media.view.Modal.prototype.on("open",function(){setTimeout(function(){e("#media-attachment-taxonomy-filter").length&&("all"==e("#media-attachment-taxonomy-filter").val()&&(e("#media-attachment-taxonomy-filter option:gt(1)").remove(),_.each(folders_media_options.terms,function(t,o){e("#media-attachment-taxonomy-filter").append("<option value='"+t.term_id+"'>"+t.name+" ("+t.count+")</option>")})),e("#wcp-content").length||e(".editor-post-featured-image").length&&e(".attachment-filters").val("all").trigger("change"))},100)}),jQuery.extend(I.Uploader.prototype,{progress:function(){},init:function(){this.uploader&&(this.uploader.bind("FileFiltered",function(t,o){w++,e(".folder-meter").css("width","0%"),e(".media-folder-loader").show(),e("#total_upload_files").text(w)}),this.uploader.bind("BeforeUpload",function(t,o){var s=a,r=t.settings.multipart_params;if((s=parseInt(s))>0&&(r.folder_for_media=s),k<w){e(".media-folder-loader").show();var i=k/w*100;e(".folder-meter").css("width",i+"%")}k++,e("#current_upload_files").text(k)}),this.uploader.bind("UploadComplete",function(e,t){a=-1}),this.uploader.bind("UploadComplete",function(t,o){var s,a=window.wp;e(".folder-meter").css("width","100%"),setTimeout(function(){e(".media-folder-loader").hide(),e(".folder-meter").css("width","0%"),w=0,k=0},1250),s=e("#media-attachment-taxonomy-filter").val(),P=jQuery.ajax({url:folders_media_options.ajax_url,data:"type=attachment&action=wcp_get_default_list&active_id=0",method:"post",beforeSend:function(){null!=P&&P.abort()},success:function(t){var t=jQuery.parseJSON(t);if(e("#media-attachment-taxonomy-filter").length){if(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=t.taxonomies;var o=e(this);o.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),t.taxonomies;for(var a=0;a<t.taxonomies.length;a++)o.append("<option value='"+t.taxonomies[a].term_id+"'>"+t.taxonomies[a].name+" ("+t.taxonomies[a].trash_count+")</option>");o.val(s).trigger("change")}),e("select.folder_for_media").length){var o=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var a=0;a<t.taxonomies.length;a++)e("select.folder_for_media option:last-child").before("<option value='"+t.taxonomies[a].term_id+"'>"+t.taxonomies[a].name+"</option>");""!=o&&e(".folder_for_media").val(o)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),a=0;a<t.taxonomies.length;a++)0!=parseInt(t.taxonomies[a].trash_count)&&(e(".jstree-node[id='"+t.taxonomies[a].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(t.taxonomies[a].trash_count),e(".sticky-folder-"+t.taxonomies[a].term_id+" .premio-folder-count").text(t.taxonomies[a].trash_count))}}}),void 0!==a.media.frame&&null!==a.media.frame.content.get()?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):e("#media-attachment-taxonomy-filter").length&&e(".attachment-filters").each(function(){e(this).trigger("change")})}))}}));var P,D=window.wp;if(void 0!==D&&"function"==typeof D.Uploader){var N=window.wp.media,A=N.view.Modal;N.view.Modal=N.view.Modal.extend({className:"folder-modal",initialize:function(){A.prototype.initialize.apply(this,arguments)},open:function(){e(".folder-modal").removeClass("folder-modal"),A.prototype.open.apply(this,arguments)&&(e(".folder-modal").length?(e(".folder-custom-menu").remove(),e(".folder-modal .media-frame-tab-panel").removeClass("has-folder-menu"),e(".folder-modal .media-frame").hasClass("hide-menu")?e(".folder-custom-menu").length||(e(".folder-modal .media-frame-tab-panel").before("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>"),e(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){M(),q()})):e(".folder-custom-menu").length||(e(".folder-modal .media-frame-menu").addClass("has-folder-menu"),e(".folder-modal .media-frame-menu .media-menu").append("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>"),e(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){M()})),e(".folder-form-data").remove(),e(".media-frame-tab-panel:first").before("<div class='folder-form-data'></div>"),e(".folder-form-data").load(folders_media_options.media_page_url+" #folder-add-update-content",function(){})):setTimeout(function(){-1!=a&&e("#media-attachment-taxonomy-filter").each(function(){e(this).val(a),e(this).trigger("change")})},1e3))},close:function(){A.prototype.close.apply(this,arguments),e(".folder-modal").removeClass("folder-modal")}})}function q(){e(o).jstree({core:{cache:!1,animation:0,check_callback:function(t,o,s,a,r){if(e("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up"),("move_node"===t||"copy_node"===t)&&r&&r.dnd)switch(r.pos){case"a":r.origin.get_node(r.ref,!0).addClass("drag-bot"),nodeId=e(".drag-bot").attr("id"),e("#jstree-dnd").text("Below "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"i":r.origin.get_node(r.ref,!0).addClass("drag-in"),nodeId=e(".drag-in").attr("id"),e("#jstree-dnd").text("Inside "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"b":r.origin.get_node(r.ref,!0).addClass("drag-up"),nodeId=e(".drag-up").attr("id"),e("#jstree-dnd").text("Above "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;default:e("#jstree-dnd").text(e("#jstree-dnd").data("txt"))}return!0}},data:{cache:!1},select_node:!1,search:{show_only_matches:!0,case_sensitive:!1,fuzzy:!1},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",function(){!function(){e("#js-tree-menu .jstree-node").each(function(){var t=parseInt(e(this).data("count"));t>0&&e(".jstree-node[id='"+e(this).attr("id")+"'] > a span.premio-folder-count").text(t);var o={folder_id:e(this).attr("id"),folder_count:t,is_sticky:e(this).hasClass("is-sticky")?1:0,is_high:e(this).hasClass("is-high")?1:0,nonce:e(this).data("nonce"),slug:e(this).data("slug"),is_deleted:0};s.push(o)}),""!=f&&0!=f&&e(".jstree-node[id='"+f+"']").length&&(e("#js-tree-menu").jstree("select_node",f),e(".sticky-folders .sticky-folder-"+f+" a").length&&e(".sticky-folders .sticky-folder-"+f+" a").addClass("active-item"));e(".ajax-preloader").hide(),e(".js-tree-data").show(),J(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active")}()}).bind("move_node.jstree",function(t,o){folderMoveId=o.node.id,orderString="",e(".jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?parentID=e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id"):parentID=0,""!=orderString&&(e(".form-loader-count").css("width","100%"),jQuery.ajax({url:folders_media_options.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+folders_media_options.post_type+"&nonce="+folders_media_options.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(t){"1"==(t=jQuery.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),Q(),B()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))})}function O(e,t){if(s.length>0)for(i=0;i<s.length;i++)if(parseInt(s[i].folder_id)==parseInt(e))return s[i][t];return""}function U(e){if(s.length>0)for(i=0;i<s.length;i++)if(parseInt(s[i].folder_id)==parseInt(e))return i;return null}function J(){e(".sticky-folders > ul").html("");var t="";if(e("#js-tree-menu li.jstree-node.is-sticky").each(function(){var o=e(this).attr("id"),s=e.trim(e("#js-tree-menu").jstree(!0).get_node(o).text),a=(e("#"+o+"_anchor .premio-folder-count").text(),e("li.jstree-node[id='"+o+"']").hasClass("is-high")?" is-high ":"");t+="<li data-folder-id='"+o+"' class='sticky-fldr "+a+" sticky-folder-"+o+"'><a href='javascript:;'><span class='folder-title'>"+s+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'></span></span></a></li>"}),e(".sticky-folders > ul").html(t),e(".jstree-anchor.jstree-clicked").length){var o=e(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");e(".sticky-folders .sticky-folder-"+o+" a").addClass("active-item")}e(".sticky-folders > ul > li").length>0?e(".sticky-folders").addClass("active"):e(".sticky-folders").removeClass("active")}function Q(){if(e(".media-toolbar").hasClass("media-toolbar-mode-select")&&e("ul.attachments li.selected").length&&(e("ul.attachments li.selected").trigger("click"),e(".select-mode-toggle-button").trigger("click")),""!=u&&(e("#js-tree-menu a.jstree-clicked").length>0||"-1"==f)){if(e("#media-attachment-taxonomy-filter").length){u=u.split(",");for(var t=0;t<u.length;t++)""!=u[t]&&e(".attachments-browser li[data-id='"+u[t]+"']").remove()}u=""}e("#media-attachment-taxonomy-filter").length?z(0):(e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=get_folders_default_list",method:"post",success:function(o){for(o=e.parseJSON(o),e(".header-posts .total-count").text(o.total_items),e(".un-categorised-items .total-count").text(o.empty_items),t=0;t<o.taxonomies.length;t++)e("#title_"+o.taxonomies[t].term_id+" .total-count").length||e("#title_"+o.taxonomies[t].term_id+" .star-icon").before("<span class='total-count'></span>"),e("#title_"+o.taxonomies[t].term_id+" .total-count").text(parseInt(o.taxonomies[t].trash_count));for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),t=0;t<o.taxonomies.length;t++)0!=parseInt(o.taxonomies[t].trash_count)&&(e(".jstree-node[id='"+o.taxonomies[t].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(o.taxonomies[t].trash_count),e(".sticky-folder-"+o.taxonomies[t].term_id+" .premio-folder-count").text(o.taxonomies[t].trash_count))}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(p+" #posts-filter",function(){var t={Title:"",Url:p};history.pushState(t,t.Title,t.Url),"show"!=folders_media_options.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),triggerInlineUpdate()}):e("#wpbody").load(p+" #wpbody-content",!1,function(t){"show"!=folders_media_options.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}))}function F(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function H(t){var o="Are you sure you want to delete the selected folder?",s="Items in the folder will not be deleted.";if(h=!1,1==t&&e("#folder-hide-show-checkbox").is(":checked")){if(h=!0,0==e("#js-tree-menu input.checkbox:checked").length)return e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html("Please select at least one folder to delete"),void e("#error-folder-popup").show();e("#js-tree-menu input.checkbox:checked").length>1&&(o="Are you sure you want to delete the selected folders?",s="Items in the selected folders will not be deleted.")}e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#remove-folder-item").text("Yes, Delete it!"),e("#remove-folder-message").text(o),e("#remove-folder-notice").text(s),e("#confirm-remove-folder").show(),e("#remove-folder-item").focus()}function V(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(l).text),parentID=e("#wcp_folder_"+l).closest("li.jstree-node").data("folder-id"),parentID==t&&(parentID=0),e("#update-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#update-folder-item-name").val(folderName),e("#update-folder-item").removeClass("disabled"),e("#update-folder-item").show(),e("#update-folder-item-name").focus(),e(".dynamic-menu").remove()}function T(){if(0==c&&n>=10)return e("#folder-limitation-message").html("You've reached the 10 folder limitation!"),e("#no-more-folder-credit").show(),!1;e("#add-update-folder-title").text("Add new folder"),e("#save-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#add-update-folder-name").val(""),g&&(y=l,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(l).text)+" #2"),l=e("#"+l+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+l+"_anchor").closest(".jstree-node").parent().parent().attr("id"):0),e("#add-update-folder").removeClass("disabled"),e("#add-update-folder").show(),e("#add-update-folder-name").focus(),e(".dynamic-menu").remove()}function M(){setTimeout(function(){if(e("#js-tree-menu .jstree-node.jstree-leaf").length==e("#js-tree-menu .jstree-node").length)e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand");else{var t=e("#js-tree-menu .jstree-node.jstree-closed").length+e("#js-tree-menu .jstree-node.jstree-open").length;e("#js-tree-menu .jstree-node.jstree-closed").length==t?(e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand")):(e("#expand-collapse-list").addClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Collapse"))}},500)}function z(o){P=e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_get_default_list&active_id="+f,method:"post",beforeSend:function(){console.log("changed"),null!=P&&P.abort()},success:function(s){if(s=e.parseJSON(s),e(".header-posts .total-count").text(s.total_items),e(".un-categorised-items .total-count").text(s.empty_items),selectedVal=e("#media-attachment-taxonomy-filter").val(),"all"!=selectedVal&&1==o){var a=parent.wp;a.media!=t&&(a.media.frame.setState("insert"),null!==a.media.frame.content.get()?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):a.media.frame.library.props.set({ignore:+new Date}))}if(s.taxonomies.length){if(e("#media-attachment-taxonomy-filter").length){folders_media_options.terms=s.taxonomies;var r=e("#media-attachment-taxonomy-filter");for(r.html("<option value='all'>All Folders</option><option value='all'>(Unassigned)</option>"),e(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),i=0;i<s.taxonomies.length;i++)r.append("<option value='"+s.taxonomies[i].term_id+"'>"+s.taxonomies[i].name+" ("+s.taxonomies[i].trash_count+")</option>"),e(".media-select-folder").append("<option value='"+s.taxonomies[i].term_id+"'>"+s.taxonomies[i].name+" ("+s.taxonomies[i].trash_count+")</option>");r.val(selectedVal),e(".media-select-folder").val("")}if(e("select.folder_for_media").length){for(selectedVal=e("select.folder_for_media").val(),e("select.folder_for_media option:not(:first-child):not(:last-child)").remove(),i=0;i<s.taxonomies.length;i++)e("select.folder_for_media option:last-child").before("<option value='"+s.taxonomies[i].term_id+"'>"+s.taxonomies[i].name+"</option>");""!=selectedVal&&e(".folder_for_media").val(selectedVal)}for(e("span.premio-folder-count").text(""),i=0;i<s.taxonomies.length;i++)0!=parseInt(s.taxonomies[i].trash_count)&&(e(".jstree-node[id='"+s.taxonomies[i].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(s.taxonomies[i].trash_count),e(".sticky-folder-"+s.taxonomies[i].term_id+" .premio-folder-count").text(s.taxonomies[i].trash_count))}""!=f&&e("#wcp_folder_"+f).addClass("active-item"),v&&(e("#title_"+l).trigger("click"),v=!1)}})}function B(){e(".folder-loader-ajax").addClass("active"),e(".folder-loader-ajax img").removeClass("active"),e(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated"),setTimeout(function(){e(".folder-loader-ajax").removeClass("active"),e(".folder-loader-ajax img").addClass("active"),e(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2e3)}e(document).ready(function(){c=parseInt(folders_media_options.is_key_active),n=parseInt(folders_media_options.folders),e(document).on("click",".header-posts a.all-posts",function(t){l=0,f="",a="all",e(".active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e(this).addClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("all").trigger("change"),e(this).closest(".media-frame").find(".folder_for_media").val("all").trigger("change")}),e(document).on("click",".un-categorised-items",function(t){l=0,f="",a="unassigned",e(".active-item").removeClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e(this).addClass("active-item"),e(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("unassigned").trigger("change"),e(this).closest(".media-frame").find(".folder_for_media").val("-1").trigger("change")}),e(document).on("click","a.jstree-anchor",function(t){var o,s=e(this).closest("li.jstree-node").attr("id");a=l=s,e(".active-item").removeClass("active-item"),e("#media-attachment-taxonomy-filter").val(s),e("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=O(s,"slug"),o=thisSlug,jQuery.ajax({url:folders_media_options.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+folders_media_options.post_type+"&post_id="+o+"&nonce="+folders_media_options.nonce,cache:!1,async:!1,success:function(){}}),e(".custom-media-select").removeClass("active")}),e(document).on("change",".folder_for_media",function(){"add-folder"!=e(this).val()&&null!=e(this).val()?a=e(this).val():"add-folder"==e(this).val()&&(a=-1)}),e(document).on("click",".update-inline-record",function(t){t.stopImmediatePropagation(),t.stopPropagation(),0!=folders_media_options.can_manage_folder&&(isHigh=e(this).closest("li.sticky-fldr").hasClass("is-high"),isSticky=e(this).closest("li.sticky-fldr").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>",hasPosts=parseInt(e(this).closest("li.jstree-node").find("h3.title:first > .total-count").text()),"attachment"==folders_media_options.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>",e(this).closest("li").append(menuHtml),e(this).offset().top+e(".dynamic-menu").height()>e(window).height()-20&&(e(".dynamic-menu").addClass("bottom-fix"),e(".dynamic-menu.bottom-fix").offset().top<e("#custom-scroll-menu").offset().top&&e(".dynamic-menu").removeClass("bottom-fix")))}),e(document).on("click","body, html",function(t){e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e(".folder-order").removeClass("active")}),e(document).on("click",".dynamic-menu, .folder-order",function(e){e.stopPropagation()}),e(document).on("contextmenu",".jstree-anchor",function(t){return e(this).find("span.folder-inline-edit").trigger("click"),!1}),e(document).on("click",".folder-actions span.folder-inline-edit",function(t){t.stopImmediatePropagation(),t.stopPropagation(),0!=folders_media_options.can_manage_folder&&(isHigh=e(this).closest("li.jstree-node").hasClass("is-high"),isSticky=e(this).closest("li.jstree-node").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>",hasPosts=parseInt(e(this).closest("a.jstree-anchor").find(".premio-folder-count").text()),"attachment"==folders_media_options.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>",e(this).closest("a.jstree-anchor").after(menuHtml),e(this).parents("li.jstree-node").addClass("active-menu"),e(this).offset().top+e(".dynamic-menu").height()>e(window).height()-20&&(e(".dynamic-menu").addClass("bottom-fix"),e(".dynamic-menu.bottom-fix").offset().top<e("#custom-scroll-menu").offset().top&&e(".dynamic-menu").removeClass("bottom-fix")))}),e(document).on("click",".dynamic-menu",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","body, html",function(){e(".dynamic-menu").remove()}),e(document).on("click",".new-folder",function(t){t.stopPropagation(),l=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),v=!1,g=!1,T()}),e(document).on("click","#add-new-folder",function(t){l=e("#custom-menu li.active-item").length?e("#custom-menu li.active-item").data("folder-id"):0,v=!1,T()}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),d=e("#add-update-folder-name").val(),""==e.trim(d))e(".folder-form-errors").addClass("active"),e("#add-update-folder-name").focus();else{e("#save-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#add-update-folder").addClass("disabled");var o=l;v&&(o=0),x=0==o?e("#js-tree-menu > ul > li.jstree-node").length:e("#js-tree-menu > ul > li.jstree-node[id='"+o+"'] > ul.jstree-children > li").length+1,e.ajax({url:folders_media_options.ajax_url,data:{parent_id:o,type:folders_media_options.post_type,action:"wcp_add_new_folder",nonce:folders_media_options.nonce,term_id:o,order:x,name:d,is_duplicate:g,duplicate_from:y},method:"post",success:function(t){if(result=e.parseJSON(t),"1"==result.status){c=parseInt(result.is_key_active),n=parseInt(result.folders),e("#current-folder").text(n),e("#ttl-fldr").text(10),M(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled");var o={folder_id:result.term_id,folder_count:0,is_sticky:0,is_high:0,nonce:result.nonce,slug:result.slug,is_deleted:0};s.push(o),B(),J(),e("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.term_id,text:" "+result.title},"last",function(){e(".jstree-node[id='"+result.term_id+"']").attr("data-nonce",result.nonce),e(".jstree-node[id='"+result.term_id+"']").attr("data-slug",result.slug)}),l=result.term_id,z(0)}else e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show()}})}return!1}),e(document).on("click",".form-cancel-btn",function(){e(".folder-popup-form").hide()}),e(document).on("click",".folder-popup-form",function(t){e(".folder-popup-form").hide()}),e(document).on("click",".popup-form-content",function(e){e.stopPropagation()}),document.onkeydown=function(t){("key"in(t=t||window.event)?"Escape"===t.key||"Esc"===t.key:27===t.keyCode)&&e(".folder-popup-form").hide()},e(".rename-folder").livequery(function(){e(this).click(function(t){t.stopPropagation(),l=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),V(),e(".dynamic-menu").remove()})}),e(document).on("click","#inline-update",function(t){e("#js-tree-menu a.jstree-clicked").length&&(l=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),V())}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),d=e("#update-folder-item-name").val(),""==e.trim(d)?(e(".folder-form-errors").addClass("active"),e("#update-folder-item-name").focus()):(e("#update-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#update-folder-item").addClass("disabled"),m=O(l,"nonce"),parentID=e(".jstree-node[id='"+l+"']").closest("li.jstree-node").attr("id"),parentID==t&&(parentID=0),e.ajax({url:folders_media_options.ajax_url,data:{parent_id:parentID,type:folders_media_options.post_type,action:"wcp_update_folder",nonce:m,term_id:l,order:x,name:d},method:"post",success:function(t){result=e.parseJSON(t),"1"==result.status?(e("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title),folderPostId=U(result.id),null!=folderPostId&&(s[folderPostId].nonce=result.nonce,s[folderPostId].slug=result.slug),e(".folder-popup-form").hide(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),B(),e("#media-attachment-taxonomy-filter").length&&z(0)):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show())}})),!1}),e(".mark-folder").livequery(function(){e(this).click(function(t){t.stopPropagation(),r=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),m=O(r,"nonce"),e(".form-loader-count").css("width","100%"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e.ajax({url:folders_media_options.ajax_url,data:"term_id="+r+"&type="+folders_media_options.post_type+"&action=wcp_mark_un_mark_folder&nonce="+m,method:"post",cache:!1,success:function(t){t=e.parseJSON(t),e(".form-loader-count").css("width","0%"),"1"==t.status?(folderPostId=U(t.id),"1"==t.marked?(e("li.jstree-node[id='"+t.id+"']").addClass("is-high"),e(".sticky-folder-"+t.id).addClass("is-high"),null!=folderPostId&&(s[folderPostId].is_high=1)):(e("li.jstree-node[id='"+t.id+"']").removeClass("is-high"),e(".sticky-folder-"+t.id).removeClass("is-high"),null!=folderPostId&&(s[folderPostId].is_high=0)),B()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})}),e(".duplicate-folder").livequery(function(){e(this).click(function(t){t.stopPropagation(),l=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),e(".dynamic-menu").remove(),v=!1,g=!0,T()})}),e(".remove-folder").livequery(function(){e(this).click(function(){r=e(this).closest("li.jstree-node").data("id"),l=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),H(0),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")})}),e(document).on("click","#remove-folder-item",function(t){t.stopPropagation(),e(".folder-popup-form").addClass("disabled"),e("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>'),m=O(l,"nonce"),h?function(){if(e("#folder-hide-show-checkbox").is(":checked")&&e("#custom-menu input.checkbox:checked").length>0){var t="";e("#custom-menu input.checkbox:checked").each(function(){t+=e(this).val()+",",e(this).closest("li.route").hasClass("active-item")&&!0}),e(".form-loader-count").css("width","100%"),e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_muliple_folder&term_id="+t+"&nonce="+folders_media_options.nonce,method:"post",success:function(t){if(t=e.parseJSON(t),e(".form-loader-count").css("width","0px"),"1"==t.status){for(c=parseInt(t.is_key_active),n=parseInt(t.folders),e("#current-folder").text(n),i=0;i<t.term_ids.length;i++)e("#js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),B(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),Q(),J(),B(),e("#wcp_folder_"+f).length||(e(".header-posts a").trigger("click"),f=0)}else window.location.reload();e("#folder-hide-show-checkbox").attr("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox")}})}}():e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_folder&term_id="+l+"&nonce="+m,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(l),c=parseInt(t.is_key_active),n=parseInt(t.folders),e("#current-folder").text(n),e("#ttl-fldr").text(10),e(".sticky-folders .sticky-folder-"+l).remove(),B(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),Q(),J(),f==l&&e(".header-posts").trigger("click")):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})}),e(document).on("click","#sort-order-list",function(t){t.stopPropagation(),e(".folder-order").toggleClass("active")}),e(document).on("click","#expand-collapse-list",function(t){t.stopPropagation();var o=0;e(this).hasClass("all-open")?(e(this).removeClass("all-open"),o=0,e(this).attr("data-folder-tooltip","Expand"),e("#js-tree-menu").jstree("close_all")):(e(this).addClass("all-open"),o=1,e(this).attr("data-folder-tooltip","Collapse"),e("#js-tree-menu").jstree("open_all")),u="",e("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){u+=e(this).attr("id")+","}),""!=u&&(e(".form-loader-count").css("width","100%"),m=folders_media_options.nonce,jQuery.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_change_all_status&status="+o+"&folders="+u+"&nonce="+m,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=jQuery.parseJSON(t)).status&&(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),e(document).on("click",".folder-sort-menu a",function(t){t.stopPropagation(),t.preventDefault(),e(".form-loader-count").css("width","100%"),e(".folder-order").removeClass("active"),e(this).attr("data-sort"),jQuery.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_folders_by_order&nonce="+folders_media_options.nonce+"&order="+e(this).attr("data-sort"),method:"post",success:function(t){1==(t=jQuery.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),q()),e(".form-loader-count").css("width","0")}})}),e(".jstree-anchor").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){r=e(this).closest("li.jstree-node").attr("id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),m=O(r,"nonce"),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?Q():(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,m=O(r,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?Q():(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,m=O(r,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),u=chkStr,e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q(),B()}}))}})}),e(".media-frame:not(.hide-router) .attachments-browser li.attachment").livequery(function(){e(this).draggable({revert:"invalid",containment:"document",helper:function(t,o){e(".selected-items").remove();var s=e(".media-frame:not(.hide-router) .attachments-browser li.attachment.selected").length;return e("<div class='selected-items'><span class='total-post-count'>"+(s=0==s||1==s?"1 Item":s+" Items")+" Selected</span></div>")},start:function(t,o){e("body").addClass("no-hover-css")},cursor:"move",appendTo:".media-modal",cursorAt:{left:0,top:0},stop:function(t,o){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}})}),e(".un-categorised-items").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){r=-1,m=folders_media_options.nonce,o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:folders_media_options.ajax_url,data:"post_id="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q()}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,chkStr=postID+",",e(".wp-list-table input:checked").each(function(){postID!=e(this).val()&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_id="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),u=chkStr,e.ajax({url:folders_media_options.ajax_url,data:"post_id="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q()}}))}})}),e(".tree-structure .folder-item").livequery(function(){e(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){e("body").removeClass("no-hover-css"),r=e(this).data("id"),o.draggable.hasClass("wcp-move-multiple")?(m=O(r,"nonce"),e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q(),B()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,m=O(r,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q(),B()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,m=O(r,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+r+"&nonce="+m+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+f,method:"post",success:function(e){Q(),B()}}))}})}),e(".wcp-move-file").livequery(function(){e(this).draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(t,o){e(this).closest("td").addClass("wcp-draggable"),e("body").addClass("no-hover-css")},stop:function(t,o){e(this).closest("td").removeClass("wcp-draggable"),e("body").removeClass("no-hover-css")}})}),e(".wcp-move-multiple").livequery(function(){e(this).draggable({revert:"invalid",containment:"document",helper:function(t,o){return e(".selected-items").remove(),selectedItems=e("#the-list th input:checked").length,selectedItems>0?(selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")):e("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")},start:function(t,o){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,o){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}})}),e(".jstree-node .jstree-icon").livequery(function(){e(this).click(function(){r=e(this).closest("li.jstree-node").attr("id"),e("li.jstree-node[id='"+r+"']").hasClass("jstree-open")?folderStatus=0:folderStatus=1,e(".form-loader-count").css("width","100%"),m=O(r,"nonce"),M(),jQuery.ajax({url:folders_media_options.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+r+"&nonce="+m,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=jQuery.parseJSON(t)).status||(e("#wcp_folder_"+r).hasClass("active")?(e("#wcp_folder_"+r).removeClass("active"),e("#wcp_folder_"+r).find("ul.ui-sortable:first-child > li").slideUp(),folderStatus=0):(e("#wcp_folder_"+r).addClass("active"),e("#wcp_folder_"+r).find("ul.ui-sortable:first-child > li").slideDown(),folderStatus=1),B())}})})}),e(document).on("keyup","#folder-search",function(){F()}),e(document).on("change","#folder-search",function(){F()}),e(document).on("blur","#folder-search",function(){F()}),e(document).on("click","#folder-hide-show-checkbox",function(){e(this).is(":checked")?e("#js-tree-menu").addClass("show-folder-checkbox"):(e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"))}),e(document).on("click",".folder-checkbox, .input-checkbox",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","#inline-remove",function(){e("#js-tree-menu a.jstree-clicked").length?(l=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),H(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#folder-hide-show-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),H(1))}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(v=!0,e("#add-new-folder").trigger("click"))})})});
1
+ (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module!=="undefined"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(K,q){var H=".folder-modal #js-tree-menu";var z=[];var F=-1;var X;var x=0;var b="add";var d=0;var l="";var G=-1;var k=0;var v="";var a=0;var O=0;var g=folders_media_options.page_url;var c="";var s="";var B=false;var r=false;var N=false;var C=0;var Q;var af="";var n="";var ag=0;var aa=[];var u="<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'><div class='folder-item is-folder' data-id='__folder_id__'><a title='__folder_name__' id='folder_view___folder_id__'class='folder-view __append_class__ has-new-folder'data-id='__folder_id__'><span class='folder item-name'><span id='wcp_folder_text___folder_id__'class='folder-title'>__folder_name__</span></span></a></div></li>";var Y=wp.media.view.AttachmentFilters.extend({id:"media-attachment-taxonomy-filter",createFilters:function(){var ah={};var ai=folders_media_options.terms.length;_.each(folders_media_options.terms||{},function(ak,aj){ah[ak.term_id]={text:ak.name+" ("+ak.count+")",props:{media_folder:ak.slug}}});ah.all={text:"All Folders",props:{media_folder:""},priority:10};ah.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10};this.filters=ah},change:function(){var ai={};_.each(folders_media_options.terms||{},function(ak,aj){ai[ak.term_id]={text:ak.name+" ("+ak.count+")",props:{media_folder:ak.slug}}});ai.all={text:"Select a folder >>",props:{media_folder:""},priority:10};ai.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10};this.filters=ai;var ah=this.filters[this.el.value];if(ah){this.model.set(ah.props)}}});var A="all";var e=0;var L=0;var M=[];var ae=wp.media.view.AttachmentsBrowser;wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({createToolbar:function(){ae.prototype.createToolbar.call(this);this.toolbar.set("MediaLibraryOrganizerTaxonomyFilter",new Y({controller:this.controller,model:this.collection.props,priority:-75}).render())}});var S=wp.media.model.Query;_.extend(S,{get:(function(){var ah=[];return function(al,ak){var aj={},an=S.orderby,ao=S.defaultProps,am,ai=false;delete al.query;delete al.cache;_.defaults(al,ao);_.each(["include","exclude"],function(ap){if(al[ap]&&!_.isArray(al[ap])){al[ap]=[al[ap]]}});_.each(al,function(ap,aq){if(_.isNull(ap)){return}aj[S.propmap[aq]||aq]=ap});_.defaults(aj,S.defaultArgs);aj.orderby=an.valuemap[al.orderby]||al.orderby;ai=false;if(ai){am=_.find(ah,function(ap){return _.isEqual(ap.args,aj)})}else{ah=[]}if(!am){am=new S([],_.extend(ak||{},{props:al,args:aj}));ah.push(am)}return am}}())});var f=window.wp;if(typeof f!=="undefined"&&typeof f.Uploader==="function"){f.media.view.Modal.prototype.on("open",function(){setTimeout(function(){if(K("#media-attachment-taxonomy-filter").length){if(K("#media-attachment-taxonomy-filter").val()=="all"){K("#media-attachment-taxonomy-filter option:gt(1)").remove();_.each(folders_media_options.terms,function(ai,ah){K("#media-attachment-taxonomy-filter").append("<option value='"+ai.term_id+"'>"+ai.name+" ("+ai.trash_count+")</option>")})}if(!K("#wcp-content").length){if(K(".editor-post-featured-image").length){K(".attachment-filters").val(A).trigger("change")}}}},100)});K.extend(f.Uploader.prototype,{progress:function(){},init:function(){if(this.uploader){this.uploader.bind("FileFiltered",function(ah,ai){e++;K(".folder-meter").css("width","0%");K(".media-folder-loader").show();K("#total_upload_files").text(e)});this.uploader.bind("BeforeUpload",function(ak,ai){var ah=F;var al=ak.settings.multipart_params;ah=parseInt(ah);if(ah>0){al.folder_for_media=ah}if(L<e){K(".media-folder-loader").show();var aj=L/e*100;K(".folder-meter").css("width",aj+"%")}L++;K("#current_upload_files").text(L)});this.uploader.bind("UploadComplete",function(ah,ai){F=-1});this.uploader.bind("UploadComplete",function(ai,aj){var ah=window.wp;K(".folder-meter").css("width","100%");setTimeout(function(){K(".media-folder-loader").hide();K(".folder-meter").css("width","0%");e=0;L=0},1250);y();if(typeof ah.media.frame!=="undefined"&&ah.media.frame.content.get()!==null){ah.media.frame.content.get().collection.props.set({ignore:(+new Date())});ah.media.frame.content.get().options.selection.reset()}else{if(K("#media-attachment-taxonomy-filter").length){K(".attachment-filters").each(function(){K(this).trigger("change")})}}})}}})}var J=window.wp;if(typeof J!=="undefined"&&typeof J.Uploader==="function"){var R=window.wp.media;var p=R.view.Modal;R.view.Modal=R.view.Modal.extend({className:"folder-modal",initialize:function(){p.prototype.initialize.apply(this,arguments)},open:function(){K(".folder-modal").removeClass("folder-modal");if(p.prototype.open.apply(this,arguments)){if(K(".folder-modal").length){K(".folder-custom-menu").remove();K(".folder-modal .media-frame-tab-panel").removeClass("has-folder-menu");if(K(".folder-modal .media-frame").hasClass("hide-menu")){if(!K(".folder-custom-menu").length){K(".folder-modal .media-frame-tab-panel").before("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>");K(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){E();U();ab()})}}else{if(!K(".folder-custom-menu").length){K(".folder-modal .media-frame-menu").addClass("has-folder-menu");K(".folder-modal .media-frame-menu .media-menu").append("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>");K(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){E();U();ab()})}}K(".folder-form-data").remove();K(".media-frame-tab-panel:first").before("<div class='folder-form-data'></div>");K(".folder-form-data").load(folders_media_options.media_page_url+" #folder-add-update-content",function(){})}else{setTimeout(function(){if(F!=-1){K("#media-attachment-taxonomy-filter").each(function(){K(this).val(F);K(this).trigger("change")})}},1000)}}},close:function(){p.prototype.close.apply(this,arguments);K(".folder-modal").removeClass("folder-modal")}})}K(document).ready(function(){aa=folders_media_options.terms;k=parseInt(folders_media_options.is_key_active);G=parseInt(folders_media_options.folders);K(document).on("click",".header-posts a.all-posts",function(ah){d=0;c="";F="all";K(".active-item").removeClass("active-item");K(".jstree-clicked").removeClass("jstree-clicked");K(this).addClass("active-item");K(".sticky-folders .active-item").removeClass("active-item");K(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("all").trigger("change");K(this).closest(".media-frame").find(".folder_for_media").val("all").trigger("change")});K(document).on("click",".un-categorised-items",function(ah){d=0;c="";F="unassigned";K(".active-item").removeClass("active-item");K(".sticky-folders .active-item").removeClass("active-item");K(".jstree-clicked").removeClass("jstree-clicked");K(this).addClass("active-item");K(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("unassigned").trigger("change");K(this).closest(".media-frame").find(".folder_for_media").val("-1").trigger("change")});K(document).on("click","a.jstree-anchor",function(ai){var ah=K(this).closest("li.jstree-node").attr("id");d=ah;F=d;K(".active-item").removeClass("active-item");K("#media-attachment-taxonomy-filter").val(ah);K("#media-attachment-taxonomy-filter").trigger("change");thisSlug=ad(ah,"slug");j(thisSlug);K(".custom-media-select").removeClass("active")});K(document).on("change",".folder_for_media",function(){if(K(this).val()!="add-folder"&&K(this).val()!=null){F=K(this).val()}else{if(K(this).val()=="add-folder"){F=-1}}});K(document).on("click",".update-inline-record",function(ah){ah.stopImmediatePropagation();ah.stopPropagation();if(folders_media_options.can_manage_folder==0){return}isHigh=K(this).closest("li.sticky-fldr").hasClass("is-high");isSticky=K(this).closest("li.sticky-fldr").hasClass("is-sticky");isStickyClass=(isSticky)?true:false;K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu");menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+((isHigh)?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>";hasPosts=parseInt(K(this).closest("li.jstree-node").find("h3.title:first > .total-count").text());if(folders_media_options.post_type=="attachment"&&hasPosts){menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"}menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>";K(this).closest("li").append(menuHtml);if((K(this).offset().top+K(".dynamic-menu").height())>(K(window).height()-20)){K(".dynamic-menu").addClass("bottom-fix");if(K(".dynamic-menu.bottom-fix").offset().top<K("#custom-scroll-menu").offset().top){K(".dynamic-menu").removeClass("bottom-fix")}}});K(document).on("click","body, html",function(ah){K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu");K(".folder-order").removeClass("active")});K(document).on("click",".dynamic-menu, .folder-order",function(ah){ah.stopPropagation()});K(document).on("contextmenu",".jstree-anchor",function(ah){K(this).find("span.folder-inline-edit").trigger("click");return false});K(document).on("click",".folder-actions span.folder-inline-edit",function(ah){ah.stopImmediatePropagation();ah.stopPropagation();if(folders_media_options.can_manage_folder==0){return}isHigh=K(this).closest("li.jstree-node").hasClass("is-high");isSticky=K(this).closest("li.jstree-node").hasClass("is-sticky");isStickyClass=(isSticky)?true:false;K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu");menuHtml="<div class='dynamic-menu'><ul><li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span> New Folder</a></li><li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span> Rename</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li><li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+((isHigh)?" Remove Star":"Add a Star")+"</a></li><li class='duplicate-folder'><a href='javascript:;'><span class=''><i class='pfolder-clone'></i></span> Duplicate folder</a></li>";hasPosts=parseInt(K(this).closest("a.jstree-anchor").find(".premio-folder-count").text());if(folders_media_options.post_type=="attachment"&&hasPosts){menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span> Download Zip (Pro)</a></li>"}menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>";K(this).closest("a.jstree-anchor").after(menuHtml);K(this).parents("li.jstree-node").addClass("active-menu");if((K(this).offset().top+K(".dynamic-menu").height())>(K(window).height()-20)){K(".dynamic-menu").addClass("bottom-fix");if(K(".dynamic-menu.bottom-fix").offset().top<K("#custom-scroll-menu").offset().top){K(".dynamic-menu").removeClass("bottom-fix")}}});K(document).on("click",".dynamic-menu",function(ah){ah.stopImmediatePropagation();ah.stopPropagation()});K(document).on("click","body, html",function(){K(".dynamic-menu").remove()});K(document).on("click",".new-folder",function(ah){ah.stopPropagation();if(K(this).closest("li.jstree-node").length){d=K(this).closest("li.jstree-node").attr("id")}else{d=K(this).closest("li.sticky-fldr").data("folder-id")}K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu");r=false;N=false;W()});K(document).on("click","#add-new-folder",function(ah){if(K("#custom-menu li.active-item").length){d=K("#custom-menu li.active-item").data("folder-id")}else{d=0}r=false;W()});K(document).on("submit","#save-folder-form",function(ah){ah.stopPropagation();ah.preventDefault();l=K("#add-update-folder-name").val();if(K.trim(l)==""){K(".folder-form-errors").addClass("active");K("#add-update-folder-name").focus()}else{K("#save-folder-data").html('<span class="dashicons dashicons-update"></span>');K("#add-update-folder").addClass("disabled");var ai=d;if(r){ai=0}if(ai==0){ag=K("#js-tree-menu > ul > li.jstree-node").length}else{ag=K("#js-tree-menu > ul > li.jstree-node[id='"+ai+"'] > ul.jstree-children > li").length+1}K.ajax({url:folders_media_options.ajax_url,data:{parent_id:ai,type:folders_media_options.post_type,action:"wcp_add_new_folder",nonce:folders_media_options.nonce,term_id:ai,order:ag,name:l,is_duplicate:N,duplicate_from:C},method:"post",success:function(aj){result=K.parseJSON(aj);if(result.status=="1"){k=parseInt(result.is_key_active);G=parseInt(result.folders);K("#current-folder").text(G);K("#ttl-fldr").text((4*4)-(2*2)-2);E();K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");var ak={folder_id:result.term_id,folder_count:0,is_sticky:0,is_high:0,nonce:result.nonce,slug:result.slug,is_deleted:0};z.push(ak);V();w();K("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.term_id,text:" "+result.title},"last",function(){K(".jstree-node[id='"+result.term_id+"']").attr("data-nonce",result.nonce);K(".jstree-node[id='"+result.term_id+"']").attr("data-slug",result.slug)});d=result.term_id;D(0)}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(result.message);K("#error-folder-popup").show()}}})}return false});K(document).on("click",".form-cancel-btn",function(){K(".folder-popup-form").hide()});K(document).on("click",".folder-popup-form",function(ah){K(".folder-popup-form").hide()});K(document).on("click",".popup-form-content",function(ah){ah.stopPropagation()});document.onkeydown=function(ah){ah=ah||window.event;var ai=false;if("key" in ah){ai=(ah.key==="Escape"||ah.key==="Esc")}else{ai=(ah.keyCode===27)}if(ai){K(".folder-popup-form").hide()}};K(".rename-folder").livequery(function(){K(this).click(function(ah){ah.stopPropagation();if(K(this).closest("li.jstree-node").length){d=K(this).closest("li.jstree-node").attr("id")}else{d=K(this).closest("li.sticky-fldr").data("folder-id")}T();K(".dynamic-menu").remove()})});K(document).on("click","#inline-update",function(ah){if(K("#js-tree-menu a.jstree-clicked").length){d=K("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");T()}});K(document).on("submit","#update-folder-form",function(ah){ah.stopPropagation();ah.preventDefault();l=K("#update-folder-item-name").val();if(K.trim(l)==""){K(".folder-form-errors").addClass("active");K("#update-folder-item-name").focus()}else{K("#update-folder-data").html('<span class="dashicons dashicons-update"></span>');K("#update-folder-item").addClass("disabled");v=ad(d,"nonce");parentID=K(".jstree-node[id='"+d+"']").closest("li.jstree-node").attr("id");if(parentID==q){parentID=0}K.ajax({url:folders_media_options.ajax_url,data:{parent_id:parentID,type:folders_media_options.post_type,action:"wcp_update_folder",nonce:v,term_id:d,order:ag,name:l},method:"post",success:function(ai){result=K.parseJSON(ai);if(result.status=="1"){K("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title);folderPostId=t(result.id);if(folderPostId!=null){z[folderPostId]["nonce"]=result.nonce;z[folderPostId]["slug"]=result.slug}K(".folder-popup-form").hide();K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");V();if(K("#media-attachment-taxonomy-filter").length){D(0)}}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(result.message);K("#error-folder-popup").show()}}})}return false});K(".mark-folder").livequery(function(){K(this).click(function(ah){ah.stopPropagation();if(K(this).closest("li.jstree-node").length){x=K(this).closest("li.jstree-node").attr("id")}else{x=K(this).closest("li.sticky-fldr").data("folder-id")}v=ad(x,"nonce");K(".form-loader-count").css("width","100%");K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu");K.ajax({url:folders_media_options.ajax_url,data:"term_id="+x+"&type="+folders_media_options.post_type+"&action=wcp_mark_un_mark_folder&nonce="+v,method:"post",cache:false,success:function(ai){ai=K.parseJSON(ai);K(".form-loader-count").css("width","0%");if(ai.status=="1"){folderPostId=t(ai.id);if(ai.marked=="1"){K("li.jstree-node[id='"+ai.id+"']").addClass("is-high");K(".sticky-folder-"+ai.id).addClass("is-high");if(folderPostId!=null){z[folderPostId]["is_high"]=1}}else{K("li.jstree-node[id='"+ai.id+"']").removeClass("is-high");K(".sticky-folder-"+ai.id).removeClass("is-high");if(folderPostId!=null){z[folderPostId]["is_high"]=0}}V()}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(ai.message);K("#error-folder-popup").show()}}})})});K(".duplicate-folder").livequery(function(){K(this).click(function(ah){ah.stopPropagation();if(K(this).closest("li.jstree-node").length){d=K(this).closest("li.jstree-node").attr("id")}else{d=K(this).closest("li.sticky-fldr").data("folder-id")}K(".dynamic-menu").remove();r=false;N=true;W()})});K(".remove-folder").livequery(function(){K(this).click(function(){x=K(this).closest("li.jstree-node").data("id");if(K(this).closest("li.jstree-node").length){d=K(this).closest("li.jstree-node").attr("id")}else{d=K(this).closest("li.sticky-fldr").data("folder-id")}Z(0);K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu")})});K(document).on("click","#remove-folder-item",function(ah){ah.stopPropagation();K(".folder-popup-form").addClass("disabled");K("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>');v=ad(d,"nonce");if(B){m()}else{K.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_folder&term_id="+d+"&nonce="+v,method:"post",success:function(ai){ai=K.parseJSON(ai);if(ai.status=="1"){K("#js-tree-menu").jstree().delete_node(d);k=parseInt(ai.is_key_active);G=parseInt(ai.folders);K("#current-folder").text(G);K("#ttl-fldr").text((3*3)+(4/(2*2)));K(".sticky-folders .sticky-folder-"+d).remove();V();K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");ac();w();if(c==d){K(".header-posts").trigger("click")}}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(ai.message);K("#error-folder-popup").show()}}})}});K(document).on("click","#sort-order-list",function(ah){ah.stopPropagation();K(".folder-order").toggleClass("active")});K(document).on("click","#expand-collapse-list",function(ai){ai.stopPropagation();var ah=0;if(K(this).hasClass("all-open")){K(this).removeClass("all-open");ah=0;K(this).attr("data-folder-tooltip","Expand");K("#js-tree-menu").jstree("close_all")}else{K(this).addClass("all-open");ah=1;K(this).attr("data-folder-tooltip","Collapse");K("#js-tree-menu").jstree("open_all")}s="";K("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){s+=K(this).attr("id")+","});if(s!=""){K(".form-loader-count").css("width","100%");v=folders_media_options.nonce;K.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_change_all_status&status="+ah+"&folders="+s+"&nonce="+v,method:"post",success:function(aj){K(".form-loader-count").css("width","0");aj=K.parseJSON(aj);if(aj.status=="0"){K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(aj.message);K("#error-folder-popup").show();window.location.reload(true)}}})}});K(document).on("click",".folder-sort-menu a",function(ah){ah.stopPropagation();ah.preventDefault();K(".form-loader-count").css("width","100%");K(".folder-order").removeClass("active");af=K(this).attr("data-sort");K.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_folders_by_order&nonce="+folders_media_options.nonce+"&order="+K(this).attr("data-sort"),method:"post",success:function(ai){ai=K.parseJSON(ai);if(ai.status==1){K("#js-tree-menu").jstree().destroy();K("#js-tree-menu").append("<ul></ul>");K("#js-tree-menu ul").html(ai.data);aa=ai.terms;P();ab()}K(".form-loader-count").css("width","0")}})});K(".jstree-anchor").livequery(function(){K(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(ah,ai){x=K(this).closest("li.jstree-node").attr("id");if(ai.draggable.hasClass("wcp-move-multiple")){if(K(".wp-list-table input:checked").length){chkStr="";K(".wp-list-table input:checked").each(function(){chkStr+=K(this).val()+","});v=ad(x,"nonce");K.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){aj=K.parseJSON(aj);if(aj.status=="1"){ac()}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(aj.message);K("#error-folder-popup").show()}}})}}else{if(ai.draggable.hasClass("wcp-move-file")){postID=ai.draggable[0].attributes["data-id"].nodeValue;v=ad(x,"nonce");chkStr=postID+",";K(".wp-list-table input:checked").each(function(){if(K(this).val()!=postID){chkStr+=K(this).val()+","}});K.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){aj=K.parseJSON(aj);if(aj.status=="1"){ac()}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(aj.message);K("#error-folder-popup").show()}}})}else{if(ai.draggable.hasClass("attachment")){chkStr=ai.draggable[0].attributes["data-id"].nodeValue;v=ad(x,"nonce");if(K(".attachments-browser li.attachment.selected").length>1){chkStr="";K(".attachments-browser li.attachment.selected").each(function(){chkStr+=K(this).data("id")+","})}s=chkStr;K.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac();V()}})}}}}})});K(".media-frame:not(.hide-router) .attachments-browser li.attachment").livequery(function(){K(this).draggable({revert:"invalid",containment:"document",helper:function(ah,ai){K(".selected-items").remove();var aj=K(".media-frame:not(.hide-router) .attachments-browser li.attachment.selected").length;aj=(aj==0||aj==1)?"1 Item":aj+" Items";return K("<div class='selected-items'><span class='total-post-count'>"+aj+" Selected</span></div>")},start:function(ah,ai){K("body").addClass("no-hover-css")},cursor:"move",appendTo:".media-modal",cursorAt:{left:0,top:0},stop:function(ah,ai){K(".selected-items").remove();K("body").removeClass("no-hover-css")}})});K(".un-categorised-items").livequery(function(){K(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(ah,ai){x=-1;v=folders_media_options.nonce;if(ai.draggable.hasClass("wcp-move-multiple")){if(K(".wp-list-table input:checked").length){chkStr="";K(".wp-list-table input:checked").each(function(){chkStr+=K(this).val()+","});K.ajax({url:folders_media_options.ajax_url,data:"post_id="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac()}})}}else{if(ai.draggable.hasClass("wcp-move-file")){postID=ai.draggable[0].attributes["data-id"].nodeValue;chkStr=postID+",";K(".wp-list-table input:checked").each(function(){if(postID!=K(this).val()){chkStr+=K(this).val()+","}});K.ajax({url:folders_media_options.ajax_url,data:"post_id="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac()}})}else{if(ai.draggable.hasClass("attachment")){chkStr=ai.draggable[0].attributes["data-id"].nodeValue;if(K(".attachments-browser li.attachment.selected").length>1){chkStr="";K(".attachments-browser li.attachment.selected").each(function(){chkStr+=K(this).data("id")+","})}s=chkStr;K.ajax({url:folders_media_options.ajax_url,data:"post_id="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac()}})}}}}})});K(".tree-structure .folder-item").livequery(function(){K(this).droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(ah,ai){K("body").removeClass("no-hover-css");x=K(this).data("id");if(ai.draggable.hasClass("wcp-move-multiple")){v=ad(x,"nonce");if(K(".wp-list-table input:checked").length){chkStr="";K(".wp-list-table input:checked").each(function(){chkStr+=K(this).val()+","});K.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac();V()}})}}else{if(ai.draggable.hasClass("wcp-move-file")){postID=ai.draggable[0].attributes["data-id"].nodeValue;v=ad(x,"nonce");chkStr=postID+",";K(".wp-list-table input:checked").each(function(){if(K(this).val()!=postID){chkStr+=K(this).val()+","}});K.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac();V()}})}else{if(ai.draggable.hasClass("attachment")){chkStr=ai.draggable[0].attributes["data-id"].nodeValue;v=ad(x,"nonce");if(K(".attachments-browser li.attachment.selected").length>1){chkStr="";K(".attachments-browser li.attachment.selected").each(function(){chkStr+=K(this).data("id")+","})}K.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+x+"&nonce="+v+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+c,method:"post",success:function(aj){ac();V()}})}}}}})});K(".wcp-move-file").livequery(function(){K(this).draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(ah,ai){K(this).closest("td").addClass("wcp-draggable");K("body").addClass("no-hover-css")},stop:function(ah,ai){K(this).closest("td").removeClass("wcp-draggable");K("body").removeClass("no-hover-css")}})});K(".wcp-move-multiple").livequery(function(){K(this).draggable({revert:"invalid",containment:"document",helper:function(ah,ai){K(".selected-items").remove();selectedItems=K("#the-list th input:checked").length;if(selectedItems>0){selectedItems=(selectedItems==0||selectedItems==1)?"1 Item":selectedItems+" Items";return K("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")}else{return K("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")}},start:function(ah,ai){K("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(ah,ai){K(".selected-items").remove();K("body").removeClass("no-hover-css")}})});K(".jstree-node .jstree-icon").livequery(function(){K(this).click(function(){x=K(this).closest("li.jstree-node").attr("id");if(K("li.jstree-node[id='"+x+"']").hasClass("jstree-open")){folderStatus=0}else{folderStatus=1}K(".form-loader-count").css("width","100%");v=ad(x,"nonce");E();K.ajax({url:folders_media_options.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+x+"&nonce="+v,method:"post",success:function(ah){K(".form-loader-count").css("width","0");ah=K.parseJSON(ah);if(ah.status=="0"){}else{if(K("#wcp_folder_"+x).hasClass("active")){K("#wcp_folder_"+x).removeClass("active");K("#wcp_folder_"+x).find("ul.ui-sortable:first-child > li").slideUp();folderStatus=0}else{K("#wcp_folder_"+x).addClass("active");K("#wcp_folder_"+x).find("ul.ui-sortable:first-child > li").slideDown();folderStatus=1}V()}}})})});K(document).on("keyup","#folder-search",function(){I()});K(document).on("change","#folder-search",function(){I()});K(document).on("blur","#folder-search",function(){I()});K(document).on("click","#folder-hide-show-checkbox",function(){if(K(this).is(":checked")){K("#js-tree-menu").addClass("show-folder-checkbox")}else{K("#js-tree-menu input.checkbox").attr("checked",false);K("#js-tree-menu").removeClass("show-folder-checkbox")}});K(document).on("click",".folder-checkbox, .input-checkbox",function(ah){ah.stopImmediatePropagation();ah.stopPropagation()});K(document).on("click","#inline-remove",function(){if(K("#js-tree-menu a.jstree-clicked").length){d=K("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");Z(1);K(".dynamic-menu").remove();K(".active-menu").removeClass("active-menu")}else{if(K("#folder-hide-show-checkbox").is(":checked")){K(".dynamic-menu").remove();Z(1)}}});K(document).on("change",".folder_for_media",function(){if(K(this).val()=="add-folder"){r=true;K("#add-new-folder").trigger("click")}})});function ab(){K(H).jstree({core:{cache:false,animation:0,check_callback:function(aj,ah,al,ai,ak){K("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up");if(("move_node"===aj||"copy_node"===aj)&&ak&&ak.dnd){switch(ak.pos){case"a":ak.origin.get_node(ak.ref,!0).addClass("drag-bot");nodeId=K(".drag-bot").attr("id");K("#jstree-dnd").text("Below "+K.trim(K("#js-tree-menu").jstree(true).get_node(nodeId).text));break;case"i":ak.origin.get_node(ak.ref,!0).addClass("drag-in");nodeId=K(".drag-in").attr("id");K("#jstree-dnd").text("Inside "+K.trim(K("#js-tree-menu").jstree(true).get_node(nodeId).text));break;case"b":ak.origin.get_node(ak.ref,!0).addClass("drag-up");nodeId=K(".drag-up").attr("id");K("#jstree-dnd").text("Above "+K.trim(K("#js-tree-menu").jstree(true).get_node(nodeId).text));break;default:K("#jstree-dnd").text(K("#jstree-dnd").data("txt"));break}}return !0}},data:{cache:false},select_node:false,search:{show_only_matches:true,case_sensitive:false,fuzzy:false},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",(function(){o()})).bind("move_node.jstree",(function(ah,ai){folderMoveId=ai.node.id;orderString="";K(".folder-modal .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){if(K(this).attr("id")!="undefined"){orderString+=K(this).attr("id")+","}});if(K(".folder-modal #"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")){parentID=K("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id")}else{parentID=0}if(orderString!=""){K(".form-loader-count").css("width","100%");K.ajax({url:folders_media_options.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+folders_media_options.post_type+"&nonce="+folders_media_options.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(aj){aj=K.parseJSON(aj);if(aj.status=="1"){K("#wcp_folder_parent").html(aj.options);K(".form-loader-count").css("width","0");ac();V();P()}else{K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html(aj.message);K("#error-folder-popup").show();window.location.reload(true)}}})}}))}function o(){K("#js-tree-menu .jstree-node").each(function(){var ai=parseInt(K(this).data("count"));if(ai>0){K(".jstree-node[id='"+K(this).attr("id")+"'] > a span.premio-folder-count").text(ai)}var ah={folder_id:K(this).attr("id"),folder_count:ai,is_sticky:K(this).hasClass("is-sticky")?1:0,is_high:K(this).hasClass("is-high")?1:0,nonce:K(this).data("nonce"),slug:K(this).data("slug"),is_deleted:0};z.push(ah)});if(c!=""&&c!=0){if(K(".jstree-node[id='"+c+"']").length){K("#js-tree-menu").jstree("select_node",c);if(K(".sticky-folders .sticky-folder-"+c+" a").length){K(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item")}}}K(".ajax-preloader").hide();K(".js-tree-data").show();U();w();if(K(".sticky-folders ul > li").length>0){K(".sticky-folders").addClass("active")}}function ad(ah,ai){if(z.length>0){for(i=0;i<z.length;i++){if(parseInt(z[i]["folder_id"])==parseInt(ah)){return z[i][ai]}}}return""}function t(ah){if(z.length>0){for(i=0;i<z.length;i++){if(parseInt(z[i]["folder_id"])==parseInt(ah)){return i}}}return null}function w(){K(".sticky-folders > ul").html("");var ah="";K("#js-tree-menu li.jstree-node.is-sticky").each(function(){var ak=K(this).attr("id");var al=K.trim(K("#js-tree-menu").jstree(true).get_node(ak).text);var am=K("#"+ak+"_anchor .premio-folder-count").text();var aj=K("li.jstree-node[id='"+ak+"']").hasClass("is-high")?" is-high ":"";ah+="<li data-folder-id='"+ak+"' class='sticky-fldr "+aj+" sticky-folder-"+ak+"'><a href='javascript:;'><span class='folder-title'>"+al+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'></span></span></a></li>"});K(".sticky-folders > ul").html(ah);if(K(".jstree-anchor.jstree-clicked").length){var ai=K(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");K(".sticky-folders .sticky-folder-"+ai+" a").addClass("active-item")}if(K(".sticky-folders > ul > li").length>0){K(".sticky-folders").addClass("active")}else{K(".sticky-folders").removeClass("active")}U()}function U(){}function m(){if(K("#folder-hide-show-checkbox").is(":checked")){if(K("#js-tree-menu input.checkbox:checked").length>0){var ah="";var ai=false;K("#js-tree-menu input.checkbox:checked").each(function(){ah+=K(this).closest("li.jstree-node").attr("id")+",";if(K(this).closest("li.jstree-node").hasClass("jstree-clicked")){ai=true}});K(".form-loader-count").css("width","100%");K.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_muliple_folder&term_id="+ah+"&nonce="+folders_media_options.nonce,method:"post",success:function(aj){aj=K.parseJSON(aj);K(".form-loader-count").css("width","0px");if(aj.status=="1"){k=parseInt(aj.is_key_active);G=parseInt(aj.folders);K("#current-folder").text(G);for(i=0;i<aj.term_ids.length;i++){K(".folder-modal #js-tree-menu").jstree().delete_node(aj.term_ids[i])}K("#ttl-fldr").text((4*2)+(4/2));V();K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");ac();w();V();if(!K(".folder-modal #wcp_folder_"+c).length){K(".header-posts a").trigger("click");c=0}}else{window.location.reload()}K("#folder-hide-show-checkbox").attr("checked",false);K("#js-tree-menu input.checkbox").attr("checked",false);K("#js-tree-menu").removeClass("show-folder-checkbox")}})}else{}}}function ac(){if(K(".media-toolbar").hasClass("media-toolbar-mode-select")){if(K("ul.attachments li.selected").length){K("ul.attachments li.selected").trigger("click");K(".select-mode-toggle-button").trigger("click")}}if(s!=""&&(K("#js-tree-menu a.jstree-clicked").length>0||c=="-1")){if(K("#media-attachment-taxonomy-filter").length){s=s.split(",");for(var ah=0;ah<s.length;ah++){if(s[ah]!=""){K(".attachments-browser li[data-id='"+s[ah]+"']").remove()}}}s=""}if(K("#media-attachment-taxonomy-filter").length){D(0)}else{K.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=get_folders_default_list",method:"post",success:function(ai){ai=K.parseJSON(ai);K(".header-posts .total-count").text(ai.total_items);K(".un-categorised-items .total-count").text(ai.empty_items);aa=ai.taxonomies;P()}});K(".folder-loader-ajax").addClass("active");if(K("#folder-posts-filter").length){K("#folder-posts-filter").load(g+" #posts-filter",function(){var ai={Title:"",Url:g};history.pushState(ai,ai.Title,ai.Url);if(folders_media_options.show_in_page=="show"&&!K(".tree-structure").length){K(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}triggerInlineUpdate()})}else{K("#wpbody").load(g+" #wpbody-content",false,function(ai){var aj={Title:"",Url:g};history.pushState(aj,aj.Title,aj.Url);if(folders_media_options.show_in_page=="show"&&!K(".tree-structure").length){K(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}})}}}function y(){var ah=K("#media-attachment-taxonomy-filter").val();h=K.ajax({url:folders_media_options.ajax_url,data:"type=attachment&action=wcp_get_default_list&active_id=0",method:"post",beforeSend:function(){if(h!=null){h.abort()}},success:function(ai){var ai=K.parseJSON(ai);aa=ai.taxonomies;P()}})}function P(){if(K("#media-attachment-taxonomy-filter").length){K("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=aa;var aj=K(this);currentDDVal=K(this).val();aj.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");M=aa;for(var ak=0;ak<aa.length;ak++){aj.append("<option value='"+aa[ak].term_id+"'>"+aa[ak].name+" ("+aa[ak].trash_count+")</option>")}aj.val(currentDDVal).trigger("change")});if(K("select.folder_for_media").length){var ai=K("select.folder_for_media").val();K("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var ah=0;ah<aa.length;ah++){K("select.folder_for_media option:last-child").before("<option value='"+aa[ah].term_id+"'>"+aa[ah].name+"</option>")}if(ai!=""){K(".folder_for_media").val(ai)}}}K("span.premio-folder-count").text("");K(".folder-count").text("");for(ah=0;ah<aa.length;ah++){if(parseInt(aa[ah].trash_count)!=0){K(".jstree-node[id='"+aa[ah].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(aa[ah].trash_count);K(".sticky-folder-"+aa[ah].term_id+" .premio-folder-count").text(aa[ah].trash_count)}}if(c!=""){K("#wcp_folder_"+c).addClass("active-item")}if(r){K("#title_"+d).trigger("click");r=false}}function I(){var ah=K.trim(K("#folder-search").val());K("#js-tree-menu").jstree("search",ah)}function Z(ah){var ai="Are you sure you want to delete the selected folder?";var aj="Items in the folder will not be deleted.";B=false;if(ah==1){if(K("#folder-hide-show-checkbox").is(":checked")){B=true;if(K("#js-tree-menu input.checkbox:checked").length==0){K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#error-folder-popup-message").html("Please select at least one folder to delete");K("#error-folder-popup").show();return}else{if(K("#js-tree-menu input.checkbox:checked").length>1){ai="Are you sure you want to delete the selected folders?";aj="Items in the selected folders will not be deleted."}}}}K(".folder-popup-form").hide();K(".folder-popup-form").removeClass("disabled");K("#remove-folder-item").text("Yes, Delete it!");K("#remove-folder-message").text(ai);K("#remove-folder-notice").text(aj);K("#confirm-remove-folder").show();K("#remove-folder-item").focus()}function T(){folderName=K.trim(K("#js-tree-menu").jstree(true).get_node(d).text);parentID=K("#wcp_folder_"+d).closest("li.jstree-node").data("folder-id");if(parentID==q){parentID=0}K("#update-folder-data").text("Submit");K(".folder-form-errors").removeClass("active");K("#update-folder-item-name").val(folderName);K("#update-folder-item").removeClass("disabled");K("#update-folder-item").show();K("#update-folder-item-name").focus();K(".dynamic-menu").remove()}function W(){if(k==0&&G>=((4*4)-(3*3)+(4/4)+(8/(2*2)))){K("#folder-limitation-message").html("You've reached the "+((4*4)-(2*2)-2)+" folder limitation!");K("#no-more-folder-credit").show();return false}K("#add-update-folder-title").text("Add new folder");K("#save-folder-data").text("Submit");K(".folder-form-errors").removeClass("active");K("#add-update-folder-name").val("");if(N){C=d;K("#add-update-folder-name").val(K.trim(K("#js-tree-menu").jstree(true).get_node(d).text)+" #2");if(K("#"+d+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")){d=K("#"+d+"_anchor").closest(".jstree-node").parent().parent().attr("id")}else{d=0}}K("#add-update-folder").removeClass("disabled");K("#add-update-folder").show();K("#add-update-folder-name").focus();K(".dynamic-menu").remove()}function E(){setTimeout(function(){var ah=true;if(K("#js-tree-menu .jstree-node.jstree-leaf").length==K("#js-tree-menu .jstree-node").length){K("#expand-collapse-list").removeClass("all-open");K("#expand-collapse-list").attr("data-folder-tooltip","Expand")}else{var ai=K("#js-tree-menu .jstree-node.jstree-closed").length+K("#js-tree-menu .jstree-node.jstree-open").length;if(K("#js-tree-menu .jstree-node.jstree-closed").length==ai){K("#expand-collapse-list").removeClass("all-open");K("#expand-collapse-list").attr("data-folder-tooltip","Expand")}else{K("#expand-collapse-list").addClass("all-open");K("#expand-collapse-list").attr("data-folder-tooltip","Collapse")}}},500)}var h;function D(ah){h=K.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_get_default_list&active_id="+c,method:"post",beforeSend:function(){if(h!=null){h.abort()}},success:function(ai){ai=K.parseJSON(ai);K(".header-posts .total-count").text(ai.total_items);K(".un-categorised-items .total-count").text(ai.empty_items);selectedVal=K("#media-attachment-taxonomy-filter").val();if(selectedVal!="all"&&ah==1){var aj=parent.wp;if(aj.media!=q){aj.media.frame.setState("insert");if(aj.media.frame.content.get()!==null){aj.media.frame.content.get().collection.props.set({ignore:(+new Date())});aj.media.frame.content.get().options.selection.reset()}else{aj.media.frame.library.props.set({ignore:(+new Date())})}}}aa=ai.taxonomies;P()}})}function j(ah){K.ajax({url:folders_media_options.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+folders_media_options.post_type+"&post_id="+ah+"&nonce="+folders_media_options.nonce,cache:false,async:false,success:function(){}})}function V(){K(".folder-loader-ajax").addClass("active");K(".folder-loader-ajax img").removeClass("active");K(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated");setTimeout(function(){K(".folder-loader-ajax").removeClass("active");K(".folder-loader-ajax img").addClass("active");K(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2000)}}));
folders.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Arrange media, pages, custom post types and posts into folders
5
- * Version: 2.5.9
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
@@ -30,7 +30,7 @@ if(!defined("WCP_FOLDER_URL")) {
30
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
31
  }
32
  if(!defined("WCP_FOLDER_VERSION")) {
33
- define('WCP_FOLDER_VERSION', "2.5.9");
34
  }
35
 
36
  include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Arrange media, pages, custom post types and posts into folders
5
+ * Version: 2.6
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
30
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
31
  }
32
  if(!defined("WCP_FOLDER_VERSION")) {
33
+ define('WCP_FOLDER_VERSION', "2.6");
34
  }
35
 
36
  include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
includes/folders.class.php CHANGED
@@ -2816,6 +2816,9 @@ class WCP_Folders
2816
  if(empty($show_in_page)) {
2817
  $show_in_page = "show";
2818
  }
 
 
 
2819
  wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
2820
  'ajax_url' => admin_url('admin-ajax.php'),
2821
  'upgrade_url' => admin_url('admin.php?page=wcp_folders_upgrade'),
@@ -2834,6 +2837,7 @@ class WCP_Folders
2834
  'selected_taxonomy' => $selected_taxonomy,
2835
  'show_in_page' => $show_in_page,
2836
  'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
 
2837
  ));
2838
  } else {
2839
  self::is_add_update_screen();
2816
  if(empty($show_in_page)) {
2817
  $show_in_page = "show";
2818
  }
2819
+ $taxonomies = self::get_terms_hierarchical($post_type);
2820
+
2821
+ $response['terms'] = $taxonomies;
2822
  wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
2823
  'ajax_url' => admin_url('admin-ajax.php'),
2824
  'upgrade_url' => admin_url('admin.php?page=wcp_folders_upgrade'),
2837
  'selected_taxonomy' => $selected_taxonomy,
2838
  'show_in_page' => $show_in_page,
2839
  'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
2840
+ 'taxonomies' => $taxonomies,
2841
  ));
2842
  } else {
2843
  self::is_add_update_screen();
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: galdub, tomeraharon, premio
3
  Tags: folder, folders, organize, pages folders, media library, posts folders, media folders, subfolders, file manager, directories, media library folders, media library folder
4
  Requires at least: 3.0.0
5
  Tested up to: 5.5
6
- Stable tag: 2.5.9
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a WordPress plugin that will help you quickly organize and manage your Media library files, Pages, Posts, and Custom Posts in folders
@@ -162,6 +162,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
162
 
163
  == Changelog ==
164
 
 
 
 
165
  = 2.5.9 =
166
  We've significantly improved the drag and drop experience (and we've also fixed some bugs)
167
 
3
  Tags: folder, folders, organize, pages folders, media library, posts folders, media folders, subfolders, file manager, directories, media library folders, media library folder
4
  Requires at least: 3.0.0
5
  Tested up to: 5.5
6
+ Stable tag: 2.6
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a WordPress plugin that will help you quickly organize and manage your Media library files, Pages, Posts, and Custom Posts in folders
162
 
163
  == Changelog ==
164
 
165
+ = 2.6 =
166
+ Gallery related bugs and items-counter issues were fixed
167
+
168
  = 2.5.9 =
169
  We've significantly improved the drag and drop experience (and we've also fixed some bugs)
170