wire/modules/Process/ProcessPageList/ProcessPageList.js
/**
	 		 * Load children via ajax call, attach them to $target and show. 
			 *
			 * @param int id ID of the page having children to show
			 * @param jQuery $target Item to attach children to
		 	 * @param int start If not starting from first item, num of item to start with
			 * @param bool beginList Set to true if this is the first call to create the list
			 * @param bool pagination Set to false if you don't want pagination, otherwise leave it out
			 * @param bool replace Should any existing list be replaced (true) or appended (false)
			 *
			 */
Load children via ajax call, attach them to $target and show.
Load children via ajax call attach them to $target and show .
function loadChildren(id, $target, start, beginList, pagination, replace, callback) {
				if(pagination == undefined) pagination = true; 
				if(replace == undefined) replace = false;
				var processChildren = function(data) {
					if(data && data.error) {
						ProcessWire.alert(data.message); 
						$loading.hide();
						ignoreClicks = false;
						return; 
					}
					var $children = listChildren($(data.children)); 
					var nextStart = data.start + data.limit; 
					if($target.hasClass('PageListItem')) {
						setNumChildren($target, data.page.numChildren, data.page.numTotal);
					}
					if(data.page.numChildren > nextStart) {
						var $a = $("<a></a>").attr('href', nextStart).data('pageId', id).text(options.moreLabel).click(clickMore); 
						$children.append($("<ul></ul>").addClass('PageListActions actions').append($("<li></li>").addClass('PageListActionMore').append($a)));
					}
					if(pagination && (data.page.numChildren > nextStart || data.start > 0)) {
						$children.prepend(getPaginationList(id, data.start, data.limit, data.page.numChildren));
					}
					$children.hide();
					if(beginList) {
						var $listRoot; 
						$listRoot = listChildren($(data.page)); 
						if(options.showRootPage) $listRoot.children(".PageListItem").addClass("PageListItemOpen"); 
							else $listRoot.children('.PageListItem').hide().parent('.PageList').addClass('PageListRootHidden'); 
						$listRoot.append($children); 
						$target.append($listRoot);
					} else if($target.hasClass('PageList')) {
						var $newChildren = $children.children(".PageListItem, .PageListActions"); 
						if(replace) {
							$target.children('.PageListItem, .PageListActions').remove();
						}
						$target.append($newChildren);
					} else {
						$target.after($children); 
					}
					if($loading.parent().is('.PageListRoot')) {
						$loading.hide();
					} else {
						$loading.fadeOut('fast');
					}
					if(replace) {
						$children.show();
						loaded();
						if(callback != undefined) callback();
					} else { 
						$children.slideDown(options.speed, function() {
							loaded();
							if(callback != undefined) callback();
						}); 
					}
					$children.prev('.PageListItem').data('start', data.start);
				}; 
				if(!replace) $target.append($loading.fadeIn('fast')); 
				var key = id + '-' + start;
				if(typeof options.openPageData[key] != "undefined" 
					&& !$target.hasClass('PageListID7') 
					&& !$target.hasClass('PageListForceReload')) {
					processChildren(options.openPageData[key]);
					return;
				} 
				var ajaxURL = options.ajaxURL + 
					"?id=" + id + 
					"&render=JSON&start=" + start + 
					"&lang=" + options.langID + 
					"&open=" + options.openPageIDs[0] + 
					"&mode=" + options.mode;
				if(options.labelName.length) ajaxURL += '&labelName=' + options.labelName;
				$.getJSON(ajaxURL)
					.done(function(data, textStatus, jqXHR) {
						processChildren(data);
					})
					.fail(function(jqXHR, textStatus, errorThrown) {
						processChildren({
							error: 1,
							message: !jqXHR.status ? options.ajaxNetworkError : options.ajaxUnknownError
						});
					});
			}
function loadChildren ( id , $target , start , beginList , pagination , replace , callback ) { if ( pagination == undefined ) pagination = true ; if ( replace == undefined ) replace = false ; var processChildren = function ( data ) { if ( data && data . error ) { ProcessWire . alert ( data . message ) ; $loading . hide ( ) ; ignoreClicks = false ; return ; } var $children = listChildren ( $ ( data . children ) ) ; var nextStart = data . start + data . limit ; if ( $target . hasClass ( 'PageListItem' ) ) { setNumChildren ( $target , data . page . numChildren , data . page . numTotal ) ; } if ( data . page . numChildren > nextStart ) { var $a = $ ( "<a></a>" ) . attr ( 'href' , nextStart ) . data ( 'pageId' , id ) . text ( options . moreLabel ) . click ( clickMore ) ; $children . append ( $ ( "<ul></ul>" ) . addClass ( 'PageListActions actions' ) . append ( $ ( "<li></li>" ) . addClass ( 'PageListActionMore' ) . append ( $a ) ) ) ; } if ( pagination && ( data . page . numChildren > nextStart || data . start > 0 ) ) { $children . prepend ( getPaginationList ( id , data . start , data . limit , data . page . numChildren ) ) ; } $children . hide ( ) ; if ( beginList ) { var $listRoot ; $listRoot = listChildren ( $ ( data . page ) ) ; if ( options . showRootPage ) $listRoot . children ( ".PageListItem" ) . addClass ( "PageListItemOpen" ) ; else $listRoot . children ( '.PageListItem' ) . hide ( ) . parent ( '.PageList' ) . addClass ( 'PageListRootHidden' ) ; $listRoot . append ( $children ) ; $target . append ( $listRoot ) ; } else if ( $target . hasClass ( 'PageList' ) ) { var $newChildren = $children . children ( ".PageListItem, .PageListActions" ) ; if ( replace ) { $target . children ( '.PageListItem, .PageListActions' ) . remove ( ) ; } $target . append ( $newChildren ) ; } else { $target . after ( $children ) ; } if ( $loading . parent ( ) . is ( '.PageListRoot' ) ) { $loading . hide ( ) ; } else { $loading . fadeOut ( 'fast' ) ; } if ( replace ) { $children . show ( ) ; loaded ( ) ; if ( callback != undefined ) callback ( ) ; } else { $children . slideDown ( options . speed , function ( ) { loaded ( ) ; if ( callback != undefined ) callback ( ) ; } ) ; } $children . prev ( '.PageListItem' ) . data ( 'start' , data . start ) ; } ; if ( ! replace ) $target . append ( $loading . fadeIn ( 'fast' ) ) ; var key = id + '-' + start ; if ( typeof options . openPageData [ key ] != "undefined" && ! $target . hasClass ( 'PageListID7' ) && ! $target . hasClass ( 'PageListForceReload' ) ) { processChildren ( options . openPageData [ key ] ) ; return ; } var ajaxURL = options . ajaxURL + "?id=" + id + "&render=JSON&start=" + start + "&lang=" + options . langID + "&open=" + options . openPageIDs [ 0 ] + "&mode=" + options . mode ; if ( options . labelName . length ) ajaxURL += '&labelName=' + options . labelName ; $ . getJSON ( ajaxURL ) . done ( function ( data , textStatus , jqXHR ) { processChildren ( data ) ; } ) . fail ( function ( jqXHR , textStatus , errorThrown ) { processChildren ( { error : 1 , message : ! jqXHR . status ? options . ajaxNetworkError : options . ajaxUnknownError } ) ; } ) ; }
Load children via ajax call, attach them to $target and show.
Load children via ajax call attach them to $target and show .
//var openPageKey = id + '-' + start; // $target.children(".PageListItem, .PageListActions").replaceWith($newChildren); // doesn't work w/jQuery 1.9+ // if a pagination is requested to be opened, and it exists, then open it /*
					if(options.openPagination > 1) {
						//var $a = $(".PageListPagination" + (options.openPagination-1) + ">a");
						var $a = $(".PageListPagination a[href=" + (options.openPagination-1) + "]");
						if($a.size() > 0) {
							$a.click();	
							options.openPagination = 0;
						} else {
							// last pagination link
							$(".PageListPagination9 a").click();
						}
					}
					*/ // trash // @teppokoivula PR #1052 // end #1052