From cae8df8ffbd8907d22239e6719de33722f1482e6 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 17 Mar 2022 17:51:56 -0500 Subject: [PATCH] CONTENTBOX-1365 #resolve Paginated results in CBAdmin for Page Children returns non-parented results for page 2 --- .../contentbox-admin/includes/js/contentbox-app.js | 8 +++----- .../contentbox-admin/includes/js/contentbox-app.min.js | 2 +- workbench/resources/js/contentList.js | 9 +++------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.js b/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.js index aa742cd113..ba32d80218 100644 --- a/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.js +++ b/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.js @@ -1028,10 +1028,7 @@ const contentListHelper = ( () => { $searchField.keyup( _.debounce( function(){ - var $this = $( this ); - var clearIt = ( $this.val().length > 0 ? false : true ); - // ajax search - contentLoad( { search: $this.val() } ); + contentLoad( { search: $( this ).val() } ); }, 300 ) @@ -1073,7 +1070,7 @@ const contentListHelper = ( () => { contentLoad( { search : $searchField.val(), page : page, - parent : $parentID, + parent : History.getState().data.parent || $parentID, fAuthors : $( "#fAuthors" ).val(), fCategories : $( "#fCategories" ).val(), fStatus : $( "#fStatus" ).val(), @@ -1222,6 +1219,7 @@ const contentListHelper = ( () => { }; } )(); + /** ********************************************************************************* * Copyright since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp diff --git a/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.min.js b/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.min.js index 13dc8cb11d..d033de161d 100644 --- a/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.min.js +++ b/modules/contentbox/modules/contentbox-admin/includes/js/contentbox-app.min.js @@ -1 +1 @@ -function activateNavbarState(){var t=$("#container");$("#toggle-left").bind("click",(function(e){$(window).width()>768&&(sidemenuCollapse=t.hasClass("sidebar-mini")?"no":"yes",$.ajax({url:$("body").attr("data-preferenceURL"),data:{value:sidemenuCollapse,preference:"sidemenuCollapse"},async:!0}))}))}function isMainSidebarOpen(){var t=$("#main-content-sidebar");return void 0!==t.attr("id")&&"block"===t.css("display")}function toggleSidebar(){var t=$("#main-content-sidebar"),e=t.css("display"),a=!1;void 0!==e&&("block"===e?(t.fadeOut(),$("#main-content-sidebar-trigger i").removeClass("fa-minus-square").addClass("fa-plus-square"),$("#main-content-slot").removeClass("col-md-8").addClass("col-md-12")):($("#main-content-sidebar-trigger i").removeClass("fa-plus-square").addClass("fa-minus-square"),t.fadeIn(),$("#main-content-slot").removeClass("col-md-12").addClass("col-md-8"),a=!0),$.ajax({url:$("body").attr("data-preferenceURL"),data:{value:a,preference:"sidebarstate"},async:!0}))}function adminAction(t,e){"null"!=t&&($("#adminActionsIcon").addClass("fa-spin textOrange"),$.post(e,{targetModule:t},(function(t){t.ERROR?adminNotifier("error"," Error running action, check logs!"):adminNotifier("info"," Action Ran, Booya!"),$("#adminActionsIcon").removeClass("fa-spin textOrange")})))}function adminNotifier(t,e,a){switch(toastr.options={closeButton:!0,preventDuplicates:!0,progressBar:!0,showDuration:"300",timeOut:"2000",positionClass:"toast-top-center"},t){case"info":toastr.info(e);break;case"error":toastr.error(e);break;case"success":toastr.success(e);break;case"warning":toastr.warning(e);break;default:toastr.info(e)}}function activateContentSearch(){$nav_search=$("#nav-search"),$nav_search_results=$("#div-search-results"),$nav_search.css("opacity","0.8"),$nav_search.focusin((function(){$(this).animate({opacity:1},500,(function(){}))})).blur((function(){$(this).animate({opacity:.5},500,(function(){}))})),$nav_search.keyup(_.debounce((function(){var t=$(this);t.val().length>1&&$nav_search_results.load($("#nav-search-url").val(),{search:t.val()},(function(t){"none"===$nav_search_results.css("display")&&$nav_search_results.fadeIn().slideDown()}))}),300)),$("body").click((function(t){$(t.target).closest("#div-search").length||closeSearchBox()}))}function closeSearchBox(){$("#div-search-results").slideUp(),$("#nav-search").val("")}function quickLinks(t){"null"!=t&&(window.location=t)}function activateTooltips(){$("[title]").tooltip(toolTipSettings)}function hideAllTooltips(){$(".tooltip").hide()}function toggleFlickers(){$(".flickerMessages").slideToggle(),$(".flickers").fadeOut(3e3)}function closeRemoteModal(){$remoteModal.modal("hide")}function resetContainerForms(t){var e=t.find("form");e.length&&$(e[0]).clearForm()}function closeModal(t){t.modal("hide")}function openModal(t,e,a){t.modal(),$(t).on("hidden.bs.modal",(function(){resetContainerForms($(this))}))}function openRemoteModal(t,e,a,n,o){if(t){var i=$remoteModal,s=$(window).height()-200,r=.85*$(window).width();i.data("url",t),i.data("params",e),i.data("width",void 0!==a?a:r),i.data("height",void 0!==n?n:s);var l=i.data("height");l.search&&-1!==l.search("%")&&(l=l.replace("%","")/100,l=$(window).height()*l),l>s&&(l=s),i.data("height",l),o?(i.data("delay",!0),i.modal()):i.load(t,e,(function(){i.modal()}))}else console.log("URL needed")}function setPreviewSize(t,e){var a=$remoteModal.find(".modal-dialog"),n=($("#previewFrame").length&&$("#previewFrame"),{width:$remoteModal.data("width")}),o={width:e};(!e||o.width>n.width)&&(o={width:n.width}),$remoteModal.find(".header-title").toggle(o.width>600),$(t).siblings(".btn-primary").removeClass("btn-primary").addClass("btn-info"),$(t).removeClass("btn-info").addClass("btn-primary"),a.animate(o,500)}function attachModalListeners(){$remoteModal.on("show.bs.modal",(function(){var t=$remoteModal;t.find(".modal-dialog").css({width:t.data("width"),height:t.data("height")})})),$remoteModal.on("shown.bs.modal",(function(){var t=$remoteModal;t.data("delay")&&t.load(t.data("url"),t.data("params"),(function(){t.find(".modal-dialog").css({width:t.data("width"),height:t.data("height")})}))})),$remoteModal.on("hidden.bs.modal",(function(){var t=$remoteModal;t.html(''),resetContainerForms(t)}))}function activateToggleCheckboxes(){$('input[data-toggle="toggle"]').change((function(){var t=$(this).data("match");$("#"+t).val($(this).prop("checked"))}))}function closeConfirmations(){$confirmIt.modal("hide")}function activateConfirmations(){$confirmIt.find("button").click((function(t){"confirm"===$(this).attr("data-action")&&($confirmIt.find("#confirmItButtons").hide(),$confirmIt.find("#confirmItLoader").fadeIn(),window.location=$confirmIt.data("confirmSrc"))})),$(".confirmIt").click((function(t){$confirmIt.find("#confirmItButtons").fadeIn(),$confirmIt.find("#confirmItLoader").hide(),$confirmIt.data("confirmSrc",$(this).attr("href"));var e=$(this).attr("data-message")?$(this).attr("data-message"):"Are you sure you want to perform this action?",a=$(this).attr("data-title")?$(this).attr("data-title"):"Are you sure?";$confirmIt.find("#confirmItMessage").html(e),$confirmIt.find("#confirmItTitle").html(a),$confirmIt.modal(),t.preventDefault()}))}function popup(t,e,a){var n=750;e&&(minWidth=e),a&&(n=a);var o=screen.width/2-500,i=screen.height/2-n/2;window.open(t,"layoutPreview","resizable=yes,status=yes,location=no,menubar=no,toolbar=no,scrollbars=yes,width=1000,height="+n+",left="+o+",top="+i+",screenX="+o+",screenY="+i)}function to(t){return window.location=t,!1}function checkAll(t,e){$("input[name='"+e+"']").each((function(){this.checked=t}))}function checkByValue(t,e){$("input[name='"+t+"']").each((function(){this.value===e?this.checked=!0:this.checked=!1}))}function getToday(t){return(t=null==t||t)?moment().format("YYYY-MM-DD"):moment().format("DD-MM-YYYY")}function importContent(){var t=$("#importForm");openModal($importDialog,500,350),t.validate({submitHandler:function(e){t.find("#importButtonBar").slideUp(),t.find("#importBarLoader").slideDown(),e.submit()}}),t.find("#closeButton").click((function(t){return closeModal($importDialog),!1})),t.find("#importButton").click((function(e){t.submit()}))}function toggleMoreInfoPanel(t){$("#moreInfo-"+t).toggleClass("hidden"),$("#moreInfoOpenButton-"+t).toggleClass("hidden"),$("#moreInfoCloseButton-"+t).toggleClass("hidden")}function passwordMeter(t){var e=$(this).val();$("#pw_rule_count").html(e.length);var a=$("#passwordRules").data("min-length"),n={lower:REGEX_LOWER.test(e),upper:REGEX_UPPER.test(e),digit:REGEX_DIGIT.test(e),special:REGEX_SPECIAL.test(e)};for(var o in e.length>=a?$("#pw_rule_count").addClass("badge-success"):$("#pw_rule_count").removeClass("badge-success"),n)n[o]?$("#pw_rule_"+o).addClass("badge-success"):$("#pw_rule_"+o).removeClass("badge-success")}function passwordValidator(t){var e=$("#passwordRules").data("min-length"),a=REGEX_LOWER.test(t),n=REGEX_UPPER.test(t),o=REGEX_DIGIT.test(t),i=(REGEX_DIGITS.test(t),REGEX_SPECIAL.test(t));return a&&n&&o&&i&&t.length>=e}function toLocalString(t,e){return new Date(t).toLocaleString(void 0,e||getDefaultDateTimeOptions())}function toLocaleDateString(t,e){return new Date(t).toLocaleDateString(void 0,e||getDefaultDateTimeOptions())}function toLocaleTimeString(t,e){return new Date(t).toLocaleTimeString(void 0,e||getDefaultDateTimeOptions())}function getDefaultDateTimeOptions(){return{dateStyle:"medium",timeStyle:"long"}}function scrollToHash(t){location.hash="#"+t}document.addEventListener("DOMContentLoaded",(()=>{REGEX_LOWER=/[a-z]/,REGEX_UPPER=/[A-Z]/,REGEX_DIGIT=/[0-9]/,REGEX_DIGITS=/[0-9].*[0-9]/,REGEX_SPECIAL=/[^a-zA-Z0-9]/,"no"==$("body").attr("data-showsidebar")&&toggleSidebar(),void 0!==$("#main-content-sidebar").attr("id")&&$("#main-content-sidebar-trigger").fadeIn(),$confirmIt=$("#confirmIt"),$remoteModal=$("#modal"),attachModalListeners(),toolTipSettings={animation:"slide",delay:{show:100,hide:100}},activateContentSearch(),activateConfirmations(),activateTooltips(),activateNavbarState(),activateToggleCheckboxes(),$.validator.setDefaults({ignore:[],highlight:function(t){$(t).closest(".form-group").removeClass("success").addClass("error")},success:function(t){t.text("Field is valid").addClass("valid").closest(".form-group").removeClass("error").addClass("success"),t.remove()},errorPlacement:function(t,e){if($(e).is(":hidden"))return!1;t.appendTo(e.closest("div.controls"))}}),$.fn.resetValidations=function(){var t=this[0].currentForm;return $(t).find(".form-group").each((function(){$(this).removeClass("error").removeClass("success")})),$(t).find(":input").each((function(){$(this).removeClass("error").removeClass("valid")})),this},$.fn.clearForm=function(){if(void 0!==this.data("validator"))return this.data("validator").resetForm(),this.find(":input").each((function(){switch(this.type){case"password":case"hidden":case"select-multiple":case"select-one":case"text":case"textarea":$(this).val("");break;case"checkbox":case"radio":this.checked=!1}})),$(this.data("validator")).resetValidations(),this},$.fn.collect=function(){var t=this.serializeArray(),e={};return $.each(t,(function(t,a){e[a.name]=a.value})),e};setTimeout(toggleFlickers(),5e3);$((function(){var t=$('[href="'+location.hash+'"]');t&&t.tab("show")})),jwerty.key("ctrl+shift+s",(function(){return $("#nav-search").focus(),!1})),$("[data-keybinding]").each((function(){var t=$(this);jwerty.key(t.data("keybinding"),(function(){t.attr("onclick")?t.click():to(t.attr("href"))}))})),$("#main-navbar li.nav-dropdown").each((function(){$(this).find("ul.nav-sub li").length||$(this).hide()})),$(".accordion[data-stateful]").each((function(){var t,e=$(this),a=e.data("stateful");a&&null!==(t=$.cookie(a))&&(e.find(".collapse").removeClass("in"),$("#"+t).addClass("in")),e.bind("shown.bs.collapse",(function(){var t=e.find(".in").attr("id");$.cookie(a,t)}))}))}));var app=function(){var t=function(){$("#toggle-left").tooltip({delay:100})},e=function(){$(".actions > .fa-chevron-down").click((function(){$(this).parent().parent().next().slideToggle("fast"),$(this).toggleClass("fa-chevron-down fa-chevron-up")}))},a=function(){$("#toggle-left").bind("click",(function(t){$("body").removeClass("off-canvas-open");var e=$("#container");$(window).width()>767?$(e).toggleClass("sidebar-mini"):$(e).toggleClass("sidebar-opened")}))},n=function(){$("#toggle-right").click((function(){$(".off-canvas").toggleClass("off-canvas-open")}))},o=function(){Array.prototype.slice.call(document.querySelectorAll(".js-switch")).forEach((function(t){new Switchery(t,{size:"small"})}))},i=function(){$(".actions > .fa-times").click((function(){$(this).parent().parent().parent().fadeOut()}))},s=function(){var t=$(".sidebar .nav");$(t).navgoco({caretHtml:!1,accordion:!0,slide:{duration:400,easing:"swing"}})};return{init:function(){t(),a(),n(),o(),s(),e(),i()},sliders:function(){$(".slider-span").slider()},morrisPie:function(){Morris.Donut({element:"donut-example",data:[{label:"Chrome",value:73},{label:"Firefox",value:71},{label:"Safari",value:69},{label:"Internet Explorer",value:40},{label:"Opera",value:20},{label:"Android Browser",value:10}],colors:["#1abc9c","#293949","#e84c3d","#3598db","#2dcc70","#f1c40f"]})}}}();document.addEventListener("DOMContentLoaded",(()=>{app.init();var t=$("#container");$(window).width()<=768&&!$(t).hasClass("sidebar-mini")&&($("body").removeClass("off-canvas-open"),$(t).toggleClass("sidebar-mini"))}));const contentListHelper=(()=>{const t={"Content-type":"application/json;charset=UTF-8"};var e="",a="",n="",o="",i="",s="",r="",l="",c="",d=t=>{null==t&&(t={}),"search"in t||(t.search=""),"page"in t||(t.page=1),"parent"in t||(t.parent=""),"fAuthors"in t||(t.fAuthors="all"),"fCreators"in t||(t.fCreators="all"),"fCategories"in t||(t.fCategories="all"),"fStatus"in t||(t.fStatus="any"),"showAll"in t||(t.showAll=!1),a.css("opacity",.6);var e={page:t.page,parent:t.parent,fAuthors:t.fAuthors,fCategories:t.fCategories,fStatus:t.fStatus,showAll:t.showAll,fCreators:t.fCreators};e[i]=t.search,a.load(n,e,(function(){a.css("opacity",1),$(this).fadeIn("fast")}))},f=()=>{"all"!=$("#fAuthors").val()||"all"!=$("#fCreators").val()||"all"!=$("#fCategories").val()||"any"!=$("#fStatus").val()?$("#filterBox").addClass("selected"):$("#filterBox").removeClass("selected"),d({fAuthors:$("#fAuthors").val(),fCategories:$("#fCategories").val(),fStatus:$("#fStatus").val(),fCreators:$("#fCreators").val()})},u=t=>{t&&d(),$("#filterBox").removeClass("selected"),$("#fAuthors").val("all"),$("#fCategories").val("all"),$("#fStatus").val("any"),$("#fCreators").val("all")};return{init:t=>{e=t.adminEntryPoint,a=t.tableContainer,n=t.tableURL,o=t.searchField,i=t.searchName,s=t.contentForm,r=t.bulkStatusURL,l=t.cloneDialog,c=t.parentID,History.Adapter.bind(window,"statechange",(function(){d({parent:History.getState().data.parent})})),o.keyup(_.debounce((function(){var t=$(this);t.val().length;d({search:t.val()})}),300)),c.length?d({parent:c}):d({})},contentLoad:d,contentFilter:f,resetFilter:u,contentDrilldown:t=>{u(),null==t&&(t=""),o.val(""),History.pushState({parent:t},document.title,"?parent="+t),scrollToHash("container")},contentShowAll:()=>{u(),d({showAll:!0})},contentPaginate:t=>{d({search:o.val(),page:t,parent:c,fAuthors:$("#fAuthors").val(),fCategories:$("#fCategories").val(),fStatus:$("#fStatus").val(),fCreators:$("#fCreators").val()})},getInfoPanelContent:t=>$("#infoPanel_"+t).html(),activateInfoPanels:()=>{$(".popovers").popover({html:!0,content:function(){return getInfoPanelContent($(this).attr("data-contentID"))},trigger:"hover",placement:"left",title:' Quick Info',delay:{show:200,hide:500}})},activateQuickLook:(t,e)=>{t.find("tr").bind("contextmenu",(function(t){3===t.which&&null!=$(this).attr("data-contentID")&&(openRemoteModal(e+$(this).attr("data-contentID")),t.preventDefault())}))},remove:(t,e)=>{checkAll(!1,e=void 0!==e?e:"contentID"),null!=t&&($("#delete_"+t).removeClass("fa fa-minus-circle").addClass("fa fa-spinner fa-spin"),checkByValue(e,t)),s.submit()},bulkRemove:()=>{s.submit()},exportSelected:t=>{var e=[];$("#contentID:checked").each((function(){e.push($(this).val())})),e.length?(checkAll(!1,"contentID"),window.open(t+"/contentID/"+e)):alert("Please select something to export!")},bulkChangeStatus:(t,e)=>{s.attr("action",r),s.find("#contentStatus").val(t),null!=e&&($("#status_"+recordID).removeClass("fa fa-minus-circle").addClass("fa fa-spinner fa-spin"),checkByValue("contentID",e)),s.submit()},openCloneDialog:(t,e)=>{var a=l.find("#cloneForm");openModal(l,500),a.validate({submitHandler:function(t){l.find("#cloneButtonBar").slideUp(),l.find("#clonerBarLoader").slideDown(),t.submit()}}),a.find("#contentID").val(t),a.find("#title").val(e).focus(),l.find("#cloneButton").click((function(t){a.submit()}))},resetHits:a=>{a.length&&fetch(e+"/content/resetHits",{method:"POST",headers:t,body:JSON.stringify({contentID:a})}).then((t=>t.json())).then((t=>{t.error?alert("Error Reseting Hits: "+t.messages.join(",")):(adminNotifier("info",t.messages.join("
"),3e3),f())})).catch((t=>{alert("Error Reseting Hits: "+t)}))},resetBulkHits:()=>{var t=[];$("#contentID:checked").each((function(){t.push($(this).val())})),t.length&&resetHits(t.join(","))}}})();function fbCKSelect(t,e,a){if(t.length&&"dir"!==a){var n,o,i=(n=new RegExp("(?:[?&]|&)"+"CKEditorFuncNum"+"=([^&]+)","i"),(o=window.location.search.match(n))&&o.length>1?o[1]:"");window.opener.CKEDITOR.tools.callFunction(i,e),window.close()}else alert("Please select a file first.")}function fbGenericClose(){window.close()}function fbTestChoose(t,e,a){alert("Path: "+t+"\n URL: "+e+"\n Type: "+a)}function fbTestCancel(){alert("Cancel Called")}function fbUpload(){$("#uploadBar").slideToggle()}function fbVerifyActiveView(){let t="#"+$listType.val()+$listFolder.val();$(t).removeClass("btn-more").addClass("btn-default")} \ No newline at end of file +function activateNavbarState(){var t=$("#container");$("#toggle-left").bind("click",(function(e){$(window).width()>768&&(sidemenuCollapse=t.hasClass("sidebar-mini")?"no":"yes",$.ajax({url:$("body").attr("data-preferenceURL"),data:{value:sidemenuCollapse,preference:"sidemenuCollapse"},async:!0}))}))}function isMainSidebarOpen(){var t=$("#main-content-sidebar");return void 0!==t.attr("id")&&"block"===t.css("display")}function toggleSidebar(){var t=$("#main-content-sidebar"),e=t.css("display"),a=!1;void 0!==e&&("block"===e?(t.fadeOut(),$("#main-content-sidebar-trigger i").removeClass("fa-minus-square").addClass("fa-plus-square"),$("#main-content-slot").removeClass("col-md-8").addClass("col-md-12")):($("#main-content-sidebar-trigger i").removeClass("fa-plus-square").addClass("fa-minus-square"),t.fadeIn(),$("#main-content-slot").removeClass("col-md-12").addClass("col-md-8"),a=!0),$.ajax({url:$("body").attr("data-preferenceURL"),data:{value:a,preference:"sidebarstate"},async:!0}))}function adminAction(t,e){"null"!=t&&($("#adminActionsIcon").addClass("fa-spin textOrange"),$.post(e,{targetModule:t},(function(t){t.ERROR?adminNotifier("error"," Error running action, check logs!"):adminNotifier("info"," Action Ran, Booya!"),$("#adminActionsIcon").removeClass("fa-spin textOrange")})))}function adminNotifier(t,e,a){switch(toastr.options={closeButton:!0,preventDuplicates:!0,progressBar:!0,showDuration:"300",timeOut:"2000",positionClass:"toast-top-center"},t){case"info":toastr.info(e);break;case"error":toastr.error(e);break;case"success":toastr.success(e);break;case"warning":toastr.warning(e);break;default:toastr.info(e)}}function activateContentSearch(){$nav_search=$("#nav-search"),$nav_search_results=$("#div-search-results"),$nav_search.css("opacity","0.8"),$nav_search.focusin((function(){$(this).animate({opacity:1},500,(function(){}))})).blur((function(){$(this).animate({opacity:.5},500,(function(){}))})),$nav_search.keyup(_.debounce((function(){var t=$(this);t.val().length>1&&$nav_search_results.load($("#nav-search-url").val(),{search:t.val()},(function(t){"none"===$nav_search_results.css("display")&&$nav_search_results.fadeIn().slideDown()}))}),300)),$("body").click((function(t){$(t.target).closest("#div-search").length||closeSearchBox()}))}function closeSearchBox(){$("#div-search-results").slideUp(),$("#nav-search").val("")}function quickLinks(t){"null"!=t&&(window.location=t)}function activateTooltips(){$("[title]").tooltip(toolTipSettings)}function hideAllTooltips(){$(".tooltip").hide()}function toggleFlickers(){$(".flickerMessages").slideToggle(),$(".flickers").fadeOut(3e3)}function closeRemoteModal(){$remoteModal.modal("hide")}function resetContainerForms(t){var e=t.find("form");e.length&&$(e[0]).clearForm()}function closeModal(t){t.modal("hide")}function openModal(t,e,a){t.modal(),$(t).on("hidden.bs.modal",(function(){resetContainerForms($(this))}))}function openRemoteModal(t,e,a,n,o){if(t){var i=$remoteModal,s=$(window).height()-200,r=.85*$(window).width();i.data("url",t),i.data("params",e),i.data("width",void 0!==a?a:r),i.data("height",void 0!==n?n:s);var l=i.data("height");l.search&&-1!==l.search("%")&&(l=l.replace("%","")/100,l=$(window).height()*l),l>s&&(l=s),i.data("height",l),o?(i.data("delay",!0),i.modal()):i.load(t,e,(function(){i.modal()}))}else console.log("URL needed")}function setPreviewSize(t,e){var a=$remoteModal.find(".modal-dialog"),n=($("#previewFrame").length&&$("#previewFrame"),{width:$remoteModal.data("width")}),o={width:e};(!e||o.width>n.width)&&(o={width:n.width}),$remoteModal.find(".header-title").toggle(o.width>600),$(t).siblings(".btn-primary").removeClass("btn-primary").addClass("btn-info"),$(t).removeClass("btn-info").addClass("btn-primary"),a.animate(o,500)}function attachModalListeners(){$remoteModal.on("show.bs.modal",(function(){var t=$remoteModal;t.find(".modal-dialog").css({width:t.data("width"),height:t.data("height")})})),$remoteModal.on("shown.bs.modal",(function(){var t=$remoteModal;t.data("delay")&&t.load(t.data("url"),t.data("params"),(function(){t.find(".modal-dialog").css({width:t.data("width"),height:t.data("height")})}))})),$remoteModal.on("hidden.bs.modal",(function(){var t=$remoteModal;t.html(''),resetContainerForms(t)}))}function activateToggleCheckboxes(){$('input[data-toggle="toggle"]').change((function(){var t=$(this).data("match");$("#"+t).val($(this).prop("checked"))}))}function closeConfirmations(){$confirmIt.modal("hide")}function activateConfirmations(){$confirmIt.find("button").click((function(t){"confirm"===$(this).attr("data-action")&&($confirmIt.find("#confirmItButtons").hide(),$confirmIt.find("#confirmItLoader").fadeIn(),window.location=$confirmIt.data("confirmSrc"))})),$(".confirmIt").click((function(t){$confirmIt.find("#confirmItButtons").fadeIn(),$confirmIt.find("#confirmItLoader").hide(),$confirmIt.data("confirmSrc",$(this).attr("href"));var e=$(this).attr("data-message")?$(this).attr("data-message"):"Are you sure you want to perform this action?",a=$(this).attr("data-title")?$(this).attr("data-title"):"Are you sure?";$confirmIt.find("#confirmItMessage").html(e),$confirmIt.find("#confirmItTitle").html(a),$confirmIt.modal(),t.preventDefault()}))}function popup(t,e,a){var n=750;e&&(minWidth=e),a&&(n=a);var o=screen.width/2-500,i=screen.height/2-n/2;window.open(t,"layoutPreview","resizable=yes,status=yes,location=no,menubar=no,toolbar=no,scrollbars=yes,width=1000,height="+n+",left="+o+",top="+i+",screenX="+o+",screenY="+i)}function to(t){return window.location=t,!1}function checkAll(t,e){$("input[name='"+e+"']").each((function(){this.checked=t}))}function checkByValue(t,e){$("input[name='"+t+"']").each((function(){this.value===e?this.checked=!0:this.checked=!1}))}function getToday(t){return(t=null==t||t)?moment().format("YYYY-MM-DD"):moment().format("DD-MM-YYYY")}function importContent(){var t=$("#importForm");openModal($importDialog,500,350),t.validate({submitHandler:function(e){t.find("#importButtonBar").slideUp(),t.find("#importBarLoader").slideDown(),e.submit()}}),t.find("#closeButton").click((function(t){return closeModal($importDialog),!1})),t.find("#importButton").click((function(e){t.submit()}))}function toggleMoreInfoPanel(t){$("#moreInfo-"+t).toggleClass("hidden"),$("#moreInfoOpenButton-"+t).toggleClass("hidden"),$("#moreInfoCloseButton-"+t).toggleClass("hidden")}function passwordMeter(t){var e=$(this).val();$("#pw_rule_count").html(e.length);var a=$("#passwordRules").data("min-length"),n={lower:REGEX_LOWER.test(e),upper:REGEX_UPPER.test(e),digit:REGEX_DIGIT.test(e),special:REGEX_SPECIAL.test(e)};for(var o in e.length>=a?$("#pw_rule_count").addClass("badge-success"):$("#pw_rule_count").removeClass("badge-success"),n)n[o]?$("#pw_rule_"+o).addClass("badge-success"):$("#pw_rule_"+o).removeClass("badge-success")}function passwordValidator(t){var e=$("#passwordRules").data("min-length"),a=REGEX_LOWER.test(t),n=REGEX_UPPER.test(t),o=REGEX_DIGIT.test(t),i=(REGEX_DIGITS.test(t),REGEX_SPECIAL.test(t));return a&&n&&o&&i&&t.length>=e}function toLocalString(t,e){return new Date(t).toLocaleString(void 0,e||getDefaultDateTimeOptions())}function toLocaleDateString(t,e){return new Date(t).toLocaleDateString(void 0,e||getDefaultDateTimeOptions())}function toLocaleTimeString(t,e){return new Date(t).toLocaleTimeString(void 0,e||getDefaultDateTimeOptions())}function getDefaultDateTimeOptions(){return{dateStyle:"medium",timeStyle:"long"}}function scrollToHash(t){location.hash="#"+t}document.addEventListener("DOMContentLoaded",(()=>{REGEX_LOWER=/[a-z]/,REGEX_UPPER=/[A-Z]/,REGEX_DIGIT=/[0-9]/,REGEX_DIGITS=/[0-9].*[0-9]/,REGEX_SPECIAL=/[^a-zA-Z0-9]/,"no"==$("body").attr("data-showsidebar")&&toggleSidebar(),void 0!==$("#main-content-sidebar").attr("id")&&$("#main-content-sidebar-trigger").fadeIn(),$confirmIt=$("#confirmIt"),$remoteModal=$("#modal"),attachModalListeners(),toolTipSettings={animation:"slide",delay:{show:100,hide:100}},activateContentSearch(),activateConfirmations(),activateTooltips(),activateNavbarState(),activateToggleCheckboxes(),$.validator.setDefaults({ignore:[],highlight:function(t){$(t).closest(".form-group").removeClass("success").addClass("error")},success:function(t){t.text("Field is valid").addClass("valid").closest(".form-group").removeClass("error").addClass("success"),t.remove()},errorPlacement:function(t,e){if($(e).is(":hidden"))return!1;t.appendTo(e.closest("div.controls"))}}),$.fn.resetValidations=function(){var t=this[0].currentForm;return $(t).find(".form-group").each((function(){$(this).removeClass("error").removeClass("success")})),$(t).find(":input").each((function(){$(this).removeClass("error").removeClass("valid")})),this},$.fn.clearForm=function(){if(void 0!==this.data("validator"))return this.data("validator").resetForm(),this.find(":input").each((function(){switch(this.type){case"password":case"hidden":case"select-multiple":case"select-one":case"text":case"textarea":$(this).val("");break;case"checkbox":case"radio":this.checked=!1}})),$(this.data("validator")).resetValidations(),this},$.fn.collect=function(){var t=this.serializeArray(),e={};return $.each(t,(function(t,a){e[a.name]=a.value})),e};setTimeout(toggleFlickers(),5e3);$((function(){var t=$('[href="'+location.hash+'"]');t&&t.tab("show")})),jwerty.key("ctrl+shift+s",(function(){return $("#nav-search").focus(),!1})),$("[data-keybinding]").each((function(){var t=$(this);jwerty.key(t.data("keybinding"),(function(){t.attr("onclick")?t.click():to(t.attr("href"))}))})),$("#main-navbar li.nav-dropdown").each((function(){$(this).find("ul.nav-sub li").length||$(this).hide()})),$(".accordion[data-stateful]").each((function(){var t,e=$(this),a=e.data("stateful");a&&null!==(t=$.cookie(a))&&(e.find(".collapse").removeClass("in"),$("#"+t).addClass("in")),e.bind("shown.bs.collapse",(function(){var t=e.find(".in").attr("id");$.cookie(a,t)}))}))}));var app=function(){var t=function(){$("#toggle-left").tooltip({delay:100})},e=function(){$(".actions > .fa-chevron-down").click((function(){$(this).parent().parent().next().slideToggle("fast"),$(this).toggleClass("fa-chevron-down fa-chevron-up")}))},a=function(){$("#toggle-left").bind("click",(function(t){$("body").removeClass("off-canvas-open");var e=$("#container");$(window).width()>767?$(e).toggleClass("sidebar-mini"):$(e).toggleClass("sidebar-opened")}))},n=function(){$("#toggle-right").click((function(){$(".off-canvas").toggleClass("off-canvas-open")}))},o=function(){Array.prototype.slice.call(document.querySelectorAll(".js-switch")).forEach((function(t){new Switchery(t,{size:"small"})}))},i=function(){$(".actions > .fa-times").click((function(){$(this).parent().parent().parent().fadeOut()}))},s=function(){var t=$(".sidebar .nav");$(t).navgoco({caretHtml:!1,accordion:!0,slide:{duration:400,easing:"swing"}})};return{init:function(){t(),a(),n(),o(),s(),e(),i()},sliders:function(){$(".slider-span").slider()},morrisPie:function(){Morris.Donut({element:"donut-example",data:[{label:"Chrome",value:73},{label:"Firefox",value:71},{label:"Safari",value:69},{label:"Internet Explorer",value:40},{label:"Opera",value:20},{label:"Android Browser",value:10}],colors:["#1abc9c","#293949","#e84c3d","#3598db","#2dcc70","#f1c40f"]})}}}();document.addEventListener("DOMContentLoaded",(()=>{app.init();var t=$("#container");$(window).width()<=768&&!$(t).hasClass("sidebar-mini")&&($("body").removeClass("off-canvas-open"),$(t).toggleClass("sidebar-mini"))}));const contentListHelper=(()=>{const t={"Content-type":"application/json;charset=UTF-8"};var e="",a="",n="",o="",i="",s="",r="",l="",c="",d=t=>{null==t&&(t={}),"search"in t||(t.search=""),"page"in t||(t.page=1),"parent"in t||(t.parent=""),"fAuthors"in t||(t.fAuthors="all"),"fCreators"in t||(t.fCreators="all"),"fCategories"in t||(t.fCategories="all"),"fStatus"in t||(t.fStatus="any"),"showAll"in t||(t.showAll=!1),a.css("opacity",.6);var e={page:t.page,parent:t.parent,fAuthors:t.fAuthors,fCategories:t.fCategories,fStatus:t.fStatus,showAll:t.showAll,fCreators:t.fCreators};e[i]=t.search,a.load(n,e,(function(){a.css("opacity",1),$(this).fadeIn("fast")}))},f=()=>{"all"!=$("#fAuthors").val()||"all"!=$("#fCreators").val()||"all"!=$("#fCategories").val()||"any"!=$("#fStatus").val()?$("#filterBox").addClass("selected"):$("#filterBox").removeClass("selected"),d({fAuthors:$("#fAuthors").val(),fCategories:$("#fCategories").val(),fStatus:$("#fStatus").val(),fCreators:$("#fCreators").val()})},u=t=>{t&&d(),$("#filterBox").removeClass("selected"),$("#fAuthors").val("all"),$("#fCategories").val("all"),$("#fStatus").val("any"),$("#fCreators").val("all")};return{init:t=>{e=t.adminEntryPoint,a=t.tableContainer,n=t.tableURL,o=t.searchField,i=t.searchName,s=t.contentForm,r=t.bulkStatusURL,l=t.cloneDialog,c=t.parentID,History.Adapter.bind(window,"statechange",(function(){d({parent:History.getState().data.parent})})),o.keyup(_.debounce((function(){d({search:$(this).val()})}),300)),c.length?d({parent:c}):d({})},contentLoad:d,contentFilter:f,resetFilter:u,contentDrilldown:t=>{u(),null==t&&(t=""),o.val(""),History.pushState({parent:t},document.title,"?parent="+t),scrollToHash("container")},contentShowAll:()=>{u(),d({showAll:!0})},contentPaginate:t=>{d({search:o.val(),page:t,parent:History.getState().data.parent||c,fAuthors:$("#fAuthors").val(),fCategories:$("#fCategories").val(),fStatus:$("#fStatus").val(),fCreators:$("#fCreators").val()})},getInfoPanelContent:t=>$("#infoPanel_"+t).html(),activateInfoPanels:()=>{$(".popovers").popover({html:!0,content:function(){return getInfoPanelContent($(this).attr("data-contentID"))},trigger:"hover",placement:"left",title:' Quick Info',delay:{show:200,hide:500}})},activateQuickLook:(t,e)=>{t.find("tr").bind("contextmenu",(function(t){3===t.which&&null!=$(this).attr("data-contentID")&&(openRemoteModal(e+$(this).attr("data-contentID")),t.preventDefault())}))},remove:(t,e)=>{checkAll(!1,e=void 0!==e?e:"contentID"),null!=t&&($("#delete_"+t).removeClass("fa fa-minus-circle").addClass("fa fa-spinner fa-spin"),checkByValue(e,t)),s.submit()},bulkRemove:()=>{s.submit()},exportSelected:t=>{var e=[];$("#contentID:checked").each((function(){e.push($(this).val())})),e.length?(checkAll(!1,"contentID"),window.open(t+"/contentID/"+e)):alert("Please select something to export!")},bulkChangeStatus:(t,e)=>{s.attr("action",r),s.find("#contentStatus").val(t),null!=e&&($("#status_"+recordID).removeClass("fa fa-minus-circle").addClass("fa fa-spinner fa-spin"),checkByValue("contentID",e)),s.submit()},openCloneDialog:(t,e)=>{var a=l.find("#cloneForm");openModal(l,500),a.validate({submitHandler:function(t){l.find("#cloneButtonBar").slideUp(),l.find("#clonerBarLoader").slideDown(),t.submit()}}),a.find("#contentID").val(t),a.find("#title").val(e).focus(),l.find("#cloneButton").click((function(t){a.submit()}))},resetHits:a=>{a.length&&fetch(e+"/content/resetHits",{method:"POST",headers:t,body:JSON.stringify({contentID:a})}).then((t=>t.json())).then((t=>{t.error?alert("Error Reseting Hits: "+t.messages.join(",")):(adminNotifier("info",t.messages.join("
"),3e3),f())})).catch((t=>{alert("Error Reseting Hits: "+t)}))},resetBulkHits:()=>{var t=[];$("#contentID:checked").each((function(){t.push($(this).val())})),t.length&&resetHits(t.join(","))}}})();function fbCKSelect(t,e,a){if(t.length&&"dir"!==a){var n,o,i=(n=new RegExp("(?:[?&]|&)"+"CKEditorFuncNum"+"=([^&]+)","i"),(o=window.location.search.match(n))&&o.length>1?o[1]:"");window.opener.CKEDITOR.tools.callFunction(i,e),window.close()}else alert("Please select a file first.")}function fbGenericClose(){window.close()}function fbTestChoose(t,e,a){alert("Path: "+t+"\n URL: "+e+"\n Type: "+a)}function fbTestCancel(){alert("Cancel Called")}function fbUpload(){$("#uploadBar").slideToggle()}function fbVerifyActiveView(){let t="#"+$listType.val()+$listFolder.val();$(t).removeClass("btn-more").addClass("btn-default")} \ No newline at end of file diff --git a/workbench/resources/js/contentList.js b/workbench/resources/js/contentList.js index 52d99d5ffb..6f5be1e18b 100644 --- a/workbench/resources/js/contentList.js +++ b/workbench/resources/js/contentList.js @@ -111,10 +111,7 @@ const contentListHelper = ( () => { $searchField.keyup( _.debounce( function(){ - var $this = $( this ); - var clearIt = ( $this.val().length > 0 ? false : true ); - // ajax search - contentLoad( { search: $this.val() } ); + contentLoad( { search: $( this ).val() } ); }, 300 ) @@ -156,7 +153,7 @@ const contentListHelper = ( () => { contentLoad( { search : $searchField.val(), page : page, - parent : $parentID, + parent : History.getState().data.parent || $parentID, fAuthors : $( "#fAuthors" ).val(), fCategories : $( "#fCategories" ).val(), fStatus : $( "#fStatus" ).val(), @@ -304,4 +301,4 @@ const contentListHelper = ( () => { } }; -} )(); \ No newline at end of file +} )();