1function MpFormRepeater(){this.itemHooks=[];this.init=function(){this.addItemHooks();this.buildRepeaterHtml()} 2this.addItemHooks=function(){let _=this;_.itemHooks.push(['item--room',function hookRepeaterRoom($item){let $childsAgeBlueprint=$('.childsAge--blueprint',$item).removeClass('childsAge--blueprint').css('display','').remove();$('.select--childrenCount',$item).change(function(){if($(this).val()>$('.childsAge',$item).length){for(let i=$('.childsAge',$item).length;i<$(this).val();i++){let $childsAge=$childsAgeBlueprint.clone();_.applyCustomSelect($childsAge);_.modifyTagNameForFormFramework($childsAge,$item.data('item-index'));$('.childrensAges',$item).append($childsAge)}}else if($(this).val()<$('.childsAge',$item).length){for(let i=$('.childsAge',$item).length;i>$(this).val();i--){$('.childrensAges',$item).children().last().remove()}}});return $item}]);_.itemHooks.push(['item--treatment',function hookRepeaterRoom($item){return $item}])} 3this.modifyTagNameForFormFramework=function($parent,itemIndex){$('select[data-form-field]',$parent).each(function(index,element){if($(element).data('form-field-is-multi')){$(element).attr('name',$(element).attr('name')+'['+itemIndex+']['+$(element).data('form-field')+'][]')}else{$(element).attr('name',$(element).attr('name')+'['+itemIndex+']['+$(element).data('form-field')+']')}})} 4this.applyCustomSelect=function($parent,options){if(typeof options==='undefined'){options={minimumResultsForSearch:0,width:'element'}} 5$('.select2--lazy',$parent).select2(options);$('span.select2-container',$parent).each(function(index,el){let parent=$(this).parent();$(this).detach().prependTo(parent)})} 6this.computeItem=function($item,currentItemIndex){$item.attr('data-item-index',currentItemIndex);for(var i=0;i<this.itemHooks.length;i++){if($item.hasClass(this.itemHooks[i][0])){$item=this.itemHooks[i][1]($item)}} 7this.modifyTagNameForFormFramework($item,$item.data('item-index'));this.applyCustomSelect($item)} 8this.buildRepeaterHtml=function(){let _=this;$('form.mpForm .formRepeater').each(function(index,element){let $formRepeater=$(this);let $itemBlueprint=$('.item--blueprint',$formRepeater).removeClass('item--blueprint').css('display','').remove();let $itemsHolder=$('.items',$formRepeater);let currentItemIndex=0;$('.item',$formRepeater).each(function(ii,$item){_.computeItem($($item),currentItemIndex);currentItemIndex++}) 9$('.btn--item.btn--add',$formRepeater).click(function(event){event.preventDefault();let $item=$itemBlueprint.clone();_.computeItem($($item),currentItemIndex);$('.btn--item.btn--remove',$item).click(function(event){event.preventDefault();$item.remove()});currentItemIndex++;$itemsHolder.append($item)})})} 10this.init()} 11jQuery(document).ready(function($){window.mp_formRepeater=new MpFormRepeater()})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.