ips.templates.set('templates.editor.newTab'," 	<a href='#' class='ipsTabs__tab' id='ipsTabs_elTemplateEditor_tabbar_tab_{{fileid}}' role='tab' aria-controls='ipsTabs_elTemplateEditor_tabbar_tab_{{fileid}}_panel' aria-selected='false' data-fileid='{{fileid}}' data-location='{{location}}'>{{title}} <span data-action='closeTab'><i class='fa-solid fa-xmark'></i></span></a>");ips.templates.set('templates.editor.tabPanel'," 	<div class='ipsTabs__panel' id='ipsTabs_elTemplateEditor_tabbar_tab_{{fileid}}_panel' role='tabpanel' aria-labelledby='ipsTabs_elTemplateEditor_tabbar_tab_{{fileid}}' hidden data-fileid='{{fileid}}' data-location='{{location}}' data-type='{{type}}' data-group='{{group}}' data-name='{{name}}' data-type='{{type}}' data-itemID='{{id}}' data-inherited-value='{{inherited}}'>		{{{content}}}	</div>");ips.templates.set('templates.editor.tabContent'," 	<input data-role='group' type='hidden' name='group_{{fileid}}' value=\"{{{group}}}\">	<input data-role='variables' type='hidden' name='variables_{{fileid}}' value=\"{{{variables}}}\">	<input data-role='title' type='hidden' name='title_{{fileid}}' value=\"{{{title}}}\">	<input data-role='description' type='hidden' name='description_{{fileid}}' value=\"{{{description}}}\">	<textarea data-fileid='{{fileid}}' id='editor_{{fileid}}'>{{{content}}}</textarea>");ips.templates.set('templates.editor.unsaved'," 	<i class='fa-solid fa-circle'></i>");ips.templates.set('templates.editor.saved'," 	<i class='fa-solid fa-xmark'></i>");ips.templates.set('templates.editor.pagesDiffHeaders'," <div class='cTemplateMergeHeaders i-background_2'>	<div class='cTemplateMergeHeader'>		<div class='i-padding_2'><strong>{{#lang}}theme_diff_original_header{{/lang}}</strong> <span class='i-font-size_-1 i-color_soft'>{{#lang}}theme_diff_original_desc{{/lang}}</span></div>	</div>	<div class='cTemplateMergeHeader'>		<div class='i-padding_2'><strong>{{#lang}}theme_diff_custom_header{{/lang}}</strong> <span class='i-font-size_-1 i-color_soft'>{{#lang}}theme_diff_custom_desc{{/lang}}</span></div>	</div></div>");;
;(function($){"use strict";ips.controller.register('core.admin.templates.conflict',{initialize:function(){this.on('click','.ipsButton',this.makeSelection);this.setup();},setup:function(){$('span[data-conflict-name] input[type=radio]').hide();},makeSelection:function(e){var span=$(e.target).closest('span');var radio=$(span).find('input[type=radio]');var name=$(span).attr('data-conflict-name');var id=$(radio).attr('name').replace(/conflict_/,'');if(span.hasClass('ipsButton--disabled')){return false;}
else if(span.hasClass('ipsButton--secondary')){radio.prop('checked',false);span.removeClass('ipsButton--secondary').addClass('ipsButton--primary').find('strong').html(ips.getString('sc_use_this_version'));$('input[type=radio][name=conflict_'+id+']').closest('span.ipsButton[data-conflict-name='+(name=='new'?'old':'new')+']').removeClass('ipsButton--disabled');$('th span[data-conflict-id='+id+'][data-conflict-name='+name+']').removeClass('ipsBadge ipsBadge--positive');ips.utils.anim.go('blindDown',this.scope.find('div[data-conflict-id='+id+']'));}
else
{radio.prop('checked',true);span.removeClass('ipsButton--primary').addClass('ipsButton--secondary').find('strong').html(ips.getString('sc_remove_selection'));$('input[type=radio][name=conflict_'+id+']').closest('span.ipsButton[data-conflict-name='+(name=='new'?'old':'new')+']').addClass('ipsButton--disabled');$('th span[data-conflict-id='+id+'][data-conflict-name='+name+']').addClass('ipsBadge ipsBadge--positive');ips.utils.anim.go('fadeOut',this.scope.find('div[data-conflict-id='+id+']'));}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('cms.admin.templates.fileEditor',{_tabBar:null,_tabContent:null,_fileStore:{},_ajaxURL:'',_cmInstances:{},_currentHeight:0,_editorPreferences:{wrap:true,lines:false},initialize:function(){this.on(document,'openFile.templates',this.openFile);this.on(document,'variablesUpdated.templates',this.updateVariables);this.on('tabChanged',this.changedTab);this.on('click','[data-action="closeTab"]',this.closeTab);this.on('click','[data-action="save"]',this.save);this.on('click','[data-action="revert"]:not( .ipsButton--disabled )',this.revert);this.on('savedFile.templates',this.updateFile);this.on('revertedFile.templates',this.updateFile);this.on('openDialog',this.openedDialog);this.on('menuItemSelected',this.menuSelected);var debounce=ips.utils.debounce(this._recalculatePanelWrapper.bind(this),100);this.on(window,'resize',debounce);this.setup();},setup:function(){var self=this;this._tabBar=this.scope.find('#elTemplateEditor_tabbar [role="tablist"]');this._tabContent=this.scope.find('#elTemplateEditor_panels');this._currentHeight=this._tabBar.outerHeight();this._ajaxURL=this.scope.closest('[data-ajaxURL]').attr('data-ajaxURL');this._normalURL=this.scope.closest('[data-normalURL]').attr('data-normalURL');this._editorPreferences['wrap']=ips.utils.db.get('templateEditor','wrap');this._editorPreferences['lines']=ips.utils.db.get('templateEditor','lines');if(this._editorPreferences['wrap']){$('#elTemplateEditor_preferences_menu').find('[data-ipsMenuValue="wrap"]').attr("aria-selected","true");}
if(this._editorPreferences['lines']){$('#elTemplateEditor_preferences_menu').find('[data-ipsMenuValue="lines"]').attr("aria-selected","true");}
this._tabContent.find('[data-group]').each(function(i,item){var original=self._tabContent.find('[data-fileid="'+$(item).attr('data-fileid')+
'"] input[data-role="variables"]');if(original.length){original.after($('<input/>').attr('type','hidden').attr('name',original.attr('name')).attr('value',original.attr('value')).attr('data-role','variables'))
original.remove();}
ips.loader.getStatic(['applications/core/interface/static/codemirror/diff_match_patch.js','applications/core/interface/static/codemirror/codemirror.js']).then(function(){self._initCodeMirror($(item).attr('data-fileid'),$(item).attr('data-type'));});});},menuSelected:function(e,data=e.detail){if(data.originalEvent){data.originalEvent.preventDefault();}
if(data.triggerID=='elTemplateEditor_preferences'){if(data.selectedItemID=='diff'){this.toggleDiff();}
else if(data.selectedItemID=='wrap'){this._changeEditorPreference(!ips.utils.db.get('templateEditor','wrap'),'wrap','lineWrapping');}else{this._changeEditorPreference(!ips.utils.db.get('templateEditor','lines'),'lines','lineNumbers');}}},_changeEditorPreference:function(toValue,type,cmName){if(toValue){$('#elTemplateEditor_preferences_menu').find('[data-ipsMenuValue="'+type+'"]').attr("aria-selected","true");}else{$('#elTemplateEditor_preferences_menu').find('[data-ipsMenuValue="'+type+'"]').removeAttr("aria-selected");}
this._editorPreferences[type]=toValue;ips.utils.db.set('templateEditor',type,toValue);for(var i in this._cmInstances){if(this._cmInstances[i]instanceof CodeMirror.MergeView){this._cmInstances[i].edit.setOption(cmName,toValue);this._cmInstances[i].left.orig.setOption(cmName,toValue);}else{this._cmInstances[i].setOption(cmName,toValue);}}},openedDialog:function(e,data){if(data.elemID=='elTemplateEditor_variables'||data.elemID=='elTemplateEditor_attributes'){this._insertVariablesIntoDialog(data);}},_insertVariablesIntoDialog:function(data){var active=this._getActiveTab();if(!active.tabPanel){return;}
var variablesValue=active.tabPanel.find('[data-role="variables"]').val().trim();var descriptionValue=active.tabPanel.find('[data-role="description"]').val().trim();var titleValue=active.tabPanel.find('[data-role="title"]').val().trim();var groupValue=active.tabPanel.find('[data-role="group"]').val().trim();data.dialog.find('[data-role="variables"]').val(variablesValue).end().find('[data-role="description"]').val(descriptionValue).end().find('[name="_variables_fileid"]').val(active.tabPanel.attr('data-fileid')).end().find('[name="_variables_location"]').val(active.tabPanel.attr('data-location')).end().find('[data-role="title"]').val(titleValue);data.dialog.find('select[data-container-type]').addClass('ipsHide');data.dialog.find('select[data-container-type='+active.tabPanel.attr('data-location')+']').removeClass('ipsHide');data.dialog.find('select[data-container-type='+active.tabPanel.attr('data-location')+']').val(groupValue);data.dialog.find('#elTemplateEditor_container_title').show();data.dialog.find('[data-role="container"]').show();data.dialog.find('[data-role="variables"]').show();data.dialog.find('#elTemplateEditor_attributes_title').show();if(active.tabPanel.attr('data-type')!='template'){data.dialog.find('#elTemplateEditor_group_title').hide();data.dialog.find('[data-role="variables"]').hide();data.dialog.find('#elTemplateEditor_attributes_title').hide();}
else if(active.tabPanel.attr('data-location')=='block'){data.dialog.find('#elTemplateEditor_group_title').hide();data.dialog.find('[data-role="group"]').hide();}
else if(active.tabPanel.attr('data-location')=='field'){data.dialog.find('#elTemplateEditor_group_title').hide();data.dialog.find('[data-role="group"]').hide();}
else if(active.tabPanel.attr('data-location')=='database'){data.dialog.find('#elTemplateEditor_group_title').hide();data.dialog.find('[data-role="group"]').hide();data.dialog.find('#elTemplateEditor_title_title').hide();data.dialog.find('[data-role="title"]').hide();}
else if(active.tabPanel.attr('data-location')=='page'){data.dialog.find('[data-role="variables"]').show();data.dialog.find('#elTemplateEditor_attributes_title').show();data.dialog.find('select[data-container-type='+active.tabPanel.attr('data-location')+']').show();}},updateVariables:function(e,data){this._tabContent.find('[data-fileid="'+data.fileID+'"]').find('[data-role="variables"]').val(data.value).end().find('[data-role="title"]').val(data.title).end().find('[data-role="description"]').val(data.description).end().find('[data-role="group"]').val(data.group);this._updateTabLabel(data.fileID,data.title);},toggleDiff:function(){var self=this;var active=this._getActiveTab();var panel=active.tabPanel;var key=panel.attr('data-fileid');if(self._cmInstances[key]instanceof CodeMirror.MergeView){self.scope.find('#editor_'+key).val(this._cmInstances[key].edit.doc.getValue());panel.find('.CodeMirror-merge,.cTemplateMergeHeaders').remove();self._initCodeMirror(key,panel.attr('data-type'));}
else{self._cmInstances[key].save();panel.find('.CodeMirror').remove();panel.addClass('ipsLoading');ips.getAjax()(this._normalURL+'&do=diffTemplate',{dataType:'json',data:this._getParametersFromPanel(panel)}).done(function(response){self._cmInstances[key]=CodeMirror.MergeView(document.getElementById(panel.attr('id')),{value:self.scope.find('#editor_'+key).val(),origLeft:response,lineWrapping:self._editorPreferences['wrap'],lineNumbers:self._editorPreferences['lines'],mode:(panel.attr('data-type')=='templates'?'htmlmixed':'css'),});panel.removeClass('ipsLoading');var headers=$(ips.templates.render('templates.editor.pagesDiffHeaders'));panel.prepend(headers);self._cmInstances[key].edit.on('change',function(doc,cm){self._setChanged(true,key);});});}},save:function(e){e.preventDefault();var self=this;var active=this._getActiveTab();var panel=active.tabPanel;var key=panel.attr('data-fileid');if(!active.tab||!active.tabPanel){Debug.warn('No active tab or tab panel');return;}
var save=this._getParametersFromPanel(panel);if(this._cmInstances[key]instanceof CodeMirror.MergeView){self.scope.find('#editor_'+key).val(this._cmInstances[key].edit.doc.getValue());}else{this._cmInstances[key].save();}
save['editor_'+key]=this.scope.find('#editor_'+key).val();save['t_name']=panel.find('[data-role="title"]').val();save['t_description']=panel.find('[data-role="description"]').val();save['t_group']=panel.find('input[data-role="group"]').val();if(panel.attr('data-location')=='block'||panel.attr('data-location')=='database'||panel.attr('data-location')=='page'||panel.attr('data-location')=='field'){save['t_variables']=panel.find('[data-role="variables"]').val();}
this.trigger('savingFile.templates');ips.getAjax()(this._normalURL+'&do=save',{dataType:'json',data:save,type:'post'}).done(function(response){if(response.msg){ips.ui.alert.show({type:'alert',message:response.msg,icon:'warn'});}
else
{self.trigger('savedFile.templates',{key:key,oldID:parseInt(panel.attr('data-itemID')),newID:parseInt(response.template_id),newTitle:response.template_title,oldContainer:parseInt(panel.attr('data-container')),newContainer:parseInt(response.template_container),status:(response.template_user_added==1)?'custom':'changed'});self._setChanged(false,key);self._updateToolbar(active.tab);self._updateTabLabel(key,response.template_title);}}).fail(function(){ips.ui.alert.show({type:'alert',message:ips.getString('saveThemeError'),icon:'warn'});}).always(function(){self.trigger('saveFileFinished.templates');});},revert:function(e,bypass){e.preventDefault();var self=this;var active=this._getActiveTab();var panel=active.tabPanel;var key=panel.attr('data-fileid');var message=($(e.currentTarget).attr('data-actionType')=='revert')?ips.getString('skin_revert_confirm'):ips.getString('skin_delete_confirm');if(bypass!==true){ips.ui.alert.show({type:'confirm',message:message,icon:'warn',callbacks:{ok:function(){self.revert(e,true);}}});return;}
var save=this._getParametersFromPanel(panel);ips.getAjax()(this._normalURL+'&do=delete&wasConfirmed=1',{dataType:'json',data:save,type:'post'}).done(function(response){if(response.template_id){self._revertedFile(response,key,active);}else{self._deletedFile(key,active);}});},_revertedFile:function(response,key,active){this.trigger('revertedFile.templates',{key:key,oldID:parseInt(active.tabPanel.attr('data-itemID')),newID:parseInt(response.template_id),status:response.InheritedValue});$('#editor_'+key).val(response.template_content);this._cmInstances[key].setValue(response.template_content);this._setChanged(false,key);this._updateToolbar(active.tab);},_deletedFile:function(key,active){this.trigger('deletedFile.templates',{key:key,fileID:active.tabPanel.attr('data-itemID'),location:active.tabPanel.attr('data-location'),type:active.tabPanel.attr('data-type')});active.tab.find('[data-action="closeTab"]').trigger('click');},_getParametersFromPanel:function(panel){return{t_type:panel.attr('data-type'),t_location:panel.attr('data-location'),t_item_id:panel.attr('data-itemID'),t_container:panel.find('input[data-role=container]').val(),t_group:panel.attr('data-group'),t_name:panel.attr('data-name'),t_key:panel.attr('data-fileid')};},updateFile:function(e,data){this.scope.find('[data-itemID="'+data.oldID+'"]').attr('data-itemID',data.newID).attr('data-container',data.newContainer).attr('data-inherited-value',data.status);},closeTab:function(e){var tab=$(e.currentTarget).closest('.ipsTabs__tab');this._doCloseTab(tab);},_doCloseTab:function(tab,bypass){var self=this;var tabParent=tab.closest('[data-fileid]');var key=tabParent.attr('data-fileid');var allTabs=this._tabBar.find('.ipsTabs__tab').closest('[data-fileid]');var newTab=null;if(tabParent.attr('data-state')=='unsaved'&&bypass!=true){ips.ui.alert.show({type:'confirm',message:ips.getString('themeUnsavedContent'),icon:'warn',callbacks:{ok:function(){self._doCloseTab(tab,true);}}});return;}
var active=(tab.attr('aria-selected')==='true');this.trigger('closedTab.templates',{fileID:key});delete(this._cmInstances[key]);if(active&&allTabs.length>1){if(allTabs.first().attr('data-fileid')==tabParent.attr('data-fileid')){newTab=tabParent.next();}else{newTab=tabParent.prev();}}
if(newTab){newTab.trigger('click');}
ips.utils.anim.go('fadeOutDown fast',tabParent).done(function(){tabParent.remove();self._recalculatePanelWrapper();});this._tabContent.find('[data-fileid="'+key+'"]').remove();},changedTab:function(e,data){var tab=data.tab;if(tab.closest('[data-fileid]').attr('data-fileid')!==undefined){this.trigger('fileSelected.templates',{fileID:tab.closest('[data-fileid]').attr('data-fileid')});}
this._updateToolbar(tab);},_updateToolbar:function(tab){var tabParent=tab.closest('[data-fileid]').attr('data-fileid');var tabPanel=this._tabContent.find('[data-fileid="'+tabParent+'"]');var status=tabPanel.attr('data-inherited-value');var type=tabPanel.attr('data-type');var revert=this.scope.find('[data-action="revert"]');var key=tabPanel.attr('data-fileid');switch(status){case'original':case'inherit':revert.addClass('ipsButton--disabled')
break;case'custom':revert.html(ips.getString('skin_delete')).removeClass('ipsButton--disabled').attr('data-actionType','delete').show();break;case'changed':revert.html(ips.getString('skin_delete')).removeClass('ipsButton--disabled').attr('data-actionType','delete').show();break;}
$('#elTemplateEditor_variables').show();$('#elTemplateEditor_attributes').hide();if(this._cmInstances[key]instanceof CodeMirror.MergeView){$('[data-ipsmenuvalue="diff"]').attr("aria-selected","true");}else{$('[data-ipsmenuvalue="diff"]').removeAttr("aria-selected");}},openFile:function(e,data){if(!this._tabBar.find('[data-fileid="'+data.meta.key+'"]').length){this._buildTab(data.meta);}else{this._tabBar.find('[data-fileid="'+data.meta.key+'"]').trigger('click');}},_buildTab:function(meta){var self=this;this._tabContent.attr('data-haseditor','true');this.scope.find('#elTemplateEditor_panels_empty').hide();this._tabBar.append(ips.templates.render('templates.editor.newTab',{title:meta.title,fileid:meta.key,location:meta.location,group:meta.group,container:meta.container,id:'tab_'+meta.key}));this._tabContent.append(ips.templates.render('templates.editor.tabPanel',{fileid:meta.key,name:meta.name,type:meta.type,location:meta.location,container:meta.container,group:meta.group,id:meta.id,inherited:meta.inherited}));this._recalculatePanelWrapper();this._tabBar.find('[data-fileid="'+meta.key+'"]').trigger('click');this._tabContent.addClass('ipsLoading ipsTabs_loadingContent');ips.getAjax()(this._ajaxURL+'&do=loadTemplate&show=json',{dataType:'json',data:{'t_container':meta.container,'t_group':meta.group,'t_name':meta.name,'t_key':meta.key,'t_location':meta.location,'t_type':meta.type}}).done(function(response){self._postProcessNewTab(response,meta);}).always(function(){self._tabContent.removeClass('ipsLoading ipsTabs_loadingContent');});},_updateTabLabel:function(key,title){var span=this._tabBar.find('[data-fileid="'+key+'"] span').clone();this._tabBar.find('[data-fileid="'+key+'"]').html(title).append(span);},_postProcessNewTab:function(response,meta){var content=ips.templates.render('templates.editor.tabContent',{fileid:meta.key,content:response.template_content,variables:response.template_params,description:response.template_desc,title:response.template_title,container:response.template_container,group:response.template_group});this._tabContent.find('[data-fileid="'+meta.key+'"]').html(content);this._initCodeMirror(meta.key,meta.type);},_initCodeMirror:function(key,type){var self=this;this._cmInstances[key]=CodeMirror.fromTextArea(document.getElementById('editor_'+key),{mode:(type=='template'?'htmlmixed':'css'),lineWrapping:this._editorPreferences['wrap'],lineNumbers:this._editorPreferences['lines']});this._cmInstances[key].on('change',function(doc,cm){self._setChanged(true,key);});},_setChanged:function(state,key){if(state==true){this._tabBar.find('[data-fileid="'+key+'"]').attr('data-state','unsaved').find('[data-action="closeTab"]').html(ips.templates.render('templates.editor.unsaved'));}else{this._tabBar.find('[data-fileid="'+key+'"]').attr('data-state','saved').find('[data-action="closeTab"]').html(ips.templates.render('templates.editor.saved'));}},_recalculatePanelWrapper:function(){},_getActiveTab:function(){var toReturn={tab:null,tabPanel:null};var tab=this._tabBar.find('[aria-selected="true"]').first();if(!tab.length){return toReturn;}
toReturn={tab:tab,tabPanel:this._tabContent.find('[data-fileid="'+tab.attr('data-fileid')+'"]')};return toReturn;},_getTabContentHeight:function(){var tabContentTop=this._tabContent.offset().top;var windowHeight=$(window).height();var infoHeight=$('#elTemplateEditor_info').outerHeight();this._panelHeight=windowHeight-tabContentTop-infoHeight;return this._panelHeight;}});}(jQuery));;
;(function($){"use strict";ips.controller.register('cms.admin.templates.fileList',{_tabBar:null,_tabContent:null,initialize:function(){this.on('click','[data-action="openFile"]',this.openFile);this.on('modifiedFile.templates',this.refreshFileList);this.on(document,'fileSelected.templates',this.selectFile);this.on(document,'savedFile.templates revertedFile.templates',this.updateItemMeta);this.on(document,'savedFile.templates revertedFile.templates',this.fileChangedStatus);this.on(document,'addedFile.templates',this.refreshFileList);this.on(document,'deletedFile.templates',this.refreshFileList);this.setup();},setup:function(){this._tabBar=this.scope.find('#elTemplateEditor_typeTabs');this._tabContent=this.scope.find('#elTemplateEditor_fileList');},refreshFileList:function(e,data){var self=this;var type=data.type;var panel=this._tabContent.find('.cTemplateList[data-type="'+type+'"]');var activeItem=panel.find('.cTemplateList_activeNode > a').attr('data-key');if(!panel.length){this._tabBar.find('[data-type="'+type+'"]').trigger('click');}else{var open=this._getOpenNodes(panel);var url=this._tabBar.find('[data-type="'+type+'"]').attr('data-tabURL');ips.getAjax()(url).done(function(response){panel.html(response);self._openNodes(open,panel,activeItem);if(data.fileID){panel.find('[data-itemid="'+data.fileID+'"]').trigger('click');}
self.trigger('fileListRefreshed.templates');});}},_openNodes:function(toOpen,panel,activeItem){var selector=[];if(toOpen.locations.length){for(var i=0;i<toOpen.locations.length;i++){selector.push('[data-location="'+toOpen.locations[i]+'"]');}}
if(toOpen.groups.length){for(var i=0;i<toOpen.groups.length;i++){var str='[data-location="'+toOpen.groups[i][0]+'"] ';str+='[data-group="'+toOpen.groups[i][1]+'"]';selector.push(str);}}
panel.find('.cTemplateList_activeBranch').removeClass('cTemplateList_activeBranch').addClass('cTemplateList_inactiveBranch').end().find(selector.join(',')).removeClass('cTemplateList_inactiveBranch').addClass('cTemplateList_activeBranch');if(activeItem){panel.find('[data-key="'+activeItem+'"]').trigger('click');}},_getOpenNodes:function(panel){var locations=[];var groups=[];panel.find('.cTemplateList_activeBranch').each(function(i,item){var el=$(item);if(el.attr('data-location')){locations.push(el.attr('data-location'));}
if(el.attr('data-group')){groups.push([el.closest('[data-location]').attr('data-location'),el.attr('data-group')]);}});return{locations:locations,groups:groups};},selectFile:function(e,data){if(data.fileID){this._makeActive(data.fileID);}},openFile:function(e){e.preventDefault();var elem=$(e.currentTarget);var meta={name:elem.attr('data-name'),key:elem.attr('data-key'),type:elem.closest('[data-type]').attr('data-type'),title:elem.text(),group:elem.closest('[data-group]').attr('data-group'),location:elem.closest('[data-location]').attr('data-location'),id:elem.closest('[data-itemID]').attr('data-itemID'),inherited:elem.closest('[data-inherited-value]').attr('data-inherited-value')};Debug.log(meta);this.trigger('openFile.templates',{meta:meta});},updateItemMeta:function(e,data){if(data.oldID!=data.newID){this.scope.find('[data-itemID="'+data.oldID+'"]').attr('data-itemID',data.newID);}
this.scope.find('[data-itemID="'+data.newID+'"]').attr('data-name',data.newTitle).html(data.newTitle);if(data.oldContainer!=data.newContainer){data.fileID=data.newID;this.trigger('modifiedFile.templates',data);}},fileChangedStatus:function(e,data){this.scope.find('[data-key="'+data.key+'"]').attr('data-inherited-value',data.status);},_makeActive:function(fileID){var file=this.scope.find('[data-key="'+fileID+'"]');this.scope.find('[data-key]').parent().removeClass('cTemplateList_activeNode');file.parent().addClass('cTemplateList_activeNode');file.parents('li[data-group], li[data-location]').each(function(idx,parent){if($(parent).hasClass('cTemplateList_inactiveBranch')){$(parent).removeClass('cTemplateList_inactiveBranch').addClass('cTemplateList_activeBranch').find('> ul').show();}});},_currentType:function(){if(this._tabBar.find('[data-type="template"]').attr('aria-selected')==="true"){return'template';}
if(this._tabBar.find('[data-type="js"]').attr('aria-selected')==="true"){return'js';}
return'css';}});}(jQuery));;
;(function($){"use strict";ips.controller.register('cms.admin.templates.main',{_timer:null,_textField:null,_lastValue:'',_ajax:null,initialize:function(){this._textField=$(this.scope).find('[data-role="templateSearch"]');this.on(document,'focus','[data-role="templateSearch"]',this.fieldFocus);this.on(document,'blur','[data-role="templateSearch"]',this.fieldBlur);this.on('menuItemSelected',this.menuSelected);this.on('savingFile.templates',this.showLoading);this.on('saveFileFinished.templates',this.hideLoading);},showLoading:function(e){ips.utils.anim.go('fadeIn',this.scope.find('[data-role="loading"]'));},hideLoading:function(e){ips.utils.anim.go('fadeOut',this.scope.find('[data-role="loading"]'));},fieldFocus:function(e){this._timer=setInterval(this._timerFocus.bind(this),700);},fieldBlur:function(e){clearInterval(this._timer);},_timerFocus:function(){var currentValue=this._textField.val();if(currentValue==this._lastValue){return;}
this._lastValue=currentValue;this._loadResults();},_swapTab:function(e,data){if(data.barID=='elTemplateEditor_typeTabs'){this._loadResults();}},menuSelected:function(e,data=e.detail){if(data.originalEvent){data.originalEvent.preventDefault();}
this._loadResults();},_loadResults:function(){if(this._ajax){this._ajax.abort();}
if(this._lastValue){this._textField.addClass('ipsField_loading');}
var type=$('#elTemplateEditor_typeTabs').find('[aria-selected="true"]').attr('data-type');var type=(type=='templates')?'template':type;$('#elTemplateEditor_fileList').find('li[data-type='+type+']').addClass('ipsHide');var filters=[];$('#elTemplateFilterMenu_menu [aria-selected="true"]').each(function(){filters.push($(this).attr('data-ipsMenuValue'));});var self=this;this._ajax=ips.getAjax()($(this.scope).attr('data-ajaxURL')+'&do=searchtemplates&type='+type+'&term='+encodeURIComponent(this._lastValue)+'&filters='+filters.join(',')).done(function(response){var i;var j;for(j in response){$('#elTemplateEditor_fileList').find('[data-location="'+j+'"]').removeClass('ipsHide');var k;for(k in response[j]){$('#elTemplateEditor_fileList').find('[data-location="'+j+'"] [data-group="'+k+'"]').removeClass('ipsHide');var l;for(l in response[j][k]){if(k=='.'){$('#elTemplateEditor_fileList').find('[data-location="'+j+'"] [data-name="'+response[j][k][l]+'"]').parent().removeClass('ipsHide');}else{$('#elTemplateEditor_fileList').find('[data-location="'+j+'"] [data-group="'+k+'"] [data-name="'+response[j][k][l]+'"]').parent().removeClass('ipsHide');}}}}
self._textField.removeClass('ipsField_loading');});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('cms.admin.templates.variablesDialog',{initialize:function(){this.on('click','input[type="submit"]',this.submitChange);},submitChange:function(e){var key=this.scope.find('[name="_variables_fileid"]').val();$('[data-fileid="'+key+'"]').attr('data-state','unsaved').find('[data-action="closeTab"]').html(ips.templates.render('templates.editor.unsaved'));this.trigger('variablesUpdated.templates',{fileID:this.scope.find('[name="_variables_fileid"]').val(),value:this.scope.find('[data-role="variables"]').val(),title:this.scope.find('[data-role="title"]').val(),description:this.scope.find('[data-role="description"]').val(),container:this.scope.find('[data-role="container"]').val(),group:this.scope.find('[data-role="group"]:not(.ipsHide)').val()});this.trigger('closeDialog');}});}(jQuery));;