jQuery(document).ready(function(){ /* DESKTOP */ assign_chevron('.widget_archive'); assign_chevron('.widget_recent_entries'); assign_chevron('.widget_nav_menu'); assign_chevron('.widget_meta'); assign_chevron('.widget_categories'); assign_chevron('.widget_pages'); addArrowToPosts(); cboxplaceholder(); topInfoInit(); jQuery("#commentform").submit(function(){ var comm = jQuery("#comment").val(); jQuery("#comment_error").remove(); if(comm == '' || comm == wp_npr_str.comment_placeholder) { jQuery("#submit").after(''+wp_npr_str.comment_error+''); var hidecobo = setInterval(function(){hideCommentEmpty()},3000); return false; } else if(jQuery("#author").length > 0 && jQuery("#email").length > 0) { var aut = jQuery("#author").val(); var em = jQuery("#email").val(); if(aut == '' || em == '' || aut == wp_npr_str.author_laceholder || em == wp_npr_str.email_placeholder) { jQuery("#submit").after(''+wp_npr_str.comment_required+''); var hidecobo = setInterval(function(){hideCommentEmpty()},3000); return false; } } else { return true; } }); /* MOBILE */ jQuery("#mobile_footer_nav_open > ul > li > a").prepend(''); jQuery("#mobile_header_nav_open > ul > li > a").prepend(''); jQuery("#footer_mobile_menu").click(function(){ jQuery("#mobile_footer_nav_open").toggle(); return false; }); jQuery("#mobile_menu").click(function(){ jQuery("#mobile_header_nav_open").toggle(); return false; }); /* TABLET */ jQuery("#top_searchbox").click(function(){ jQuery("#top_search").addClass('active'); }); jQuery('#content_area').click(function(){ if(jQuery("#top_search").hasClass('active')) jQuery("#top_search").removeClass('active'); }); }); function assign_chevron(to) { jQuery(''+to+' ul > li > a').prepend(''); } function cboxplaceholder() { setPlaceholder(jQuery("#comment"),wp_npr_str.comment_placeholder); setPlaceholder(jQuery("#author"),wp_npr_str.author_placeholder); setPlaceholder(jQuery("#email"),wp_npr_str.email_placeholder); setPlaceholder(jQuery("#url"),wp_npr_str.url_placeholder); } function hideCommentEmpty() { jQuery("#comment_error").fadeOut(600,function(){jQuery("#comment_error").remove();}); } function elementSupportsAttribute(element, attribute) { var test = document.createElement(element); if(attribute in test) { return true; } else { return false; } } function setPlaceholder(elm,plht) { if (!elementSupportsAttribute('textarea','placeholder')) { elm.val(plht); elm.css("color", "#999") .focus(function() { if (this.value == plht) { this.value = ""; } }) .blur(function() { if (this.value == "") { this.value = plht; } }); } else { elm.attr("placeholder", plht); } } function initNprContactForm(formid,cpn,cpn1,cpn2,cpd) { setPlaceholder(jQuery("#name_"+formid),wp_npr_str.contact_name_placeholder); setPlaceholder(jQuery("#email_"+formid),wp_npr_str.contact_email_placeholder); setPlaceholder(jQuery("#subject_"+formid),wp_npr_str.subject_placeholder); setPlaceholder(jQuery("#message_"+formid),wp_npr_str.message_placeholder); setPlaceholder(jQuery("#errn_"+formid),wp_npr_str.contact_cpnres + ''+(cpn1/2/cpd)+' + '+(cpn2/3/cpd)+''); jQuery("#"+formid).append(''); jQuery("#"+formid).submit(function(){ var msg_err = ''; var name_con = jQuery("#name_"+formid).val(); var email_con = jQuery("#email_"+formid).val(); var subject_con = jQuery("#subject_"+formid).val(); var message_con = jQuery("#message_"+formid).val(); var captcha_con = jQuery("#errn_"+formid).val(); var rcpn = cpn / cpd; var emchck = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; jQuery("#errbox_"+formid).remove(); if(name_con == '' || name_con == wp_npr_str.contact_name_placeholder) { msg_err = msg_err + '

' + wp_npr_str.contact_name_required + '

'; } if(email_con == '' || email_con == wp_npr_str.contact_email_placeholder) { msg_err = msg_err + '

' + wp_npr_str.contact_email_required + '

'; } else if(!emchck.test(email_con)) { msg_err = msg_err + '

' + wp_npr_str.contact_wrongemail + '

'; } if(subject_con == '' || subject_con == wp_npr_str.subject_placeholder) { msg_err = msg_err + '

' + wp_npr_str.contact_subject_required + '

'; } if(message_con == '' || message_con == wp_npr_str.message_placeholder) { msg_err = msg_err + '

' + wp_npr_str.contact_message_required + '

'; } if(captcha_con != rcpn) { msg_err = msg_err + '

' + wp_npr_str.contact_captcha_not_match + '

'; } if(msg_err == '') { jQuery.post(jQuery(this).attr('action'),jQuery("#"+formid).serializeArray(),function(data) { if(data == 1) { jQuery("#cfrm_"+formid).fadeOut(300,function(){ jQuery("#cfrm_"+formid).html(wp_npr_str.contact_form_sent).fadeIn(300); }); } else { jQuery("#submit_"+formid).parent('p').after('
'+data+'
'); } }); } else { jQuery("#submit_"+formid).parent('p').after('
'+msg_err+'
'); } return false; }); } function cformEmail(sp1,sp2,frm) { var frmid = 'cformem_'+frm; var ema = sp1 + '@' + sp2; jQuery('#'+frmid).attr('href','mailto:'+ema).html(ema); } function addArrowToPosts() { //jQuery('.content-area .content-title a').append(' »'); } function topInfoInit() { var tpm = '50px'; var topt = 'top_first_title_ok'; if(jQuery("#top_small_title").length == 0) { tpm = '68px'; topt = 'top_first_title_ok_b'; } jQuery("#top_first_title").addClass(topt,800); jQuery("#top_small_title").addClass('top_small_title_ok',800); /*jQuery("#top_first_title").animate({"top":tpm,"opacity":1},800); jQuery("#top_small_title").animate({"bottom":"40px","opacity":1},800);*/ }