| 1 |
/** |
| 2 |
* Custom jQuery functions and trigger events |
| 3 |
*/ |
| 4 |
jQuery(document).ready(function($){ |
| 5 |
$("#setting-error-settings_updated").hide(); |
| 6 |
|
| 7 |
// Show Hide Toggle Box |
| 8 |
$(".option-content").hide(); |
| 9 |
|
| 10 |
$(".open").show(); |
| 11 |
|
| 12 |
$("h3.option-toggle").click(function(){ |
| 13 |
$(this).toggleClass("option-active").next().slideToggle("fast"); |
| 14 |
return false; |
| 15 |
}); |
| 16 |
|
| 17 |
setTimeout(function () { |
| 18 |
$(".fade").fadeOut("slow", function () { |
| 19 |
$(".fade").remove(); |
| 20 |
}); |
| 21 |
|
| 22 |
}, 2000); |
| 23 |
|
| 24 |
if (jQuery('#catchwebtools_seo_title').length ) { |
| 25 |
var length = jQuery("#catchwebtools_seo_title").val().length; |
| 26 |
jQuery("#catchwebtools_seo_title_left").html(70-length); |
| 27 |
|
| 28 |
length = jQuery("#catchwebtools_seo_description").val().length; |
| 29 |
jQuery("#catchwebtools_seo_description_left").html(156-length); |
| 30 |
|
| 31 |
jQuery("#catchwebtools_seo_title").keypress (function(){ |
| 32 |
var length = jQuery(this).val().length; |
| 33 |
jQuery("#catchwebtools_seo_title_left").html(70-length); |
| 34 |
}); |
| 35 |
jQuery("#catchwebtools_seo_description").keypress (function(){ |
| 36 |
var length = jQuery(this).val().length; |
| 37 |
jQuery("#catchwebtools_seo_description_left").html(156-length); |
| 38 |
}); |
| 39 |
} |
| 40 |
|
| 41 |
//For Color picker in social icons |
| 42 |
if (jQuery('#catchwebtools_social_colorpicker').length ) { |
| 43 |
$('#catchwebtools_social_colorpicker').hide(); |
| 44 |
|
| 45 |
$("#catchwebtools_social_color").click(function(){jQuery('#catchwebtools_social_colorpicker').slideToggle()}); |
| 46 |
|
| 47 |
$('#catchwebtools_social_colorpicker').farbtastic(function() { |
| 48 |
$("#catchwebtools_social_color").css("background-color",$.farbtastic('#catchwebtools_social_colorpicker').color).css("color", invertColor($.farbtastic('#catchwebtools_social_colorpicker').color)); |
| 49 |
|
| 50 |
$("#catchwebtools_social_color").val($.farbtastic('#catchwebtools_social_colorpicker').color); |
| 51 |
|
| 52 |
$(".genericon").css("color", $.farbtastic('#catchwebtools_social_colorpicker').color); |
| 53 |
}); |
| 54 |
|
| 55 |
var default_color = $("#catchwebtools_social_color").val(); |
| 56 |
|
| 57 |
var icon_size = $("#catchwebtools_social_icon_size").val() + 'px'; |
| 58 |
|
| 59 |
$("#catchwebtools_social_color").css({ |
| 60 |
'background-color' : default_color, |
| 61 |
'color' : invertColor(default_color) |
| 62 |
}); |
| 63 |
} |
| 64 |
|
| 65 |
$(".genericon").css({ |
| 66 |
'color' : default_color, |
| 67 |
'font-size' : icon_size, |
| 68 |
width : icon_size, |
| 69 |
height : icon_size |
| 70 |
}); |
| 71 |
|
| 72 |
$("#catchwebtools_social_icon_size").change(function(){ |
| 73 |
var size = this.value + 'px'; |
| 74 |
|
| 75 |
$(".genericon").css({ |
| 76 |
'font-size' : size, |
| 77 |
width : size, |
| 78 |
height : size |
| 79 |
}); |
| 80 |
}); |
| 81 |
|
| 82 |
}); |
| 83 |
|
| 84 |
/** |
| 85 |
* Function to inverted hex color with the one in parameter |
| 86 |
* @param {[string]} hexTripletColor [hex color] |
| 87 |
* @return {[string]} [inverted hex color] |
| 88 |
*/ |
| 89 |
function invertColor(hexTripletColor) { |
| 90 |
var color = hexTripletColor; |
| 91 |
color = color.substring(1); // remove # |
| 92 |
color = parseInt(color, 16); // convert to integer |
| 93 |
color = 0xFFFFFF ^ color; // invert three bytes |
| 94 |
color = color.toString(16); // convert to hex |
| 95 |
color = ("000000" + color).slice(-6); // pad with leading zeros |
| 96 |
color = "#" + color; // prepend # |
| 97 |
return color; |
| 98 |
} |
| 99 |
|
| 100 |
|