| 1 |
// Throughout the admin I chose to use slow animations to make it clear that stuff is being hidden or shown depending on settings. |
| 2 |
jQuery(document).ready(function() { |
| 3 |
jQuery('.show_list').change(function() { |
| 4 |
if (jQuery('.show_list:checked').val()=='manual') { |
| 5 |
jQuery('#addmanual-help').show('slow'); |
| 6 |
jQuery('.content_placement').hide('slow'); |
| 7 |
jQuery('.content_placement input').attr('disabled','disabled'); |
| 8 |
} else { |
| 9 |
jQuery('#addmanual-help').hide('slow'); |
| 10 |
jQuery('.content_placement').show('slow'); |
| 11 |
jQuery('.content_placement input').removeAttr('disabled'); |
| 12 |
} |
| 13 |
}); |
| 14 |
if (jQuery('.show_list:checked').val()=='manual') { |
| 15 |
jQuery('#addmanual-help').show('slow'); |
| 16 |
jQuery('.content_placement').hide(); |
| 17 |
jQuery('.content_placement input').attr('disabled','disabled'); |
| 18 |
} |
| 19 |
|
| 20 |
jQuery('#colorSelector').ColorPicker({ |
| 21 |
color: jQuery('#text_color').val(), |
| 22 |
onShow: function (colpkr) { |
| 23 |
jQuery(colpkr).fadeIn(500); |
| 24 |
return false; |
| 25 |
}, |
| 26 |
onHide: function (colpkr) { |
| 27 |
jQuery(colpkr).fadeOut(500); |
| 28 |
return false; |
| 29 |
}, |
| 30 |
onChange: function (hsb, hex, rgb) { |
| 31 |
jQuery('#colorSelector div').css('backgroundColor', '#' + hex); |
| 32 |
jQuery('#text_color').val('#' + hex); |
| 33 |
jQuery('.printfriendly-text2').css('color','#' + hex); |
| 34 |
} |
| 35 |
}); |
| 36 |
|
| 37 |
jQuery('#text_size').change(function(){ |
| 38 |
size = jQuery('#text_size').val(); |
| 39 |
jQuery('.printfriendly-text2').css('font-size',parseInt(size)); |
| 40 |
}).change(); |
| 41 |
|
| 42 |
jQuery('#custom_text').change(function(){ |
| 43 |
pf_custom_text_change(); |
| 44 |
}).change(); |
| 45 |
|
| 46 |
jQuery('#custom_text').keyup(function(){ |
| 47 |
pf_custom_text_change(); |
| 48 |
}); |
| 49 |
|
| 50 |
function pf_custom_text_change(){ |
| 51 |
jQuery('#buttongroup3 span:not(.printandpdf)').text( jQuery('#custom_text').val() ); |
| 52 |
jQuery('#custom span.printfriendly-text2').text( jQuery('#custom_text').val() ); |
| 53 |
} |
| 54 |
|
| 55 |
jQuery('.printfriendly-text2').css('color', jQuery('#text_color').val() ); |
| 56 |
|
| 57 |
function pf_initialize_preview(urlInputSelector, previewSelector) { |
| 58 |
var el = jQuery(urlInputSelector); |
| 59 |
var preview = jQuery(previewSelector + '-preview'); |
| 60 |
var error = jQuery(previewSelector + '-error'); |
| 61 |
el.bind('input paste change keyup', function() { |
| 62 |
setTimeout(function() { |
| 63 |
var img = jQuery('<img />').on('error', function() { |
| 64 |
preview.html(''); |
| 65 |
if(img.attr('src') != '') { |
| 66 |
error.html('<div class="error settings-error"><p><strong>Invalid Image URL</strong></p></div>'); |
| 67 |
} |
| 68 |
}).attr('src', jQuery.trim(el.val())); |
| 69 |
error.html(''); |
| 70 |
preview.html('').append(img); |
| 71 |
}, 100); |
| 72 |
}); |
| 73 |
} |
| 74 |
|
| 75 |
pf_initialize_preview('#custom_image', '#pf-custom-button'); |
| 76 |
pf_initialize_preview('#upload-an-image', '#pf-image'); |
| 77 |
jQuery('#custom_image, #upload-an-image').change(); |
| 78 |
jQuery('#custom_image').bind('focus', function() { |
| 79 |
jQuery('#custom-image').attr('checked', 'checked'); |
| 80 |
jQuery('#pf-custom-button-error').show(); |
| 81 |
}); |
| 82 |
jQuery('#button-style input.radio').bind('change', function() { |
| 83 |
if(jQuery('#custom-image').attr('checked')) { |
| 84 |
jQuery('#pf-custom-button-error').show(); |
| 85 |
} else { |
| 86 |
jQuery('#pf-custom-button-error').hide(); |
| 87 |
} |
| 88 |
}).change(); |
| 89 |
|
| 90 |
jQuery('#pf-logo').bind('change', function() { |
| 91 |
if(jQuery(this).val() == 'favicon') { |
| 92 |
jQuery('.custom-logo, #image-preview').hide(); |
| 93 |
} else { |
| 94 |
jQuery('.custom-logo').css('display', 'inline-block'); |
| 95 |
jQuery('#image-preview').show(); |
| 96 |
} |
| 97 |
}).change(); |
| 98 |
|
| 99 |
jQuery('#website_protocol').bind('change', function() { |
| 100 |
if(jQuery(this).val() == 'https') { |
| 101 |
jQuery('#https-beta-registration').show('slow'); |
| 102 |
} else { |
| 103 |
jQuery('#https-beta-registration').hide('slow'); |
| 104 |
} |
| 105 |
}).change(); |
| 106 |
|
| 107 |
jQuery('#password_protected').bind('change', function() { |
| 108 |
if(jQuery(this).val() == 'yes') { |
| 109 |
jQuery('#javascript').val('yes').change(); |
| 110 |
pf_on_javascript(); |
| 111 |
jQuery('#javascript').attr('disabled', 'disabled'); |
| 112 |
jQuery('#pf-javascript-container').hide('slow'); |
| 113 |
} else { |
| 114 |
jQuery('#javascript').removeAttr('disabled'); |
| 115 |
jQuery('#pf-javascript-container').show('slow'); |
| 116 |
} |
| 117 |
}).change(); |
| 118 |
|
| 119 |
jQuery('#javascript').bind('change', function() { |
| 120 |
if(jQuery(this).val() == 'yes') { |
| 121 |
pf_on_javascript(); |
| 122 |
} else { |
| 123 |
pf_on_no_javascript(); |
| 124 |
} |
| 125 |
}).change(); |
| 126 |
|
| 127 |
function pf_on_javascript() { |
| 128 |
jQuery('.javascript').show(); |
| 129 |
jQuery('.no-javascript').hide(); |
| 130 |
jQuery('#print-options').show('slow'); |
| 131 |
} |
| 132 |
|
| 133 |
function pf_on_no_javascript() { |
| 134 |
jQuery('.javascript').hide(); |
| 135 |
jQuery('.no-javascript').show(); |
| 136 |
jQuery('#print-options').hide('slow'); |
| 137 |
} |
| 138 |
|
| 139 |
}); |
| 140 |
|