Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function($){
- var options = ['General Options', 'Header Options', 'Footer Options'];
- $('.b4b-options-menu ul li:first').addClass('selected-options'); //make the first set of options selected
- //hide the menus besides the first one
- $('h3').each(function(){
- if($(this).text() != options[0] && $.inArray($(this).text(), options) != -1){ //if the text doesn't equal the first option and is in the options array
- $(this).hide();
- $(this).next().hide();
- }
- });
- //shows menu based on menu click and hides the old one
- $('.b4b-options-menu ul li').click(function(){
- $('.b4b-options-menu ul li').removeClass();
- $(this).addClass('selected-options');
- var name = $(this).text();
- $('h3').each(function(){
- if($(this).text() == name){ //if the h3's text equals the name of the option clicked
- $(this).fadeIn('fast');
- $(this).next().fadeIn('fast');
- } else if($.inArray($(this).text(), options) != -1 && $(this).is(':visible')){ //if the item is in options and is visible then
- $(this).hide();
- $(this).next().hide();
- }
- });
- });
- //when the header options are shown this shows/hides the fields corresponding to the selected option that's loaded
- $('.b4b-options-menu li').click(function(){
- var value;
- $('select#header_type option').each(function(){
- if ($(this).is(':selected')){
- value = $(this).val();
- }
- });
- if (value == 'text'){
- $('span#header_image').closest('tr').hide();
- } else if (value == 'image'){
- $('input#header_title').closest('tr').hide();
- $('input#header_slogan').closest('tr').hide();
- }
- });
- //shows/hides the fields corresponding to the selected option by the user
- $('select#header_type').click(function(){
- if ($(this).val() == 'text'){
- $('span#header_image').closest('tr').hide();
- $('input#header_title').closest('tr').fadeIn('fast');
- $('input#header_slogan').closest('tr').fadeIn('fast');
- } else if ($(this).val() == 'image'){
- $('span#header_image').closest('tr').fadeIn('fast');
- $('input#header_title').closest('tr').hide();
- $('input#header_slogan').closest('tr').hide();
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement