praiadeseselle/wire/modules/Process/ProcessPageList/ProcessPageList.min.js

1 line
28 KiB
JavaScript
Raw Normal View History

function ProcessPageListInit(){if(ProcessWire.config.ProcessPageList){$("#"+ProcessWire.config.ProcessPageList.containerID).ProcessPageList(ProcessWire.config.ProcessPageList)}}$(document).ready(function(){ProcessPageListInit()});(function($){$.fn.ProcessPageList=function(customOptions){var options={mode:"",limit:35,rootPageID:0,showRootPage:true,selectedPageID:0,adminPageID:2,trashPageID:7,langID:0,selectAllowUnselect:false,selectShowPageHeader:true,selectShowPath:true,selectMultiple:false,selectStartLabel:"Change",selectCancelLabel:"Cancel",selectSelectLabel:"Select",selectUnselectLabel:"Unselect",moreLabel:"More",trashLabel:"Trash",moveInstructionLabel:"Click and drag to move",selectSelectHref:"#",selectUnselectHref:"#",ajaxURL:ProcessWire.config.urls.admin+"page/list/",ajaxMoveURL:ProcessWire.config.urls.admin+"page/sort/",paginationClass:"PageListPagination",paginationCurrentClass:"PageListPaginationCurrent",paginationLinkClass:"ui-state-default",paginationLinkCurrentClass:"ui-state-active",paginationHoverClass:"ui-state-hover",paginationDisabledClass:"ui-priority-secondary",openPagination:0,openPageIDs:[],openPageData:{},speed:200,useHoverActions:false,hoverActionDelay:250,hoverActionFade:150,useNarrowActions:$("body").hasClass("pw-narrow-width"),spinnerMarkup:"<span class='PageListLoading'><i class='ui-priority-secondary fa fa-fw fa-spin fa-spinner'></i></span>",labelName:"",qtyType:""};var currentOpenPageIDs=[];var ignoreClicks=false;var isModal=$("body").hasClass("modal")||$("body").hasClass("pw-iframe");if(typeof ProcessWire.config.ProcessPageList!="undefined"){$.extend(options,ProcessWire.config.ProcessPageList)}$.extend(options,customOptions);return this.each(function(index){var $container=$(this);var $outer;var $root;var $loading=$(options.spinnerMarkup);var firstPagination=0;var curPagination=0;function init(){$root=$("<div class='PageListRoot'></div>");if($container.is(":input")){options.selectedPageID=$container.val();if(!options.selectedPageID.length)options.selectedPageID=0;options.mode="select";$container.before($root);$outer=$container.closest(".InputfieldContent");setupSelectMode()}else{options.mode="actions";$container.append($root);$outer=$container;loadChildren(options.rootPageID>0?options.rootPageID:1,$root,0,true)}$(document).on("pageListRefresh",function(e,pageID){refreshList(pageID)});if(options.useHoverActions){$root.addClass("PageListUseHoverActions");setupHoverActions()}}function setupHoverActions(){var hoverTimeout=null;var hoverOutTimeout=null;var $hoveredItem=null;function showItem($item){var $actions=$item.find(".PageListActions");if(!$actions.is(":visible")||$item.hasClass("PageListItemOpen")){$item.addClass("PageListItemHover");$actions.css("display","inline").css("opacity",0).animate({opacity:1},options.hoverActionFade)}}function hideItem($item){var $actions=$item.find(".PageListActions");$item.removeClass("PageListItemHover");if($actions.is(":visible")){$actions.animate({opacity:0},options.hoverActionFade,function(){$actions.hide()})}}$outer.on("keydown",".PageListItem",function(e){e=e||window.event;if(e.keyCode==0||e.keyCode==32){var $actions=$(this).find(".PageListActions");if($actions.is(":visible")){$actions.css("display","none")}else{$actions.css("display","inline-block")}return false}});$outer.on("mouseover",".PageListItem",function(e){if($root.is(".PageListSorting")||$root.is(".PageListSortSaving"))return;var $a=$(this).children("a").first();if($a.length&&!$a.is(":hover"))return;$hoveredItem=$(this);if($hoveredItem.hasClass("PageListItemHover"))return;var $item=$(this);if(hoverTimeout)clearTimeout(hoverTimeout);var delay=options.hoverActionDelay;hoverTimeout=setTimeout(function(){if($hoveredItem.attr("class")==$item.attr("class")){var $a=$hoveredItem.children("a").first();if($a.length&&!$a.is(":hover"))return;var $hideItems=$outer.find(".PageListItemHover");showItem($hoveredItem);$hideItems.each(function(){hideItem($(this))})}},delay)}).on("mouseout",".PageListItem",function(e){if($root.is(".PageListSorting")||$root.is(".PageListSortSaving"))return;var $item=$(this);if($item