Advertisement
kaed

b4b-options.js - 7/22/13

Jul 22nd, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 2.13 KB | None | 0 0
  1. jQuery(document).ready(function($){
  2.     var options = ['General Options', 'Header Options', 'Footer Options'];
  3.     $('.b4b-options-menu ul li:first').addClass('selected-options'); //make the first set of options selected
  4.    
  5.     //hide the menus besides the first one
  6.     $('h3').each(function(){
  7.         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
  8.             $(this).hide();
  9.             $(this).next().hide();
  10.         }
  11.     });
  12.    
  13.     //shows menu based on menu click and hides the old one
  14.     $('.b4b-options-menu ul li').click(function(){
  15.         $('.b4b-options-menu ul li').removeClass();
  16.         $(this).addClass('selected-options');
  17.        
  18.         var name = $(this).text();
  19.         $('h3').each(function(){
  20.             if($(this).text() == name){ //if the h3's text equals the name of the option clicked
  21.                 $(this).fadeIn('fast');
  22.                 $(this).next().fadeIn('fast');
  23.             } else if($.inArray($(this).text(), options) != -1 && $(this).is(':visible')){ //if the item is in options and is visible then
  24.                 $(this).hide();
  25.                 $(this).next().hide();
  26.             }
  27.         });
  28.     });
  29.    
  30.     //when the header options are shown this shows/hides the fields corresponding to the selected option that's loaded
  31.     $('.b4b-options-menu li').click(function(){
  32.         var value;
  33.         $('select#header_type option').each(function(){
  34.             if ($(this).is(':selected')){
  35.                 value = $(this).val();
  36.             }
  37.         });
  38.        
  39.         if (value == 'text'){
  40.             $('span#header_image').closest('tr').hide();
  41.         } else if (value == 'image'){
  42.             $('input#header_title').closest('tr').hide();
  43.             $('input#header_slogan').closest('tr').hide();
  44.         }
  45.     });
  46.    
  47.     //shows/hides the fields corresponding to the selected option by the user
  48.     $('select#header_type').click(function(){
  49.         if ($(this).val() == 'text'){
  50.             $('span#header_image').closest('tr').hide();
  51.             $('input#header_title').closest('tr').fadeIn('fast');
  52.             $('input#header_slogan').closest('tr').fadeIn('fast');
  53.         } else if ($(this).val() == 'image'){
  54.             $('span#header_image').closest('tr').fadeIn('fast');
  55.             $('input#header_title').closest('tr').hide();
  56.             $('input#header_slogan').closest('tr').hide();
  57.         }
  58.     });
  59. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement