diff --git a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js
index a299a04f..32798d6e 100644
--- a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js
+++ b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js
@@ -2,7 +2,7 @@
* Alternate Select Multiple (asmSelect) 1.3 - jQuery Plugin
* http://www.ryancramer.com/projects/asmselect/
*
- * Copyright (c) 2009-2014 by Ryan Cramer - http://www.ryancramer.com
+ * Copyright (c) 2009-2018 by Ryan Cramer - http://www.ryancramer.com
*
* Licensed under the MIT license.
*
@@ -16,6 +16,8 @@
listType: 'ol', // Ordered list 'ol', or unordered list 'ul'
sortable: false, // Should the list be sortable?
+ addable: true, // Can items be added to selection?
+ deletable: true, // Can items be removed from selection?
highlight: false, // Use the highlight feature?
fieldset: false, // Use fieldset support? (for PW Fieldset types)
animate: false, // Animate the the adding/removing of items in the list?
@@ -75,6 +77,7 @@
function init() {
// initialize the alternate select multiple
+ if(options.deletable && !options.addable) options.hideDeleted = false;
// this loop ensures uniqueness, in case of existing asmSelects placed by ajax (1.0.3)
while($("#" + options.containerClass + index).length > 0) index++;
@@ -84,6 +87,7 @@
.addClass($original.attr('class'))
.attr('name', options.selectClass + index)
.attr('id', options.selectClass + index);
+ if(!options.addable) $select.hide();
$selectRemoved = $("");
@@ -332,7 +336,8 @@
if(!$O) return; // this is the first item, selectLabel
- var $removeLink = $("")
+ var $removeLink = null;
+ if(options.deletable) $removeLink = $("")
.attr("href", "#")
.addClass(options.removeClass)
.prepend(options.removeLabel)
@@ -388,9 +393,9 @@
.addClass(options.listItemClass)
.append($itemLabel)
.append($itemDesc)
- .append($itemStatus)
- .append($removeLink)
- .hide();
+ .append($itemStatus);
+ if($removeLink) $item.append($removeLink);
+ $item.hide();
if(options.jQueryUI) {
$item.addClass('ui-state-default')
diff --git a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.min.js b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.min.js
index 24ef05be..7481d91e 100644
--- a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.min.js
+++ b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.min.js
@@ -1 +1 @@
-(function(a){a.fn.asmSelect=function(b){var c={listType:"ol",sortable:false,highlight:false,fieldset:false,animate:false,addItemTarget:"bottom",hideWhenAdded:false,hideWhenEmpty:false,debugMode:false,jQueryUI:true,hideDeleted:true,deletedOpacity:0.5,deletedPrepend:"-",sortLabel:'↕',removeLabel:'×',highlightAddedLabel:"Added: ",highlightRemovedLabel:"Removed: ",containerClass:"asmContainer",selectClass:"asmSelect",optionDisabledClass:"asmOptionDisabled",listClass:"asmList",listSortableClass:"asmListSortable",listItemClass:"asmListItem",listItemLabelClass:"asmListItemLabel",listItemDescClass:"asmListItemDesc",listItemStatusClass:"asmListItemStatus",listItemHandleClass:"asmListItemHandle",removeClass:"asmListItemRemove",editClass:"asmListItemEdit",highlightClass:"asmHighlight",deletedClass:"asmListItemDeleted",editLink:"",editLabel:'',editLinkOnlySelected:true,editLinkModal:true,editLinkButtonSelector:"form button.ui-button:visible"};a.extend(c,b);return this.each(function(m){var D=a(this);var u;var A;var o;var q=false;var e=false;var h=false;var j={};var p=0;function w(){while(a("#"+c.containerClass+m).length>0){m++}A=a("").addClass(c.selectClass).addClass(D.attr("class")).attr("name",c.selectClass+m).attr("id",c.selectClass+m);$selectRemoved=a("");o=a("<"+c.listType+">"+c.listType+">").addClass(c.listClass).attr("id",c.listClass+m);u=a("
").addClass(c.containerClass).attr("id",c.containerClass+m);z();A.change(n).click(E);D.change(s).wrap(u).before(A).before(o);if(c.sortable){B()}if(typeof a.browser!="undefined"&&typeof a.browser.msie!="undefined"){p=a.browser.msie?a.browser.version:0}if(p>0&&p<8){o.css("display","inline-block")}if(c.fieldset){x();D.children("option").each(function(){var F=a(this).text();if(F.indexOf("_END")>0&&F.substring(F.length-4)=="_END"){j[F]=a(this)}})}D.trigger("init");if(c.editLinkModal==="longclick"){o.on("longclick","a.asmEditLinkModalLongclick",y)}}function B(){var F=[];o.sortable({items:"li."+c.listItemClass,axis:"y",cancel:"a.asmEditLinkModalLongclick",update:function(I,H){var G;$option=a("#"+H.item.attr("rel"));G=$option.attr("id");a(this).children("li").each(function(J){$option=a("#"+a(this).attr("rel"));D.append($option)});if(G){v(G,"sort")}},start:function(J,I){if(c.jQueryUI){I.item.addClass("ui-state-highlight")}if(I.item.hasClass("asmFieldsetStart")){var H=I.item;var G=I.item.find(".asmListItemLabel").text()+"_END";do{if(H.find(".asmListItemLabel").text()==G){break}H=H.next("li");if(H.length&&!H.hasClass("ui-sortable-placeholder")){H.fadeTo(50,0.7).slideUp("fast");F.push(H)}}while(H.length)}},stop:function(J,I){if(c.jQueryUI){I.item.removeClass("ui-state-highlight")}if(I.item.hasClass("asmFieldsetStart")){var H=I.item;for(var K=0;K0&&p<7&&!e){return}var G=a(this).children("option:selected").slice(0,1).attr("rel");t(G);e=false;v(G,"add")}function E(){e=true}function s(F){if(h){h=false;return}A.empty();o.empty();z();if(typeof a.browser!="undefined"){if(a.browser.opera){o.hide().fadeIn("fast")}}if(c.fieldset){x()}}function z(){q=true;var G=D.attr("title");var F=0;if(G===undefined){G=""}A.prepend("");D.children("option").each(function(J){var I=a(this);var H;if(!I.attr("id")){I.attr("id","asm"+m+"option"+J)}H=I.attr("id");if(I.is(":selected")){t(H);i(H,true)}else{F++;i(H)}});if(!c.debugMode){D.hide()}g();if(c.hideWhenEmpty){if(F>0){A.show()}else{A.hide()}}q=false}function i(H,G){if(G==undefined){var G=false}var F=a("#"+H);var I=a("").val(F.val()).attr("rel",H);if(G){r(I)}A.append(I)}function g(){A.children(":eq(0)").attr("selected",true)}function r(F){F.addClass(c.optionDisabledClass).attr("selected",false).attr("disabled",true);if(c.hideWhenEmpty){if(F.siblings("[disabled!=true]").length<2){A.hide()}}if(c.hideWhenAdded){F.hide()}if(p){A.hide().show()}}function f(F){F.removeClass(c.optionDisabledClass).attr("disabled",false);if(c.hideWhenEmpty){A.show()}if(c.hideWhenAdded){F.show()}if(p){A.hide().show()}}function t(K){var F=a("#"+K);if(!F){return}var I=a("").attr("href","#").addClass(c.removeClass).prepend(c.removeLabel).click(function(){l(a(this).parent("li").attr("rel"));return false});var G=a("").addClass(c.listItemLabelClass);var J=a("").addClass(c.listItemStatusClass);if(F.attr("data-status")){J.html(F.attr("data-status"))}var H=a("").addClass(c.listItemDescClass);if(c.editLink.length>0&&(F.is(":selected")||!c.editLinkOnlySelected)){var O=a("").html(F.html()).attr("href",c.editLink.replace(/\{value\}/,F.val())).append(c.editLabel);if(c.editLinkModal==="longclick"){O.addClass("asmEditLinkModalLongclick")}else{if(c.editLinkModal){O.click(y)}}G.addClass(c.editClass).append(O);if(F.attr("data-desc")){var M=a("").html(F.attr("data-desc")).attr("href",O.attr("href")).append(c.editLabel);H.addClass(c.editClass).append(M);if(c.editLinkModal==="longclick"){M.addClass("asmEditLinkModalLongclick")}else{if(c.editLinkModal){M.click(y)}}}}else{G.html(F.html());if(F.attr("data-desc")){H.html(F.attr("data-desc"))}}var N=a("").attr("rel",K).addClass(c.listItemClass).append(G).append(H).append(J).append(I).hide();if(c.jQueryUI){N.addClass("ui-state-default").hover(function(){a(this).addClass("ui-state-hover").removeClass("ui-state-default")},function(){a(this).addClass("ui-state-default").removeClass("ui-state-hover")});if(c.sortable){if(F.attr("data-handle")){N.prepend(a(F.attr("data-handle")).addClass(c.listItemHandleClass))}else{N.prepend(a(c.sortLabel).addClass(c.listItemHandleClass))}}}if(!q){if(F.is(":selected")){return}F.attr("selected",true)}if(c.addItemTarget=="top"&&!q){o.prepend(N);if(c.sortable){D.prepend(F)}}else{o.append(N);if(c.sortable){D.append(F)}}d(N);r(a("[rel="+K+"]",A));if(!q){C(N,c.highlightAddedLabel);g();if(c.sortable){o.sortable("refresh")}if(c.fieldset){var P=F.text();if(P.indexOf("_END")>0&&P.substring(P.length-4)=="_END"){N.addClass("asmFieldset asmFieldsetEnd")}else{var L=P+"_END";if(typeof j[L]!="undefined"){N.addClass("asmFieldset asmFieldsetStart");t(j[L].attr("id"))}}}}}function d(F){if(c.animate&&!q){F.animate({opacity:"show",height:"show"},100,"swing",function(){F.animate({height:"+=2px"},50,"swing",function(){F.animate({height:"-=2px"},25,"swing")})})}else{F.show()}}function l(I,F){var G=a("#"+I);if(c.hideDeleted){if(F==undefined){var F=true}G.attr("selected",false);$item=o.children("li[rel="+I+"]");k($item);f(a("[rel="+I+"]",c.removeWhenAdded?$selectRemoved:A));if(F){C($item,c.highlightRemovedLabel)}}else{$item=o.children("li[rel="+I+"]");var H=G.attr("value");if(H=="undefined"){H=G.text()}if($item.hasClass(c.deletedClass)){$item.removeClass(c.deletedClass);if(c.deletedOpacity!=1){$item.css("opacity",1)}G.attr("value",H.substring(c.deletedPrepend.length))}else{$item.addClass(c.deletedClass);if(c.deletedOpacity!=1){$item.css("opacity",c.deletedOpacity)}G.attr("value",c.deletedPrepend+H)}}v(I,"drop")}function k(F){if(c.animate&&!q){$prevItem=F.prev("li");F.animate({opacity:"hide",height:"hide"},100,"linear",function(){$prevItem.animate({height:"-=2px"},50,"swing",function(){$prevItem.animate({height:"+=2px"},100,"swing")});F.remove()})}else{F.remove()}}function C(F,G){if(!c.highlight){return}A.next("#"+c.highlightClass+m).remove();var H=a("").hide().addClass(c.highlightClass).attr("id",c.highlightClass+m).html(G+F.children("."+c.listItemLabelClass).slice(0,1).text());A.after(H);H.fadeIn("fast",function(){setTimeout(function(){H.fadeOut("slow",function(){a(this).remove()})},50)})}function v(G,F){h=true;$option=a("#"+G);D.trigger("change",[{option:$option,value:$option.val(),id:G,item:o.children("[rel="+G+"]"),type:F}])}function y(I){if(!c.editLinkModal){return true}var F=a(this).parents("."+c.listItemClass);var G=a(this).attr("href");var H=pwModalWindow(G,{},"medium");H.load(function(){var L=H.contents();var K=[];var J=0;L.find(c.editLinkButtonSelector).each(function(R){var Q=a(this);var N=Q.text();var P=true;var M=Q.is(".ui-priority-secondary");for(var O=0;O0){F.find("."+c.listItemStatusClass).html(S.eq(0).val())}var T=L.find("#"+c.listItemDescClass);if(T.length==0){T=L.find(":input."+c.listItemDescClass)}if(T.length>0){T=T.eq(0);var V=a("").text(T.val()).html();var U=F.find("."+c.listItemDescClass);var W=U.find("a");if(W.length>0){W.html(V)}else{U.html(V)}}}H.dialog("close")}};J++}Q.hide()});H.setButtons(K)});return false}function x(){o.find("span.asmFieldsetIndent").remove();var F=o.children("li");o.children("li").children("span.asmListItemLabel").each(function(){var K=a(this);var H=K.text();if(H.substring(H.length-4)!="_END"){return}H=H.substring(0,H.length-4);var J=a(this).closest("li.asmListItem");J.addClass("asmFieldset asmFieldsetEnd");while(1){J=J.prev("li.asmListItem");if(J.length<1){break}var G=J.children("span.asmListItemLabel");var I=G.text();if(I==H){J.addClass("asmFieldset asmFieldsetStart");break}G.prepend(a(''))}})}w()})}})(jQuery);
\ No newline at end of file
+(function(a){a.fn.asmSelect=function(b){var c={listType:"ol",sortable:false,addable:true,deletable:true,highlight:false,fieldset:false,animate:false,addItemTarget:"bottom",hideWhenAdded:false,hideWhenEmpty:false,debugMode:false,jQueryUI:true,hideDeleted:true,deletedOpacity:0.5,deletedPrepend:"-",sortLabel:'↕',removeLabel:'×',highlightAddedLabel:"Added: ",highlightRemovedLabel:"Removed: ",containerClass:"asmContainer",selectClass:"asmSelect",optionDisabledClass:"asmOptionDisabled",listClass:"asmList",listSortableClass:"asmListSortable",listItemClass:"asmListItem",listItemLabelClass:"asmListItemLabel",listItemDescClass:"asmListItemDesc",listItemStatusClass:"asmListItemStatus",listItemHandleClass:"asmListItemHandle",removeClass:"asmListItemRemove",editClass:"asmListItemEdit",highlightClass:"asmHighlight",deletedClass:"asmListItemDeleted",editLink:"",editLabel:'',editLinkOnlySelected:true,editLinkModal:true,editLinkButtonSelector:"form button.ui-button:visible"};a.extend(c,b);return this.each(function(m){var D=a(this);var u;var A;var o;var q=false;var e=false;var h=false;var j={};var p=0;function w(){if(c.deletable&&!c.addable){c.hideDeleted=false}while(a("#"+c.containerClass+m).length>0){m++}A=a("").addClass(c.selectClass).addClass(D.attr("class")).attr("name",c.selectClass+m).attr("id",c.selectClass+m);if(!c.addable){A.hide()}$selectRemoved=a("");o=a("<"+c.listType+">"+c.listType+">").addClass(c.listClass).attr("id",c.listClass+m);u=a("").addClass(c.containerClass).attr("id",c.containerClass+m);z();A.change(n).click(E);D.change(s).wrap(u).before(A).before(o);if(c.sortable){B()}if(typeof a.browser!="undefined"&&typeof a.browser.msie!="undefined"){p=a.browser.msie?a.browser.version:0}if(p>0&&p<8){o.css("display","inline-block")}if(c.fieldset){x();D.children("option").each(function(){var F=a(this).text();if(F.indexOf("_END")>0&&F.substring(F.length-4)=="_END"){j[F]=a(this)}})}D.trigger("init");if(c.editLinkModal==="longclick"){o.on("longclick","a.asmEditLinkModalLongclick",y)}}function B(){var F=[];o.sortable({items:"li."+c.listItemClass,axis:"y",cancel:"a.asmEditLinkModalLongclick",update:function(I,H){var G;$option=a("#"+H.item.attr("rel"));G=$option.attr("id");a(this).children("li").each(function(J){$option=a("#"+a(this).attr("rel"));D.append($option)});if(G){v(G,"sort")}},start:function(J,I){if(c.jQueryUI){I.item.addClass("ui-state-highlight")}if(I.item.hasClass("asmFieldsetStart")){var H=I.item;var G=I.item.find(".asmListItemLabel").text()+"_END";do{if(H.find(".asmListItemLabel").text()==G){break}H=H.next("li");if(H.length&&!H.hasClass("ui-sortable-placeholder")){H.fadeTo(50,0.7).slideUp("fast");F.push(H)}}while(H.length)}},stop:function(J,I){if(c.jQueryUI){I.item.removeClass("ui-state-highlight")}if(I.item.hasClass("asmFieldsetStart")){var H=I.item;for(var K=0;K0&&p<7&&!e){return}var G=a(this).children("option:selected").slice(0,1).attr("rel");t(G);e=false;v(G,"add")}function E(){e=true}function s(F){if(h){h=false;return}A.empty();o.empty();z();if(typeof a.browser!="undefined"){if(a.browser.opera){o.hide().fadeIn("fast")}}if(c.fieldset){x()}}function z(){q=true;var G=D.attr("title");var F=0;if(G===undefined){G=""}A.prepend("");D.children("option").each(function(J){var I=a(this);var H;if(!I.attr("id")){I.attr("id","asm"+m+"option"+J)}H=I.attr("id");if(I.is(":selected")){t(H);i(H,true)}else{F++;i(H)}});if(!c.debugMode){D.hide()}g();if(c.hideWhenEmpty){if(F>0){A.show()}else{A.hide()}}q=false}function i(H,G){if(G==undefined){var G=false}var F=a("#"+H);var I=a("").val(F.val()).attr("rel",H);if(G){r(I)}A.append(I)}function g(){A.children(":eq(0)").attr("selected",true)}function r(F){F.addClass(c.optionDisabledClass).attr("selected",false).attr("disabled",true);if(c.hideWhenEmpty){if(F.siblings("[disabled!=true]").length<2){A.hide()}}if(c.hideWhenAdded){F.hide()}if(p){A.hide().show()}}function f(F){F.removeClass(c.optionDisabledClass).attr("disabled",false);if(c.hideWhenEmpty){A.show()}if(c.hideWhenAdded){F.show()}if(p){A.hide().show()}}function t(K){var F=a("#"+K);if(!F){return}var I=null;if(c.deletable){I=a("").attr("href","#").addClass(c.removeClass).prepend(c.removeLabel).click(function(){l(a(this).parent("li").attr("rel"));return false})}var G=a("").addClass(c.listItemLabelClass);var J=a("").addClass(c.listItemStatusClass);if(F.attr("data-status")){J.html(F.attr("data-status"))}var H=a("").addClass(c.listItemDescClass);if(c.editLink.length>0&&(F.is(":selected")||!c.editLinkOnlySelected)){var O=a("").html(F.html()).attr("href",c.editLink.replace(/\{value\}/,F.val())).append(c.editLabel);if(c.editLinkModal==="longclick"){O.addClass("asmEditLinkModalLongclick")}else{if(c.editLinkModal){O.click(y)}}G.addClass(c.editClass).append(O);if(F.attr("data-desc")){var M=a("").html(F.attr("data-desc")).attr("href",O.attr("href")).append(c.editLabel);H.addClass(c.editClass).append(M);if(c.editLinkModal==="longclick"){M.addClass("asmEditLinkModalLongclick")}else{if(c.editLinkModal){M.click(y)}}}}else{G.html(F.html());if(F.attr("data-desc")){H.html(F.attr("data-desc"))}}var N=a("").attr("rel",K).addClass(c.listItemClass).append(G).append(H).append(J);if(I){N.append(I)}N.hide();if(c.jQueryUI){N.addClass("ui-state-default").hover(function(){a(this).addClass("ui-state-hover").removeClass("ui-state-default")},function(){a(this).addClass("ui-state-default").removeClass("ui-state-hover")});if(c.sortable){if(F.attr("data-handle")){N.prepend(a(F.attr("data-handle")).addClass(c.listItemHandleClass))}else{N.prepend(a(c.sortLabel).addClass(c.listItemHandleClass))}}}if(!q){if(F.is(":selected")){return}F.attr("selected",true)}if(c.addItemTarget=="top"&&!q){o.prepend(N);if(c.sortable){D.prepend(F)}}else{o.append(N);if(c.sortable){D.append(F)}}d(N);r(a("[rel="+K+"]",A));if(!q){C(N,c.highlightAddedLabel);g();if(c.sortable){o.sortable("refresh")}if(c.fieldset){var P=F.text();if(P.indexOf("_END")>0&&P.substring(P.length-4)=="_END"){N.addClass("asmFieldset asmFieldsetEnd")}else{var L=P+"_END";if(typeof j[L]!="undefined"){N.addClass("asmFieldset asmFieldsetStart");t(j[L].attr("id"))}}}}}function d(F){if(c.animate&&!q){F.animate({opacity:"show",height:"show"},100,"swing",function(){F.animate({height:"+=2px"},50,"swing",function(){F.animate({height:"-=2px"},25,"swing")})})}else{F.show()}}function l(I,F){var G=a("#"+I);if(c.hideDeleted){if(F==undefined){var F=true}G.attr("selected",false);$item=o.children("li[rel="+I+"]");k($item);f(a("[rel="+I+"]",c.removeWhenAdded?$selectRemoved:A));if(F){C($item,c.highlightRemovedLabel)}}else{$item=o.children("li[rel="+I+"]");var H=G.attr("value");if(H=="undefined"){H=G.text()}if($item.hasClass(c.deletedClass)){$item.removeClass(c.deletedClass);if(c.deletedOpacity!=1){$item.css("opacity",1)}G.attr("value",H.substring(c.deletedPrepend.length))}else{$item.addClass(c.deletedClass);if(c.deletedOpacity!=1){$item.css("opacity",c.deletedOpacity)}G.attr("value",c.deletedPrepend+H)}}v(I,"drop")}function k(F){if(c.animate&&!q){$prevItem=F.prev("li");F.animate({opacity:"hide",height:"hide"},100,"linear",function(){$prevItem.animate({height:"-=2px"},50,"swing",function(){$prevItem.animate({height:"+=2px"},100,"swing")});F.remove()})}else{F.remove()}}function C(F,G){if(!c.highlight){return}A.next("#"+c.highlightClass+m).remove();var H=a("").hide().addClass(c.highlightClass).attr("id",c.highlightClass+m).html(G+F.children("."+c.listItemLabelClass).slice(0,1).text());A.after(H);H.fadeIn("fast",function(){setTimeout(function(){H.fadeOut("slow",function(){a(this).remove()})},50)})}function v(G,F){h=true;$option=a("#"+G);D.trigger("change",[{option:$option,value:$option.val(),id:G,item:o.children("[rel="+G+"]"),type:F}])}function y(I){if(!c.editLinkModal){return true}var F=a(this).parents("."+c.listItemClass);var G=a(this).attr("href");var H=pwModalWindow(G,{},"medium");H.load(function(){var L=H.contents();var K=[];var J=0;L.find(c.editLinkButtonSelector).each(function(R){var Q=a(this);var N=Q.text();var P=true;var M=Q.is(".ui-priority-secondary");for(var O=0;O0){F.find("."+c.listItemStatusClass).html(S.eq(0).val())}var T=L.find("#"+c.listItemDescClass);if(T.length==0){T=L.find(":input."+c.listItemDescClass)}if(T.length>0){T=T.eq(0);var V=a("").text(T.val()).html();var U=F.find("."+c.listItemDescClass);var W=U.find("a");if(W.length>0){W.html(V)}else{U.html(V)}}}H.dialog("close")}};J++}Q.hide()});H.setButtons(K)});return false}function x(){o.find("span.asmFieldsetIndent").remove();var F=o.children("li");o.children("li").children("span.asmListItemLabel").each(function(){var K=a(this);var H=K.text();if(H.substring(H.length-4)!="_END"){return}H=H.substring(0,H.length-4);var J=a(this).closest("li.asmListItem");J.addClass("asmFieldset asmFieldsetEnd");while(1){J=J.prev("li.asmListItem");if(J.length<1){break}var G=J.children("span.asmListItemLabel");var I=G.text();if(I==H){J.addClass("asmFieldset asmFieldsetStart");break}G.prepend(a(''))}})}w()})}})(jQuery);
\ No newline at end of file
diff --git a/wire/modules/Markup/MarkupPageArray.module b/wire/modules/Markup/MarkupPageArray.module
index 6b9c6a99..7d81e394 100644
--- a/wire/modules/Markup/MarkupPageArray.module
+++ b/wire/modules/Markup/MarkupPageArray.module
@@ -14,11 +14,11 @@
* It will also generate pagination if the selector had a limit placed on it (i.e. "limit=10"),
* and there are more pages left to render, and the page's template supports page numbers.
*
- * Also adds a PageArray::renderPager() method, which is convenient when you are generating your
+ * Also adds a PaginatedArray::renderPager() method, which is convenient when you are generating your
* own page list markup, but just want to use the automatic pagination generator.
*
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2018 by Ryan Cramer
* https://processwire.com
*
*
@@ -29,7 +29,7 @@ class MarkupPageArray extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'PageArray Markup',
- 'summary' => 'Adds a render() method to all PageArray instances for basic unordered list generation of PageArrays.',
+ 'summary' => 'Adds renderPager() method to all PaginatedArray types, for easy pagination output. Plus a render() method to PageArray instances.',
'version' => 100,
'permanent' => false,
'singular' => true,
@@ -48,17 +48,24 @@ class MarkupPageArray extends WireData implements Module {
* Can be accessed as $mypages->render() where '$mypages' is any instance of a PageArray.
*
* Be sure to see the $defaultOptions in the method if you want to change it's behavior or output.
+ *
+ * @param HookEvent $event
*
- * @param array $options Optional list of options to modify the behavior and output.
- * @return string
+ * #param array $options Optional list of options to modify the behavior and output.
+ * #return string
*
*/
public function renderPageArray(HookEvent $event) {
- $pageArray = $event->object;
- if(!count($pageArray)) return '';
- $arguments = $event->arguments;
+ /** @var PaginatedArray $pageArray */
+ $pageArray = $event->object;
+ $arguments = $event->arguments;
$options = array();
+
+ if(!count($pageArray)) {
+ $event->return = '';
+ return;
+ }
$defaultOptions = array(
@@ -91,14 +98,18 @@ class MarkupPageArray extends WireData implements Module {
$options = array_merge($defaultOptions, $options);
$out = '';
+ $fields = array();
- if(preg_match_all('/\{[-_a-z0-9|]+\}/i', $options['itemMarkup'], $matches)) $fields = $matches[0];
- else $fields = array();
+ if(preg_match_all('/\{[-_a-z0-9|]+\}/i', $options['itemMarkup'], $matches)) {
+ $fields = $matches[0];
+ }
foreach($pageArray as $page) {
- if(!$page->viewable()) continue;
+ if($page instanceof Page && !$page->viewable()) continue;
$values = array();
- foreach($fields as $field) $values[$field] = $page->get(trim($field, '{}'));
+ foreach($fields as $field) {
+ $values[$field] = $page->get(trim($field, '{}'));
+ }
$out .= str_replace($fields, $values, $options['itemMarkup']);
}
@@ -106,6 +117,7 @@ class MarkupPageArray extends WireData implements Module {
if(($options['pagerTop'] || $options['pagerBottom']) && $pageArray->getTotal() > count($pageArray)) {
+ /** @var MarkupPagerNav $pager */
$pager = $this->modules->get('MarkupPagerNav');
$pagerOptions = $options['pagerOptions'];
@@ -128,17 +140,21 @@ class MarkupPageArray extends WireData implements Module {
* Render pagination markup for a PageArray
*
* i.e. echo $mypages->renderPager(), where '$mypages' is a PageArray instance
+ *
+ * @param HookEvent $event
*
- * @param array $options Optional options to provide to MarkupPagerNav - see MarkupPagerNav::$options
- * @return string
+ * #param array $options Optional options to provide to MarkupPagerNav - see MarkupPagerNav::$options
+ * #return string
*
*/
public function renderPager(HookEvent $event) {
+ /** @var PaginatedArray $pageArray */
$pageArray = $event->object;
if(!$pageArray->getLimit()) return;
$arguments = $event->arguments;
$options = array();
if(isset($arguments[0]) && is_array($arguments[0])) $options = $arguments[0];
+ /** @var MarkupPagerNav $pager */
$pager = $this->modules->get('MarkupPagerNav');
if(empty($options['baseUrl'])) {
$baseUrl = $this->wire('page')->url;