Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Табы для настроек темы
В themes.xml в разделе <thumb>970</thumb> после 970 вставить код
<![CDATA[
<style>.block.fields.form .tabs {height: auto;white-space: normal;}</style>
<script>
/*global $*/
$.dmllcTheme = {
tabs: [],
addtabs: function() {
var tabheaders='',tabcontent = '';
for (var i = 0; i < this.tabs.length; i++) {
tabheaders += '<li><a href="#" data-tab-id ='+i+' >'+this.tabs[i]+'</a></li>';
tabcontent += '<div class="block" data-tabcontent-id='+i+'></div>';
}
$('#theme-settings').prepend('<div class="block fields form"><ul class="tabs">'+tabheaders+'</ul><div class="tab-content">'+tabcontent+'</div></div>');
},
parseSettings: function() {
var fields = $('.fields', '#theme-settings').children().not('.wa-design-save-panel');
var tab_id = 0;
this.tabs[tab_id] = '<i class="icon16 home"></i>';
for (var i in Object.keys(fields)) {
if ($(fields[i]).hasClass('field')) {
$(fields[i]).attr('data-tab-id', tab_id);
} else if ($(fields[i]).hasClass('heading')) {
tab_id += 1;
$(fields[i]).attr('data-tab-id', tab_id);
this.tabs[tab_id] = $(fields[i]).text();
}
}
},
moveSettings: function() {
for (var i = 0; i < this.tabs.length; i++) {
$('div[data-tab-id='+i+']').detach().appendTo('div[data-tabcontent-id='+i+']');
$('h5[data-tab-id='+i+']').remove();
$('div[data-tabcontent-id]').hide();
}
},
init: function() {
this.parseSettings();
this.addtabs();
this.moveSettings();
$('#theme-settings').on('click', 'a[data-tab-id]', function(e){
e.preventDefault();
$('a[data-tab-id]').parent().removeClass('selected');
$(this).parent().addClass('selected');
$('div.block','.tab-content').hide();
$('div[data-tabcontent-id='+$(this).data('tab-id')+']','.tab-content').show();
});
$('a[data-tab-id]:first','#theme-settings').trigger('click');
}
};
$.dmllcTheme.init();
</script>]]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.