diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa889022ad..09dd8396fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 4 +## 4.4.10.1 - 2023-05-10 + +- Fixed a bug where it wasn’t possible to add new Matrix blocks via the “Add a block” menu. ([#13177](https://github.com/craftcms/cms/issues/13177)) + ## 4.4.10 - 2023-05-09 - PHP warnings and notices no longer halt execution when Dev Mode is disabled. ([#13164](https://github.com/craftcms/cms/issues/13164)) diff --git a/src/config/app.php b/src/config/app.php index 4909ccea342..32002c65d7f 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -3,7 +3,7 @@ return [ 'id' => 'CraftCMS', 'name' => 'Craft CMS', - 'version' => '4.4.10', + 'version' => '4.4.10.1', 'schemaVersion' => '4.4.0.4', 'minVersionRequired' => '3.7.11', 'basePath' => dirname(__DIR__), // Defines the @app alias diff --git a/src/web/assets/matrix/dist/MatrixInput.js b/src/web/assets/matrix/dist/MatrixInput.js index 4d960de420a..f578c902b8c 100644 --- a/src/web/assets/matrix/dist/MatrixInput.js +++ b/src/web/assets/matrix/dist/MatrixInput.js @@ -1,2 +1,2 @@ -!function(t){Craft.MatrixInput=Garnish.Base.extend({id:null,blockTypes:null,blockTypesByHandle:null,inputNamePrefix:null,inputIdPrefix:null,showingAddBlockMenu:!1,addBlockBtnGroupWidth:null,addBlockBtnContainerWidth:null,$container:null,$form:null,$blockContainer:null,$addBlockBtnContainer:null,$addBlockBtnGroup:null,$addBlockBtnGroupBtns:null,$statusMessage:null,blockSort:null,blockSelect:null,totalNewBlocks:0,init:function(a,i,n,o){var s,l=this;for(this.id=a,this.blockTypes=i,this.inputNamePrefix=n,this.inputIdPrefix=Craft.formatInputId(this.inputNamePrefix),"number"==typeof o&&(o={maxBlocks:o}),this.setSettings(o,Craft.MatrixInput.defaults),this.$container=t("#"+this.id),this.$form=this.$container.closest("form"),this.$blockContainer=this.$container.children(".blocks"),this.$addBlockBtnContainer=this.$container.children(".buttons"),this.$addBlockBtnGroup=this.$addBlockBtnContainer.children(".btngroup"),this.$addBlockBtnGroupBtns=this.$addBlockBtnGroup.children(".btn"),this.$addBlockMenuBtn=this.$addBlockBtnContainer.children(".menubtn"),this.$statusMessage=this.$container.find("[data-status-message]"),this.$container.data("matrix",this),this.setNewBlockBtn(),this.blockTypesByHandle={},s=0;s .actions > .move",axis:"y",filter:function(){return l.blockSort.$targetItem.hasClass("sel")?l.blockSelect.getSelectedItems():l.blockSort.$targetItem},collapseDraggees:!0,magnetStrength:4,helperLagBase:1.5,helperOpacity:.9,onDragStop:function(){l.trigger("blockSortDragStop")},onSortChange:function(){l.blockSelect.resetItemOrder()}}),this.blockSelect=new Garnish.Select(this.$blockContainer,d,{multi:!0,vertical:!0,handle:"> .checkbox, > .titlebar",checkboxMode:!0}),s=0;sthis.totalNewBlocks&&(this.totalNewBlocks=parseInt(u[1]));var f=new e(this,h);f.id&&-1!==t.inArray(""+f.id,r)&&f.collapse()}this.addListener(this.$addBlockBtnGroupBtns,"click",(function(e){var a=t(e.target).data("type");this.addBlock(a)})),this.$addBlockMenuBtn.length&&(this.$addBlockMenuBtn.data("menubtn")&&this.$addBlockMenuBtn.data("menubtn").destroy(),new Garnish.MenuBtn(this.$addBlockMenuBtn,{onOptionSelect:function(e){l.addBlock(t(e).data("type"))}})),this.updateAddBlockBtn(),this.addListener(this.$container,"resize","setNewBlockBtn"),Garnish.$doc.ready(this.setNewBlockBtn.bind(this)),this.trigger("afterInit")},setNewBlockBtn:function(){var t=this;(this.addBlockBtnGroupWidth||(this.addBlockBtnGroupWidth=this.$addBlockBtnGroup.width(),this.addBlockBtnGroupWidth))&&this.addBlockBtnContainerWidth!==(this.addBlockBtnContainerWidth=this.$addBlockBtnContainer.width())&&(this.addBlockBtnGroupWidth>this.addBlockBtnContainerWidth?this.showingAddBlockMenu||(this.$addBlockBtnGroup.addClass("hidden"),this.$addBlockMenuBtn.removeClass("hidden"),this.showingAddBlockMenu=!0):this.showingAddBlockMenu&&(this.$addBlockMenuBtn.addClass("hidden"),this.$addBlockBtnGroup.removeClass("hidden"),this.showingAddBlockMenu=!1,-1!==navigator.userAgent.indexOf("Safari")&&Garnish.requestAnimationFrame((function(){t.$addBlockBtnGroup.css("opacity",.99),Garnish.requestAnimationFrame((function(){t.$addBlockBtnGroup.css("opacity","")}))}))))},canAddMoreBlocks:function(){return!this.maxBlocks||this.$blockContainer.children().length\n \n \n \n
\n
').concat(this.getBlockTypeByHandle(a).name,'
\n
\n
\n
\n \n ');var p=t(d),u=this.$form.data("elementEditor");u&&u.pause(),i?p.insertBefore(i):p.appendTo(this.$blockContainer);var f=t('
').appendTo(p),k=this.getParsedBlockHtml(this.blockTypesByHandle[a].bodyHtml,s),B=this.getParsedBlockHtml(this.blockTypesByHandle[a].js,s);t(k).appendTo(f),this.trigger("blockAdded",{$block:p}),p.css(this.getHiddenBlockCss(p)).velocity({opacity:1,"margin-bottom":10},"fast",(function(){p.css("margin-bottom",""),Garnish.$bod.append(B),Craft.initUiElements(f),new e(o,p),o.blockSort.addItems(p),o.blockSelect.addItems(p),o.updateAddBlockBtn(),Garnish.requestAnimationFrame((function(){(void 0===n||n)&&(Garnish.scrollContainerToElement(p),p.find(".flex-fields :focusable").first().trigger("focus")),u&&u.resume()}))}))}else this.updateStatusMessage()},getBlockTypeByHandle:function(t){for(var e=0;e .actions [data-disclosure-trigger]"),n=i.data("trigger")||new Garnish.DisclosureMenu(i);this.$actionMenu=n.$container,this.actionDisclosure=n,n.on("show",(function(){a.$container.addClass("active"),a.$container.prev(".matrixblock").length?a.$actionMenu.find("a[data-action=moveUp]:first").parent().removeClass("hidden"):a.$actionMenu.find("a[data-action=moveUp]:first").parent().addClass("hidden"),a.$container.next(".matrixblock").length?a.$actionMenu.find("a[data-action=moveDown]:first").parent().removeClass("hidden"):a.$actionMenu.find("a[data-action=moveDown]:first").parent().addClass("hidden")})),n.on("hide",(function(){a.$container.removeClass("active")})),this.$actionMenuOptions=this.$actionMenu.find("a[data-action]"),this.addListener(this.$actionMenuOptions,"click",this.handleActionClick),this.addListener(this.$actionMenuOptions,"keydown",this.handleActionKeydown),Garnish.hasAttr(this.$container,"data-collapsed")&&this.collapse(),this._handleTitleBarClick=function(t){t.preventDefault(),this.toggle()},this.addListener(this.$titlebar,"doubletap",this._handleTitleBarClick)},toggle:function(){this.collapsed?this.expand():this.collapse(!0)},collapse:function(e){var a=this;if(!this.collapsed){this.$container.addClass("collapsed");for(var i="",n=this.$fieldsContainer.children().children(),o=0;o| ":"")+l)}this.$previewContainer.html(i),this.$fieldsContainer.velocity("stop"),this.$container.velocity("stop"),e&&!Garnish.prefersReducedMotion()?(this.$fieldsContainer.velocity("fadeOut",{duration:"fast"}),this.$container.velocity({height:32},"fast")):(this.$previewContainer.show(),this.$fieldsContainer.hide(),this.$container.css({height:32})),setTimeout((function(){a.$actionMenu.find("a[data-action=collapse]:first").parent().addClass("hidden"),a.$actionMenu.find("a[data-action=expand]:first").parent().removeClass("hidden")}),200),this.isNew?this.$collapsedInput?this.$collapsedInput.val("1"):this.$collapsedInput=t('').appendTo(this.$container):Craft.MatrixInput.rememberCollapsedBlockId(this.id),this.collapsed=!0}},_inputPreviewText:function(e){if(e.is("select,multiselect")){for(var a=[],i=e.find("option:selected"),n=0;n1&&this.matrix.blockSelect.isSelected(this.$container),i=t(e);switch(i.data("action")){case"collapse":a?this.matrix.collapseSelectedBlocks():this.collapse(!0);break;case"expand":a?this.matrix.expandSelectedBlocks():this.expand();break;case"disable":a?this.matrix.disableSelectedBlocks():this.disable();break;case"enable":a?this.matrix.enableSelectedBlocks():(this.enable(),this.expand());break;case"moveUp":this.moveUp();break;case"moveDown":this.moveDown();break;case"add":var n=i.data("type");this.matrix.addBlock(n,this.$container);break;case"delete":a?confirm(Craft.t("app","Are you sure you want to delete the selected blocks?"))&&this.matrix.deleteSelectedBlocks():this.selfDestruct()}this.actionDisclosure.hide()},selfDestruct:function(){var e=this;t("[name]",this.$container).removeAttr("name"),this.$container.velocity(this.matrix.getHiddenBlockCss(this.$container),"fast",(function(){e.$container.remove(),e.matrix.updateAddBlockBtn(),e.matrix.trigger("blockDeleted",{$block:e.$container})}))}})}(jQuery); +!function(t){Craft.MatrixInput=Garnish.Base.extend({id:null,blockTypes:null,blockTypesByHandle:null,inputNamePrefix:null,inputIdPrefix:null,showingAddBlockMenu:!1,addBlockBtnGroupWidth:null,addBlockBtnContainerWidth:null,$container:null,$form:null,$blockContainer:null,$addBlockBtnContainer:null,$addBlockBtnGroup:null,$addBlockBtnGroupBtns:null,$statusMessage:null,blockSort:null,blockSelect:null,totalNewBlocks:0,init:function(a,i,n,o){var s,l=this;for(this.id=a,this.blockTypes=i,this.inputNamePrefix=n,this.inputIdPrefix=Craft.formatInputId(this.inputNamePrefix),"number"==typeof o&&(o={maxBlocks:o}),this.setSettings(o,Craft.MatrixInput.defaults),this.$container=t("#"+this.id),this.$form=this.$container.closest("form"),this.$blockContainer=this.$container.children(".blocks"),this.$addBlockBtnContainer=this.$container.children(".buttons"),this.$addBlockBtnGroup=this.$addBlockBtnContainer.children(".btngroup"),this.$addBlockBtnGroupBtns=this.$addBlockBtnGroup.children(".btn"),this.$addBlockMenuBtn=this.$addBlockBtnContainer.children(".menubtn"),this.$statusMessage=this.$container.find("[data-status-message]"),this.$container.data("matrix",this),this.setNewBlockBtn(),this.blockTypesByHandle={},s=0;s .actions > .move",axis:"y",filter:function(){return l.blockSort.$targetItem.hasClass("sel")?l.blockSelect.getSelectedItems():l.blockSort.$targetItem},collapseDraggees:!0,magnetStrength:4,helperLagBase:1.5,helperOpacity:.9,onDragStop:function(){l.trigger("blockSortDragStop")},onSortChange:function(){l.blockSelect.resetItemOrder()}}),this.blockSelect=new Garnish.Select(this.$blockContainer,d,{multi:!0,vertical:!0,handle:"> .checkbox, > .titlebar",checkboxMode:!0}),s=0;sthis.totalNewBlocks&&(this.totalNewBlocks=parseInt(u[1]));var f=new e(this,h);f.id&&-1!==t.inArray(""+f.id,r)&&f.collapse()}this.addListener(this.$addBlockBtnGroupBtns,"click",(function(e){var a=t(e.target).data("type");this.addBlock(a)})),this.$addBlockMenuBtn.length&&(this.$addBlockMenuBtn.menubtn(),this.$addBlockMenuBtn.data("menubtn").on("optionSelect",(function(e){l.addBlock(t(e.option).data("type"))}))),this.updateAddBlockBtn(),this.addListener(this.$container,"resize","setNewBlockBtn"),Garnish.$doc.ready(this.setNewBlockBtn.bind(this)),this.trigger("afterInit")},setNewBlockBtn:function(){var t=this;(this.addBlockBtnGroupWidth||(this.addBlockBtnGroupWidth=this.$addBlockBtnGroup.width(),this.addBlockBtnGroupWidth))&&this.addBlockBtnContainerWidth!==(this.addBlockBtnContainerWidth=this.$addBlockBtnContainer.width())&&(this.addBlockBtnGroupWidth>this.addBlockBtnContainerWidth?this.showingAddBlockMenu||(this.$addBlockBtnGroup.addClass("hidden"),this.$addBlockMenuBtn.removeClass("hidden"),this.showingAddBlockMenu=!0):this.showingAddBlockMenu&&(this.$addBlockMenuBtn.addClass("hidden"),this.$addBlockBtnGroup.removeClass("hidden"),this.showingAddBlockMenu=!1,-1!==navigator.userAgent.indexOf("Safari")&&Garnish.requestAnimationFrame((function(){t.$addBlockBtnGroup.css("opacity",.99),Garnish.requestAnimationFrame((function(){t.$addBlockBtnGroup.css("opacity","")}))}))))},canAddMoreBlocks:function(){return!this.maxBlocks||this.$blockContainer.children().length\n \n \n \n
\n
').concat(this.getBlockTypeByHandle(a).name,'
\n
\n
\n
\n \n
');var p=t(d),u=this.$form.data("elementEditor");u&&u.pause(),i?p.insertBefore(i):p.appendTo(this.$blockContainer);var f=t('
').appendTo(p),k=this.getParsedBlockHtml(this.blockTypesByHandle[a].bodyHtml,s),B=this.getParsedBlockHtml(this.blockTypesByHandle[a].js,s);t(k).appendTo(f),this.trigger("blockAdded",{$block:p}),p.css(this.getHiddenBlockCss(p)).velocity({opacity:1,"margin-bottom":10},"fast",(function(){p.css("margin-bottom",""),Garnish.$bod.append(B),Craft.initUiElements(f),new e(o,p),o.blockSort.addItems(p),o.blockSelect.addItems(p),o.updateAddBlockBtn(),Garnish.requestAnimationFrame((function(){(void 0===n||n)&&(Garnish.scrollContainerToElement(p),p.find(".flex-fields :focusable").first().trigger("focus")),u&&u.resume()}))}))}else this.updateStatusMessage()},getBlockTypeByHandle:function(t){for(var e=0;e .actions [data-disclosure-trigger]"),n=i.data("trigger")||new Garnish.DisclosureMenu(i);this.$actionMenu=n.$container,this.actionDisclosure=n,n.on("show",(function(){a.$container.addClass("active"),a.$container.prev(".matrixblock").length?a.$actionMenu.find("a[data-action=moveUp]:first").parent().removeClass("hidden"):a.$actionMenu.find("a[data-action=moveUp]:first").parent().addClass("hidden"),a.$container.next(".matrixblock").length?a.$actionMenu.find("a[data-action=moveDown]:first").parent().removeClass("hidden"):a.$actionMenu.find("a[data-action=moveDown]:first").parent().addClass("hidden")})),n.on("hide",(function(){a.$container.removeClass("active")})),this.$actionMenuOptions=this.$actionMenu.find("a[data-action]"),this.addListener(this.$actionMenuOptions,"click",this.handleActionClick),this.addListener(this.$actionMenuOptions,"keydown",this.handleActionKeydown),Garnish.hasAttr(this.$container,"data-collapsed")&&this.collapse(),this._handleTitleBarClick=function(t){t.preventDefault(),this.toggle()},this.addListener(this.$titlebar,"doubletap",this._handleTitleBarClick)},toggle:function(){this.collapsed?this.expand():this.collapse(!0)},collapse:function(e){var a=this;if(!this.collapsed){this.$container.addClass("collapsed");for(var i="",n=this.$fieldsContainer.children().children(),o=0;o| ":"")+l)}this.$previewContainer.html(i),this.$fieldsContainer.velocity("stop"),this.$container.velocity("stop"),e&&!Garnish.prefersReducedMotion()?(this.$fieldsContainer.velocity("fadeOut",{duration:"fast"}),this.$container.velocity({height:32},"fast")):(this.$previewContainer.show(),this.$fieldsContainer.hide(),this.$container.css({height:32})),setTimeout((function(){a.$actionMenu.find("a[data-action=collapse]:first").parent().addClass("hidden"),a.$actionMenu.find("a[data-action=expand]:first").parent().removeClass("hidden")}),200),this.isNew?this.$collapsedInput?this.$collapsedInput.val("1"):this.$collapsedInput=t('').appendTo(this.$container):Craft.MatrixInput.rememberCollapsedBlockId(this.id),this.collapsed=!0}},_inputPreviewText:function(e){if(e.is("select,multiselect")){for(var a=[],i=e.find("option:selected"),n=0;n1&&this.matrix.blockSelect.isSelected(this.$container),i=t(e);switch(i.data("action")){case"collapse":a?this.matrix.collapseSelectedBlocks():this.collapse(!0);break;case"expand":a?this.matrix.expandSelectedBlocks():this.expand();break;case"disable":a?this.matrix.disableSelectedBlocks():this.disable();break;case"enable":a?this.matrix.enableSelectedBlocks():(this.enable(),this.expand());break;case"moveUp":this.moveUp();break;case"moveDown":this.moveDown();break;case"add":var n=i.data("type");this.matrix.addBlock(n,this.$container);break;case"delete":a?confirm(Craft.t("app","Are you sure you want to delete the selected blocks?"))&&this.matrix.deleteSelectedBlocks():this.selfDestruct()}this.actionDisclosure.hide()},selfDestruct:function(){var e=this;t("[name]",this.$container).removeAttr("name"),this.$container.velocity(this.matrix.getHiddenBlockCss(this.$container),"fast",(function(){e.$container.remove(),e.matrix.updateAddBlockBtn(),e.matrix.trigger("blockDeleted",{$block:e.$container})}))}})}(jQuery); //# sourceMappingURL=MatrixInput.js.map \ No newline at end of file diff --git a/src/web/assets/matrix/dist/MatrixInput.js.map b/src/web/assets/matrix/dist/MatrixInput.js.map index 49e081d356e..5945cb6c14a 100644 --- a/src/web/assets/matrix/dist/MatrixInput.js.map +++ b/src/web/assets/matrix/dist/MatrixInput.js.map @@ -1 +1 @@ -{"version":3,"file":"MatrixInput.js","mappings":"CAAA,SAAWA,GAMTC,MAAMC,YAAcC,QAAQC,KAAKC,OAC/B,CACEC,GAAI,KACJC,WAAY,KACZC,mBAAoB,KACpBC,gBAAiB,KACjBC,cAAe,KAEfC,qBAAqB,EACrBC,sBAAuB,KACvBC,0BAA2B,KAE3BC,WAAY,KACZC,MAAO,KACPC,gBAAiB,KACjBC,sBAAuB,KACvBC,kBAAmB,KACnBC,sBAAuB,KACvBC,eAAgB,KAEhBC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oI,OAAOtB,uBAGd9G,KAAKwM,eAOXxM,KAAKwI,iBAAiBmC,MACxB,EAEA6B,aAAc,WAAY,WAExBnO,EAAE,SAAU2B,KAAKb,YAAYgF,WAAW,QAExCnE,KAAKb,WAAW6G,SACdhG,KAAKoI,OAAOrC,kBAAkB/F,KAAKb,YACnC,QACA,WACE,EAAKA,WAAWsN,SAChB,EAAKrE,OAAO/E,oBAEZ,EAAK+E,OAAOxG,QAAQ,eAAgB,CAClCO,OAAQ,EAAKhD,YAEjB,GAEJ,GAEH,CA1gCD,CA0gCGuN","sources":["webpack:///./MatrixInput.js"],"sourcesContent":["(function ($) {\n /** global: Craft */\n /** global: Garnish */\n /**\n * Matrix input class\n */\n Craft.MatrixInput = Garnish.Base.extend(\n {\n id: null,\n blockTypes: null,\n blockTypesByHandle: null,\n inputNamePrefix: null,\n inputIdPrefix: null,\n\n showingAddBlockMenu: false,\n addBlockBtnGroupWidth: null,\n addBlockBtnContainerWidth: null,\n\n $container: null,\n $form: null,\n $blockContainer: null,\n $addBlockBtnContainer: null,\n $addBlockBtnGroup: null,\n $addBlockBtnGroupBtns: null,\n $statusMessage: null,\n\n blockSort: null,\n blockSelect: null,\n totalNewBlocks: 0,\n\n init: function (id, blockTypes, inputNamePrefix, settings) {\n this.id = id;\n this.blockTypes = blockTypes;\n this.inputNamePrefix = inputNamePrefix;\n this.inputIdPrefix = Craft.formatInputId(this.inputNamePrefix);\n\n // see if settings was actually set to the maxBlocks value\n if (typeof settings === 'number') {\n settings = {maxBlocks: settings};\n }\n this.setSettings(settings, Craft.MatrixInput.defaults);\n\n this.$container = $('#' + this.id);\n this.$form = this.$container.closest('form');\n this.$blockContainer = this.$container.children('.blocks');\n this.$addBlockBtnContainer = this.$container.children('.buttons');\n this.$addBlockBtnGroup =\n this.$addBlockBtnContainer.children('.btngroup');\n this.$addBlockBtnGroupBtns = this.$addBlockBtnGroup.children('.btn');\n this.$addBlockMenuBtn = this.$addBlockBtnContainer.children('.menubtn');\n this.$statusMessage = this.$container.find('[data-status-message]');\n\n this.$container.data('matrix', this);\n\n this.setNewBlockBtn();\n\n this.blockTypesByHandle = {};\n\n var i;\n\n for (i = 0; i < this.blockTypes.length; i++) {\n var blockType = this.blockTypes[i];\n this.blockTypesByHandle[blockType.handle] = blockType;\n }\n\n var $blocks = this.$blockContainer.children(),\n collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds();\n\n this.blockSort = new Garnish.DragSort($blocks, {\n handle: '> .actions > .move',\n axis: 'y',\n filter: () => {\n // Only return all the selected items if the target item is selected\n if (this.blockSort.$targetItem.hasClass('sel')) {\n return this.blockSelect.getSelectedItems();\n } else {\n return this.blockSort.$targetItem;\n }\n },\n collapseDraggees: true,\n magnetStrength: 4,\n helperLagBase: 1.5,\n helperOpacity: 0.9,\n onDragStop: () => {\n this.trigger('blockSortDragStop');\n },\n onSortChange: () => {\n this.blockSelect.resetItemOrder();\n },\n });\n\n this.blockSelect = new Garnish.Select(this.$blockContainer, $blocks, {\n multi: true,\n vertical: true,\n handle: '> .checkbox, > .titlebar',\n checkboxMode: true,\n });\n\n for (i = 0; i < $blocks.length; i++) {\n var $block = $($blocks[i]),\n blockId = $block.data('id');\n\n // Is this a new block?\n var newMatch =\n typeof blockId === 'string' && blockId.match(/new(\\d+)/);\n\n if (newMatch && newMatch[1] > this.totalNewBlocks) {\n this.totalNewBlocks = parseInt(newMatch[1]);\n }\n\n var block = new MatrixBlock(this, $block);\n\n if (block.id && $.inArray('' + block.id, collapsedBlocks) !== -1) {\n block.collapse();\n }\n }\n\n this.addListener(this.$addBlockBtnGroupBtns, 'click', function (ev) {\n var type = $(ev.target).data('type');\n this.addBlock(type);\n });\n\n if (this.$addBlockMenuBtn.length) {\n if (this.$addBlockMenuBtn.data('menubtn')) {\n this.$addBlockMenuBtn.data('menubtn').destroy();\n }\n new Garnish.MenuBtn(this.$addBlockMenuBtn, {\n onOptionSelect: (option) => {\n this.addBlock($(option).data('type'));\n },\n });\n }\n\n this.updateAddBlockBtn();\n\n this.addListener(this.$container, 'resize', 'setNewBlockBtn');\n Garnish.$doc.ready(this.setNewBlockBtn.bind(this));\n\n this.trigger('afterInit');\n },\n\n setNewBlockBtn: function () {\n // Do we know what the button group width is yet?\n if (!this.addBlockBtnGroupWidth) {\n this.addBlockBtnGroupWidth = this.$addBlockBtnGroup.width();\n\n if (!this.addBlockBtnGroupWidth) {\n return;\n }\n }\n\n // Only check if the container width has resized\n if (\n this.addBlockBtnContainerWidth !==\n (this.addBlockBtnContainerWidth = this.$addBlockBtnContainer.width())\n ) {\n if (this.addBlockBtnGroupWidth > this.addBlockBtnContainerWidth) {\n if (!this.showingAddBlockMenu) {\n this.$addBlockBtnGroup.addClass('hidden');\n this.$addBlockMenuBtn.removeClass('hidden');\n this.showingAddBlockMenu = true;\n }\n } else {\n if (this.showingAddBlockMenu) {\n this.$addBlockMenuBtn.addClass('hidden');\n this.$addBlockBtnGroup.removeClass('hidden');\n this.showingAddBlockMenu = false;\n\n // Because Safari is awesome\n if (navigator.userAgent.indexOf('Safari') !== -1) {\n Garnish.requestAnimationFrame(() => {\n this.$addBlockBtnGroup.css('opacity', 0.99);\n\n Garnish.requestAnimationFrame(() => {\n this.$addBlockBtnGroup.css('opacity', '');\n });\n });\n }\n }\n }\n }\n },\n\n canAddMoreBlocks: function () {\n return (\n !this.maxBlocks ||\n this.$blockContainer.children().length < this.maxBlocks\n );\n },\n\n updateAddBlockBtn: function () {\n var i, block;\n\n if (this.canAddMoreBlocks()) {\n this.$addBlockBtnGroup.removeClass('disabled');\n this.$addBlockMenuBtn.removeClass('disabled');\n\n this.$addBlockBtnGroupBtns.each(function () {\n $(this).removeAttr('aria-disabled');\n });\n\n for (i = 0; i < this.blockSelect.$items.length; i++) {\n block = this.blockSelect.$items.eq(i).data('block');\n\n if (block) {\n block.$actionMenu\n .find('a[data-action=add]')\n .parent()\n .removeClass('disabled');\n block.$actionMenu\n .find('a[data-action=add]')\n .removeAttr('aria-disabled');\n }\n }\n } else {\n this.$addBlockBtnGroup.addClass('disabled');\n this.$addBlockMenuBtn.addClass('disabled');\n\n this.$addBlockBtnGroupBtns.each(function () {\n $(this).attr('aria-disabled', 'true');\n });\n\n for (i = 0; i < this.blockSelect.$items.length; i++) {\n block = this.blockSelect.$items.eq(i).data('block');\n\n if (block) {\n block.$actionMenu\n .find('a[data-action=add]')\n .parent()\n .addClass('disabled');\n block.$actionMenu\n .find('a[data-action=add]')\n .attr('aria-disabled', 'true');\n }\n }\n }\n },\n\n updateStatusMessage: function () {\n this.$statusMessage.empty();\n let message;\n\n if (!this.canAddMoreBlocks()) {\n message = Craft.t(\n 'app',\n 'Matrix block could not be added. Maximum number of blocks reached.'\n );\n }\n\n setTimeout(() => {\n this.$statusMessage.text(message);\n }, 250);\n },\n\n addBlock: function (type, $insertBefore, autofocus) {\n if (!this.canAddMoreBlocks()) {\n this.updateStatusMessage();\n return;\n }\n\n this.totalNewBlocks++;\n\n const id = `new${this.totalNewBlocks}`;\n const typeName = this.blockTypesByHandle[type].name;\n const actionMenuId = `matrixblock-action-menu-${id}`;\n\n var html = `\n
\n \n \n \n
\n
${\n this.getBlockTypeByHandle(type).name\n }
\n
\n
\n
\n
\n
\n
\n \n
\n `;\n\n if (!this.settings.staticBlocks) {\n html += `\n
\n \n
\n `;\n }\n\n html += `\n
\n
\n \n
\n
`;\n\n var $block = $(html);\n\n // Pause the draft editor\n const elementEditor = this.$form.data('elementEditor');\n if (elementEditor) {\n elementEditor.pause();\n }\n\n if ($insertBefore) {\n $block.insertBefore($insertBefore);\n } else {\n $block.appendTo(this.$blockContainer);\n }\n\n var $fieldsContainer = $('
').appendTo($block),\n bodyHtml = this.getParsedBlockHtml(\n this.blockTypesByHandle[type].bodyHtml,\n id\n ),\n js = this.getParsedBlockHtml(this.blockTypesByHandle[type].js, id);\n\n $(bodyHtml).appendTo($fieldsContainer);\n\n this.trigger('blockAdded', {\n $block: $block,\n });\n\n // Animate the block into position\n $block.css(this.getHiddenBlockCss($block)).velocity(\n {\n opacity: 1,\n 'margin-bottom': 10,\n },\n 'fast',\n () => {\n $block.css('margin-bottom', '');\n Garnish.$bod.append(js);\n Craft.initUiElements($fieldsContainer);\n new MatrixBlock(this, $block);\n this.blockSort.addItems($block);\n this.blockSelect.addItems($block);\n this.updateAddBlockBtn();\n\n Garnish.requestAnimationFrame(() => {\n if (typeof autofocus === 'undefined' || autofocus) {\n // Scroll to the block\n Garnish.scrollContainerToElement($block);\n // Focus on the first focusable element\n $block.find('.flex-fields :focusable').first().trigger('focus');\n }\n\n // Resume the draft editor\n if (elementEditor) {\n elementEditor.resume();\n }\n });\n }\n );\n },\n\n getBlockTypeByHandle: function (handle) {\n for (var i = 0; i < this.blockTypes.length; i++) {\n if (this.blockTypes[i].handle === handle) {\n return this.blockTypes[i];\n }\n }\n },\n\n collapseSelectedBlocks: function () {\n this.callOnSelectedBlocks('collapse');\n },\n\n expandSelectedBlocks: function () {\n this.callOnSelectedBlocks('expand');\n },\n\n disableSelectedBlocks: function () {\n this.callOnSelectedBlocks('disable');\n },\n\n enableSelectedBlocks: function () {\n this.callOnSelectedBlocks('enable');\n },\n\n deleteSelectedBlocks: function () {\n this.callOnSelectedBlocks('selfDestruct');\n },\n\n callOnSelectedBlocks: function (fn) {\n for (var i = 0; i < this.blockSelect.$selectedItems.length; i++) {\n this.blockSelect.$selectedItems.eq(i).data('block')[fn]();\n }\n },\n\n getHiddenBlockCss: function ($block) {\n return {\n opacity: 0,\n marginBottom: -$block.outerHeight(),\n };\n },\n\n getParsedBlockHtml: function (html, id) {\n if (typeof html === 'string') {\n return html.replace(\n new RegExp(`__BLOCK_${this.settings.placeholderKey}__`, 'g'),\n id\n );\n } else {\n return '';\n }\n },\n\n get maxBlocks() {\n return this.settings.maxBlocks;\n },\n },\n {\n defaults: {\n placeholderKey: null,\n maxBlocks: null,\n staticBlocks: false,\n },\n\n collapsedBlockStorageKey:\n 'Craft-' + Craft.systemUid + '.MatrixInput.collapsedBlocks',\n\n getCollapsedBlockIds: function () {\n if (\n typeof localStorage[Craft.MatrixInput.collapsedBlockStorageKey] ===\n 'string'\n ) {\n return Craft.filterArray(\n localStorage[Craft.MatrixInput.collapsedBlockStorageKey].split(',')\n );\n } else {\n return [];\n }\n },\n\n setCollapsedBlockIds: function (ids) {\n localStorage[Craft.MatrixInput.collapsedBlockStorageKey] =\n ids.join(',');\n },\n\n rememberCollapsedBlockId: function (id) {\n if (typeof Storage !== 'undefined') {\n var collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds();\n\n if ($.inArray('' + id, collapsedBlocks) === -1) {\n collapsedBlocks.push(id);\n Craft.MatrixInput.setCollapsedBlockIds(collapsedBlocks);\n }\n }\n },\n\n forgetCollapsedBlockId: function (id) {\n if (typeof Storage !== 'undefined') {\n var collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds(),\n collapsedBlocksIndex = $.inArray('' + id, collapsedBlocks);\n\n if (collapsedBlocksIndex !== -1) {\n collapsedBlocks.splice(collapsedBlocksIndex, 1);\n Craft.MatrixInput.setCollapsedBlockIds(collapsedBlocks);\n }\n }\n },\n }\n );\n\n var MatrixBlock = Garnish.Base.extend({\n matrix: null,\n $container: null,\n $titlebar: null,\n $fieldsContainer: null,\n $previewContainer: null,\n $actionMenu: null,\n $collapsedInput: null,\n\n actionDisclosure: null,\n\n isNew: null,\n id: null,\n\n collapsed: false,\n\n init: function (matrix, $container) {\n this.matrix = matrix;\n this.$container = $container;\n this.$titlebar = $container.children('.titlebar');\n this.$previewContainer = this.$titlebar.children('.preview');\n this.$fieldsContainer = $container.children('.fields');\n\n this.$container.data('block', this);\n\n this.id = this.$container.data('id');\n this.isNew =\n !this.id ||\n (typeof this.id === 'string' && this.id.substring(0, 3) === 'new');\n\n const $actionMenuBtn = this.$container.find(\n '> .actions [data-disclosure-trigger]'\n );\n const actionDisclosure =\n $actionMenuBtn.data('trigger') ||\n new Garnish.DisclosureMenu($actionMenuBtn);\n\n this.$actionMenu = actionDisclosure.$container;\n this.actionDisclosure = actionDisclosure;\n\n actionDisclosure.on('show', () => {\n this.$container.addClass('active');\n if (this.$container.prev('.matrixblock').length) {\n this.$actionMenu\n .find('a[data-action=moveUp]:first')\n .parent()\n .removeClass('hidden');\n } else {\n this.$actionMenu\n .find('a[data-action=moveUp]:first')\n .parent()\n .addClass('hidden');\n }\n if (this.$container.next('.matrixblock').length) {\n this.$actionMenu\n .find('a[data-action=moveDown]:first')\n .parent()\n .removeClass('hidden');\n } else {\n this.$actionMenu\n .find('a[data-action=moveDown]:first')\n .parent()\n .addClass('hidden');\n }\n });\n\n actionDisclosure.on('hide', () => {\n this.$container.removeClass('active');\n });\n\n this.$actionMenuOptions = this.$actionMenu.find('a[data-action]');\n\n this.addListener(\n this.$actionMenuOptions,\n 'click',\n this.handleActionClick\n );\n this.addListener(\n this.$actionMenuOptions,\n 'keydown',\n this.handleActionKeydown\n );\n\n // Was this block already collapsed?\n if (Garnish.hasAttr(this.$container, 'data-collapsed')) {\n this.collapse();\n }\n\n this._handleTitleBarClick = function (ev) {\n ev.preventDefault();\n this.toggle();\n };\n\n this.addListener(this.$titlebar, 'doubletap', this._handleTitleBarClick);\n },\n\n toggle: function () {\n if (this.collapsed) {\n this.expand();\n } else {\n this.collapse(true);\n }\n },\n\n collapse: function (animate) {\n if (this.collapsed) {\n return;\n }\n\n this.$container.addClass('collapsed');\n\n var previewHtml = '',\n $fields = this.$fieldsContainer.children().children();\n\n for (var i = 0; i < $fields.length; i++) {\n var $field = $($fields[i]),\n $inputs = $field\n .children('.input')\n .find('select,input[type!=\"hidden\"],textarea,.label'),\n inputPreviewText = '';\n\n for (var j = 0; j < $inputs.length; j++) {\n var $input = $($inputs[j]),\n value;\n\n if ($input.hasClass('label')) {\n var $maybeLightswitchContainer = $input.parent().parent();\n\n if (\n $maybeLightswitchContainer.hasClass('lightswitch') &&\n (($maybeLightswitchContainer.hasClass('on') &&\n $input.hasClass('off')) ||\n (!$maybeLightswitchContainer.hasClass('on') &&\n $input.hasClass('on')))\n ) {\n continue;\n }\n\n value = $input.text();\n } else {\n value = Craft.getText(this._inputPreviewText($input));\n }\n\n if (value instanceof Array) {\n value = value.join(', ');\n }\n\n if (value) {\n value = Craft.trim(Craft.escapeHtml(value));\n\n if (value) {\n if (inputPreviewText) {\n inputPreviewText += ', ';\n }\n\n inputPreviewText += value;\n }\n }\n }\n\n if (inputPreviewText) {\n previewHtml +=\n (previewHtml ? ' | ' : '') + inputPreviewText;\n }\n }\n\n this.$previewContainer.html(previewHtml);\n\n this.$fieldsContainer.velocity('stop');\n this.$container.velocity('stop');\n\n if (animate && !Garnish.prefersReducedMotion()) {\n this.$fieldsContainer.velocity('fadeOut', {duration: 'fast'});\n this.$container.velocity({height: 32}, 'fast');\n } else {\n this.$previewContainer.show();\n this.$fieldsContainer.hide();\n this.$container.css({height: 32});\n }\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=collapse]:first')\n .parent()\n .addClass('hidden');\n this.$actionMenu\n .find('a[data-action=expand]:first')\n .parent()\n .removeClass('hidden');\n }, 200);\n\n // Remember that?\n if (!this.isNew) {\n Craft.MatrixInput.rememberCollapsedBlockId(this.id);\n } else {\n if (!this.$collapsedInput) {\n this.$collapsedInput = $(\n ''\n ).appendTo(this.$container);\n } else {\n this.$collapsedInput.val('1');\n }\n }\n\n this.collapsed = true;\n },\n\n _inputPreviewText: function ($input) {\n if ($input.is('select,multiselect')) {\n const labels = [];\n const $options = $input.find('option:selected');\n for (let k = 0; k < $options.length; k++) {\n labels.push($options.eq(k).text());\n }\n return labels;\n }\n\n if (\n $input.is('input[type=\"checkbox\"]:checked,input[type=\"radio\"]:checked')\n ) {\n const id = $input.attr('id');\n const $label = $(`label[for=\"${id}\"]`);\n if ($label.length) {\n return $label.text();\n }\n }\n\n return Garnish.getInputPostVal($input);\n },\n\n expand: function () {\n if (!this.collapsed) {\n return;\n }\n\n this.$container.removeClass('collapsed');\n\n this.$fieldsContainer.velocity('stop');\n this.$container.velocity('stop');\n\n var collapsedContainerHeight = this.$container.height();\n this.$container.height('auto');\n this.$fieldsContainer.show();\n var expandedContainerHeight = this.$container.height();\n var displayValue = this.$fieldsContainer.css('display') || 'block';\n this.$container.height(collapsedContainerHeight);\n this.$fieldsContainer\n .hide()\n .velocity('fadeIn', {duration: 'fast', display: displayValue});\n\n const animationDuration = Garnish.prefersReducedMotion() ? 0 : 'fast';\n this.$container.velocity(\n {height: expandedContainerHeight},\n animationDuration,\n () => {\n this.$previewContainer.html('');\n this.$container.height('auto');\n this.$container.trigger('scroll');\n }\n );\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=collapse]:first')\n .parent()\n .removeClass('hidden');\n this.$actionMenu\n .find('a[data-action=expand]:first')\n .parent()\n .addClass('hidden');\n }, 200);\n\n // Remember that?\n if (!this.isNew && typeof Storage !== 'undefined') {\n var collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds(),\n collapsedBlocksIndex = $.inArray('' + this.id, collapsedBlocks);\n\n if (collapsedBlocksIndex !== -1) {\n collapsedBlocks.splice(collapsedBlocksIndex, 1);\n Craft.MatrixInput.setCollapsedBlockIds(collapsedBlocks);\n }\n }\n\n if (!this.isNew) {\n Craft.MatrixInput.forgetCollapsedBlockId(this.id);\n } else if (this.$collapsedInput) {\n this.$collapsedInput.val('');\n }\n\n this.collapsed = false;\n },\n\n disable: function () {\n this.$container.children('input[name$=\"[enabled]\"]:first').val('');\n this.$container.addClass('disabled');\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=disable]:first')\n .parent()\n .addClass('hidden');\n this.$actionMenu\n .find('a[data-action=enable]:first')\n .parent()\n .removeClass('hidden');\n }, 200);\n\n this.collapse(true);\n },\n\n enable: function () {\n this.$container.children('input[name$=\"[enabled]\"]:first').val('1');\n this.$container.removeClass('disabled');\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=disable]:first')\n .parent()\n .removeClass('hidden');\n this.$actionMenu\n .find('a[data-action=enable]:first')\n .parent()\n .addClass('hidden');\n }, 200);\n },\n\n moveUp: function () {\n this.matrix.trigger('beforeMoveBlockUp', {\n block: this,\n });\n let $prev = this.$container.prev('.matrixblock');\n if ($prev.length) {\n this.$container.insertBefore($prev);\n this.matrix.blockSelect.resetItemOrder();\n }\n this.matrix.trigger('moveBlockUp', {\n block: this,\n });\n },\n\n moveDown: function () {\n this.matrix.trigger('beforeMoveBlockDown', {\n block: this,\n });\n let $next = this.$container.next('.matrixblock');\n if ($next.length) {\n this.$container.insertAfter($next);\n this.matrix.blockSelect.resetItemOrder();\n }\n this.matrix.trigger('moveBlockDown', {\n block: this,\n });\n },\n\n handleActionClick: function (event) {\n event.preventDefault();\n this.onActionSelect(event.target);\n },\n\n handleActionKeydown: function (event) {\n const keyCode = event.keyCode;\n\n if (keyCode !== Garnish.SPACE_KEY) return;\n\n event.preventDefault();\n this.onActionSelect(event.target);\n },\n\n onActionSelect: function (option) {\n const batchAction =\n this.matrix.blockSelect.totalSelected > 1 &&\n this.matrix.blockSelect.isSelected(this.$container),\n $option = $(option);\n\n switch ($option.data('action')) {\n case 'collapse': {\n if (batchAction) {\n this.matrix.collapseSelectedBlocks();\n } else {\n this.collapse(true);\n }\n\n break;\n }\n\n case 'expand': {\n if (batchAction) {\n this.matrix.expandSelectedBlocks();\n } else {\n this.expand();\n }\n\n break;\n }\n\n case 'disable': {\n if (batchAction) {\n this.matrix.disableSelectedBlocks();\n } else {\n this.disable();\n }\n\n break;\n }\n\n case 'enable': {\n if (batchAction) {\n this.matrix.enableSelectedBlocks();\n } else {\n this.enable();\n this.expand();\n }\n\n break;\n }\n\n case 'moveUp': {\n this.moveUp();\n break;\n }\n\n case 'moveDown': {\n this.moveDown();\n break;\n }\n\n case 'add': {\n var type = $option.data('type');\n this.matrix.addBlock(type, this.$container);\n break;\n }\n\n case 'delete': {\n if (batchAction) {\n if (\n confirm(\n Craft.t(\n 'app',\n 'Are you sure you want to delete the selected blocks?'\n )\n )\n ) {\n this.matrix.deleteSelectedBlocks();\n }\n } else {\n this.selfDestruct();\n }\n\n break;\n }\n }\n\n this.actionDisclosure.hide();\n },\n\n selfDestruct: function () {\n // Remove any inputs from the form data\n $('[name]', this.$container).removeAttr('name');\n\n this.$container.velocity(\n this.matrix.getHiddenBlockCss(this.$container),\n 'fast',\n () => {\n this.$container.remove();\n this.matrix.updateAddBlockBtn();\n\n this.matrix.trigger('blockDeleted', {\n $block: this.$container,\n });\n }\n );\n },\n });\n})(jQuery);\n"],"names":["$","Craft","MatrixInput","Garnish","Base","extend","id","blockTypes","blockTypesByHandle","inputNamePrefix","inputIdPrefix","showingAddBlockMenu","addBlockBtnGroupWidth","addBlockBtnContainerWidth","$container","$form","$blockContainer","$addBlockBtnContainer","$addBlockBtnGroup","$addBlockBtnGroupBtns","$statusMessage","blockSort","blockSelect","totalNewBlocks","init","settings","i","this","formatInputId","maxBlocks","setSettings","defaults","closest","children","$addBlockMenuBtn","find","data","setNewBlockBtn","length","blockType","handle","$blocks","collapsedBlocks","getCollapsedBlockIds","DragSort","axis","filter","$targetItem","hasClass","getSelectedItems","collapseDraggees","magnetStrength","helperLagBase","helperOpacity","onDragStop","trigger","onSortChange","resetItemOrder","Select","multi","vertical","checkboxMode","$block","blockId","newMatch","match","parseInt","block","MatrixBlock","inArray","collapse","addListener","ev","type","target","addBlock","destroy","MenuBtn","onOptionSelect","option","updateAddBlockBtn","$doc","ready","bind","width","addClass","removeClass","navigator","userAgent","indexOf","requestAnimationFrame","css","canAddMoreBlocks","each","removeAttr","$items","eq","$actionMenu","parent","attr","updateStatusMessage","message","empty","t","setTimeout","text","$insertBefore","autofocus","typeName","name","actionMenuId","html","getBlockTypeByHandle","staticBlocks","elementEditor","pause","insertBefore","appendTo","$fieldsContainer","bodyHtml","getParsedBlockHtml","js","getHiddenBlockCss","velocity","opacity","$bod","append","initUiElements","addItems","scrollContainerToElement","first","resume","collapseSelectedBlocks","callOnSelectedBlocks","expandSelectedBlocks","disableSelectedBlocks","enableSelectedBlocks","deleteSelectedBlocks","fn","$selectedItems","marginBottom","outerHeight","replace","RegExp","placeholderKey","collapsedBlockStorageKey","systemUid","localStorage","filterArray","split","setCollapsedBlockIds","ids","join","rememberCollapsedBlockId","Storage","push","forgetCollapsedBlockId","collapsedBlocksIndex","splice","matrix","$titlebar","$previewContainer","$collapsedInput","actionDisclosure","isNew","collapsed","substring","$actionMenuBtn","DisclosureMenu","on","prev","next","$actionMenuOptions","handleActionClick","handleActionKeydown","hasAttr","_handleTitleBarClick","preventDefault","toggle","expand","animate","previewHtml","$fields","$inputs","inputPreviewText","j","value","$input","$maybeLightswitchContainer","getText","_inputPreviewText","Array","trim","escapeHtml","prefersReducedMotion","duration","height","show","hide","val","is","labels","$options","k","$label","getInputPostVal","collapsedContainerHeight","expandedContainerHeight","displayValue","display","animationDuration","disable","enable","moveUp","$prev","moveDown","$next","insertAfter","event","onActionSelect","keyCode","SPACE_KEY","batchAction","totalSelected","isSelected","$option","confirm","selfDestruct","remove","jQuery"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"MatrixInput.js","mappings":"CAAA,SAAWA,GAMTC,MAAMC,YAAcC,QAAQC,KAAKC,OAC/B,CACEC,GAAI,KACJC,WAAY,KACZC,mBAAoB,KACpBC,gBAAiB,KACjBC,cAAe,KAEfC,qBAAqB,EACrBC,sBAAuB,KACvBC,0BAA2B,KAE3BC,WAAY,KACZC,MAAO,KACPC,gBAAiB,KACjBC,sBAAuB,KACvBC,kBAAmB,KACnBC,sBAAuB,KACvBC,eAAgB,KAEhBC,UAAW,KACXC,YAAa,KACbC,eAAgB,EAEhBC,KAAM,SAAUlB,EAAIC,EAAYE,EAAiBgB,GAAU,IA4BrDC,EA5BqD,OA8BzD,IA7BAC,KAAKrB,GAAKA,EACVqB,KAAKpB,WAAaA,EAClBoB,KAAKlB,gBAAkBA,EACvBkB,KAAKjB,cAAgBT,MAAM2B,cAAcD,KAAKlB,iBAGtB,iBAAbgB,IACTA,EAAW,CAACI,UAAWJ,IAEzBE,KAAKG,YAAYL,EAAUxB,MAAMC,YAAY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":["(function ($) {\n /** global: Craft */\n /** global: Garnish */\n /**\n * Matrix input class\n */\n Craft.MatrixInput = Garnish.Base.extend(\n {\n id: null,\n blockTypes: null,\n blockTypesByHandle: null,\n inputNamePrefix: null,\n inputIdPrefix: null,\n\n showingAddBlockMenu: false,\n addBlockBtnGroupWidth: null,\n addBlockBtnContainerWidth: null,\n\n $container: null,\n $form: null,\n $blockContainer: null,\n $addBlockBtnContainer: null,\n $addBlockBtnGroup: null,\n $addBlockBtnGroupBtns: null,\n $statusMessage: null,\n\n blockSort: null,\n blockSelect: null,\n totalNewBlocks: 0,\n\n init: function (id, blockTypes, inputNamePrefix, settings) {\n this.id = id;\n this.blockTypes = blockTypes;\n this.inputNamePrefix = inputNamePrefix;\n this.inputIdPrefix = Craft.formatInputId(this.inputNamePrefix);\n\n // see if settings was actually set to the maxBlocks value\n if (typeof settings === 'number') {\n settings = {maxBlocks: settings};\n }\n this.setSettings(settings, Craft.MatrixInput.defaults);\n\n this.$container = $('#' + this.id);\n this.$form = this.$container.closest('form');\n this.$blockContainer = this.$container.children('.blocks');\n this.$addBlockBtnContainer = this.$container.children('.buttons');\n this.$addBlockBtnGroup =\n this.$addBlockBtnContainer.children('.btngroup');\n this.$addBlockBtnGroupBtns = this.$addBlockBtnGroup.children('.btn');\n this.$addBlockMenuBtn = this.$addBlockBtnContainer.children('.menubtn');\n this.$statusMessage = this.$container.find('[data-status-message]');\n\n this.$container.data('matrix', this);\n\n this.setNewBlockBtn();\n\n this.blockTypesByHandle = {};\n\n var i;\n\n for (i = 0; i < this.blockTypes.length; i++) {\n var blockType = this.blockTypes[i];\n this.blockTypesByHandle[blockType.handle] = blockType;\n }\n\n var $blocks = this.$blockContainer.children(),\n collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds();\n\n this.blockSort = new Garnish.DragSort($blocks, {\n handle: '> .actions > .move',\n axis: 'y',\n filter: () => {\n // Only return all the selected items if the target item is selected\n if (this.blockSort.$targetItem.hasClass('sel')) {\n return this.blockSelect.getSelectedItems();\n } else {\n return this.blockSort.$targetItem;\n }\n },\n collapseDraggees: true,\n magnetStrength: 4,\n helperLagBase: 1.5,\n helperOpacity: 0.9,\n onDragStop: () => {\n this.trigger('blockSortDragStop');\n },\n onSortChange: () => {\n this.blockSelect.resetItemOrder();\n },\n });\n\n this.blockSelect = new Garnish.Select(this.$blockContainer, $blocks, {\n multi: true,\n vertical: true,\n handle: '> .checkbox, > .titlebar',\n checkboxMode: true,\n });\n\n for (i = 0; i < $blocks.length; i++) {\n var $block = $($blocks[i]),\n blockId = $block.data('id');\n\n // Is this a new block?\n var newMatch =\n typeof blockId === 'string' && blockId.match(/new(\\d+)/);\n\n if (newMatch && newMatch[1] > this.totalNewBlocks) {\n this.totalNewBlocks = parseInt(newMatch[1]);\n }\n\n var block = new MatrixBlock(this, $block);\n\n if (block.id && $.inArray('' + block.id, collapsedBlocks) !== -1) {\n block.collapse();\n }\n }\n\n this.addListener(this.$addBlockBtnGroupBtns, 'click', function (ev) {\n var type = $(ev.target).data('type');\n this.addBlock(type);\n });\n\n if (this.$addBlockMenuBtn.length) {\n this.$addBlockMenuBtn.menubtn();\n this.$addBlockMenuBtn.data('menubtn').on('optionSelect', (ev) => {\n this.addBlock($(ev.option).data('type'));\n });\n }\n\n this.updateAddBlockBtn();\n\n this.addListener(this.$container, 'resize', 'setNewBlockBtn');\n Garnish.$doc.ready(this.setNewBlockBtn.bind(this));\n\n this.trigger('afterInit');\n },\n\n setNewBlockBtn: function () {\n // Do we know what the button group width is yet?\n if (!this.addBlockBtnGroupWidth) {\n this.addBlockBtnGroupWidth = this.$addBlockBtnGroup.width();\n\n if (!this.addBlockBtnGroupWidth) {\n return;\n }\n }\n\n // Only check if the container width has resized\n if (\n this.addBlockBtnContainerWidth !==\n (this.addBlockBtnContainerWidth = this.$addBlockBtnContainer.width())\n ) {\n if (this.addBlockBtnGroupWidth > this.addBlockBtnContainerWidth) {\n if (!this.showingAddBlockMenu) {\n this.$addBlockBtnGroup.addClass('hidden');\n this.$addBlockMenuBtn.removeClass('hidden');\n this.showingAddBlockMenu = true;\n }\n } else {\n if (this.showingAddBlockMenu) {\n this.$addBlockMenuBtn.addClass('hidden');\n this.$addBlockBtnGroup.removeClass('hidden');\n this.showingAddBlockMenu = false;\n\n // Because Safari is awesome\n if (navigator.userAgent.indexOf('Safari') !== -1) {\n Garnish.requestAnimationFrame(() => {\n this.$addBlockBtnGroup.css('opacity', 0.99);\n\n Garnish.requestAnimationFrame(() => {\n this.$addBlockBtnGroup.css('opacity', '');\n });\n });\n }\n }\n }\n }\n },\n\n canAddMoreBlocks: function () {\n return (\n !this.maxBlocks ||\n this.$blockContainer.children().length < this.maxBlocks\n );\n },\n\n updateAddBlockBtn: function () {\n var i, block;\n\n if (this.canAddMoreBlocks()) {\n this.$addBlockBtnGroup.removeClass('disabled');\n this.$addBlockMenuBtn.removeClass('disabled');\n\n this.$addBlockBtnGroupBtns.each(function () {\n $(this).removeAttr('aria-disabled');\n });\n\n for (i = 0; i < this.blockSelect.$items.length; i++) {\n block = this.blockSelect.$items.eq(i).data('block');\n\n if (block) {\n block.$actionMenu\n .find('a[data-action=add]')\n .parent()\n .removeClass('disabled');\n block.$actionMenu\n .find('a[data-action=add]')\n .removeAttr('aria-disabled');\n }\n }\n } else {\n this.$addBlockBtnGroup.addClass('disabled');\n this.$addBlockMenuBtn.addClass('disabled');\n\n this.$addBlockBtnGroupBtns.each(function () {\n $(this).attr('aria-disabled', 'true');\n });\n\n for (i = 0; i < this.blockSelect.$items.length; i++) {\n block = this.blockSelect.$items.eq(i).data('block');\n\n if (block) {\n block.$actionMenu\n .find('a[data-action=add]')\n .parent()\n .addClass('disabled');\n block.$actionMenu\n .find('a[data-action=add]')\n .attr('aria-disabled', 'true');\n }\n }\n }\n },\n\n updateStatusMessage: function () {\n this.$statusMessage.empty();\n let message;\n\n if (!this.canAddMoreBlocks()) {\n message = Craft.t(\n 'app',\n 'Matrix block could not be added. Maximum number of blocks reached.'\n );\n }\n\n setTimeout(() => {\n this.$statusMessage.text(message);\n }, 250);\n },\n\n addBlock: function (type, $insertBefore, autofocus) {\n if (!this.canAddMoreBlocks()) {\n this.updateStatusMessage();\n return;\n }\n\n this.totalNewBlocks++;\n\n const id = `new${this.totalNewBlocks}`;\n const typeName = this.blockTypesByHandle[type].name;\n const actionMenuId = `matrixblock-action-menu-${id}`;\n\n var html = `\n
\n \n \n \n
\n
${\n this.getBlockTypeByHandle(type).name\n }
\n
\n
\n
\n
\n
\n
\n \n
\n `;\n\n if (!this.settings.staticBlocks) {\n html += `\n
\n \n
\n `;\n }\n\n html += `\n
\n
\n \n
\n
`;\n\n var $block = $(html);\n\n // Pause the draft editor\n const elementEditor = this.$form.data('elementEditor');\n if (elementEditor) {\n elementEditor.pause();\n }\n\n if ($insertBefore) {\n $block.insertBefore($insertBefore);\n } else {\n $block.appendTo(this.$blockContainer);\n }\n\n var $fieldsContainer = $('
').appendTo($block),\n bodyHtml = this.getParsedBlockHtml(\n this.blockTypesByHandle[type].bodyHtml,\n id\n ),\n js = this.getParsedBlockHtml(this.blockTypesByHandle[type].js, id);\n\n $(bodyHtml).appendTo($fieldsContainer);\n\n this.trigger('blockAdded', {\n $block: $block,\n });\n\n // Animate the block into position\n $block.css(this.getHiddenBlockCss($block)).velocity(\n {\n opacity: 1,\n 'margin-bottom': 10,\n },\n 'fast',\n () => {\n $block.css('margin-bottom', '');\n Garnish.$bod.append(js);\n Craft.initUiElements($fieldsContainer);\n new MatrixBlock(this, $block);\n this.blockSort.addItems($block);\n this.blockSelect.addItems($block);\n this.updateAddBlockBtn();\n\n Garnish.requestAnimationFrame(() => {\n if (typeof autofocus === 'undefined' || autofocus) {\n // Scroll to the block\n Garnish.scrollContainerToElement($block);\n // Focus on the first focusable element\n $block.find('.flex-fields :focusable').first().trigger('focus');\n }\n\n // Resume the draft editor\n if (elementEditor) {\n elementEditor.resume();\n }\n });\n }\n );\n },\n\n getBlockTypeByHandle: function (handle) {\n for (var i = 0; i < this.blockTypes.length; i++) {\n if (this.blockTypes[i].handle === handle) {\n return this.blockTypes[i];\n }\n }\n },\n\n collapseSelectedBlocks: function () {\n this.callOnSelectedBlocks('collapse');\n },\n\n expandSelectedBlocks: function () {\n this.callOnSelectedBlocks('expand');\n },\n\n disableSelectedBlocks: function () {\n this.callOnSelectedBlocks('disable');\n },\n\n enableSelectedBlocks: function () {\n this.callOnSelectedBlocks('enable');\n },\n\n deleteSelectedBlocks: function () {\n this.callOnSelectedBlocks('selfDestruct');\n },\n\n callOnSelectedBlocks: function (fn) {\n for (var i = 0; i < this.blockSelect.$selectedItems.length; i++) {\n this.blockSelect.$selectedItems.eq(i).data('block')[fn]();\n }\n },\n\n getHiddenBlockCss: function ($block) {\n return {\n opacity: 0,\n marginBottom: -$block.outerHeight(),\n };\n },\n\n getParsedBlockHtml: function (html, id) {\n if (typeof html === 'string') {\n return html.replace(\n new RegExp(`__BLOCK_${this.settings.placeholderKey}__`, 'g'),\n id\n );\n } else {\n return '';\n }\n },\n\n get maxBlocks() {\n return this.settings.maxBlocks;\n },\n },\n {\n defaults: {\n placeholderKey: null,\n maxBlocks: null,\n staticBlocks: false,\n },\n\n collapsedBlockStorageKey:\n 'Craft-' + Craft.systemUid + '.MatrixInput.collapsedBlocks',\n\n getCollapsedBlockIds: function () {\n if (\n typeof localStorage[Craft.MatrixInput.collapsedBlockStorageKey] ===\n 'string'\n ) {\n return Craft.filterArray(\n localStorage[Craft.MatrixInput.collapsedBlockStorageKey].split(',')\n );\n } else {\n return [];\n }\n },\n\n setCollapsedBlockIds: function (ids) {\n localStorage[Craft.MatrixInput.collapsedBlockStorageKey] =\n ids.join(',');\n },\n\n rememberCollapsedBlockId: function (id) {\n if (typeof Storage !== 'undefined') {\n var collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds();\n\n if ($.inArray('' + id, collapsedBlocks) === -1) {\n collapsedBlocks.push(id);\n Craft.MatrixInput.setCollapsedBlockIds(collapsedBlocks);\n }\n }\n },\n\n forgetCollapsedBlockId: function (id) {\n if (typeof Storage !== 'undefined') {\n var collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds(),\n collapsedBlocksIndex = $.inArray('' + id, collapsedBlocks);\n\n if (collapsedBlocksIndex !== -1) {\n collapsedBlocks.splice(collapsedBlocksIndex, 1);\n Craft.MatrixInput.setCollapsedBlockIds(collapsedBlocks);\n }\n }\n },\n }\n );\n\n var MatrixBlock = Garnish.Base.extend({\n matrix: null,\n $container: null,\n $titlebar: null,\n $fieldsContainer: null,\n $previewContainer: null,\n $actionMenu: null,\n $collapsedInput: null,\n\n actionDisclosure: null,\n\n isNew: null,\n id: null,\n\n collapsed: false,\n\n init: function (matrix, $container) {\n this.matrix = matrix;\n this.$container = $container;\n this.$titlebar = $container.children('.titlebar');\n this.$previewContainer = this.$titlebar.children('.preview');\n this.$fieldsContainer = $container.children('.fields');\n\n this.$container.data('block', this);\n\n this.id = this.$container.data('id');\n this.isNew =\n !this.id ||\n (typeof this.id === 'string' && this.id.substring(0, 3) === 'new');\n\n const $actionMenuBtn = this.$container.find(\n '> .actions [data-disclosure-trigger]'\n );\n const actionDisclosure =\n $actionMenuBtn.data('trigger') ||\n new Garnish.DisclosureMenu($actionMenuBtn);\n\n this.$actionMenu = actionDisclosure.$container;\n this.actionDisclosure = actionDisclosure;\n\n actionDisclosure.on('show', () => {\n this.$container.addClass('active');\n if (this.$container.prev('.matrixblock').length) {\n this.$actionMenu\n .find('a[data-action=moveUp]:first')\n .parent()\n .removeClass('hidden');\n } else {\n this.$actionMenu\n .find('a[data-action=moveUp]:first')\n .parent()\n .addClass('hidden');\n }\n if (this.$container.next('.matrixblock').length) {\n this.$actionMenu\n .find('a[data-action=moveDown]:first')\n .parent()\n .removeClass('hidden');\n } else {\n this.$actionMenu\n .find('a[data-action=moveDown]:first')\n .parent()\n .addClass('hidden');\n }\n });\n\n actionDisclosure.on('hide', () => {\n this.$container.removeClass('active');\n });\n\n this.$actionMenuOptions = this.$actionMenu.find('a[data-action]');\n\n this.addListener(\n this.$actionMenuOptions,\n 'click',\n this.handleActionClick\n );\n this.addListener(\n this.$actionMenuOptions,\n 'keydown',\n this.handleActionKeydown\n );\n\n // Was this block already collapsed?\n if (Garnish.hasAttr(this.$container, 'data-collapsed')) {\n this.collapse();\n }\n\n this._handleTitleBarClick = function (ev) {\n ev.preventDefault();\n this.toggle();\n };\n\n this.addListener(this.$titlebar, 'doubletap', this._handleTitleBarClick);\n },\n\n toggle: function () {\n if (this.collapsed) {\n this.expand();\n } else {\n this.collapse(true);\n }\n },\n\n collapse: function (animate) {\n if (this.collapsed) {\n return;\n }\n\n this.$container.addClass('collapsed');\n\n var previewHtml = '',\n $fields = this.$fieldsContainer.children().children();\n\n for (var i = 0; i < $fields.length; i++) {\n var $field = $($fields[i]),\n $inputs = $field\n .children('.input')\n .find('select,input[type!=\"hidden\"],textarea,.label'),\n inputPreviewText = '';\n\n for (var j = 0; j < $inputs.length; j++) {\n var $input = $($inputs[j]),\n value;\n\n if ($input.hasClass('label')) {\n var $maybeLightswitchContainer = $input.parent().parent();\n\n if (\n $maybeLightswitchContainer.hasClass('lightswitch') &&\n (($maybeLightswitchContainer.hasClass('on') &&\n $input.hasClass('off')) ||\n (!$maybeLightswitchContainer.hasClass('on') &&\n $input.hasClass('on')))\n ) {\n continue;\n }\n\n value = $input.text();\n } else {\n value = Craft.getText(this._inputPreviewText($input));\n }\n\n if (value instanceof Array) {\n value = value.join(', ');\n }\n\n if (value) {\n value = Craft.trim(Craft.escapeHtml(value));\n\n if (value) {\n if (inputPreviewText) {\n inputPreviewText += ', ';\n }\n\n inputPreviewText += value;\n }\n }\n }\n\n if (inputPreviewText) {\n previewHtml +=\n (previewHtml ? ' | ' : '') + inputPreviewText;\n }\n }\n\n this.$previewContainer.html(previewHtml);\n\n this.$fieldsContainer.velocity('stop');\n this.$container.velocity('stop');\n\n if (animate && !Garnish.prefersReducedMotion()) {\n this.$fieldsContainer.velocity('fadeOut', {duration: 'fast'});\n this.$container.velocity({height: 32}, 'fast');\n } else {\n this.$previewContainer.show();\n this.$fieldsContainer.hide();\n this.$container.css({height: 32});\n }\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=collapse]:first')\n .parent()\n .addClass('hidden');\n this.$actionMenu\n .find('a[data-action=expand]:first')\n .parent()\n .removeClass('hidden');\n }, 200);\n\n // Remember that?\n if (!this.isNew) {\n Craft.MatrixInput.rememberCollapsedBlockId(this.id);\n } else {\n if (!this.$collapsedInput) {\n this.$collapsedInput = $(\n ''\n ).appendTo(this.$container);\n } else {\n this.$collapsedInput.val('1');\n }\n }\n\n this.collapsed = true;\n },\n\n _inputPreviewText: function ($input) {\n if ($input.is('select,multiselect')) {\n const labels = [];\n const $options = $input.find('option:selected');\n for (let k = 0; k < $options.length; k++) {\n labels.push($options.eq(k).text());\n }\n return labels;\n }\n\n if (\n $input.is('input[type=\"checkbox\"]:checked,input[type=\"radio\"]:checked')\n ) {\n const id = $input.attr('id');\n const $label = $(`label[for=\"${id}\"]`);\n if ($label.length) {\n return $label.text();\n }\n }\n\n return Garnish.getInputPostVal($input);\n },\n\n expand: function () {\n if (!this.collapsed) {\n return;\n }\n\n this.$container.removeClass('collapsed');\n\n this.$fieldsContainer.velocity('stop');\n this.$container.velocity('stop');\n\n var collapsedContainerHeight = this.$container.height();\n this.$container.height('auto');\n this.$fieldsContainer.show();\n var expandedContainerHeight = this.$container.height();\n var displayValue = this.$fieldsContainer.css('display') || 'block';\n this.$container.height(collapsedContainerHeight);\n this.$fieldsContainer\n .hide()\n .velocity('fadeIn', {duration: 'fast', display: displayValue});\n\n const animationDuration = Garnish.prefersReducedMotion() ? 0 : 'fast';\n this.$container.velocity(\n {height: expandedContainerHeight},\n animationDuration,\n () => {\n this.$previewContainer.html('');\n this.$container.height('auto');\n this.$container.trigger('scroll');\n }\n );\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=collapse]:first')\n .parent()\n .removeClass('hidden');\n this.$actionMenu\n .find('a[data-action=expand]:first')\n .parent()\n .addClass('hidden');\n }, 200);\n\n // Remember that?\n if (!this.isNew && typeof Storage !== 'undefined') {\n var collapsedBlocks = Craft.MatrixInput.getCollapsedBlockIds(),\n collapsedBlocksIndex = $.inArray('' + this.id, collapsedBlocks);\n\n if (collapsedBlocksIndex !== -1) {\n collapsedBlocks.splice(collapsedBlocksIndex, 1);\n Craft.MatrixInput.setCollapsedBlockIds(collapsedBlocks);\n }\n }\n\n if (!this.isNew) {\n Craft.MatrixInput.forgetCollapsedBlockId(this.id);\n } else if (this.$collapsedInput) {\n this.$collapsedInput.val('');\n }\n\n this.collapsed = false;\n },\n\n disable: function () {\n this.$container.children('input[name$=\"[enabled]\"]:first').val('');\n this.$container.addClass('disabled');\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=disable]:first')\n .parent()\n .addClass('hidden');\n this.$actionMenu\n .find('a[data-action=enable]:first')\n .parent()\n .removeClass('hidden');\n }, 200);\n\n this.collapse(true);\n },\n\n enable: function () {\n this.$container.children('input[name$=\"[enabled]\"]:first').val('1');\n this.$container.removeClass('disabled');\n\n setTimeout(() => {\n this.$actionMenu\n .find('a[data-action=disable]:first')\n .parent()\n .removeClass('hidden');\n this.$actionMenu\n .find('a[data-action=enable]:first')\n .parent()\n .addClass('hidden');\n }, 200);\n },\n\n moveUp: function () {\n this.matrix.trigger('beforeMoveBlockUp', {\n block: this,\n });\n let $prev = this.$container.prev('.matrixblock');\n if ($prev.length) {\n this.$container.insertBefore($prev);\n this.matrix.blockSelect.resetItemOrder();\n }\n this.matrix.trigger('moveBlockUp', {\n block: this,\n });\n },\n\n moveDown: function () {\n this.matrix.trigger('beforeMoveBlockDown', {\n block: this,\n });\n let $next = this.$container.next('.matrixblock');\n if ($next.length) {\n this.$container.insertAfter($next);\n this.matrix.blockSelect.resetItemOrder();\n }\n this.matrix.trigger('moveBlockDown', {\n block: this,\n });\n },\n\n handleActionClick: function (event) {\n event.preventDefault();\n this.onActionSelect(event.target);\n },\n\n handleActionKeydown: function (event) {\n const keyCode = event.keyCode;\n\n if (keyCode !== Garnish.SPACE_KEY) return;\n\n event.preventDefault();\n this.onActionSelect(event.target);\n },\n\n onActionSelect: function (option) {\n const batchAction =\n this.matrix.blockSelect.totalSelected > 1 &&\n this.matrix.blockSelect.isSelected(this.$container),\n $option = $(option);\n\n switch ($option.data('action')) {\n case 'collapse': {\n if (batchAction) {\n this.matrix.collapseSelectedBlocks();\n } else {\n this.collapse(true);\n }\n\n break;\n }\n\n case 'expand': {\n if (batchAction) {\n this.matrix.expandSelectedBlocks();\n } else {\n this.expand();\n }\n\n break;\n }\n\n case 'disable': {\n if (batchAction) {\n this.matrix.disableSelectedBlocks();\n } else {\n this.disable();\n }\n\n break;\n }\n\n case 'enable': {\n if (batchAction) {\n this.matrix.enableSelectedBlocks();\n } else {\n this.enable();\n this.expand();\n }\n\n break;\n }\n\n case 'moveUp': {\n this.moveUp();\n break;\n }\n\n case 'moveDown': {\n this.moveDown();\n break;\n }\n\n case 'add': {\n var type = $option.data('type');\n this.matrix.addBlock(type, this.$container);\n break;\n }\n\n case 'delete': {\n if (batchAction) {\n if (\n confirm(\n Craft.t(\n 'app',\n 'Are you sure you want to delete the selected blocks?'\n )\n )\n ) {\n this.matrix.deleteSelectedBlocks();\n }\n } else {\n this.selfDestruct();\n }\n\n break;\n }\n }\n\n this.actionDisclosure.hide();\n },\n\n selfDestruct: function () {\n // Remove any inputs from the form data\n $('[name]', this.$container).removeAttr('name');\n\n this.$container.velocity(\n this.matrix.getHiddenBlockCss(this.$container),\n 'fast',\n () => {\n this.$container.remove();\n this.matrix.updateAddBlockBtn();\n\n this.matrix.trigger('blockDeleted', {\n $block: this.$container,\n });\n }\n );\n },\n });\n})(jQuery);\n"],"names":["$","Craft","MatrixInput","Garnish","Base","extend","id","blockTypes","blockTypesByHandle","inputNamePrefix","inputIdPrefix","showingAddBlockMenu","addBlockBtnGroupWidth","addBlockBtnContainerWidth","$container","$form","$blockContainer","$addBlockBtnContainer","$addBlockBtnGroup","$addBlockBtnGroupBtns","$statusMessage","blockSort","blockSelect","totalNewBlocks","init","settings","i","this","formatInputId","maxBlocks","setSettings","defaults","closest","children","$addBlockMenuBtn","find","data","setNewBlockBtn","length","blockType","handle","$blocks","collapsedBlocks","getCollapsedBlockIds","DragSort","axis","filter","$targetItem","hasClass","getSelectedItems","collapseDraggees","magnetStrength","helperLagBase","helperOpacity","onDragStop","trigger","onSortChange","resetItemOrder","Select","multi","vertical","checkboxMode","$block","blockId","newMatch","match","parseInt","block","MatrixBlock","inArray","collapse","addListener","ev","type","target","addBlock","menubtn","on","option","updateAddBlockBtn","$doc","ready","bind","width","addClass","removeClass","navigator","userAgent","indexOf","requestAnimationFrame","css","canAddMoreBlocks","each","removeAttr","$items","eq","$actionMenu","parent","attr","updateStatusMessage","message","empty","t","setTimeout","text","$insertBefore","autofocus","typeName","name","actionMenuId","html","getBlockTypeByHandle","staticBlocks","elementEditor","pause","insertBefore","appendTo","$fieldsContainer","bodyHtml","getParsedBlockHtml","js","getHiddenBlockCss","velocity","opacity","$bod","append","initUiElements","addItems","scrollContainerToElement","first","resume","collapseSelectedBlocks","callOnSelectedBlocks","expandSelectedBlocks","disableSelectedBlocks","enableSelectedBlocks","deleteSelectedBlocks","fn","$selectedItems","marginBottom","outerHeight","replace","RegExp","placeholderKey","collapsedBlockStorageKey","systemUid","localStorage","filterArray","split","setCollapsedBlockIds","ids","join","rememberCollapsedBlockId","Storage","push","forgetCollapsedBlockId","collapsedBlocksIndex","splice","matrix","$titlebar","$previewContainer","$collapsedInput","actionDisclosure","isNew","collapsed","substring","$actionMenuBtn","DisclosureMenu","prev","next","$actionMenuOptions","handleActionClick","handleActionKeydown","hasAttr","_handleTitleBarClick","preventDefault","toggle","expand","animate","previewHtml","$fields","$inputs","inputPreviewText","j","value","$input","$maybeLightswitchContainer","getText","_inputPreviewText","Array","trim","escapeHtml","prefersReducedMotion","duration","height","show","hide","val","is","labels","$options","k","$label","getInputPostVal","collapsedContainerHeight","expandedContainerHeight","displayValue","display","animationDuration","disable","enable","moveUp","$prev","moveDown","$next","insertAfter","event","onActionSelect","keyCode","SPACE_KEY","batchAction","totalSelected","isSelected","$option","confirm","selfDestruct","remove","jQuery"],"sourceRoot":""} \ No newline at end of file diff --git a/src/web/assets/matrix/src/MatrixInput.js b/src/web/assets/matrix/src/MatrixInput.js index 171e2ee94be..15bd857d14a 100644 --- a/src/web/assets/matrix/src/MatrixInput.js +++ b/src/web/assets/matrix/src/MatrixInput.js @@ -121,13 +121,9 @@ }); if (this.$addBlockMenuBtn.length) { - if (this.$addBlockMenuBtn.data('menubtn')) { - this.$addBlockMenuBtn.data('menubtn').destroy(); - } - new Garnish.MenuBtn(this.$addBlockMenuBtn, { - onOptionSelect: (option) => { - this.addBlock($(option).data('type')); - }, + this.$addBlockMenuBtn.menubtn(); + this.$addBlockMenuBtn.data('menubtn').on('optionSelect', (ev) => { + this.addBlock($(ev.option).data('type')); }); }