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

Version Description

WordPress 5.6 compatibility + Visual composer overlapping bug 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.2
Comparing to
See all releases

Code changes from version 2.6.1 to 2.6.2

assets/js/folders.js CHANGED
@@ -318,48 +318,73 @@
318
  });
319
 
320
  /* grag and drop */
321
- $(".jstree-anchor").livequery(function(){
322
- $(this).droppable({
323
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
324
- hoverClass: 'wcp-drop-hover',
325
- classes: {
326
- "ui-droppable-active": "ui-state-highlight"
327
- },
328
- drop: function( event, ui ) {
329
- folderID = $(this).closest("li.jstree-node").attr('id');
330
- if ( ui.draggable.hasClass( 'wcp-move-multiple')) {
331
- if($(".wp-list-table input:checked").length) {
332
- chkStr = "";
333
- $(".wp-list-table input:checked").each(function(){
334
- chkStr += $(this).val()+",";
335
- });
336
- nonce = getSettingForPost(folderID, 'nonce');
337
- $.ajax({
338
- url: wcp_settings.ajax_url,
339
- 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,
340
- method: 'post',
341
- success: function (res) {
342
- res = $.parseJSON(res);
343
- if(res.status == "1") {
344
- resetMediaAndPosts();
345
- } else {
346
- $(".folder-popup-form").hide();
347
- $(".folder-popup-form").removeClass("disabled");
348
- $("#error-folder-popup-message").html(res.message);
349
- $("#error-folder-popup").show()
350
- }
351
- }
352
- });
353
- }
354
- } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
355
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
356
- nonce = getSettingForPost(folderID, 'nonce');
357
- chkStr = postID+",";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  $(".wp-list-table input:checked").each(function(){
359
- if($(this).val() != postID) {
360
- chkStr += $(this).val() + ",";
361
- }
362
  });
 
363
  $.ajax({
364
  url: wcp_settings.ajax_url,
365
  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,
@@ -367,7 +392,6 @@
367
  success: function (res) {
368
  res = $.parseJSON(res);
369
  if(res.status == "1") {
370
- // window.location.reload();
371
  resetMediaAndPosts();
372
  } else {
373
  $(".folder-popup-form").hide();
@@ -377,63 +401,70 @@
377
  }
378
  }
379
  });
380
- } else if (ui.draggable.hasClass('attachment')) {
381
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
382
- nonce = getSettingForPost(folderID, 'nonce');
383
- if ($(".attachments-browser li.attachment.selected").length > 1) {
384
- chkStr = "";
385
- $(".attachments-browser li.attachment.selected").each(function(){
386
- chkStr += $(this).data("id") + ",";
387
- });
388
  }
389
- folderIDs = chkStr;
390
- $.ajax({
391
- url: wcp_settings.ajax_url,
392
- 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,
393
- method: 'post',
394
- success: function (res) {
 
 
395
  // window.location.reload();
396
  resetMediaAndPosts();
 
 
 
 
 
397
  }
 
 
 
 
 
 
 
 
 
398
  });
399
  }
 
 
 
 
 
 
 
 
 
 
400
  }
401
- });
402
  });
403
 
404
- $(".un-categorised-items").livequery(function(){
405
- $(this).droppable({
406
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
407
- hoverClass: 'wcp-hover-list',
408
- classes: {
409
- "ui-droppable-active": "ui-state-highlight"
410
- },
411
- drop: function (event, ui) {
412
- folderID = -1;
413
- nonce = wcp_settings.nonce;
414
- if (ui.draggable.hasClass('wcp-move-multiple')) {
415
- if ($(".wp-list-table input:checked").length) {
416
- chkStr = "";
417
- $(".wp-list-table input:checked").each(function(){
418
- chkStr += $(this).val() + ",";
419
- });
420
- $.ajax({
421
- url: wcp_settings.ajax_url,
422
- data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
423
- method: 'post',
424
- success: function (res) {
425
- //window.location.reload();
426
- resetMediaAndPosts();
427
- }
428
- });
429
- }
430
- } else if (ui.draggable.hasClass('wcp-move-file')) {
431
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
432
- chkStr = postID+",";
433
  $(".wp-list-table input:checked").each(function(){
434
- if(postID != $(this).val()) {
435
- chkStr += $(this).val() + ",";
436
- }
437
  });
438
  $.ajax({
439
  url: wcp_settings.ajax_url,
@@ -444,90 +475,84 @@
444
  resetMediaAndPosts();
445
  }
446
  });
447
- } else if (ui.draggable.hasClass('attachment')) {
448
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
449
- if ($(".attachments-browser li.attachment.selected").length > 1) {
450
- chkStr = "";
451
- $(".attachments-browser li.attachment.selected").each(function(){
452
- chkStr += $(this).data("id") + ",";
453
- });
454
  }
455
- folderIDs = chkStr;
456
- $.ajax({
457
- url: wcp_settings.ajax_url,
458
- data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
459
- method: 'post',
460
- success: function (res) {
461
- // window.location.reload();
462
- resetMediaAndPosts();
463
- }
 
 
 
 
 
 
 
464
  });
465
  }
 
 
 
 
 
 
 
 
 
 
466
  }
467
- });
468
  });
469
 
470
- $(".attachments-browser li.attachment").livequery(function(){
471
- $(this).draggable({
472
- revert: "invalid",
473
- containment: "document",
474
- helper: function (event, ui) {
475
- $(".selected-items").remove();
476
- selectedItems = $(".attachments-browser li.attachment.selected").length;
477
- selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
478
- return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
479
- },
480
- start: function( event, ui){
481
- $("body").addClass("no-hover-css");
482
- },
483
- cursor: "move",
484
- cursorAt: {
485
- left: 0,
486
- top: 0
487
- },
488
- stop: function( event, ui ) {
489
- $(".selected-items").remove();
490
- $("body").removeClass("no-hover-css");
491
- }
492
- });
493
  });
494
-
495
- $(".tree-structure .folder-item").livequery(function(){
496
- $(this).droppable({
497
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
498
- hoverClass: 'wcp-drop-hover-list',
499
- classes: {
500
- "ui-droppable-active": "ui-state-highlight"
501
- },
502
- drop: function( event, ui ) {
503
- $("body").removeClass("no-hover-css");
504
- folderID = $(this).data('id');
505
- if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
506
- nonce = getSettingForPost(folderID, 'nonce');
507
- if($(".wp-list-table input:checked").length) {
508
- chkStr = "";
509
- $(".wp-list-table input:checked").each(function(){
510
- chkStr += $(this).val()+",";
511
- });
512
- $.ajax({
513
- url: wcp_settings.ajax_url,
514
- 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,
515
- method: 'post',
516
- success: function (res) {
517
- // window.location.reload();
518
- resetMediaAndPosts();
519
- ajaxAnimation();
520
- }
521
- });
522
- }
523
- } else if ( ui.draggable.hasClass( 'wcp-move-file' ) ) {
524
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
525
- nonce = getSettingForPost(folderID, 'nonce');
526
- chkStr = postID+",";
527
  $(".wp-list-table input:checked").each(function(){
528
- if($(this).val() != postID) {
529
- chkStr += $(this).val() + ",";
530
- }
531
  });
532
  $.ajax({
533
  url: wcp_settings.ajax_url,
@@ -539,73 +564,64 @@
539
  ajaxAnimation();
540
  }
541
  });
542
- } else if( ui.draggable.hasClass( 'attachment' ) ){
543
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
544
- nonce = getSettingForPost(folderID, 'nonce');
545
- if($(".attachments-browser li.attachment.selected").length > 1) {
546
- chkStr = "";
547
- $(".attachments-browser li.attachment.selected").each(function(){
548
- chkStr += $(this).data("id")+",";
549
- });
550
  }
551
- $.ajax({
552
- url: wcp_settings.ajax_url,
553
- 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,
554
- method: 'post',
555
- success: function (res) {
556
- // window.location.reload();
557
- resetMediaAndPosts();
558
- ajaxAnimation();
559
- }
 
 
 
 
 
 
 
 
 
560
  });
561
  }
 
 
 
 
 
 
 
 
 
 
562
  }
563
- });
564
  });
565
 
566
- $(".sticky-folders li a").livequery(function(){
567
- $(this).droppable({
568
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
569
- hoverClass: 'wcp-drop-hover',
570
- classes: {
571
- "ui-droppable-active": "ui-state-highlight"
572
- },
573
- drop: function( event, ui ) {
574
- folderID = $(this).closest("li").data('folder-id');
575
- if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
576
- if($(".wp-list-table input:checked").length) {
577
- chkStr = "";
578
- $(".wp-list-table input:checked").each(function(){
579
- chkStr += $(this).val()+",";
580
- });
581
- nonce = getSettingForPost(folderID, 'nonce');
582
- $.ajax({
583
- url: wcp_settings.ajax_url,
584
- 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,
585
- method: 'post',
586
- success: function (res) {
587
- res = $.parseJSON(res);
588
- if(res.status == "1") {
589
- resetMediaAndPosts();
590
- ajaxAnimation();
591
- } else {
592
- $(".folder-popup-form").hide();
593
- $(".folder-popup-form").removeClass("disabled");
594
- $("#error-folder-popup-message").html(res.message);
595
- $("#error-folder-popup").show()
596
- }
597
- }
598
- });
599
- }
600
- } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
601
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
602
- nonce = getSettingForPost(folderID, 'nonce');
603
- chkStr = postID+",";
604
  $(".wp-list-table input:checked").each(function(){
605
- if($(this).val() != postID) {
606
- chkStr += $(this).val() + ",";
607
- }
608
  });
 
609
  $.ajax({
610
  url: wcp_settings.ajax_url,
611
  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,
@@ -613,7 +629,6 @@
613
  success: function (res) {
614
  res = $.parseJSON(res);
615
  if(res.status == "1") {
616
- // window.location.reload();
617
  resetMediaAndPosts();
618
  ajaxAnimation();
619
  } else {
@@ -624,31 +639,60 @@
624
  }
625
  }
626
  });
627
- } else if (ui.draggable.hasClass('attachment')) {
628
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
629
- nonce = getSettingForPost(folderID, 'nonce');
630
- if ($(".attachments-browser li.attachment.selected").length > 1) {
631
- chkStr = "";
632
- $(".attachments-browser li.attachment.selected").each(function () {
633
- chkStr += $(this).data("id") + ",";
634
- });
635
  }
636
- folderIDs = chkStr;
637
- $.ajax({
638
- url: wcp_settings.ajax_url,
639
- 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,
640
- method: 'post',
641
- success: function (res) {
 
 
642
  // window.location.reload();
643
  resetMediaAndPosts();
644
  ajaxAnimation();
 
 
 
 
 
645
  }
 
 
 
 
 
 
 
 
 
646
  });
647
  }
 
 
 
 
 
 
 
 
 
 
 
648
  }
649
- });
650
  });
651
- });
 
 
652
 
653
  function setFolderCount() {
654
  $("#js-tree-menu .jstree-node").each(function(){
@@ -864,6 +908,8 @@
864
  var activeTermId = $("#js-tree-menu li.jstree-node.active-item").data("folder-id");
865
  $(".sticky-folders .sticky-folder-"+activeTermId+" a").addClass("active-item");
866
  }
 
 
867
  }
868
 
869
  $(window).on("resize", function(){
@@ -902,46 +948,40 @@
902
 
903
  /* add folder code */
904
  $(document).ready(function(){
905
- $("#add-new-folder").livequery(function(){
906
- $(this).click(function() {
907
- if($("#js-tree-menu a.jstree-clicked").length) {
908
- fileFolderID = $("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");
909
- } else {
910
- fileFolderID = 0;
911
- }
912
- isItFromMedia = false;
913
- addFolder();
914
- });
915
  });
916
 
917
- $(".new-folder").livequery(function(){
918
- $(this).click(function() {
919
- if($(this).closest("li.jstree-node").length) {
920
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
921
- } else {
922
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
923
- }
924
- isItFromMedia = false;
925
- addFolder();
926
- });
927
  });
928
 
929
- $(".duplicate-folder").livequery(function(){
930
- $(this).click(function(e) {
931
- e.stopPropagation();
932
- if($(this).closest("li.jstree-node").length) {
933
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
934
- } else {
935
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
936
- }
937
- $(".dynamic-menu").remove();
938
- isItFromMedia = false;
939
- isDuplicate = true;
940
- addFolder();
941
- add_menu_to_list();
942
- });
943
  });
944
-
945
  $(document).on("submit", "#save-folder-form", function(e){
946
  e.stopPropagation();
947
  e.preventDefault();
@@ -1065,18 +1105,17 @@
1065
  }
1066
  });
1067
 
1068
- $(".rename-folder").livequery(function(){
1069
- $(this).click(function(e){
1070
- e.stopPropagation();
1071
- if($(this).closest("li.jstree-node").length) {
1072
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
1073
- } else {
1074
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
1075
- }
1076
- updateFolder();
1077
- $(".dynamic-menu").remove();
1078
- });
1079
  });
 
1080
 
1081
  $(document).on("click", ".form-cancel-btn", function(){
1082
  $(".folder-popup-form").hide();
@@ -1195,18 +1234,16 @@
1195
  e.stopPropagation();
1196
  });
1197
 
1198
- $(".remove-folder").livequery(function(){
1199
- $(this).click(function() {
1200
- folderID = $(this).closest("li.jstree-node").data("id");
1201
- if($(this).closest("li.jstree-node").length) {
1202
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
1203
- } else {
1204
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
1205
- }
1206
- removeFolderFromID(0);
1207
- $(".dynamic-menu").remove();
1208
- $(".active-menu").removeClass("active-menu");
1209
- });
1210
  });
1211
 
1212
  $(document).on("click", "#remove-folder-item", function (e){
@@ -1350,94 +1387,90 @@
1350
  }
1351
 
1352
  $(document).ready(function(){
1353
- $(".mark-folder").livequery(function(){
1354
- $(this).click(function(e){
1355
- e.stopPropagation();
1356
- if($(this).closest("li.jstree-node").length) {
1357
- folderID = $(this).closest("li.jstree-node").attr("id");
1358
- } else {
1359
- folderID = $(this).closest("li.sticky-fldr").data("folder-id");
1360
- }
1361
- nonce = getSettingForPost(folderID, 'nonce');
1362
- $(".form-loader-count").css("width","100%");
1363
- $(".dynamic-menu").remove();
1364
- $(".active-menu").removeClass("active-menu");
1365
- $.ajax({
1366
- url: wcp_settings.ajax_url,
1367
- data: "term_id=" + folderID + "&type=" + wcp_settings.post_type + "&action=wcp_mark_un_mark_folder&nonce="+nonce,
1368
- method: 'post',
1369
- cache: false,
1370
- success: function (res) {
1371
- res = $.parseJSON(res);
1372
- $(".form-loader-count").css("width","0%");
1373
- if (res.status == '1') {
1374
- folderPostId = getIndexForPostSetting(res.id);
1375
- if(res.marked == '1') {
1376
- $("li.jstree-node[id='"+res.id+"']").addClass("is-high");
1377
- $(".sticky-folder-"+res.id).addClass("is-high");
1378
- if(folderPostId != null) {
1379
- folderPropertyArray[folderPostId]['is_high'] = 1;
1380
- }
1381
- } else {
1382
- $("li.jstree-node[id='"+res.id+"']").removeClass("is-high");
1383
- $(".sticky-folder-"+res.id).removeClass("is-high");
1384
- if(folderPostId != null) {
1385
- folderPropertyArray[folderPostId]['is_high'] = 0;
1386
- }
1387
  }
1388
- add_menu_to_list();
1389
- ajaxAnimation();
1390
  } else {
1391
- $(".folder-popup-form").hide();
1392
- $(".folder-popup-form").removeClass("disabled");
1393
- $("#error-folder-popup-message").html(res.message);
1394
- $("#error-folder-popup").show();
 
1395
  }
 
 
 
 
 
 
 
1396
  }
1397
- });
1398
  });
1399
  });
1400
  });
1401
 
1402
  /* change folder status */
1403
  $(document).ready(function(){
1404
- $(".jstree-node .jstree-icon").livequery(function(){
1405
- $(this).click(function(){
1406
- folderID = $(this).closest("li.jstree-node").attr("id");
1407
- if($("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")) {
1408
- folderStatus = 0;
1409
- } else {
1410
- folderStatus = 1;
1411
- }
1412
- $(".form-loader-count").css("width","100%");
1413
- nonce = getSettingForPost(folderID, 'nonce');
1414
- checkForExpandCollapse();
1415
- $.ajax({
1416
- url: wcp_settings.ajax_url,
1417
- data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1418
- method: 'post',
1419
- success: function (res) {
1420
- $(".form-loader-count").css("width","0");
1421
- res = $.parseJSON(res);
1422
- if(res.status == "0") {
1423
- // $(".folder-popup-form").hide();
1424
- // $(".folder-popup-form").removeClass("disabled");
1425
- // $("#error-folder-popup-message").html(res.message);
1426
- // $("#error-folder-popup").show();
 
 
 
 
1427
  } else {
1428
- if($("#wcp_folder_"+folderID).hasClass("active")) {
1429
- $("#wcp_folder_"+folderID).removeClass("active");
1430
- $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp();
1431
- folderStatus = 0;
1432
- } else {
1433
- $("#wcp_folder_"+folderID).addClass("active");
1434
- $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown();
1435
- folderStatus = 1;
1436
- }
1437
- ajaxAnimation();
1438
  }
 
1439
  }
1440
- });
1441
  });
1442
  });
1443
  });
@@ -1674,6 +1707,25 @@
1674
  }
1675
  }).bind("ready.jstree", (function() {
1676
  setFolderCount();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1677
  })).bind("move_node.jstree", (function(t, n) {
1678
  folderMoveId = n.node.id;
1679
  orderString = "";
@@ -1701,6 +1753,7 @@
1701
  resetMediaAndPosts();
1702
  ajaxAnimation();
1703
  setFolderCountAndDD();
 
1704
  } else {
1705
  $(".folder-popup-form").hide();
1706
  $(".folder-popup-form").removeClass("disabled");
@@ -1774,63 +1827,6 @@
1774
 
1775
  /* checkbox library */
1776
  $(document).ready(function(){
1777
- $(".wcp-move-file").livequery(function(){
1778
- $(this).draggable({
1779
- revert: "invalid",
1780
- containment: "document",
1781
- helper: "clone",
1782
- cursor: "move",
1783
- start: function( event, ui){
1784
- $(this).closest("td").addClass("wcp-draggable");
1785
- $("body").addClass("no-hover-css");
1786
- },
1787
- stop: function( event, ui ) {
1788
- $(this).closest("td").removeClass("wcp-draggable");
1789
- $("body").removeClass("no-hover-css");
1790
- }
1791
- });
1792
- });
1793
-
1794
- $(".wcp-move-multiple").livequery(function(){
1795
- $(this).draggable({
1796
- // /*cancel: "a.ui-icon",*/
1797
- // revert: "invalid",
1798
- // containment: "document",
1799
- // helper: "clone",
1800
- // cursor: "move",
1801
- // start: function( event, ui){
1802
- // $("body").addClass("no-hover-css");
1803
- // },
1804
- // stop: function( event, ui ) {
1805
- // $("body").removeClass("no-hover-css");
1806
- // }
1807
- revert: "invalid",
1808
- containment: "document",
1809
- helper: function (event, ui) {
1810
- $(".selected-items").remove();
1811
- selectedItems = $("#the-list th input:checked").length;
1812
- if(selectedItems > 0) {
1813
- selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
1814
- return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
1815
- } else {
1816
- return $("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>");
1817
- }
1818
- },
1819
- start: function( event, ui){
1820
- $("body").addClass("no-hover-css");
1821
- },
1822
- cursor: "move",
1823
- cursorAt: {
1824
- left: 0,
1825
- top: 0
1826
- },
1827
- stop: function( event, ui ) {
1828
- $(".selected-items").remove();
1829
- $("body").removeClass("no-hover-css");
1830
- }
1831
- });
1832
- });
1833
-
1834
  $(document).on("click", ".folders-toggle-button", function(){
1835
  dbStatus = 'show';
1836
  if($(".tree-structure-content").hasClass("active")) {
@@ -1890,6 +1886,8 @@
1890
  }
1891
  }
1892
  }, 500);
 
 
1893
  }
1894
 
1895
  function apply_animation_height() {
318
  });
319
 
320
  /* grag and drop */
321
+ setDragAndDropElements();
322
+
323
+ $( document ).ajaxComplete(function( event, xhr, settings ) {
324
+ if(settings.data != undefined && settings.data != "" && settings.data.indexOf("action=query-attachments") != -1) {
325
+ setDragAndDropElements();
326
+ }
327
+ });
328
+ });
329
+
330
+ function setDragAndDropElements() {
331
+ $(".wcp-move-file:not(.ui-draggable)").draggable({
332
+ revert: "invalid",
333
+ containment: "document",
334
+ helper: "clone",
335
+ cursor: "move",
336
+ start: function( event, ui){
337
+ $(this).closest("td").addClass("wcp-draggable");
338
+ $("body").addClass("no-hover-css");
339
+ },
340
+ stop: function( event, ui ) {
341
+ $(this).closest("td").removeClass("wcp-draggable");
342
+ $("body").removeClass("no-hover-css");
343
+ }
344
+ });
345
+
346
+ $(".wcp-move-multiple:not(.ui-draggable)").draggable({
347
+ revert: "invalid",
348
+ containment: "document",
349
+ helper: function (event, ui) {
350
+ $(".selected-items").remove();
351
+ selectedItems = $("#the-list th input:checked").length;
352
+ if(selectedItems > 0) {
353
+ selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
354
+ return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
355
+ } else {
356
+ return $("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>");
357
+ }
358
+ },
359
+ start: function( event, ui){
360
+ $("body").addClass("no-hover-css");
361
+ },
362
+ cursor: "move",
363
+ cursorAt: {
364
+ left: 0,
365
+ top: 0
366
+ },
367
+ stop: function( event, ui ) {
368
+ $(".selected-items").remove();
369
+ $("body").removeClass("no-hover-css");
370
+ }
371
+ });
372
+
373
+ $(".jstree-anchor:not(.ui-droppable)").droppable({
374
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
375
+ hoverClass: 'wcp-drop-hover',
376
+ classes: {
377
+ "ui-droppable-active": "ui-state-highlight"
378
+ },
379
+ drop: function( event, ui ) {
380
+ folderID = $(this).closest("li.jstree-node").attr('id');
381
+ if ( ui.draggable.hasClass( 'wcp-move-multiple')) {
382
+ if($(".wp-list-table input:checked").length) {
383
+ chkStr = "";
384
  $(".wp-list-table input:checked").each(function(){
385
+ chkStr += $(this).val()+",";
 
 
386
  });
387
+ nonce = getSettingForPost(folderID, 'nonce');
388
  $.ajax({
389
  url: wcp_settings.ajax_url,
390
  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,
392
  success: function (res) {
393
  res = $.parseJSON(res);
394
  if(res.status == "1") {
 
395
  resetMediaAndPosts();
396
  } else {
397
  $(".folder-popup-form").hide();
401
  }
402
  }
403
  });
404
+ }
405
+ } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
406
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
407
+ nonce = getSettingForPost(folderID, 'nonce');
408
+ chkStr = postID+",";
409
+ $(".wp-list-table input:checked").each(function(){
410
+ if($(this).val() != postID) {
411
+ chkStr += $(this).val() + ",";
412
  }
413
+ });
414
+ $.ajax({
415
+ url: wcp_settings.ajax_url,
416
+ 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,
417
+ method: 'post',
418
+ success: function (res) {
419
+ res = $.parseJSON(res);
420
+ if(res.status == "1") {
421
  // window.location.reload();
422
  resetMediaAndPosts();
423
+ } else {
424
+ $(".folder-popup-form").hide();
425
+ $(".folder-popup-form").removeClass("disabled");
426
+ $("#error-folder-popup-message").html(res.message);
427
+ $("#error-folder-popup").show()
428
  }
429
+ }
430
+ });
431
+ } else if (ui.draggable.hasClass('attachment')) {
432
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
433
+ nonce = getSettingForPost(folderID, 'nonce');
434
+ if ($(".attachments-browser li.attachment.selected").length > 1) {
435
+ chkStr = "";
436
+ $(".attachments-browser li.attachment.selected").each(function(){
437
+ chkStr += $(this).data("id") + ",";
438
  });
439
  }
440
+ folderIDs = chkStr;
441
+ $.ajax({
442
+ url: wcp_settings.ajax_url,
443
+ 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,
444
+ method: 'post',
445
+ success: function (res) {
446
+ // window.location.reload();
447
+ resetMediaAndPosts();
448
+ }
449
+ });
450
  }
451
+ }
452
  });
453
 
454
+ $(".un-categorised-items:not(.ui-droppable)").droppable({
455
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
456
+ hoverClass: 'wcp-hover-list',
457
+ classes: {
458
+ "ui-droppable-active": "ui-state-highlight"
459
+ },
460
+ drop: function (event, ui) {
461
+ folderID = -1;
462
+ nonce = wcp_settings.nonce;
463
+ if (ui.draggable.hasClass('wcp-move-multiple')) {
464
+ if ($(".wp-list-table input:checked").length) {
465
+ chkStr = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  $(".wp-list-table input:checked").each(function(){
467
+ chkStr += $(this).val() + ",";
 
 
468
  });
469
  $.ajax({
470
  url: wcp_settings.ajax_url,
475
  resetMediaAndPosts();
476
  }
477
  });
478
+ }
479
+ } else if (ui.draggable.hasClass('wcp-move-file')) {
480
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
481
+ chkStr = postID+",";
482
+ $(".wp-list-table input:checked").each(function(){
483
+ if(postID != $(this).val()) {
484
+ chkStr += $(this).val() + ",";
485
  }
486
+ });
487
+ $.ajax({
488
+ url: wcp_settings.ajax_url,
489
+ data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
490
+ method: 'post',
491
+ success: function (res) {
492
+ //window.location.reload();
493
+ resetMediaAndPosts();
494
+ }
495
+ });
496
+ } else if (ui.draggable.hasClass('attachment')) {
497
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
498
+ if ($(".attachments-browser li.attachment.selected").length > 1) {
499
+ chkStr = "";
500
+ $(".attachments-browser li.attachment.selected").each(function(){
501
+ chkStr += $(this).data("id") + ",";
502
  });
503
  }
504
+ folderIDs = chkStr;
505
+ $.ajax({
506
+ url: wcp_settings.ajax_url,
507
+ data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
508
+ method: 'post',
509
+ success: function (res) {
510
+ // window.location.reload();
511
+ resetMediaAndPosts();
512
+ }
513
+ });
514
  }
515
+ }
516
  });
517
 
518
+ $(".attachments-browser li.attachment:not(.ui-draggable)").draggable({
519
+ revert: "invalid",
520
+ containment: "document",
521
+ helper: function (event, ui) {
522
+ $(".selected-items").remove();
523
+ selectedItems = $(".attachments-browser li.attachment.selected").length;
524
+ selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
525
+ return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
526
+ },
527
+ start: function( event, ui){
528
+ $("body").addClass("no-hover-css");
529
+ },
530
+ cursor: "move",
531
+ cursorAt: {
532
+ left: 0,
533
+ top: 0
534
+ },
535
+ stop: function( event, ui ) {
536
+ $(".selected-items").remove();
537
+ $("body").removeClass("no-hover-css");
538
+ }
 
 
539
  });
540
+
541
+ $(".tree-structure .folder-item:not(.ui-droppable)").droppable({
542
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
543
+ hoverClass: 'wcp-drop-hover-list',
544
+ classes: {
545
+ "ui-droppable-active": "ui-state-highlight"
546
+ },
547
+ drop: function( event, ui ) {
548
+ $("body").removeClass("no-hover-css");
549
+ folderID = $(this).data('id');
550
+ if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
551
+ nonce = getSettingForPost(folderID, 'nonce');
552
+ if($(".wp-list-table input:checked").length) {
553
+ chkStr = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  $(".wp-list-table input:checked").each(function(){
555
+ chkStr += $(this).val()+",";
 
 
556
  });
557
  $.ajax({
558
  url: wcp_settings.ajax_url,
564
  ajaxAnimation();
565
  }
566
  });
567
+ }
568
+ } else if ( ui.draggable.hasClass( 'wcp-move-file' ) ) {
569
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
570
+ nonce = getSettingForPost(folderID, 'nonce');
571
+ chkStr = postID+",";
572
+ $(".wp-list-table input:checked").each(function(){
573
+ if($(this).val() != postID) {
574
+ chkStr += $(this).val() + ",";
575
  }
576
+ });
577
+ $.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
+ // window.location.reload();
583
+ resetMediaAndPosts();
584
+ ajaxAnimation();
585
+ }
586
+ });
587
+ } else if( ui.draggable.hasClass( 'attachment' ) ){
588
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
589
+ nonce = getSettingForPost(folderID, 'nonce');
590
+ if($(".attachments-browser li.attachment.selected").length > 1) {
591
+ chkStr = "";
592
+ $(".attachments-browser li.attachment.selected").each(function(){
593
+ chkStr += $(this).data("id")+",";
594
  });
595
  }
596
+ $.ajax({
597
+ url: wcp_settings.ajax_url,
598
+ 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,
599
+ method: 'post',
600
+ success: function (res) {
601
+ // window.location.reload();
602
+ resetMediaAndPosts();
603
+ ajaxAnimation();
604
+ }
605
+ });
606
  }
607
+ }
608
  });
609
 
610
+ $(".sticky-folders li a:not(.ui-droppable)").droppable({
611
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
612
+ hoverClass: 'wcp-drop-hover',
613
+ classes: {
614
+ "ui-droppable-active": "ui-state-highlight"
615
+ },
616
+ drop: function( event, ui ) {
617
+ folderID = $(this).closest("li").data('folder-id');
618
+ if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
619
+ if($(".wp-list-table input:checked").length) {
620
+ chkStr = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  $(".wp-list-table input:checked").each(function(){
622
+ chkStr += $(this).val()+",";
 
 
623
  });
624
+ nonce = getSettingForPost(folderID, 'nonce');
625
  $.ajax({
626
  url: wcp_settings.ajax_url,
627
  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,
629
  success: function (res) {
630
  res = $.parseJSON(res);
631
  if(res.status == "1") {
 
632
  resetMediaAndPosts();
633
  ajaxAnimation();
634
  } else {
639
  }
640
  }
641
  });
642
+ }
643
+ } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
644
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
645
+ nonce = getSettingForPost(folderID, 'nonce');
646
+ chkStr = postID+",";
647
+ $(".wp-list-table input:checked").each(function(){
648
+ if($(this).val() != postID) {
649
+ chkStr += $(this).val() + ",";
650
  }
651
+ });
652
+ $.ajax({
653
+ url: wcp_settings.ajax_url,
654
+ 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,
655
+ method: 'post',
656
+ success: function (res) {
657
+ res = $.parseJSON(res);
658
+ if(res.status == "1") {
659
  // window.location.reload();
660
  resetMediaAndPosts();
661
  ajaxAnimation();
662
+ } else {
663
+ $(".folder-popup-form").hide();
664
+ $(".folder-popup-form").removeClass("disabled");
665
+ $("#error-folder-popup-message").html(res.message);
666
+ $("#error-folder-popup").show()
667
  }
668
+ }
669
+ });
670
+ } else if (ui.draggable.hasClass('attachment')) {
671
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
672
+ nonce = getSettingForPost(folderID, 'nonce');
673
+ if ($(".attachments-browser li.attachment.selected").length > 1) {
674
+ chkStr = "";
675
+ $(".attachments-browser li.attachment.selected").each(function () {
676
+ chkStr += $(this).data("id") + ",";
677
  });
678
  }
679
+ folderIDs = chkStr;
680
+ $.ajax({
681
+ url: wcp_settings.ajax_url,
682
+ 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,
683
+ method: 'post',
684
+ success: function (res) {
685
+ // window.location.reload();
686
+ resetMediaAndPosts();
687
+ ajaxAnimation();
688
+ }
689
+ });
690
  }
691
+ }
692
  });
693
+
694
+ setFolderCountAndDD();
695
+ }
696
 
697
  function setFolderCount() {
698
  $("#js-tree-menu .jstree-node").each(function(){
908
  var activeTermId = $("#js-tree-menu li.jstree-node.active-item").data("folder-id");
909
  $(".sticky-folders .sticky-folder-"+activeTermId+" a").addClass("active-item");
910
  }
911
+
912
+ setDragAndDropElements();
913
  }
914
 
915
  $(window).on("resize", function(){
948
 
949
  /* add folder code */
950
  $(document).ready(function(){
951
+ $(document).on("click", "#add-new-folder", function(){
952
+ if($("#js-tree-menu a.jstree-clicked").length) {
953
+ fileFolderID = $("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");
954
+ } else {
955
+ fileFolderID = 0;
956
+ }
957
+ isItFromMedia = false;
958
+ addFolder();
 
 
959
  });
960
 
961
+ $(document).on("click", "#new-folder", function(){
962
+ if($(this).closest("li.jstree-node").length) {
963
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
964
+ } else {
965
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
966
+ }
967
+ isItFromMedia = false;
968
+ addFolder();
 
 
969
  });
970
 
971
+ $(document).on("click", ".duplicate-folder", function(e){
972
+ e.stopPropagation();
973
+ if($(this).closest("li.jstree-node").length) {
974
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
975
+ } else {
976
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
977
+ }
978
+ $(".dynamic-menu").remove();
979
+ isItFromMedia = false;
980
+ isDuplicate = true;
981
+ addFolder();
982
+ add_menu_to_list();
 
 
983
  });
984
+
985
  $(document).on("submit", "#save-folder-form", function(e){
986
  e.stopPropagation();
987
  e.preventDefault();
1105
  }
1106
  });
1107
 
1108
+ $(document).on("click", ".rename-folder", function(e){
1109
+ e.stopPropagation();
1110
+ if($(this).closest("li.jstree-node").length) {
1111
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
1112
+ } else {
1113
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
1114
+ }
1115
+ updateFolder();
1116
+ $(".dynamic-menu").remove();
 
 
1117
  });
1118
+
1119
 
1120
  $(document).on("click", ".form-cancel-btn", function(){
1121
  $(".folder-popup-form").hide();
1234
  e.stopPropagation();
1235
  });
1236
 
1237
+ $(document).on("click", ".remove-folder", function(){
1238
+ folderID = $(this).closest("li.jstree-node").data("id");
1239
+ if($(this).closest("li.jstree-node").length) {
1240
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
1241
+ } else {
1242
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
1243
+ }
1244
+ removeFolderFromID(0);
1245
+ $(".dynamic-menu").remove();
1246
+ $(".active-menu").removeClass("active-menu");
 
 
1247
  });
1248
 
1249
  $(document).on("click", "#remove-folder-item", function (e){
1387
  }
1388
 
1389
  $(document).ready(function(){
1390
+ $(document).on("click", ".mark-folder", function(e){
1391
+ e.stopPropagation();
1392
+ if($(this).closest("li.jstree-node").length) {
1393
+ folderID = $(this).closest("li.jstree-node").attr("id");
1394
+ } else {
1395
+ folderID = $(this).closest("li.sticky-fldr").data("folder-id");
1396
+ }
1397
+ nonce = getSettingForPost(folderID, 'nonce');
1398
+ $(".form-loader-count").css("width","100%");
1399
+ $(".dynamic-menu").remove();
1400
+ $(".active-menu").removeClass("active-menu");
1401
+ $.ajax({
1402
+ url: wcp_settings.ajax_url,
1403
+ data: "term_id=" + folderID + "&type=" + wcp_settings.post_type + "&action=wcp_mark_un_mark_folder&nonce="+nonce,
1404
+ method: 'post',
1405
+ cache: false,
1406
+ success: function (res) {
1407
+ res = $.parseJSON(res);
1408
+ $(".form-loader-count").css("width","0%");
1409
+ if (res.status == '1') {
1410
+ folderPostId = getIndexForPostSetting(res.id);
1411
+ if(res.marked == '1') {
1412
+ $("li.jstree-node[id='"+res.id+"']").addClass("is-high");
1413
+ $(".sticky-folder-"+res.id).addClass("is-high");
1414
+ if(folderPostId != null) {
1415
+ folderPropertyArray[folderPostId]['is_high'] = 1;
 
 
 
 
 
 
 
 
1416
  }
 
 
1417
  } else {
1418
+ $("li.jstree-node[id='"+res.id+"']").removeClass("is-high");
1419
+ $(".sticky-folder-"+res.id).removeClass("is-high");
1420
+ if(folderPostId != null) {
1421
+ folderPropertyArray[folderPostId]['is_high'] = 0;
1422
+ }
1423
  }
1424
+ add_menu_to_list();
1425
+ ajaxAnimation();
1426
+ } else {
1427
+ $(".folder-popup-form").hide();
1428
+ $(".folder-popup-form").removeClass("disabled");
1429
+ $("#error-folder-popup-message").html(res.message);
1430
+ $("#error-folder-popup").show();
1431
  }
1432
+ }
1433
  });
1434
  });
1435
  });
1436
 
1437
  /* change folder status */
1438
  $(document).ready(function(){
1439
+ $(document).on("click", ".jstree-node .jstree-icon", function(){
1440
+ folderID = $(this).closest("li.jstree-node").attr("id");
1441
+ if($("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")) {
1442
+ folderStatus = 0;
1443
+ } else {
1444
+ folderStatus = 1;
1445
+ }
1446
+ $(".form-loader-count").css("width","100%");
1447
+ nonce = getSettingForPost(folderID, 'nonce');
1448
+ checkForExpandCollapse();
1449
+ $.ajax({
1450
+ url: wcp_settings.ajax_url,
1451
+ data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1452
+ method: 'post',
1453
+ success: function (res) {
1454
+ $(".form-loader-count").css("width","0");
1455
+ res = $.parseJSON(res);
1456
+ if(res.status == "0") {
1457
+ // $(".folder-popup-form").hide();
1458
+ // $(".folder-popup-form").removeClass("disabled");
1459
+ // $("#error-folder-popup-message").html(res.message);
1460
+ // $("#error-folder-popup").show();
1461
+ } else {
1462
+ if($("#wcp_folder_"+folderID).hasClass("active")) {
1463
+ $("#wcp_folder_"+folderID).removeClass("active");
1464
+ $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp();
1465
+ folderStatus = 0;
1466
  } else {
1467
+ $("#wcp_folder_"+folderID).addClass("active");
1468
+ $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown();
1469
+ folderStatus = 1;
 
 
 
 
 
 
 
1470
  }
1471
+ ajaxAnimation();
1472
  }
1473
+ }
1474
  });
1475
  });
1476
  });
1707
  }
1708
  }).bind("ready.jstree", (function() {
1709
  setFolderCount();
1710
+ setDragAndDropElements();
1711
+ })).bind("after_open.jstree", (function() {
1712
+ //data.text is the new name:
1713
+ setDragAndDropElements();
1714
+ })).bind("open_all.jstree", (function() {
1715
+ //data.text is the new name:
1716
+ setDragAndDropElements();
1717
+ })).bind("create_node.jstree", (function() {
1718
+ //data.text is the new name:
1719
+ setDragAndDropElements();
1720
+ })).bind("delete_node.jstree", (function() {
1721
+ //data.text is the new name:
1722
+ setDragAndDropElements();
1723
+ })).bind("close_all.jstree", (function() {
1724
+ //data.text is the new name:
1725
+ setDragAndDropElements();
1726
+ })).bind("after_close.jstree", (function() {
1727
+ //data.text is the new name:
1728
+ setDragAndDropElements();
1729
  })).bind("move_node.jstree", (function(t, n) {
1730
  folderMoveId = n.node.id;
1731
  orderString = "";
1753
  resetMediaAndPosts();
1754
  ajaxAnimation();
1755
  setFolderCountAndDD();
1756
+ setDragAndDropElements();
1757
  } else {
1758
  $(".folder-popup-form").hide();
1759
  $(".folder-popup-form").removeClass("disabled");
1827
 
1828
  /* checkbox library */
1829
  $(document).ready(function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1830
  $(document).on("click", ".folders-toggle-button", function(){
1831
  dbStatus = 'show';
1832
  if($(".tree-structure-content").hasClass("active")) {
1886
  }
1887
  }
1888
  }, 500);
1889
+
1890
+ setDragAndDropElements();
1891
  }
1892
 
1893
  function apply_animation_height() {
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=[],g=wcp_settings.page_url,_=[],v="<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 w(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 y(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 j(){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?J(0):(e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=get_folders_default_list",method:"post",success:function(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),_=t.taxonomies,z()}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:"",Url:g};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>'),k(),b()}):e("#wpbody").load(g+" #wpbody-content",!1,function(t){var s={Title:"",Url:g};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>'),k()}))}function b(){k(),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 k(){if(h.length&&e("li.jstree-node").each(function(){folderPostId=y(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=v.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=v.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)}),H(),"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 x(){k()}function C(){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 I(){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 S(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 D(){e(r).jstree({core:{cache:!1,animation:0,check_callback:function(t,s,o,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(){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)}),""!=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(),O(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active"),k()}).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%"),e.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=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),j(),U(),z()):(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 P(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function T(t){e.ajax({url:wcp_settings.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+wcp_settings.post_type+"&post_id="+t+"&nonce="+wcp_settings.nonce,cache:!1,async:!1,success:function(){}})}function N(){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 H(){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 U(){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 O(){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(),r=e("li.jstree-node[id='"+s+"']").hasClass("is-high")?" is-high ":"";t+="<li data-folder-id='"+s+"' class='sticky-fldr "+r+" 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")}function z(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=_;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),lastFolderData=_;for(var s=0;s<_.length;s++)t.append("<option value='"+_[s].term_id+"'>"+_[s].name+" ("+_[s].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var s=0;s<_.length;s++)e("select.folder_for_media option:last-child").before("<option value='"+_[s].term_id+"'>"+_[s].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),s=0;s<_.length;s++)0!=parseInt(_[s].trash_count)&&(e(".jstree-node[id='"+_[s].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(_[s].trash_count),e(".sticky-folder-"+_[s].term_id+" .premio-folder-count").text(_[s].trash_count));if(e(".media-select-folder").length){for(e(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),s=0;s<_.length;s++)e(".media-select-folder").append("<option value='"+_[s].term_id+"'>"+_[s].name+" ("+_[s].trash_count+")</option>");e(".media-select-folder").val("")}""!=l&&e("#wcp_folder_"+l).addClass("active-item"),n&&(e("#title_"+p).trigger("click"),n=!1)}if(e(document).ready(function(){_=wcp_settings.taxonomies,o=parseInt(wcp_settings.is_key_active),a=parseInt(wcp_settings.folders),l=parseInt(wcp_settings.selected_taxonomy),h=wcp_settings.folder_settings,D();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",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(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",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(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",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(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=w(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?j():(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=w(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?j():(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=w(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){j()}}))}})}),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){j()}})):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){j()}})):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){j()}}))}})}),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=w(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){j(),U()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=w(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){j(),U()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=w(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){j(),U()}}))}})}),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=w(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?(j(),U()):(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=w(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?(j(),U()):(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=w(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){j(),U()}}))}})})}),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,C()})}),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,C()})}),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,C(),x()})}),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),N(),x(),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),U(),O(),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,J(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"),I())}),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"),I(),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=w(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=y(result.id),null!=folderPostId&&(h[folderPostId].nonce=result.nonce,h[folderPostId].slug=result.slug),x(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),U(),e("#media-attachment-taxonomy-filter").length&&J(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"),S(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#folder-hide-show-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),S(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"),S(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=w(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),U(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),j(),O(),U(),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(),x(),U(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),j(),O(),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=w(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=y(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)),x(),U()):(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=w(folderID,"nonce"),N(),e.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=e.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),U())}})})})}),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=w(s,"slug"),g=wcp_settings.page_url+thisSlug;var o={Title:thisSlug,Url:g};history.pushState(o,o.Title,o.Url),T(thisSlug),e(".custom-media-select").removeClass("active")}else{var a=w(l,"slug");g=wcp_settings.page_url+a,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:a,Url:g};history.pushState(t,t.Title,t.Url),T(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>'),b()}):e("#wpbody").load(g+" #wpbody-content",function(){var t={Title:a,Url:g};history.pushState(t,t.Title,t.Url),T(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>'),b()})}k(),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),T("all"),k()}else g=wcp_settings.page_url,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),T("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>'),k(),b()}):e("#wpbody").load(g+" #wpbody-content",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),T("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>'),k(),b()})}),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),T("-1"),k()}else g=wcp_settings.page_url+"-1",e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),T("-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>'),k(),b()}):e("#wpbody").load(g+" #wpbody-content",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),T("-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>'),k(),b()})}),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,e.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=e.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))}}))}),N()}),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"),e.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=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),D(),_=t.terms,z()),e(".form-loader-count").css("width","0"),k()}})})}),e(document).ready(function(){e(document).on("keyup","#folder-search",function(){P()}),e(document).on("change","#folder-search",function(){P()}),e(document).on("blur","#folder-search",function(){P()})}),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")}})}),e(document).on("click",".folders-toggle-button",function(){dbStatus="show",e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").animate({height:"40px"},100,function(){e(".tree-structure-content").removeClass("active")}),dbStatus="hide"):(newHeight=parseInt(e(".tree-structure-content .tree-structure").attr("data-height")),e(".tree-structure-content .tree-structure").animate({height:newHeight},100,function(){e(".tree-structure-content").addClass("active")})),e.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(e){}})})}),"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>'),x(),H()}),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(){J(1)}),e(document).ajaxComplete(function(e,t,s){actionName=s.data,"undefined"!=typeof actionName&&actionName.length&&0==actionName.indexOf("action=delete-post&id=")&&J(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"))):M("media-select-mode"),J(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()?e.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(t){0!=p&&p!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),j(),U()}}):(s=w(e(this).val(),"nonce"),e.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=e.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(0!=p&&p!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),j(),U()):(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 q=null;function J(s){q=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!=q&&q.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}))}_=o.taxonomies,z(),""!=l&&e("#wcp_folder_"+l).addClass("active-item"),n&&(e("#title_"+p).trigger("click"),n=!1)}})}function R(){e(".media-frame-content .media-toolbar").width(e(".media-frame-content").width()-20)}function A(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 M(e){document.cookie=e+"=; Max-Age=-99999999;"}R(),e(window).resize(function(){R()}),e(document).ready(function(){}),e(document).on("click",".button.organize-button",function(){e(".media-frame").hasClass("mode-select")?M("media-select-mode"):A("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")||A("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,C())}),e(window).scroll(function(){})}else;});
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=[],g=wcp_settings.page_url,_=[],v="<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 w(){e(".wcp-move-file:not(.ui-draggable)").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:not(.ui-draggable)").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")}}),e(".jstree-anchor:not(.ui-droppable)").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=j(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?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())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=j(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?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())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=j(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){b()}}))}}),e(".un-categorised-items:not(.ui-droppable)").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){b()}})):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){b()}})):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){b()}}))}}),e(".attachments-browser li.attachment:not(.ui-draggable)").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:not(.ui-droppable)").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=j(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){b(),O()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=j(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){b(),O()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=j(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){b(),O()}}))}}),e(".sticky-folders li a:not(.ui-droppable)").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=j(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?(b(),O()):(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=j(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?(b(),O()):(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=j(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){b(),O()}}))}}),J()}function j(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 y(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 b(){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?A(0):(e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=get_folders_default_list",method:"post",success:function(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),_=t.taxonomies,J()}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:"",Url:g};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(),k()}):e("#wpbody").load(g+" #wpbody-content",!1,function(t){var s={Title:"",Url:g};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 k(){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=y(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=v.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=v.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)}),U(),"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")}w()}function C(){x()}function I(){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 S(){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 D(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 P(){e(r).jstree({core:{cache:!1,animation:0,check_callback:function(t,s,o,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(){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)}),""!=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(),z(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active"),x(),w()}).bind("after_open.jstree",function(){w()}).bind("open_all.jstree",function(){w()}).bind("create_node.jstree",function(){w()}).bind("delete_node.jstree",function(){w()}).bind("close_all.jstree",function(){w()}).bind("after_close.jstree",function(){w()}).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%"),e.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=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),b(),O(),J(),w()):(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 T(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function N(t){e.ajax({url:wcp_settings.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+wcp_settings.post_type+"&post_id="+t+"&nonce="+wcp_settings.nonce,cache:!1,async:!1,success:function(){}})}function H(){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),w()}function U(){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 O(){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 z(){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(),r=e("li.jstree-node[id='"+s+"']").hasClass("is-high")?" is-high ":"";t+="<li data-folder-id='"+s+"' class='sticky-fldr "+r+" 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")}function J(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=_;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),lastFolderData=_;for(var s=0;s<_.length;s++)t.append("<option value='"+_[s].term_id+"'>"+_[s].name+" ("+_[s].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var s=0;s<_.length;s++)e("select.folder_for_media option:last-child").before("<option value='"+_[s].term_id+"'>"+_[s].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),s=0;s<_.length;s++)0!=parseInt(_[s].trash_count)&&(e(".jstree-node[id='"+_[s].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(_[s].trash_count),e(".sticky-folder-"+_[s].term_id+" .premio-folder-count").text(_[s].trash_count));if(e(".media-select-folder").length){for(e(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),s=0;s<_.length;s++)e(".media-select-folder").append("<option value='"+_[s].term_id+"'>"+_[s].name+" ("+_[s].trash_count+")</option>");e(".media-select-folder").val("")}""!=l&&e("#wcp_folder_"+l).addClass("active-item"),n&&(e("#title_"+p).trigger("click"),n=!1)}if(e(document).ready(function(){_=wcp_settings.taxonomies,o=parseInt(wcp_settings.is_key_active),a=parseInt(wcp_settings.folders),l=parseInt(wcp_settings.selected_taxonomy),h=wcp_settings.folder_settings,P();var r="1"==wcp_settings.isRTL||1==wcp_settings.isRTL?"w":"e";e(".wcp-content").resizable({resizeHeight:!1,handles:r,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",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(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",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(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",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(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){}})}),w(),e(document).ajaxComplete(function(e,s,o){o.data!=t&&""!=o.data&&-1!=o.data.indexOf("action=query-attachments")&&w()})}),e(window).on("resize",function(){}),e(window).scroll(function(){}),e(document).ready(function(){e(document).on("click","#add-new-folder",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,I()}),e(document).on("click","#new-folder",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,I()}),e(document).on("click",".duplicate-folder",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,I(),C()}),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),H(),C(),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),O(),z(),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,A(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"),S())}),e(document).on("click",".rename-folder",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"),S(),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=j(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=y(result.id),null!=folderPostId&&(h[folderPostId].nonce=result.nonce,h[folderPostId].slug=result.slug),C(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),O(),e("#media-attachment-taxonomy-filter").length&&A(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"),D(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#folder-hide-show-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),D(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(document).on("click",".remove-folder",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"),D(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=j(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),O(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),b(),z(),O(),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(),C(),O(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),b(),z(),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(document).on("click",".mark-folder",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=j(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=y(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)),C(),O()):(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(document).on("click",".jstree-node .jstree-icon",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=j(folderID,"nonce"),H(),e.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=e.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),O())}})})}),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=j(s,"slug"),g=wcp_settings.page_url+thisSlug;var o={Title:thisSlug,Url:g};history.pushState(o,o.Title,o.Url),N(thisSlug),e(".custom-media-select").removeClass("active")}else{var a=j(l,"slug");g=wcp_settings.page_url+a,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:a,Url:g};history.pushState(t,t.Title,t.Url),N(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>'),k()}):e("#wpbody").load(g+" #wpbody-content",function(){var t={Title:a,Url:g};history.pushState(t,t.Title,t.Url),N(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>'),k()})}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),N("all"),x()}else g=wcp_settings.page_url,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),N("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(),k()}):e("#wpbody").load(g+" #wpbody-content",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),N("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(),k()})}),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),N("-1"),x()}else g=wcp_settings.page_url+"-1",e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(g+" #posts-filter",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),N("-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(),k()}):e("#wpbody").load(g+" #wpbody-content",function(){var t={Title:"",Url:g};history.pushState(t,t.Title,t.Url),N("-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(),k()})}),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,e.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=e.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))}}))}),H()}),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"),e.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=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),P(),_=t.terms,J()),e(".form-loader-count").css("width","0"),x()}})})}),e(document).ready(function(){e(document).on("keyup","#folder-search",function(){T()}),e(document).on("change","#folder-search",function(){T()}),e(document).on("blur","#folder-search",function(){T()})}),e(document).ready(function(){e(document).on("click",".folders-toggle-button",function(){dbStatus="show",e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").animate({height:"40px"},100,function(){e(".tree-structure-content").removeClass("active")}),dbStatus="hide"):(newHeight=parseInt(e(".tree-structure-content .tree-structure").attr("data-height")),e(".tree-structure-content .tree-structure").animate({height:newHeight},100,function(){e(".tree-structure-content").addClass("active")})),e.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(e){}})})}),"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>'),C(),U()}),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(){A(1)}),e(document).ajaxComplete(function(e,t,s){actionName=s.data,"undefined"!=typeof actionName&&actionName.length&&0==actionName.indexOf("action=delete-post&id=")&&A(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"))):F("media-select-mode"),A(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()?e.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(t){0!=p&&p!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),b(),O()}}):(s=j(e(this).val(),"nonce"),e.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=e.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(0!=p&&p!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),b(),O()):(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 R=null;function A(s){R=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!=R&&R.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}))}_=o.taxonomies,J(),""!=l&&e("#wcp_folder_"+l).addClass("active-item"),n&&(e("#title_"+p).trigger("click"),n=!1)}})}function M(){e(".media-frame-content .media-toolbar").width(e(".media-frame-content").width()-20)}function V(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 F(e){document.cookie=e+"=; Max-Age=-99999999;"}M(),e(window).resize(function(){M()}),e(document).ready(function(){}),e(document).on("click",".button.organize-button",function(){e(".media-frame").hasClass("mode-select")?F("media-select-mode"):V("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")||V("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,I())}),e(window).scroll(function(){})}else;});
assets/js/livequery.min.js DELETED
@@ -1,8 +0,0 @@
1
- /*! jquery.livequery - v1.3.6 - 2013-08-26
2
- * Copyright (c)
3
- * (c) 2010, Brandon Aaron (http://brandonaaron.net)
4
- * (c) 2012 - 2013, Alexander Zaytsev (http://hazzik.ru/en)
5
- * Dual licensed under the MIT (MIT_LICENSE.txt)
6
- * and GPL Version 2 (GPL_LICENSE.txt) licenses.
7
- */
8
- !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a,b){function c(a,b,c,d){return!(a.selector!=b.selector||a.context!=b.context||c&&c.$lqguid!=b.fn.$lqguid||d&&d.$lqguid!=b.fn2.$lqguid)}a.extend(a.fn,{livequery:function(b,e){var f,g=this;return a.each(d.queries,function(a,d){return c(g,d,b,e)?(f=d)&&!1:void 0}),f=f||new d(g.selector,g.context,b,e),f.stopped=!1,f.run(),g},expire:function(b,e){var f=this;return a.each(d.queries,function(a,g){c(f,g,b,e)&&!f.stopped&&d.stop(g.id)}),f}});var d=a.livequery=function(b,c,e,f){var g=this;return g.selector=b,g.context=c,g.fn=e,g.fn2=f,g.elements=a([]),g.stopped=!1,g.id=d.queries.push(g)-1,e.$lqguid=e.$lqguid||d.guid++,f&&(f.$lqguid=f.$lqguid||d.guid++),g};d.prototype={stop:function(){var b=this;b.stopped||(b.fn2&&b.elements.each(b.fn2),b.elements=a([]),b.stopped=!0)},run:function(){var b=this;if(!b.stopped){var c=b.elements,d=a(b.selector,b.context),e=d.not(c),f=c.not(d);b.elements=d,e.each(b.fn),b.fn2&&f.each(b.fn2)}}},a.extend(d,{guid:0,queries:[],queue:[],running:!1,timeout:null,registered:[],checkQueue:function(){if(d.running&&d.queue.length)for(var a=d.queue.length;a--;)d.queries[d.queue.shift()].run()},pause:function(){d.running=!1},play:function(){d.running=!0,d.run()},registerPlugin:function(){a.each(arguments,function(b,c){if(a.fn[c]&&!(a.inArray(c,d.registered)>0)){var e=a.fn[c];a.fn[c]=function(){var a=e.apply(this,arguments);return d.run(),a},d.registered.push(c)}})},run:function(c){c!==b?a.inArray(c,d.queue)<0&&d.queue.push(c):a.each(d.queries,function(b){a.inArray(b,d.queue)<0&&d.queue.push(b)}),d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(d.checkQueue,20)},stop:function(c){c!==b?d.queries[c].stop():a.each(d.queries,d.prototype.stop)}}),d.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove","html","prop","removeProp"),a(function(){d.play()})});
 
 
 
 
 
 
 
 
assets/js/page-post-media.js CHANGED
@@ -265,8 +265,18 @@
265
  initialize: function () {
266
  windowModal.prototype.initialize.apply(this, arguments);
267
  }, open: function () {
268
- $(".folder-modal").removeClass("folder-modal");
269
  if (windowModal.prototype.open.apply(this, arguments)) {
 
 
 
 
 
 
 
 
 
 
270
  if($(".folder-modal").length) {
271
  $(".folder-custom-menu").remove();
272
  $(".folder-modal .media-frame-tab-panel").removeClass("has-folder-menu");
@@ -330,6 +340,12 @@
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);
@@ -363,9 +379,9 @@
363
  var thisIndex = $(this).closest("li.jstree-node").attr("id");
364
  fileFolderID = thisIndex;
365
  selectedFolderMediaId = fileFolderID;
366
- $(".active-item").removeClass("active-item");
367
- $("#media-attachment-taxonomy-filter").val(thisIndex);
368
- $("#media-attachment-taxonomy-filter").trigger("change");
369
  thisSlug = getSettingForPost(thisIndex, 'slug');
370
  set_default_folders(thisSlug);
371
  $(".custom-media-select").removeClass("active");
@@ -605,17 +621,15 @@
605
  };
606
 
607
  /* Update folder */
608
- $(".rename-folder").livequery(function(){
609
- $(this).click(function(e){
610
- e.stopPropagation();
611
- if($(this).closest("li.jstree-node").length) {
612
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
613
- } else {
614
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
615
- }
616
- updateFolder();
617
- $(".dynamic-menu").remove();
618
- });
619
  });
620
 
621
  $(document).on("click", "#inline-update", function (e) {
@@ -684,82 +698,76 @@
684
  });
685
 
686
  /* Mark Folder */
687
- $(".mark-folder").livequery(function(){
688
- $(this).click(function(e){
689
- e.stopPropagation();
690
- if($(this).closest("li.jstree-node").length) {
691
- folderID = $(this).closest("li.jstree-node").attr("id");
692
- } else {
693
- folderID = $(this).closest("li.sticky-fldr").data("folder-id");
694
- }
695
- nonce = getSettingForPost(folderID, 'nonce');
696
- $(".form-loader-count").css("width","100%");
697
- $(".dynamic-menu").remove();
698
- $(".active-menu").removeClass("active-menu");
699
- $.ajax({
700
- url: folders_media_options.ajax_url,
701
- data: "term_id=" + folderID + "&type=" + folders_media_options.post_type + "&action=wcp_mark_un_mark_folder&nonce="+nonce,
702
- method: 'post',
703
- cache: false,
704
- success: function (res) {
705
- res = $.parseJSON(res);
706
- $(".form-loader-count").css("width","0%");
707
- if (res.status == '1') {
708
- folderPostId = getIndexForPostSetting(res.id);
709
- if(res.marked == '1') {
710
- $("li.jstree-node[id='"+res.id+"']").addClass("is-high");
711
- $(".sticky-folder-"+res.id).addClass("is-high");
712
- if(folderPostId != null) {
713
- folderPropertyArray[folderPostId]['is_high'] = 1;
714
- }
715
- } else {
716
- $("li.jstree-node[id='"+res.id+"']").removeClass("is-high");
717
- $(".sticky-folder-"+res.id).removeClass("is-high");
718
- if(folderPostId != null) {
719
- folderPropertyArray[folderPostId]['is_high'] = 0;
720
- }
721
  }
722
- ajaxAnimation();
723
  } else {
724
- $(".folder-popup-form").hide();
725
- $(".folder-popup-form").removeClass("disabled");
726
- $("#error-folder-popup-message").html(res.message);
727
- $("#error-folder-popup").show();
 
728
  }
 
 
 
 
 
 
729
  }
730
- });
731
  });
732
  });
733
 
734
  /* Duplicate Folder */
735
- $(".duplicate-folder").livequery(function(){
736
- $(this).click(function(e) {
737
- e.stopPropagation();
738
- if($(this).closest("li.jstree-node").length) {
739
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
740
- } else {
741
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
742
- }
743
- $(".dynamic-menu").remove();
744
- isItFromMedia = false;
745
- isDuplicate = true;
746
- addFolder();
747
- });
748
  });
749
 
750
  /* Remove folder */
751
- $(".remove-folder").livequery(function(){
752
- $(this).click(function() {
753
- folderID = $(this).closest("li.jstree-node").data("id");
754
- if($(this).closest("li.jstree-node").length) {
755
- fileFolderID = $(this).closest("li.jstree-node").attr("id");
756
- } else {
757
- fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
758
- }
759
- removeFolderFromID(0);
760
- $(".dynamic-menu").remove();
761
- $(".active-menu").removeClass("active-menu");
762
- });
763
  });
764
 
765
  $(document).on("click", "#remove-folder-item", function (e){
@@ -872,48 +880,110 @@
872
  });
873
  });
874
 
875
- $(".jstree-anchor").livequery(function(){
876
- $(this).droppable({
877
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
878
- hoverClass: 'wcp-drop-hover',
879
- classes: {
880
- "ui-droppable-active": "ui-state-highlight"
881
- },
882
- drop: function( event, ui ) {
883
- folderID = $(this).closest("li.jstree-node").attr('id');
884
- if ( ui.draggable.hasClass( 'wcp-move-multiple')) {
885
- if($(".wp-list-table input:checked").length) {
886
- chkStr = "";
887
- $(".wp-list-table input:checked").each(function(){
888
- chkStr += $(this).val()+",";
889
- });
890
- nonce = getSettingForPost(folderID, 'nonce');
891
- $.ajax({
892
- url: folders_media_options.ajax_url,
893
- data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
894
- method: 'post',
895
- success: function (res) {
896
- res = $.parseJSON(res);
897
- if(res.status == "1") {
898
- resetMediaAndPosts();
899
- } else {
900
- $(".folder-popup-form").hide();
901
- $(".folder-popup-form").removeClass("disabled");
902
- $("#error-folder-popup-message").html(res.message);
903
- $("#error-folder-popup").show()
904
- }
905
- }
906
- });
907
  }
908
- } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
909
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
910
- nonce = getSettingForPost(folderID, 'nonce');
911
- chkStr = postID+",";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  $(".wp-list-table input:checked").each(function(){
913
- if($(this).val() != postID) {
914
- chkStr += $(this).val() + ",";
915
- }
916
  });
 
917
  $.ajax({
918
  url: folders_media_options.ajax_url,
919
  data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
@@ -921,7 +991,6 @@
921
  success: function (res) {
922
  res = $.parseJSON(res);
923
  if(res.status == "1") {
924
- // window.location.reload();
925
  resetMediaAndPosts();
926
  } else {
927
  $(".folder-popup-form").hide();
@@ -931,90 +1000,95 @@
931
  }
932
  }
933
  });
934
- } else if (ui.draggable.hasClass('attachment')) {
935
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
936
- nonce = getSettingForPost(folderID, 'nonce');
937
- if ($(".attachments-browser li.attachment.selected").length > 1) {
938
- chkStr = "";
939
- $(".attachments-browser li.attachment.selected").each(function(){
940
- chkStr += $(this).data("id") + ",";
941
- });
942
  }
943
- folderIDs = chkStr;
944
- $.ajax({
945
- url: folders_media_options.ajax_url,
946
- data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
947
- method: 'post',
948
- success: function (res) {
 
 
949
  // window.location.reload();
950
  resetMediaAndPosts();
951
- ajaxAnimation();
 
 
 
 
952
  }
 
 
 
 
 
 
 
 
 
953
  });
954
  }
 
 
 
 
 
 
 
 
 
 
 
955
  }
956
- });
957
  });
958
 
959
- $(".media-frame:not(.hide-router) .attachments-browser li.attachment").livequery(function () {
960
- $(this).draggable({
961
- revert: "invalid",
962
- containment: "document",
963
- helper: function (event, ui) {
964
- $(".selected-items").remove();
965
- var selectedItems = $(".media-frame:not(.hide-router) .attachments-browser li.attachment.selected").length;
966
- selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
967
- return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
968
- },
969
- start: function( event, ui){
970
- $("body").addClass("no-hover-css");
971
- },
972
- cursor: "move",
973
- appendTo: ".media-modal",
974
- cursorAt: {
975
- left: 0,
976
- top: 0
977
- },
978
- stop: function( event, ui ) {
979
- $(".selected-items").remove();
980
- $("body").removeClass("no-hover-css");
981
- }
982
- });
983
  });
984
 
985
- $(".un-categorised-items").livequery(function(){
986
- $(this).droppable({
987
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
988
- hoverClass: 'wcp-hover-list',
989
- classes: {
990
- "ui-droppable-active": "ui-state-highlight"
991
- },
992
- drop: function (event, ui) {
993
- folderID = -1;
994
- nonce = folders_media_options.nonce;
995
- if (ui.draggable.hasClass('wcp-move-multiple')) {
996
- if ($(".wp-list-table input:checked").length) {
997
- chkStr = "";
998
- $(".wp-list-table input:checked").each(function(){
999
- chkStr += $(this).val() + ",";
1000
- });
1001
- $.ajax({
1002
- url: folders_media_options.ajax_url,
1003
- data: "post_id=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1004
- method: 'post',
1005
- success: function (res) {
1006
- //window.location.reload();
1007
- resetMediaAndPosts();
1008
- }
1009
- });
1010
- }
1011
- } else if (ui.draggable.hasClass('wcp-move-file')) {
1012
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
1013
- chkStr = postID+",";
1014
  $(".wp-list-table input:checked").each(function(){
1015
- if(postID != $(this).val()) {
1016
- chkStr += $(this).val() + ",";
1017
- }
1018
  });
1019
  $.ajax({
1020
  url: folders_media_options.ajax_url,
@@ -1025,66 +1099,61 @@
1025
  resetMediaAndPosts();
1026
  }
1027
  });
1028
- } else if (ui.draggable.hasClass('attachment')) {
1029
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
1030
- if ($(".attachments-browser li.attachment.selected").length > 1) {
1031
- chkStr = "";
1032
- $(".attachments-browser li.attachment.selected").each(function(){
1033
- chkStr += $(this).data("id") + ",";
1034
- });
1035
  }
1036
- folderIDs = chkStr;
1037
- $.ajax({
1038
- url: folders_media_options.ajax_url,
1039
- data: "post_id=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1040
- method: 'post',
1041
- success: function (res) {
1042
- // window.location.reload();
1043
- resetMediaAndPosts();
1044
- }
 
 
 
 
 
 
 
1045
  });
1046
  }
 
 
 
 
 
 
 
 
 
 
1047
  }
1048
- });
1049
  });
1050
 
1051
- //
1052
- $(".tree-structure .folder-item").livequery(function(){
1053
- $(this).droppable({
1054
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
1055
- hoverClass: 'wcp-drop-hover-list',
1056
- classes: {
1057
- "ui-droppable-active": "ui-state-highlight"
1058
- },
1059
- drop: function( event, ui ) {
1060
- $("body").removeClass("no-hover-css");
1061
- folderID = $(this).data('id');
1062
- if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
1063
- nonce = getSettingForPost(folderID, 'nonce');
1064
- if($(".wp-list-table input:checked").length) {
1065
- chkStr = "";
1066
- $(".wp-list-table input:checked").each(function(){
1067
- chkStr += $(this).val()+",";
1068
- });
1069
- $.ajax({
1070
- url: folders_media_options.ajax_url,
1071
- data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1072
- method: 'post',
1073
- success: function (res) {
1074
- // window.location.reload();
1075
- resetMediaAndPosts();
1076
- ajaxAnimation();
1077
- }
1078
- });
1079
- }
1080
- } else if ( ui.draggable.hasClass( 'wcp-move-file' ) ) {
1081
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
1082
- nonce = getSettingForPost(folderID, 'nonce');
1083
- chkStr = postID+",";
1084
  $(".wp-list-table input:checked").each(function(){
1085
- if($(this).val() != postID) {
1086
- chkStr += $(this).val() + ",";
1087
- }
1088
  });
1089
  $.ajax({
1090
  url: folders_media_options.ajax_url,
@@ -1096,163 +1165,91 @@
1096
  ajaxAnimation();
1097
  }
1098
  });
1099
- } else if( ui.draggable.hasClass( 'attachment' ) ){
1100
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
1101
- nonce = getSettingForPost(folderID, 'nonce');
1102
- if($(".attachments-browser li.attachment.selected").length > 1) {
1103
- chkStr = "";
1104
- $(".attachments-browser li.attachment.selected").each(function(){
1105
- chkStr += $(this).data("id")+",";
1106
- });
1107
  }
1108
- $.ajax({
1109
- url: folders_media_options.ajax_url,
1110
- data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1111
- method: 'post',
1112
- success: function (res) {
1113
- // window.location.reload();
1114
- resetMediaAndPosts();
1115
- ajaxAnimation();
1116
- }
 
 
 
 
 
 
 
 
 
1117
  });
1118
  }
1119
- }
1120
- });
1121
- });
1122
-
1123
- $(".wcp-move-file").livequery(function(){
1124
- $(this).draggable({
1125
- revert: "invalid",
1126
- containment: "document",
1127
- helper: "clone",
1128
- cursor: "move",
1129
- start: function( event, ui){
1130
- $(this).closest("td").addClass("wcp-draggable");
1131
- $("body").addClass("no-hover-css");
1132
- },
1133
- stop: function( event, ui ) {
1134
- $(this).closest("td").removeClass("wcp-draggable");
1135
- $("body").removeClass("no-hover-css");
1136
- }
1137
- });
1138
- });
1139
-
1140
- $(".wcp-move-multiple").livequery(function(){
1141
- $(this).draggable({
1142
- revert: "invalid",
1143
- containment: "document",
1144
- helper: function (event, ui) {
1145
- $(".selected-items").remove();
1146
- selectedItems = $("#the-list th input:checked").length;
1147
- if(selectedItems > 0) {
1148
- selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
1149
- return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
1150
- } else {
1151
- return $("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>");
1152
- }
1153
- },
1154
- start: function( event, ui){
1155
- $("body").addClass("no-hover-css");
1156
- },
1157
- cursor: "move",
1158
- cursorAt: {
1159
- left: 0,
1160
- top: 0
1161
- },
1162
- stop: function( event, ui ) {
1163
- $(".selected-items").remove();
1164
- $("body").removeClass("no-hover-css");
1165
- }
1166
- });
1167
- });
1168
-
1169
- $(".jstree-node .jstree-icon").livequery(function(){
1170
- $(this).click(function(){
1171
- folderID = $(this).closest("li.jstree-node").attr("id");
1172
- if($("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")) {
1173
- folderStatus = 0;
1174
- } else {
1175
- folderStatus = 1;
1176
- }
1177
- $(".form-loader-count").css("width","100%");
1178
- nonce = getSettingForPost(folderID, 'nonce');
1179
- checkForExpandCollapse();
1180
- $.ajax({
1181
- url: folders_media_options.ajax_url,
1182
- data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
1183
- method: 'post',
1184
- success: function (res) {
1185
- $(".form-loader-count").css("width","0");
1186
- res = $.parseJSON(res);
1187
- if(res.status == "0") {
1188
- // $(".folder-popup-form").hide();
1189
- // $(".folder-popup-form").removeClass("disabled");
1190
- // $("#error-folder-popup-message").html(res.message);
1191
- // $("#error-folder-popup").show();
1192
- } else {
1193
- if($("#wcp_folder_"+folderID).hasClass("active")) {
1194
- $("#wcp_folder_"+folderID).removeClass("active");
1195
- $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp();
1196
- folderStatus = 0;
1197
- } else {
1198
- $("#wcp_folder_"+folderID).addClass("active");
1199
- $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown();
1200
- folderStatus = 1;
1201
- }
1202
  ajaxAnimation();
1203
  }
1204
- }
1205
- });
1206
- });
1207
- });
1208
-
1209
- $(document).on("keyup", "#folder-search", function(){
1210
- checkForFolderSearch();
1211
- });
1212
-
1213
- $(document).on("change", "#folder-search", function(){
1214
- checkForFolderSearch();
1215
- });
1216
-
1217
- $(document).on("blur", "#folder-search", function(){
1218
- checkForFolderSearch();
1219
- });
1220
-
1221
- $(document).on("click","#folder-hide-show-checkbox",function(){
1222
- if($(this).is(":checked")) {
1223
- $("#js-tree-menu").addClass("show-folder-checkbox");
1224
- } else {
1225
- $("#js-tree-menu input.checkbox").attr("checked", false);
1226
- $("#js-tree-menu").removeClass("show-folder-checkbox");
1227
  }
1228
  });
1229
 
1230
- $(document).on("click", ".folder-checkbox, .input-checkbox", function(e){
1231
- e.stopImmediatePropagation();
1232
- e.stopPropagation();
1233
- });
1234
-
1235
- $(document).on("click", "#inline-remove", function(){
1236
- if($("#js-tree-menu a.jstree-clicked").length) {
1237
- fileFolderID = $("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");
1238
- removeFolderFromID(1);
1239
- $(".dynamic-menu").remove();
1240
- $(".active-menu").removeClass("active-menu");
1241
- } else {
1242
- if($("#folder-hide-show-checkbox").is(":checked")) {
1243
- $(".dynamic-menu").remove();
1244
- removeFolderFromID(1);
1245
- }
1246
  }
1247
  });
1248
 
1249
- $(document).on("change", ".folder_for_media", function(){
1250
- if($(this).val() == "add-folder") {
1251
- isItFromMedia = true;
1252
- $("#add-new-folder").trigger("click");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1253
  }
1254
  });
1255
- });
1256
 
1257
  function initJSTree() {
1258
  $(treeId).jstree({
@@ -1305,6 +1302,25 @@
1305
  }
1306
  }).bind("ready.jstree", (function() {
1307
  setFolderCount();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1308
  })).bind("move_node.jstree", (function(t, n) {
1309
  folderMoveId = n.node.id;
1310
  orderString = "";
@@ -1332,6 +1348,7 @@
1332
  resetMediaAndPosts();
1333
  ajaxAnimation();
1334
  setFolderCountAndDD();
 
1335
  } else {
1336
  $(".folder-popup-form").hide();
1337
  $(".folder-popup-form").removeClass("disabled");
@@ -1343,6 +1360,7 @@
1343
  });
1344
  }
1345
  }));
 
1346
  }
1347
 
1348
  function setFolderCount() {
@@ -1518,6 +1536,7 @@
1518
  $(".un-categorised-items .total-count").text(res.empty_items);
1519
  foldersArray = res.taxonomies;
1520
  setFolderCountAndDD();
 
1521
  }
1522
  });
1523
  $(".folder-loader-ajax").addClass("active");
@@ -1557,6 +1576,7 @@
1557
  var res = $.parseJSON(res);
1558
  foldersArray = res.taxonomies;
1559
  setFolderCountAndDD();
 
1560
  }
1561
  });
1562
  }
@@ -1699,6 +1719,8 @@
1699
  }
1700
  }
1701
  }, 500);
 
 
1702
  }
1703
 
1704
  var resetMediaFlag;
@@ -1732,6 +1754,7 @@
1732
  }
1733
  foldersArray = res.taxonomies;
1734
  setFolderCountAndDD();
 
1735
  }
1736
  });
1737
  }
@@ -1758,5 +1781,6 @@
1758
  $(".folder-loader-ajax img").addClass("active");
1759
  $(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated");
1760
  }, 2000);
 
1761
  }
1762
  }));
265
  initialize: function () {
266
  windowModal.prototype.initialize.apply(this, arguments);
267
  }, open: function () {
268
+ //$(".folder-modal").removeClass("folder-modal");
269
  if (windowModal.prototype.open.apply(this, arguments)) {
270
+ if(!$(".folder-modal").length) {
271
+ if($(".supports-drag-drop").length) {
272
+ $(".supports-drag-drop").each(function(){
273
+ if($(this).css("display") == "block" || $(this).css("display") == "inline-block") {
274
+ console.log("class added");
275
+ $(this).addClass("folder-modal");
276
+ }
277
+ });
278
+ }
279
+ }
280
  if($(".folder-modal").length) {
281
  $(".folder-custom-menu").remove();
282
  $(".folder-modal .media-frame-tab-panel").removeClass("has-folder-menu");
340
 
341
  $(document).ready(function(){
342
 
343
+ $( document ).ajaxComplete(function( event, xhr, settings ) {
344
+ if(settings.data != undefined && settings.data != "" && settings.data.indexOf("action=query-attachments") != -1) {
345
+ setDragAndDropElements();
346
+ }
347
+ });
348
+
349
  foldersArray = folders_media_options.terms;
350
  isKeyActive = parseInt(folders_media_options.is_key_active);
351
  n_o_file = parseInt(folders_media_options.folders);
379
  var thisIndex = $(this).closest("li.jstree-node").attr("id");
380
  fileFolderID = thisIndex;
381
  selectedFolderMediaId = fileFolderID;
382
+ $(this).closest(".folder-modal").find(".active-item").removeClass("active-item");
383
+ $(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").val(thisIndex);
384
+ $(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").trigger("change");
385
  thisSlug = getSettingForPost(thisIndex, 'slug');
386
  set_default_folders(thisSlug);
387
  $(".custom-media-select").removeClass("active");
621
  };
622
 
623
  /* Update folder */
624
+ $(document).on("click", ".rename-folder", function(e){
625
+ e.stopPropagation();
626
+ if($(this).closest("li.jstree-node").length) {
627
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
628
+ } else {
629
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
630
+ }
631
+ updateFolder();
632
+ $(".dynamic-menu").remove();
 
 
633
  });
634
 
635
  $(document).on("click", "#inline-update", function (e) {
698
  });
699
 
700
  /* Mark Folder */
701
+ $(document).on("click", ".mark-folder", function(e){
702
+ e.stopPropagation();
703
+ if($(this).closest("li.jstree-node").length) {
704
+ folderID = $(this).closest("li.jstree-node").attr("id");
705
+ } else {
706
+ folderID = $(this).closest("li.sticky-fldr").data("folder-id");
707
+ }
708
+ nonce = getSettingForPost(folderID, 'nonce');
709
+ $(".form-loader-count").css("width","100%");
710
+ $(".dynamic-menu").remove();
711
+ $(".active-menu").removeClass("active-menu");
712
+ $.ajax({
713
+ url: folders_media_options.ajax_url,
714
+ data: "term_id=" + folderID + "&type=" + folders_media_options.post_type + "&action=wcp_mark_un_mark_folder&nonce="+nonce,
715
+ method: 'post',
716
+ cache: false,
717
+ success: function (res) {
718
+ res = $.parseJSON(res);
719
+ $(".form-loader-count").css("width","0%");
720
+ if (res.status == '1') {
721
+ folderPostId = getIndexForPostSetting(res.id);
722
+ if(res.marked == '1') {
723
+ $("li.jstree-node[id='"+res.id+"']").addClass("is-high");
724
+ $(".sticky-folder-"+res.id).addClass("is-high");
725
+ if(folderPostId != null) {
726
+ folderPropertyArray[folderPostId]['is_high'] = 1;
 
 
 
 
 
 
 
 
727
  }
 
728
  } else {
729
+ $("li.jstree-node[id='"+res.id+"']").removeClass("is-high");
730
+ $(".sticky-folder-"+res.id).removeClass("is-high");
731
+ if(folderPostId != null) {
732
+ folderPropertyArray[folderPostId]['is_high'] = 0;
733
+ }
734
  }
735
+ ajaxAnimation();
736
+ } else {
737
+ $(".folder-popup-form").hide();
738
+ $(".folder-popup-form").removeClass("disabled");
739
+ $("#error-folder-popup-message").html(res.message);
740
+ $("#error-folder-popup").show();
741
  }
742
+ }
743
  });
744
  });
745
 
746
  /* Duplicate Folder */
747
+ $(document).on("click", ".duplicate-folder", function(e){
748
+ e.stopPropagation();
749
+ if($(this).closest("li.jstree-node").length) {
750
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
751
+ } else {
752
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
753
+ }
754
+ $(".dynamic-menu").remove();
755
+ isItFromMedia = false;
756
+ isDuplicate = true;
757
+ addFolder();
 
 
758
  });
759
 
760
  /* Remove folder */
761
+ $(document).on("click", ".remove-folder", function(){
762
+ folderID = $(this).closest("li.jstree-node").data("id");
763
+ if($(this).closest("li.jstree-node").length) {
764
+ fileFolderID = $(this).closest("li.jstree-node").attr("id");
765
+ } else {
766
+ fileFolderID = $(this).closest("li.sticky-fldr").data("folder-id");
767
+ }
768
+ removeFolderFromID(0);
769
+ $(".dynamic-menu").remove();
770
+ $(".active-menu").removeClass("active-menu");
 
 
771
  });
772
 
773
  $(document).on("click", "#remove-folder-item", function (e){
880
  });
881
  });
882
 
883
+ $(document).on("click", ".jstree-node .jstree-icon", function(){
884
+ folderID = $(this).closest("li.jstree-node").attr("id");
885
+ if($("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")) {
886
+ folderStatus = 0;
887
+ } else {
888
+ folderStatus = 1;
889
+ }
890
+ $(".form-loader-count").css("width","100%");
891
+ nonce = getSettingForPost(folderID, 'nonce');
892
+ checkForExpandCollapse();
893
+ $.ajax({
894
+ url: folders_media_options.ajax_url,
895
+ data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
896
+ method: 'post',
897
+ success: function (res) {
898
+ $(".form-loader-count").css("width","0");
899
+ res = $.parseJSON(res);
900
+ if(res.status == "0") {
901
+ // $(".folder-popup-form").hide();
902
+ // $(".folder-popup-form").removeClass("disabled");
903
+ // $("#error-folder-popup-message").html(res.message);
904
+ // $("#error-folder-popup").show();
905
+ } else {
906
+ if($("#wcp_folder_"+folderID).hasClass("active")) {
907
+ $("#wcp_folder_"+folderID).removeClass("active");
908
+ $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp();
909
+ folderStatus = 0;
910
+ } else {
911
+ $("#wcp_folder_"+folderID).addClass("active");
912
+ $("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown();
913
+ folderStatus = 1;
 
914
  }
915
+ ajaxAnimation();
916
+ }
917
+ }
918
+ });
919
+ });
920
+
921
+ $(document).on("keyup", "#folder-search", function(){
922
+ checkForFolderSearch();
923
+ });
924
+
925
+ $(document).on("change", "#folder-search", function(){
926
+ checkForFolderSearch();
927
+ });
928
+
929
+ $(document).on("blur", "#folder-search", function(){
930
+ checkForFolderSearch();
931
+ });
932
+
933
+ $(document).on("click","#folder-hide-show-checkbox",function(){
934
+ if($(this).is(":checked")) {
935
+ $("#js-tree-menu").addClass("show-folder-checkbox");
936
+ } else {
937
+ $("#js-tree-menu input.checkbox").attr("checked", false);
938
+ $("#js-tree-menu").removeClass("show-folder-checkbox");
939
+ }
940
+ });
941
+
942
+ $(document).on("click", ".folder-checkbox, .input-checkbox", function(e){
943
+ e.stopImmediatePropagation();
944
+ e.stopPropagation();
945
+ });
946
+
947
+ $(document).on("click", "#inline-remove", function(){
948
+ if($("#js-tree-menu a.jstree-clicked").length) {
949
+ fileFolderID = $("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id");
950
+ removeFolderFromID(1);
951
+ $(".dynamic-menu").remove();
952
+ $(".active-menu").removeClass("active-menu");
953
+ } else {
954
+ if($("#folder-hide-show-checkbox").is(":checked")) {
955
+ $(".dynamic-menu").remove();
956
+ removeFolderFromID(1);
957
+ }
958
+ }
959
+ });
960
+
961
+ $(document).on("change", ".folder_for_media", function(){
962
+ if($(this).val() == "add-folder") {
963
+ isItFromMedia = true;
964
+ $("#add-new-folder").trigger("click");
965
+ }
966
+ });
967
+
968
+ setDragAndDropElements();
969
+ });
970
+
971
+ function setDragAndDropElements() {
972
+ $(".jstree-anchor:not(.ui-droppable)").droppable({
973
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
974
+ hoverClass: 'wcp-drop-hover',
975
+ classes: {
976
+ "ui-droppable-active": "ui-state-highlight"
977
+ },
978
+ drop: function( event, ui ) {
979
+ folderID = $(this).closest("li.jstree-node").attr('id');
980
+ if ( ui.draggable.hasClass( 'wcp-move-multiple')) {
981
+ if($(".wp-list-table input:checked").length) {
982
+ chkStr = "";
983
  $(".wp-list-table input:checked").each(function(){
984
+ chkStr += $(this).val()+",";
 
 
985
  });
986
+ nonce = getSettingForPost(folderID, 'nonce');
987
  $.ajax({
988
  url: folders_media_options.ajax_url,
989
  data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
991
  success: function (res) {
992
  res = $.parseJSON(res);
993
  if(res.status == "1") {
 
994
  resetMediaAndPosts();
995
  } else {
996
  $(".folder-popup-form").hide();
1000
  }
1001
  }
1002
  });
1003
+ }
1004
+ } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
1005
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
1006
+ nonce = getSettingForPost(folderID, 'nonce');
1007
+ chkStr = postID+",";
1008
+ $(".wp-list-table input:checked").each(function(){
1009
+ if($(this).val() != postID) {
1010
+ chkStr += $(this).val() + ",";
1011
  }
1012
+ });
1013
+ $.ajax({
1014
+ url: folders_media_options.ajax_url,
1015
+ data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1016
+ method: 'post',
1017
+ success: function (res) {
1018
+ res = $.parseJSON(res);
1019
+ if(res.status == "1") {
1020
  // window.location.reload();
1021
  resetMediaAndPosts();
1022
+ } else {
1023
+ $(".folder-popup-form").hide();
1024
+ $(".folder-popup-form").removeClass("disabled");
1025
+ $("#error-folder-popup-message").html(res.message);
1026
+ $("#error-folder-popup").show()
1027
  }
1028
+ }
1029
+ });
1030
+ } else if (ui.draggable.hasClass('attachment')) {
1031
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
1032
+ nonce = getSettingForPost(folderID, 'nonce');
1033
+ if ($(".attachments-browser li.attachment.selected").length > 1) {
1034
+ chkStr = "";
1035
+ $(".attachments-browser li.attachment.selected").each(function(){
1036
+ chkStr += $(this).data("id") + ",";
1037
  });
1038
  }
1039
+ folderIDs = chkStr;
1040
+ $.ajax({
1041
+ url: folders_media_options.ajax_url,
1042
+ data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1043
+ method: 'post',
1044
+ success: function (res) {
1045
+ // window.location.reload();
1046
+ resetMediaAndPosts();
1047
+ ajaxAnimation();
1048
+ }
1049
+ });
1050
  }
1051
+ }
1052
  });
1053
 
1054
+ $(".media-frame:not(.hide-router) .attachments-browser li.attachment:not(.ui-draggable)").draggable({
1055
+ revert: "invalid",
1056
+ containment: "document",
1057
+ helper: function (event, ui) {
1058
+ $(".selected-items").remove();
1059
+ var selectedItems = $(".media-frame:not(.hide-router) .attachments-browser li.attachment.selected").length;
1060
+ selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
1061
+ return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
1062
+ },
1063
+ start: function( event, ui){
1064
+ $("body").addClass("no-hover-css");
1065
+ },
1066
+ cursor: "move",
1067
+ appendTo: ".media-modal",
1068
+ cursorAt: {
1069
+ left: 0,
1070
+ top: 0
1071
+ },
1072
+ stop: function( event, ui ) {
1073
+ $(".selected-items").remove();
1074
+ $("body").removeClass("no-hover-css");
1075
+ }
 
 
1076
  });
1077
 
1078
+ $(".un-categorised-items").droppable({
1079
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
1080
+ hoverClass: 'wcp-hover-list',
1081
+ classes: {
1082
+ "ui-droppable-active": "ui-state-highlight"
1083
+ },
1084
+ drop: function (event, ui) {
1085
+ folderID = -1;
1086
+ nonce = folders_media_options.nonce;
1087
+ if (ui.draggable.hasClass('wcp-move-multiple')) {
1088
+ if ($(".wp-list-table input:checked").length) {
1089
+ chkStr = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1090
  $(".wp-list-table input:checked").each(function(){
1091
+ chkStr += $(this).val() + ",";
 
 
1092
  });
1093
  $.ajax({
1094
  url: folders_media_options.ajax_url,
1099
  resetMediaAndPosts();
1100
  }
1101
  });
1102
+ }
1103
+ } else if (ui.draggable.hasClass('wcp-move-file')) {
1104
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
1105
+ chkStr = postID+",";
1106
+ $(".wp-list-table input:checked").each(function(){
1107
+ if(postID != $(this).val()) {
1108
+ chkStr += $(this).val() + ",";
1109
  }
1110
+ });
1111
+ $.ajax({
1112
+ url: folders_media_options.ajax_url,
1113
+ data: "post_id=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1114
+ method: 'post',
1115
+ success: function (res) {
1116
+ //window.location.reload();
1117
+ resetMediaAndPosts();
1118
+ }
1119
+ });
1120
+ } else if (ui.draggable.hasClass('attachment')) {
1121
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
1122
+ if ($(".attachments-browser li.attachment.selected").length > 1) {
1123
+ chkStr = "";
1124
+ $(".attachments-browser li.attachment.selected").each(function(){
1125
+ chkStr += $(this).data("id") + ",";
1126
  });
1127
  }
1128
+ folderIDs = chkStr;
1129
+ $.ajax({
1130
+ url: folders_media_options.ajax_url,
1131
+ data: "post_id=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1132
+ method: 'post',
1133
+ success: function (res) {
1134
+ // window.location.reload();
1135
+ resetMediaAndPosts();
1136
+ }
1137
+ });
1138
  }
1139
+ }
1140
  });
1141
 
1142
+ $(".tree-structure .folder-item:not(.ui-droppable)").droppable({
1143
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
1144
+ hoverClass: 'wcp-drop-hover-list',
1145
+ classes: {
1146
+ "ui-droppable-active": "ui-state-highlight"
1147
+ },
1148
+ drop: function( event, ui ) {
1149
+ $("body").removeClass("no-hover-css");
1150
+ folderID = $(this).data('id');
1151
+ if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
1152
+ nonce = getSettingForPost(folderID, 'nonce');
1153
+ if($(".wp-list-table input:checked").length) {
1154
+ chkStr = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1155
  $(".wp-list-table input:checked").each(function(){
1156
+ chkStr += $(this).val()+",";
 
 
1157
  });
1158
  $.ajax({
1159
  url: folders_media_options.ajax_url,
1165
  ajaxAnimation();
1166
  }
1167
  });
1168
+ }
1169
+ } else if ( ui.draggable.hasClass( 'wcp-move-file' ) ) {
1170
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
1171
+ nonce = getSettingForPost(folderID, 'nonce');
1172
+ chkStr = postID+",";
1173
+ $(".wp-list-table input:checked").each(function(){
1174
+ if($(this).val() != postID) {
1175
+ chkStr += $(this).val() + ",";
1176
  }
1177
+ });
1178
+ $.ajax({
1179
+ url: folders_media_options.ajax_url,
1180
+ data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1181
+ method: 'post',
1182
+ success: function (res) {
1183
+ // window.location.reload();
1184
+ resetMediaAndPosts();
1185
+ ajaxAnimation();
1186
+ }
1187
+ });
1188
+ } else if( ui.draggable.hasClass( 'attachment' ) ){
1189
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
1190
+ nonce = getSettingForPost(folderID, 'nonce');
1191
+ if($(".attachments-browser li.attachment.selected").length > 1) {
1192
+ chkStr = "";
1193
+ $(".attachments-browser li.attachment.selected").each(function(){
1194
+ chkStr += $(this).data("id")+",";
1195
  });
1196
  }
1197
+ $.ajax({
1198
+ url: folders_media_options.ajax_url,
1199
+ data: "post_ids=" + chkStr + "&type=" + folders_media_options.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+activeRecordID,
1200
+ method: 'post',
1201
+ success: function (res) {
1202
+ // window.location.reload();
1203
+ resetMediaAndPosts();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1204
  ajaxAnimation();
1205
  }
1206
+ });
1207
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1208
  }
1209
  });
1210
 
1211
+ $(".wcp-move-file:not(.ui-draggable)").draggable({
1212
+ revert: "invalid",
1213
+ containment: "document",
1214
+ helper: "clone",
1215
+ cursor: "move",
1216
+ start: function( event, ui){
1217
+ $(this).closest("td").addClass("wcp-draggable");
1218
+ $("body").addClass("no-hover-css");
1219
+ },
1220
+ stop: function( event, ui ) {
1221
+ $(this).closest("td").removeClass("wcp-draggable");
1222
+ $("body").removeClass("no-hover-css");
 
 
 
 
1223
  }
1224
  });
1225
 
1226
+ $(".wcp-move-multiple:not(.ui-draggable)").draggable({
1227
+ revert: "invalid",
1228
+ containment: "document",
1229
+ helper: function (event, ui) {
1230
+ $(".selected-items").remove();
1231
+ selectedItems = $("#the-list th input:checked").length;
1232
+ if(selectedItems > 0) {
1233
+ selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
1234
+ return $("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
1235
+ } else {
1236
+ return $("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>");
1237
+ }
1238
+ },
1239
+ start: function( event, ui){
1240
+ $("body").addClass("no-hover-css");
1241
+ },
1242
+ cursor: "move",
1243
+ cursorAt: {
1244
+ left: 0,
1245
+ top: 0
1246
+ },
1247
+ stop: function( event, ui ) {
1248
+ $(".selected-items").remove();
1249
+ $("body").removeClass("no-hover-css");
1250
  }
1251
  });
1252
+ }
1253
 
1254
  function initJSTree() {
1255
  $(treeId).jstree({
1302
  }
1303
  }).bind("ready.jstree", (function() {
1304
  setFolderCount();
1305
+ setDragAndDropElements();
1306
+ })).bind("after_open.jstree", (function() {
1307
+ //data.text is the new name:
1308
+ setDragAndDropElements();
1309
+ })).bind("open_all.jstree", (function() {
1310
+ //data.text is the new name:
1311
+ setDragAndDropElements();
1312
+ })).bind("create_node.jstree", (function() {
1313
+ //data.text is the new name:
1314
+ setDragAndDropElements();
1315
+ })).bind("delete_node.jstree", (function() {
1316
+ //data.text is the new name:
1317
+ setDragAndDropElements();
1318
+ })).bind("close_all.jstree", (function() {
1319
+ //data.text is the new name:
1320
+ setDragAndDropElements();
1321
+ })).bind("after_close.jstree", (function() {
1322
+ //data.text is the new name:
1323
+ setDragAndDropElements();
1324
  })).bind("move_node.jstree", (function(t, n) {
1325
  folderMoveId = n.node.id;
1326
  orderString = "";
1348
  resetMediaAndPosts();
1349
  ajaxAnimation();
1350
  setFolderCountAndDD();
1351
+ setDragAndDropElements();
1352
  } else {
1353
  $(".folder-popup-form").hide();
1354
  $(".folder-popup-form").removeClass("disabled");
1360
  });
1361
  }
1362
  }));
1363
+ setDragAndDropElements();
1364
  }
1365
 
1366
  function setFolderCount() {
1536
  $(".un-categorised-items .total-count").text(res.empty_items);
1537
  foldersArray = res.taxonomies;
1538
  setFolderCountAndDD();
1539
+ setDragAndDropElements();
1540
  }
1541
  });
1542
  $(".folder-loader-ajax").addClass("active");
1576
  var res = $.parseJSON(res);
1577
  foldersArray = res.taxonomies;
1578
  setFolderCountAndDD();
1579
+ setDragAndDropElements();
1580
  }
1581
  });
1582
  }
1719
  }
1720
  }
1721
  }, 500);
1722
+
1723
+ setDragAndDropElements();
1724
  }
1725
 
1726
  var resetMediaFlag;
1754
  }
1755
  foldersArray = res.taxonomies;
1756
  setFolderCountAndDD();
1757
+ setDragAndDropElements();
1758
  }
1759
  });
1760
  }
1781
  $(".folder-loader-ajax img").addClass("active");
1782
  $(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated");
1783
  }, 2000);
1784
+ setDragAndDropElements();
1785
  }
1786
  }));
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=".folder-modal #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,j=0,w=[],k=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)}}),x=0,b=0,C=wp.media.view.AttachmentsBrowser;wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({createToolbar:function(){C.prototype.createToolbar.call(this),this.toolbar.set("MediaLibraryOrganizerTaxonomyFilter",new k({controller:this.controller,model:this.collection.props,priority:-75}).render())}});var S,I=wp.media.model.Query;_.extend(I,{get:(S=[],function(e,t){var o,s={},a=I.orderby,r=I.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[I.propmap[t]||t]=e)}),_.defaults(s,I.defaultArgs),s.orderby=a.valuemap[e.orderby]||e.orderby,S=[],o||(o=new I([],_.extend(t||{},{props:e,args:s})),S.push(o)),o})});var P=window.wp;void 0!==P&&"function"==typeof P.Uploader&&(P.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.trash_count+")</option>")})),e("#wcp-content").length||e(".editor-post-featured-image").length&&e(".attachment-filters").val("all").trigger("change"))},100)}),e.extend(P.Uploader.prototype,{progress:function(){},init:function(){this.uploader&&(this.uploader.bind("FileFiltered",function(t,o){x++,e(".folder-meter").css("width","0%"),e(".media-folder-loader").show(),e("#total_upload_files").text(x)}),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),b<x){e(".media-folder-loader").show();var i=b/x*100;e(".folder-meter").css("width",i+"%")}b++,e("#current_upload_files").text(b)}),this.uploader.bind("UploadComplete",function(e,t){a=-1}),this.uploader.bind("UploadComplete",function(t,o){var s=window.wp;e(".folder-meter").css("width","100%"),setTimeout(function(){e(".media-folder-loader").hide(),e(".folder-meter").css("width","0%"),x=0,b=0},1250),function(){e("#media-attachment-taxonomy-filter").val();D=e.ajax({url:folders_media_options.ajax_url,data:"type=attachment&action=wcp_get_default_list&active_id=0",method:"post",beforeSend:function(){null!=D&&D.abort()},success:function(t){var t=e.parseJSON(t);w=t.taxonomies,F()}})}(),void 0!==s.media.frame&&null!==s.media.frame.content.get()?(s.media.frame.content.get().collection.props.set({ignore:+new Date}),s.media.frame.content.get().options.selection.reset()):e("#media-attachment-taxonomy-filter").length&&e(".attachment-filters").each(function(){e(this).trigger("change")})}))}}));var D,N=window.wp;if(void 0!==N&&"function"==typeof N.Uploader){var A=window.wp.media,q=A.view.Modal;A.view.Modal=A.view.Modal.extend({className:"folder-modal",initialize:function(){q.prototype.initialize.apply(this,arguments)},open:function(){e(".folder-modal").removeClass("folder-modal"),q.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(){E(),O()})):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(){E(),O()})),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(){q.prototype.close.apply(this,arguments),e(".folder-modal").removeClass("folder-modal")}})}function O(){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)}),""!=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(),T(),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(".folder-modal .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e(".folder-modal #"+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%"),e.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=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),H(),Q(),F()):(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 U(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 J(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 T(){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 H(){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?R(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(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),w=t.taxonomies,F()}}),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){var o={Title:"",Url:p};history.pushState(o,o.Title,o.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>')}))}function F(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=w;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),w;for(var o=0;o<w.length;o++)t.append("<option value='"+w[o].term_id+"'>"+w[o].name+" ("+w[o].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var o=0;o<w.length;o++)e("select.folder_for_media option:last-child").before("<option value='"+w[o].term_id+"'>"+w[o].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),o=0;o<w.length;o++)0!=parseInt(w[o].trash_count)&&(e(".jstree-node[id='"+w[o].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(w[o].trash_count),e(".sticky-folder-"+w[o].term_id+" .premio-folder-count").text(w[o].trash_count));""!=f&&e("#wcp_folder_"+f).addClass("active-item"),v&&(e("#title_"+l).trigger("click"),v=!1)}function M(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function V(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 z(){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 B(){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 E(){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 R(o){D=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(){null!=D&&D.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}))}w=s.taxonomies,F()}})}function Q(){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(){w=folders_media_options.terms,c=parseInt(folders_media_options.is_key_active),n=parseInt(folders_media_options.folders),s=folders_media_options.folder_settings,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=U(s,"slug"),o=thisSlug,e.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,B()}),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,B()}),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),j=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:j,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),E(),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),Q(),T(),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,R(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"),z(),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"),z())}),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=U(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:j,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=J(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"),Q(),e("#media-attachment-taxonomy-filter").length&&R(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=U(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=J(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)),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())}})})}),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,B()})}),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"),V(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=U(l,"nonce"),h?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: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(".folder-modal #js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),Q(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),T(),Q(),e(".folder-modal #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(),Q(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),T(),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,e.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=e.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"),e.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=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),w=t.terms,F(),O()),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=U(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?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,m=U(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?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,m=U(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){H(),Q()}}))}})}),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){H()}})):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){H()}})):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){H()}}))}})}),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=U(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){H(),Q()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,m=U(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){H(),Q()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,m=U(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){H(),Q()}}))}})}),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=U(r,"nonce"),E(),e.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=e.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),Q())}})})}),e(document).on("keyup","#folder-search",function(){M()}),e(document).on("change","#folder-search",function(){M()}),e(document).on("blur","#folder-search",function(){M()}),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"),V(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#folder-hide-show-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),V(1))}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(v=!0,e("#add-new-folder").trigger("click"))})})});
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=".folder-modal #js-tree-menu",s=[],a=-1,r=0,d=0,l="",n=-1,c=0,m="",p=folders_media_options.page_url,f="",u="",h=!1,v=!1,g=!1,y=0,j=0,w=[],k=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)}}),x=0,b=0,C=wp.media.view.AttachmentsBrowser;wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({createToolbar:function(){C.prototype.createToolbar.call(this),this.toolbar.set("MediaLibraryOrganizerTaxonomyFilter",new k({controller:this.controller,model:this.collection.props,priority:-75}).render())}});var S,I=wp.media.model.Query;_.extend(I,{get:(S=[],function(e,t){var o,s={},a=I.orderby,r=I.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[I.propmap[t]||t]=e)}),_.defaults(s,I.defaultArgs),s.orderby=a.valuemap[e.orderby]||e.orderby,S=[],o||(o=new I([],_.extend(t||{},{props:e,args:s})),S.push(o)),o})});var P=window.wp;void 0!==P&&"function"==typeof P.Uploader&&(P.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.trash_count+")</option>")})),e("#wcp-content").length||e(".editor-post-featured-image").length&&e(".attachment-filters").val("all").trigger("change"))},100)}),e.extend(P.Uploader.prototype,{progress:function(){},init:function(){this.uploader&&(this.uploader.bind("FileFiltered",function(t,o){x++,e(".folder-meter").css("width","0%"),e(".media-folder-loader").show(),e("#total_upload_files").text(x)}),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),b<x){e(".media-folder-loader").show();var d=b/x*100;e(".folder-meter").css("width",d+"%")}b++,e("#current_upload_files").text(b)}),this.uploader.bind("UploadComplete",function(e,t){a=-1}),this.uploader.bind("UploadComplete",function(t,o){var s=window.wp;e(".folder-meter").css("width","100%"),setTimeout(function(){e(".media-folder-loader").hide(),e(".folder-meter").css("width","0%"),x=0,b=0},1250),function(){e("#media-attachment-taxonomy-filter").val();D=e.ajax({url:folders_media_options.ajax_url,data:"type=attachment&action=wcp_get_default_list&active_id=0",method:"post",beforeSend:function(){null!=D&&D.abort()},success:function(t){var t=e.parseJSON(t);w=t.taxonomies,V(),U()}})}(),void 0!==s.media.frame&&null!==s.media.frame.content.get()?(s.media.frame.content.get().collection.props.set({ignore:+new Date}),s.media.frame.content.get().options.selection.reset()):e("#media-attachment-taxonomy-filter").length&&e(".attachment-filters").each(function(){e(this).trigger("change")})}))}}));var D,N=window.wp;if(void 0!==N&&"function"==typeof N.Uploader){var A=window.wp.media,O=A.view.Modal;A.view.Modal=A.view.Modal.extend({className:"folder-modal",initialize:function(){O.prototype.initialize.apply(this,arguments)},open:function(){O.prototype.open.apply(this,arguments)&&(e(".folder-modal").length||e(".supports-drag-drop").length&&e(".supports-drag-drop").each(function(){"block"!=e(this).css("display")&&"inline-block"!=e(this).css("display")||(console.log("class added"),e(this).addClass("folder-modal"))}),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(){R(),J()})):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(){R(),J()})),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(){O.prototype.close.apply(this,arguments),e(".folder-modal").removeClass("folder-modal")}})}function U(){e(".jstree-anchor:not(.ui-droppable)").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=T(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?M():(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=T(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?M():(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=T(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){M(),Y()}}))}}),e(".media-frame:not(.hide-router) .attachments-browser li.attachment:not(.ui-draggable)").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").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){M()}})):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){M()}})):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){M()}}))}}),e(".tree-structure .folder-item:not(.ui-droppable)").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=T(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){M(),Y()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,m=T(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){M(),Y()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,m=T(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){M(),Y()}}))}}),e(".wcp-move-file:not(.ui-draggable)").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:not(.ui-draggable)").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")}})}function J(){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)}),""!=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(),F(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active")}(),U()}).bind("after_open.jstree",function(){U()}).bind("open_all.jstree",function(){U()}).bind("create_node.jstree",function(){U()}).bind("delete_node.jstree",function(){U()}).bind("close_all.jstree",function(){U()}).bind("after_close.jstree",function(){U()}).bind("move_node.jstree",function(t,o){folderMoveId=o.node.id,orderString="",e(".folder-modal .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e(".folder-modal #"+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%"),e.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=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),M(),Y(),V(),U()):(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))}}))}),U()}function T(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 H(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 F(){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 M(){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?Q(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(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),w=t.taxonomies,V(),U()}}),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){var o={Title:"",Url:p};history.pushState(o,o.Title,o.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>')}))}function V(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=w;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),w;for(var o=0;o<w.length;o++)t.append("<option value='"+w[o].term_id+"'>"+w[o].name+" ("+w[o].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var o=0;o<w.length;o++)e("select.folder_for_media option:last-child").before("<option value='"+w[o].term_id+"'>"+w[o].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),o=0;o<w.length;o++)0!=parseInt(w[o].trash_count)&&(e(".jstree-node[id='"+w[o].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(w[o].trash_count),e(".sticky-folder-"+w[o].term_id+" .premio-folder-count").text(w[o].trash_count));""!=f&&e("#wcp_folder_"+f).addClass("active-item"),v&&(e("#title_"+d).trigger("click"),v=!1)}function z(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function q(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 B(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(d).text),parentID=e("#wcp_folder_"+d).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 E(){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=d,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(d).text)+" #2"),d=e("#"+d+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+d+"_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 R(){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),U()}function Q(o){D=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(){null!=D&&D.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}))}w=s.taxonomies,V(),U()}})}function Y(){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),U()}e(document).ready(function(){e(document).ajaxComplete(function(e,o,s){s.data!=t&&""!=s.data&&-1!=s.data.indexOf("action=query-attachments")&&U()}),w=folders_media_options.terms,c=parseInt(folders_media_options.is_key_active),n=parseInt(folders_media_options.folders),s=folders_media_options.folder_settings,e(document).on("click",".header-posts a.all-posts",function(t){d=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){d=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=d=s,e(this).closest(".folder-modal").find(".active-item").removeClass("active-item"),e(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").val(s),e(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=T(s,"slug"),o=thisSlug,e.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(),d=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,E()}),e(document).on("click","#add-new-folder",function(t){d=e("#custom-menu li.active-item").length?e("#custom-menu li.active-item").data("folder-id"):0,v=!1,E()}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),l=e("#add-update-folder-name").val(),""==e.trim(l))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=d;v&&(o=0),j=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:j,name:l,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),R(),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),Y(),F(),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)}),d=result.term_id,Q(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(document).on("click",".rename-folder",function(t){t.stopPropagation(),d=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),B(),e(".dynamic-menu").remove()}),e(document).on("click","#inline-update",function(t){e("#js-tree-menu a.jstree-clicked").length&&(d=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),B())}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),l=e("#update-folder-item-name").val(),""==e.trim(l)?(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=T(d,"nonce"),parentID=e(".jstree-node[id='"+d+"']").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:d,order:j,name:l},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=H(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"),Y(),e("#media-attachment-taxonomy-filter").length&&Q(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).on("click",".mark-folder",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=T(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=H(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)),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())}})}),e(document).on("click",".duplicate-folder",function(t){t.stopPropagation(),d=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,E()}),e(document).on("click",".remove-folder",function(){r=e(this).closest("li.jstree-node").data("id"),d=e(this).closest("li.jstree-node").length?e(this).closest("li.jstree-node").attr("id"):e(this).closest("li.sticky-fldr").data("folder-id"),q(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=T(d,"nonce"),h?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: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(".folder-modal #js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),Y(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),M(),F(),Y(),e(".folder-modal #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="+d+"&nonce="+m,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(d),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-"+d).remove(),Y(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),M(),F(),f==d&&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,e.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=e.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"),e.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=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),w=t.terms,V(),J()),e(".form-loader-count").css("width","0")}})}),e(document).on("click",".jstree-node .jstree-icon",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=T(r,"nonce"),R(),e.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=e.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),Y())}})}),e(document).on("keyup","#folder-search",function(){z()}),e(document).on("change","#folder-search",function(){z()}),e(document).on("blur","#folder-search",function(){z()}),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?(d=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),q(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#folder-hide-show-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),q(1))}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(v=!0,e("#add-new-folder").trigger("click"))}),U()})});
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.6.1
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.6.1");
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.2
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.2");
34
  }
35
 
36
  include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
includes/folders.class.php CHANGED
@@ -965,7 +965,6 @@ class WCP_Folders
965
  );
966
  }
967
 
968
- wp_enqueue_script('folders-livequery', plugin_dir_url(dirname(__FILE__)) . 'assets/js/livequery.min.js', array(), WCP_FOLDER_VERSION);
969
  wp_enqueue_script('folders-tree', WCP_FOLDER_URL . 'assets/js/jstree.min.js', array(), WCP_FOLDER_VERSION, true);
970
  wp_enqueue_script('folders-media', WCP_FOLDER_URL . 'assets/js/page-post-media.min.js', array('media-editor', 'media-views', 'jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION, true);
971
  wp_localize_script('folders-media', 'folders_media_options', array(
@@ -1001,7 +1000,6 @@ class WCP_Folders
1001
  $width = $width - 40;
1002
  $string = "";
1003
  $css_text = "";
1004
- $css_text .= '.ui-state-highlight { background: transparent; border: dashed 1px #0073AA; width:150px; height: 25px !important; }';
1005
  $customize_folders = get_option('customize_folders');
1006
  if (isset($customize_folders['new_folder_color']) && !empty($customize_folders['new_folder_color'])) {
1007
  $css_text .= ".media-frame a.add-new-folder { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; border-color: " . esc_attr($customize_folders['new_folder_color']) . "}";
@@ -2773,10 +2771,8 @@ class WCP_Folders
2773
  if (self::is_active_for_screen()) {
2774
  global $typenow;
2775
  /* Free/Pro Version change */
2776
- wp_enqueue_script('wcp-folders-alert', plugin_dir_url(dirname(__FILE__)) . 'assets/js/livequery.min.js', array(), WCP_FOLDER_VERSION);
2777
- // wp_register_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/custom.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
2778
  wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jstree.min.js', array('jquery'), WCP_FOLDER_VERSION);
2779
- wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/folders.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
2780
 
2781
 
2782
  $post_type = self::get_custom_post_type($typenow);
965
  );
966
  }
967
 
 
968
  wp_enqueue_script('folders-tree', WCP_FOLDER_URL . 'assets/js/jstree.min.js', array(), WCP_FOLDER_VERSION, true);
969
  wp_enqueue_script('folders-media', WCP_FOLDER_URL . 'assets/js/page-post-media.min.js', array('media-editor', 'media-views', 'jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION, true);
970
  wp_localize_script('folders-media', 'folders_media_options', array(
1000
  $width = $width - 40;
1001
  $string = "";
1002
  $css_text = "";
 
1003
  $customize_folders = get_option('customize_folders');
1004
  if (isset($customize_folders['new_folder_color']) && !empty($customize_folders['new_folder_color'])) {
1005
  $css_text .= ".media-frame a.add-new-folder { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; border-color: " . esc_attr($customize_folders['new_folder_color']) . "}";
2771
  if (self::is_active_for_screen()) {
2772
  global $typenow;
2773
  /* Free/Pro Version change */
 
 
2774
  wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jstree.min.js', array('jquery'), WCP_FOLDER_VERSION);
2775
+ wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/folders.min.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
2776
 
2777
 
2778
  $post_type = self::get_custom_post_type($typenow);
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.6.1
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.6.1 =
166
  Various bugs fixed
167
 
2
  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.6
6
+ Stable tag: 2.6.2
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.2 =
166
+ WordPress 5.6 compatibility + Visual composer overlapping bug fixed
167
+
168
  = 2.6.1 =
169
  Various bugs fixed
170
 
templates/admin/admin-content.php CHANGED
@@ -14,12 +14,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
14
  ?>
15
  </style>
16
  <style>
17
- .ui-state-highlight {
18
- background: transparent;
19
- border: dashed 1px #0073AA;
20
- width:150px;
21
- height: 25px !important;
22
- }
23
  <?php
24
  if(isset($customize_folders['new_folder_color']) && !empty($customize_folders['new_folder_color'])) {
25
  ?>
14
  ?>
15
  </style>
16
  <style>
 
 
 
 
 
 
17
  <?php
18
  if(isset($customize_folders['new_folder_color']) && !empty($customize_folders['new_folder_color'])) {
19
  ?>