options-custom.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * Prints out the inline javascript needed for the colorpicker and choosing
  3. * the tabs in the panel.
  4. */
  5. jQuery(document).ready(function($) {
  6. // Fade out the save message
  7. $('.fade').delay(1000).fadeOut(1000);
  8. $('.of-color').wpColorPicker();
  9. // Switches option sections
  10. $('.group').hide();
  11. var activetab = '';
  12. if (typeof(localStorage) != 'undefined' ) {
  13. activetab = localStorage.getItem("activetab");
  14. }
  15. if (activetab != '' && $(activetab).length ) {
  16. $(activetab).fadeIn();
  17. } else {
  18. $('.group:first').fadeIn();
  19. }
  20. $('.group .collapsed').each(function(){
  21. $(this).find('input:checked').parent().parent().parent().nextAll().each(
  22. function(){
  23. if ($(this).hasClass('last')) {
  24. $(this).removeClass('hidden');
  25. return false;
  26. }
  27. $(this).filter('.hidden').removeClass('hidden');
  28. });
  29. });
  30. if (activetab != '' && $(activetab + '-tab').length ) {
  31. $(activetab + '-tab').addClass('nav-tab-active');
  32. }
  33. else {
  34. $('.nav-tab-wrapper a:first').addClass('nav-tab-active');
  35. }
  36. $('.nav-tab-wrapper a').click(function(evt) {
  37. $('.nav-tab-wrapper a').removeClass('nav-tab-active');
  38. $(this).addClass('nav-tab-active').blur();
  39. var clicked_group = $(this).attr('href');
  40. if (typeof(localStorage) != 'undefined' ) {
  41. localStorage.setItem("activetab", $(this).attr('href'));
  42. }
  43. $('.group').hide();
  44. $(clicked_group).fadeIn();
  45. evt.preventDefault();
  46. // Editor Height (needs improvement)
  47. $('.wp-editor-wrap').each(function() {
  48. var editor_iframe = $(this).find('iframe');
  49. if ( editor_iframe.height() < 30 ) {
  50. editor_iframe.css({'height':'auto'});
  51. }
  52. });
  53. });
  54. $('.group .collapsed input:checkbox').click(unhideHidden);
  55. function unhideHidden(){
  56. if ($(this).attr('checked')) {
  57. $(this).parent().parent().parent().nextAll().removeClass('hidden');
  58. }
  59. else {
  60. $(this).parent().parent().parent().nextAll().each(
  61. function(){
  62. if ($(this).filter('.last').length) {
  63. $(this).addClass('hidden');
  64. return false;
  65. }
  66. $(this).addClass('hidden');
  67. });
  68. }
  69. }
  70. // Image Options
  71. $('.of-radio-img-img').click(function(){
  72. $(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
  73. $(this).addClass('of-radio-img-selected');
  74. });
  75. $('.of-radio-img-label').hide();
  76. $('.of-radio-img-img').show();
  77. $('.of-radio-img-radio').hide();
  78. });