ips.templates.set('templates.customizationMedia.grid',"	<ul class='cMedia_manager__items'>		{{{contents}}}	</ul>");ips.templates.set('templates.customizationMedia.noItems',"	<div class='i-text-align_center i-font-size_2 i-color_soft i-padding_4'>		{{#lang}}mediaEmptyFolder{{/lang}}	</div>");ips.templates.set('templates.customizationMedia.noSearchResults',"	<div class='i-text-align_center i-font-size_2 i-color_soft i-padding_4'>		{{#lang}}mediaNoResults{{/lang}}	</div>");;
;(function($){"use strict";ips.controller.register('core.admin.customization.customTemplatesForm',{currentHookPoint:null,initialize:function(){this.on('change','input[name=template_type]',this.typeChanged);this.on('change','select[name=template_hookapp]',this.hookAppChanged);this.on('change','select[name^=template_path_]',this.hookPathChanged);this.on('change','select[name^=template_hookpoint_]',this.hookPointChanged);this.on('click','[data-role=viewTemplate]',this.viewTemplate);this.setup();},setup:function(){$('li[id^=template_path_]').hide();$('#template_hookapp').hide();$('li[id^=template_hookpoint_]').hide();$('#template_hookpoint_type').hide();$('#template_key').hide();this.typeChanged();},viewTemplate:function(e){let currentApp=$('select[name=template_hookapp]').val();let currentPath=$('select[name=template_path_'+currentApp+']').val();let dialogRef=ips.ui.dialog.create({title:ips.getString('custom_theme_template_title'),url:'?app=core&module=customization&controller=customtemplates&do=ajaxGetTemplate&hookpoint='+currentApp+'/'+currentPath.replace(/_/g,'/',)+':'+this.currentHookPoint,forceReload:true,remoteSubmit:true});dialogRef.show();},typeChanged:function(e,data){if($('input[name="template_type"]:checked').val()==='hook'){$('#template_key').hide();$('#template_hookapp').show();this.hookAppChanged(e,data);}else{$('#template_hookapp').hide();$('li[id^=template_path_]').hide();$('li[id^=template_hookpoint_]').hide();$('#template_key').show();}},hookAppChanged:function(e,data){$('li[id^=template_path_]').hide();$('li[id^=template_hookpoint_]').hide();$('#template_path_'+$('select[name=template_hookapp]').val()).show();this.hookPathChanged(e,data);},hookPathChanged:function(e,data){let currentApp=$('select[name=template_hookapp]').val();$('li[id^=template_hookpoint_'+currentApp+'_]').hide();$('#template_hookpoint_'+currentApp+'_'+$('select[name=template_path_'+currentApp+']').val()).show();this.hookPointChanged(e,data);},hookPointChanged:function(e,data){let currentApp=$('select[name=template_hookapp]').val();let currentPath=$('select[name=template_path_'+currentApp+']').val();this.currentHookPoint=$('select[name=template_hookpoint_'+currentApp+'_'+currentPath+']').val();$('#template_hookpoint_type').show();this.getTemplateParams(e,data);},getTemplateParams:function(e,data){let currentApp=$('select[name=template_hookapp]').val();let currentPath=$('select[name=template_path_'+currentApp+']').val();ips.getAjax()('?app=core&module=customization&controller=customtemplates&do=ajaxGetAvailableParams',{data:{hookpoint:currentApp+'/'+currentPath.replace(/_/g,'/',)+':'+this.currentHookPoint,hookpoint_type:$('#template_hookpoint_type').val(),}}).done(function(response){$('span[data-template-params]').html(response);});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.customization.designerCore',{_cmInstances:{},isSaving:false,initialize:function(){this.on('click','button[type="submit"]',this.save);this.on('tabChanged',this.changedTab);const debounce=ips.utils.debounce(this._recalculatePanelWrapper.bind(this),100);this.on(window,'resize',debounce);const disableSubmit=()=>{this.isSaving=true}
const debouncedEnableSubmit=ips.utils.debounce(()=>{this.isSaving=false},500)
this.elem.addEventListener('ips:codebox#update',()=>{disableSubmit();debouncedEnableSubmit();})},changedTab:function(e,data){this._recalculatePanelWrapper();},async save(e){e.preventDefault();const form=this.scope.find('form[data-formid="form"]');if(this.isSaving){await new Promise(resolve=>setTimeout(resolve,500));}
const save=Object.fromEntries(new FormData(form.get(0)).entries());Debug.log(save);this.scope.find('button[type="submit"]').addClass('ipsButton_disabled').removeClass('ipsButton_primary');try{await ips.fetch(form.attr('action'),{dataType:'json',data:save,type:'post'});ips.ui.flashMsg.show(ips.getString('saved'));}catch(jqXHR){let message=ips.getString('saveThemeError');try{message=JSON.parse(jqXHR.responseText);}
catch(e){}
ips.ui.alert.show({type:'alert',icon:'warn',message});}
this.scope.find('button[type="submit"]').removeClass('ipsButton_disabled').addClass('ipsButton_primary');},_getContentHeight:function(){return $(window).height()-this.scope.find('#tabs_form').offset().top-250;},_recalculatePanelWrapper:function(){var self=this;for(const cm of Object.values(this._cmInstances)){cm.setSize(null,self._getContentHeight());};}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.customization.emoticons',{initialize:function(){this.on('blur','[data-role="emoticonTyped"]',this.checkTypedValue);this.on('submit',this.submit);this.setup();},setup:function(){this.scope.find('[data-role="setList"]').sortable({update:this._saveSetOrder.bind(this)});this.scope.find('[data-role="emoticonsList"]').sortable({connectWith:this.scope.find('[data-role="emoticonsList"]'),handle:'[data-role="dragHandle"]',update:this._saveOrder.bind(this)});},submit:function(e){if(!window.JSON){return;}
var formElements=this.scope.find(':input:enabled:not([name="csrfKey"])');var output=ips.utils.form.serializeAsObject(formElements);var newInput=$('<input />').attr('type','hidden').attr('name','emoticons_squashed');Debug.log("Before encoding, emoticon data is:");Debug.log(output);output=JSON.stringify(output);this.scope.prepend(newInput.val(output));formElements.prop('disabled',true);},checkTypedValue:function(e){var elem=$(e.currentTarget);var val=elem.val();elem.val(val.replace(/\s/g,''));if(val.match(/\s/)){ips.ui.alert.show({type:'alert',message:ips.getString('emoticon_no_spaces'),icon:'warn'});}},_saveSetOrder:function(){var setOrder=[];this.scope.find('[data-emoticonSet]').each(function(){setOrder.push($(this).attr('data-emoticonSet'));});ips.getAjax()(this.scope.attr('action'),{type:'post',data:{setOrder:setOrder}});},_saveOrder:function(e,ui){var output={};var item=ui.item;var group=ui.item.closest('[data-emoticonSet]').attr('data-emoticonSet');ui.item.find('.cEmoticons_input > input[type="hidden"]').val(group);this.scope.find('[data-emoticonGroup]').each(function(){var itemOrder=[];$(this).find('[data-emoticonID]').each(function(){itemOrder.push(parseInt($(this).attr('data-emoticonID')));});output[$(this).attr('data-emoticonGroup')]=itemOrder;});ips.getAjax()(this.scope.attr('action'),{type:'post',data:output});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.customization.media',{_fileListing:null,_sidebar:null,_cachedFileInfo:{},_searchTimer:null,_uploadURL:'',initialize:function(){this.on('click','[data-role="mediaItem"]',this.clickItem);this.on('click','[data-action="deleteSelected"]',this.deleteSelected);this.on('keyup','[data-role="mediaSearch"]',this.doSearch);this.on('submitDialog','[data-role="uploadButton"]',this.dialogSubmitted);this.on('submitDialog','[data-role="replaceFile"]',this.replaceDialogSubmitted);this.on('click','[data-role="replaceFile"]',this.uploadNewFile);this.setup();},setup:function(){this._fileListing=this.scope.find('[data-role="fileListing"]');this._searchResults=this.scope.find('[data-role="searchResults"]');this._sidebar=this.scope.find('[data-role="mediaSidebar"]');this._uploadURL=this.scope.find('[data-role="uploadButton"]').attr('href');this._searchStyleTag=this.scope.find('[data-role="searchStyleTag"]');this.scope.find('[data-role="uploadButton"]').attr('href',this._uploadURL);this._unselectAll();this._updatePreview();this._checkDeleteButton();},dialogSubmitted:function(e,data){var newHTML=[];for(const[key,file]of Object.entries(data.response.rows)){newHTML.push(file);};this._buildFileListing(newHTML);ips.ui.flashMsg.show(ips.pluralize(ips.getString('mediaUploadedCount'),data.response.count));},replaceDialogSubmitted:function(e,data){var newHTML=[];for(const[key,file]of Object.entries(data.response.rows)){newHTML.push(file);};this._buildFileListing(newHTML);delete this._cachedFileInfo[data.response.fileID];ips.ui.flashMsg.show(ips.getString('mediaUploadedReplace'));this._fileListing.find('[data-fileid="'+data.response.fileID+'"]').trigger('click');},deleteSelected:function(e){e.preventDefault();var self=this;var selected=this._getSelected().closest('[data-role="mediaItem"]');var selectedIDs=[];$.each(selected,function(){selectedIDs.push($(this).attr('data-fileid'));});ips.ui.alert.show({type:'confirm',message:ips.pluralize(ips.getString('mediaConfirmDelete'),selected.length),icon:'warn',callbacks:{ok:function(){selected.find('.cMedia_itemSelected').removeClass('cMedia_itemSelected')
ips.utils.anim.go('fadeOutDown',selected).done(function(){selected.remove();self._updatePreview();self._checkDeleteButton();});ips.getAjax()('?app=core&module=customization&controller=media&do=deleteByFileIds&set_id='+self.scope.attr('data-theme-id'),{data:{fileIds:selectedIDs}}).fail(function(){ips.ui.alert.show({type:'alert',message:ips.pluralize(ips.getString('mediaErrorDeleting'),selected.length)});})}}});},clickItem:function(e){var item=$(e.currentTarget).find('> .cMedia_item');var metaPressed=e.metaKey;if(!metaPressed){this._unselectAll();item.addClass('cMedia_itemSelected');}else if(metaPressed){item.toggleClass('cMedia_itemSelected',(!item.hasClass('cMedia_itemSelected')));}
this._updatePreview();this._checkDeleteButton();},uploadNewFile:function(e){if(e){e.preventDefault();}
var itemId=this._getSelected().closest('[data-role="mediaItem"]').attr('data-fileid');$(e.currentTarget).ipsDialog({remoteSubmit:true,forceReload:true,url:$(e.currentTarget).attr('data-baseUrl')+itemId,destructOnClose:true,title:ips.getString('replaceMediaFile')});},_checkDeleteButton:function(){var selected=this._getSelected().closest('[data-role="mediaItem"]');if(selected.length==0){this.scope.find('[data-action="deleteSelected"]').addClass('ipsHide');}else{this.scope.find('[data-action="deleteSelected"]').removeClass('ipsHide');}},_buildFileListing:function(data){var output;if(!data.length){output=ips.templates.render('templates.customizationMedia.noItems');}else{output=ips.templates.render('templates.customizationMedia.grid',{contents:data.join('')});}
console.log(output);this._fileListing.html(output);$(document).trigger('contentChange',[this._fileListing]);},_updatePreview:function(){var self=this;var selected=this._getSelected().closest('[data-role="mediaItem"]');if(selected.length==0||selected.length>1){var language=(selected.length==0)?ips.getString('mediaNoneSelected'):ips.pluralize(ips.getString('mediaMultipleSelected'),selected.length);this._sidebar.find('[data-role="multipleItemsMessage"]').html(language);this._sidebar.find('[data-role="itemInformation"]').hide().end().find('[data-role="multipleItems"]').show();this._sidebar.find('[data-role="replaceFile"]').hide();}else{var info={itemFilename:selected.attr('data-filename'),itemUploaded:selected.attr('data-uploaded'),itemTag:'{resource="'+selected.attr('data-path').replace(/^\/|\/$/g,'')+'/'+selected.attr('data-filename')+'" app="core" location="front"}',itemUrl:selected.attr('data-url'),itemID:selected.attr('data-fileid'),itemShowDimensions:selected.is('[data-filename$=".jpg"], [data-filename$=".png"], [data-filename$=".gif"], [data-filename$=".webp"], [data-filename$=".jpeg"], [data-filename$=".tiff"], [data-filename$=".avif"]'),itemFilesize:null,itemDimensions:null};var cache=this._cachedFileInfo[info.itemID];if(cache!==undefined){info.itemFilesize=cache['itemFilesize'];info.itemDimensions=cache['itemDimensions'];}else{this._infoAjax=ips.getAjax()('?app=core&module=customization&controller=media&set_id='+this.scope.attr('data-theme-id')+'&do=getFileInfo&id='+info.itemID).done(function(response){self._cachedFileInfo[info.itemID]={itemFilesize:response.fileSize,itemDimensions:response.dimensions};self._sidebar.find('[data-role="itemFilesize"]').text(response.fileSize);self._sidebar.find('[data-role="itemDimensions"]').text(response.dimensions);});}
for(const[key,value]of Object.entries(info)){var elem=self._sidebar.find('[data-role="'+key+'"]');if(elem.is('input')){elem.val(value);}else if(key=='itemPreview'){elem.html(value);}else if(key=='itemUrl'){elem.html($('<a/>').attr('href',value).text(value).attr('target','_blank'));}
else if(value===null){elem.html($('<span/>').addClass('i-color_soft').text('Loading...'));}else{elem.text(value);}};this._sidebar.find('[data-role="itemDimensionsRow"]').toggle(info.itemShowDimensions);this._sidebar.find('[data-role="itemTag"]').get(0).select();this._sidebar.find('[data-role="itemInformation"]').show().end().find('[data-role="multipleItems"]').hide();this._sidebar.find('[data-role="replaceFile"]').show();$(document).trigger('contentChange',[this._sidebar]);}},doSearch:function(){var value=this.scope.find('[data-role="mediaSearch"]').val();if(value.trim()){this._searchStyleTag.html('[data-role="mediaItem"]:not([data-filename*="'+value.replace(/['"]+/g,'')+'" i]){ display: none; }');this._unselectAll();}else{this._searchStyleTag.html('');}
this._updatePreview();this._checkDeleteButton();},_getSelected:function(){if(this._fileListing.is(':visible')){return this._fileListing.find('.cMedia_itemSelected');}else{return this._searchResults.find('.cMedia_itemSelected');}},_resetSearch:function(){this.scope.find('[data-role="mediaSearch"]').val('');this._searchResults.hide();this._fileListing.show();this._unselectAll();this._updatePreview();this._checkDeleteButton();},_unselectAll:function(){this._fileListing.find('.cMedia_item').removeClass('cMedia_itemSelected');this._searchResults.find('.cMedia_item').removeClass('cMedia_itemSelected');}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.customization.themeForm',{initialize:function(){this.headerFooterCssFieldSetUp();},headerFooterCssFieldSetUp:function(){$('#theme_header').addClass('ipsFieldRow--fullWidth');$('#theme_footer').addClass('ipsFieldRow--fullWidth');$('#theme_css').addClass('ipsFieldRow--fullWidth');}});}(jQuery));;