$(function () { $('[data-toggle="tooltip"]').tooltip() }) $(document).on("click", ".navbar-right .dropdown-menu", function(e){ e.stopPropagation(); }); $(document).ready(function() { $('a[href="#search"]').on('click', function(event) { event.preventDefault(); $('#search').addClass('open'); $('#search > form > input[type="search"]').focus(); }); $('#search, #search button.close').on('click keyup', function(event) { if (event.target == this || event.target.className == 'close' || event.keyCode == 27) { $(this).removeClass('open'); } }); // Configure/customize these variables. var showChar = 280; // How many characters are shown by default var ellipsestext = "..."; var moretext = "(more)"; var lesstext = "(less)"; $('.more').each(function() { var content = $(this).html(); if(content.length > showChar) { var c = content.substr(0, showChar); var h = content.substr(showChar, content.length - showChar); var html = '' + c + '' + ellipsestext+ ' ' + h + '  ' + moretext + ''; $(this).html(html); } }); $(".morelink").click(function(){ if($(this).hasClass("less")) { $(this).removeClass("less"); $(this).html(moretext); } else { $(this).addClass("less"); $(this).html(lesstext); } $(this).parent().prev().toggle(); $(this).prev().toggle(); return false; }); }); $(document).ready(function() { $('button#ch_add').on("click", function(event) { // submit form via ajax, then event.preventDefault(); setTimeout(function(){ $('#commentModal').modal( 'hide' ); },2000) }); $(document).ready(function () { $('#ctaModal').modal('show'); }); }); $(window).scroll(function() { var scroll = $(window).scrollTop(), headH = $(".belief-intro").height(); if (scroll >= headH) { $(".belief-content").addClass("display"); } }); function CopyToClipboard(id, f) { text = window.location.href.split('/').slice(0, 3).join('/')+"?id="+id+"&f="+f if (window.clipboardData && window.clipboardData.setData) { // IE specific code path to prevent textarea being shown while dialog is visible. return clipboardData.setData("Text", text); } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { var textarea = document.createElement("textarea"); textarea.textContent = text; textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge. document.body.appendChild(textarea); textarea.select(); try { return document.execCommand("copy"); // Security exception may be thrown by some browsers. } catch (ex) { console.warn("Copy to clipboard failed.", ex); return false; } finally { document.body.removeChild(textarea); } } } function slideVote(id) { var slider = document.getElementById("myRange"+id); //var output = document.getElementById("demo"+id); //output.innerHTML = slider.value; var prev_svote = $.cookie('slideVote_'+id); //if user already voted if (prev_svote !== 'undefined' && prev_svote !== 0) { prev_svote = parseInt(getNum(prev_svote)); var val = slider.value - prev_svote; $.get( "slide_vote.php", { id: id, val: val, type: "repeat" } ); } else { var val = slider.value; $.get( "slide_vote.php", { id: id, val: val, type: "new" } ); } $.cookie('slideVote_'+id, slider.value, { expires: 1 }); $('#avg_score'+id).show(); } function vote( obj, rc_id, type ) { //$('#troll_'+rc_id).attr('class', 'vote-btn-default'); $('#agree_'+rc_id).attr('class', 'vote-btn-default'); $('#disagree_'+rc_id).attr('class', 'vote-btn-default'); //undo previous vote count change var utype = $.cookie('undo_type_'+rc_id); var uval = parseInt(getNum($.cookie('undo_value_'+rc_id))); //console.log(type+utype+uval); if (utype !== 'undefined' && uval !== 0) { $('#'+utype+'_cnt_'+rc_id).text( parseInt($('#'+utype+'_cnt_'+rc_id).text()) + uval ); $.get( "vote.php", { id: rc_id, type: type, val: -1 } ); } //if we just undid a vote, update count. if (utype==type && uval==-1) { //$('#'+type+'_'+rc_id).attr('class', 'vote-btn-secondary'); $.cookie('undo_value_'+rc_id, '0', { expires: 0 }); $.cookie('undo_type_'+rc_id, type, { expires: 1 }); } else { $.cookie("vote_"+rc_id, type, { expires: 1 }); //cookie for class $('#'+type+'_'+rc_id).attr('class', 'vote-btn-secondary'); $('#'+type+'_cnt_'+rc_id).text( parseInt($('#'+type+'_cnt_'+rc_id).text()) + 1 ); $.get( "vote.php", { id: rc_id, type: type, val: 1 } ); $.cookie('undo_value_'+rc_id, '-1', { expires: 1 }); $.cookie('undo_type_'+rc_id, type, { expires: 1 }); } } function getNum(val) { if (isNaN(val)) { return 0; } return val; } function addThis( obj ) { $.get( "/ajax", { action: 'add', content: $('#modal_content').val(), content_type: $('#modal_type').val(), ref_id: $('#modal_ref_id').val() , //notify_check: $('#notify_check').prop('checked'), notify_check: 0, tagline: $('#modal_tagline').val() }, function(data){ } ); $('#modal_conf_div').html('
Thank you for adding your response. It may take a few hours for your submission to be reviewed and put live.
'); $('#modal_form').hide(); } function setModalValues(ref_id='', ref_tagline = '', comment_type='Response') { $('#modal_title').text('RE: ' + ref_tagline); $('#ModalLabel').text('Add ' + comment_type); //$('#summary_title').text(comment_type); $('#modal_ref_id').val(ref_id); $('#modal_type').val(comment_type); $('#modal_conf_div').html(''); $('#modal_tagline').val(''); $('#modal_form').show(); } function handleVote(myRadio) { alert("Please login before voting."); } function validateEmail() { email = $('#email_reg').val(); var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (re.test(String(email).toLowerCase())) { return true; } else { alert('Please input valid email address.'); return false; } }