wire/modules/Process/ProcessPageList/ProcessPageList.js
/**
			 * Event called when the mouse stops after performing a 'move'
			 *
			 * @param event e
			 * @param jQueryUI ui
			 * @return bool
			 *
			 */
Event called when the mouse stops after performing a 'move'
@param event e
@param jQueryUI ui
@return bool
Event called when the mouse stops after performing a ' move ' @param event e @param jQueryUI ui @return bool
function stopMove(e, ui) {
				var $li = ui.item; 
				var $a = $li.children('.PageListPage'); 
				var id = parseInt($li.data('pageId')); 
				var $ul = $li.parent('.PageList'); 
				var $from = $("#PageListMoveFrom")
				var $ulPrev = $ul.prev().is('.PageListItem') ? $ul.prev() : $ul.prev().prev();
				var parent_id = parseInt($ulPrev.data('pageId')); 
				var $liPrev = $li.prev(".PageListItem"); 
				if($liPrev.is(".PageListItemOpen")) return false; 
				if($ul.is('.PageListPlaceholder')) {
					var $ulNext = $ul.next();
					if($ulNext.is('.PageList:visible')) {
						$ulNext.prepend($li);
						$ul = $ulNext;
					} else {
						$ul.removeClass('PageListPlaceholder').children('.PageListPlaceholderItem').remove();
					}
				}
				$root.addClass('PageListSortSaving'); 
				cancelMove($li); 
				$li.append($loading.fadeIn('fast')); 
				var sortCSV = '';
				$ul.children(".PageListItem").each(function() {
					sortCSV += $(this).data('pageId') + ','; 
				}); 
				var postData = {
					id: id, 
					parent_id: parent_id, 
					sort: sortCSV
				}; 
				postData[$('#PageListContainer').attr('data-token-name')] = $('#PageListContainer').attr('data-token-value'); 
				var success = 'unknown'; 
				$.post(options.ajaxMoveURL, postData, function(data) {
					$loading.fadeOut('fast');
					$a.fadeOut('fast', function() {
						$(this).fadeIn("fast")
						$li.removeClass('PageListSortItem'); 
						$root.removeClass('PageListSorting');
					}); 
					if(data && data.error) {
						ProcessWire.alert(data.message); 
					}
					if(!$ul.is("#PageListMoveFrom")) {
						var $fromItem = $from.prev(".PageListItem"); 	
						var numChildren = getNumChildren($fromItem);
						var numTotal = getNumTotal($fromItem);
						if(numChildren > 0) {
							numChildren--;
							adjustNumTotal($fromItem, -1);
						} else {
							$from.remove(); 
						}
						setNumChildren($fromItem, numChildren, false);
						setForceReload($fromItem);
						var $toItem = $ul.prev(".PageListItem"); 
						numChildren = getNumChildren($toItem) + 1;
						adjustNumTotal($toItem, 1);
						setNumChildren($toItem, numChildren, false);
						setForceReload($toItem);
					}
					$from.attr('id', ''); 
					$root.removeClass('PageListSortSaving'); 
				}, 'json'); 
				$li.trigger('pageMoved'); 
				return true; 
			}
function stopMove ( e , ui ) { var $li = ui . item ; var $a = $li . children ( '.PageListPage' ) ; var id = parseInt ( $li . data ( 'pageId' ) ) ; var $ul = $li . parent ( '.PageList' ) ; var $from = $ ( "#PageListMoveFrom" ) var $ulPrev = $ul . prev ( ) . is ( '.PageListItem' ) ? $ul . prev ( ) : $ul . prev ( ) . prev ( ) ; var parent_id = parseInt ( $ulPrev . data ( 'pageId' ) ) ; var $liPrev = $li . prev ( ".PageListItem" ) ; if ( $liPrev . is ( ".PageListItemOpen" ) ) return false ; if ( $ul . is ( '.PageListPlaceholder' ) ) { var $ulNext = $ul . next ( ) ; if ( $ulNext . is ( '.PageList:visible' ) ) { $ulNext . prepend ( $li ) ; $ul = $ulNext ; } else { $ul . removeClass ( 'PageListPlaceholder' ) . children ( '.PageListPlaceholderItem' ) . remove ( ) ; } } $root . addClass ( 'PageListSortSaving' ) ; cancelMove ( $li ) ; $li . append ( $loading . fadeIn ( 'fast' ) ) ; var sortCSV = '' ; $ul . children ( ".PageListItem" ) . each ( function ( ) { sortCSV += $ ( this ) . data ( 'pageId' ) + ',' ; } ) ; var postData = { id : id , parent_id : parent_id , sort : sortCSV } ; postData [ $ ( '#PageListContainer' ) . attr ( 'data-token-name' ) ] = $ ( '#PageListContainer' ) . attr ( 'data-token-value' ) ; var success = 'unknown' ; $ . post ( options . ajaxMoveURL , postData , function ( data ) { $loading . fadeOut ( 'fast' ) ; $a . fadeOut ( 'fast' , function ( ) { $ ( this ) . fadeIn ( "fast" ) $li . removeClass ( 'PageListSortItem' ) ; $root . removeClass ( 'PageListSorting' ) ; } ) ; if ( data && data . error ) { ProcessWire . alert ( data . message ) ; } if ( ! $ul . is ( "#PageListMoveFrom" ) ) { var $fromItem = $from . prev ( ".PageListItem" ) ; var numChildren = getNumChildren ( $fromItem ) ; var numTotal = getNumTotal ( $fromItem ) ; if ( numChildren > 0 ) { numChildren -- ; adjustNumTotal ( $fromItem , - 1 ) ; } else { $from . remove ( ) ; } setNumChildren ( $fromItem , numChildren , false ) ; setForceReload ( $fromItem ) ; var $toItem = $ul . prev ( ".PageListItem" ) ; numChildren = getNumChildren ( $toItem ) + 1 ; adjustNumTotal ( $toItem , 1 ) ; setNumChildren ( $toItem , numChildren , false ) ; setForceReload ( $toItem ) ; } $from . attr ( 'id' , '' ) ; $root . removeClass ( 'PageListSortSaving' ) ; } , 'json' ) ; $li . trigger ( 'pageMoved' ) ; return true ; }
Event called when the mouse stops after performing a 'move'
 @param event e
 @param jQueryUI ui
 @return bool
Event called when the mouse stops after performing a ' move ' @param event e @param jQueryUI ui @return bool
// get the previous sibling .PageListItem, and skip over the pagination list if it's there // check if item was moved to an invalid spot // in this case, a spot between another open PageListItem and its PageList // check if item was moved into an invisible parent placeholder PageList // first item at top of list ended up in placeholder, but belongs in next sibling PageList // if so, it's no longer a placeholder, but a real PageList // setup to save the change // create a CSV string containing the order of Page IDs	 // CSRF Token // save the change	 // if item moved from one list to another, then update the numChildren counts // update count where item came from // empty list, no longer needed // update count where item went to	 // remove tempoary #PageListMoveFrom // trigger pageMoved event: @teppokoivula // whether or not to allow the sort