$(document).ready(function() { // user vars var onload_auth; var association_id; var comment_type; var tmp_this; var id; var login_pulled; //move to top on click $("a.to_top").click(function() { $('html, body').animate({scrollTop:0}, 'slow') }); //show link_info data on click $("a.link_info").click(function() { $(this).next().next("div.hide").toggle(300); }); $('img#remove_new_here').click(function() { $(this).parent().parent().fadeOut(300); }); onload_auth = $("input[name='onload_auth']#onload_auth").val(); if(onload_auth) { $("input[name='author']").val(""); $("input[name='from']").val("your name"); $("div.comment_form").children("div.message").hide(); $("div.comment_form").children("form.form_add_comment").show(); $("div#my_account").show(); $("div#register").hide(); $("div#login").hide(); bind_form_my_account(); } else { $("div.comment_form").children("div.message").show(); $("div.comment_form").children("form.form_add_comment").hide(); } if(onload_auth<3) { // enable the admin stylesheet document.styleSheets[4].disabled = false; } else { // disable the admin stylesheet document.styleSheets[4].disabled = true; } editor_tools(); // login jQuery pulldown $("#btn_pulldown").click(function(){ $("div#panel").animate({ height: "310px" }) .animate({ height: "275px" }, "fast"); $("div.panel_button").toggle(); login_pulled = true; }); $("#hide_button").click(function(){ $("div#panel").animate({ height: "310px" }) .animate({ height: "275px" }, "fast"); $("div.panel_button").toggle(); }); $("div#hide_button").click(function(){ $("div#panel").animate({ height: "0px" }, "fast"); login_pulled = false; }); // bind 'form_register' and provide a callback function $('form#form_register').ajaxForm({ target: '#register_result', success: function() { $('#register_result').fadeIn(300,function() { $('#register_result').fadeOut(2000,function() { var auth; var full_name; var nickname; id = ""; id = $("input[name='register_id']#register_id").val(); if(id) { //hide the login/register forms $("div#login").fadeOut(300); $("div#register").fadeOut(300,function() { //show the account form $.get("index.php",{'ajax_form_my_account':id}, function(form_my_account) { //replace the my account div with the updated form content $("div#my_account").html(form_my_account); $("div#my_account").fadeIn(300); // bind 'form_my_account' and provide a callback function bind_form_my_account(); jQuery('.btn_facebox_change_img').facebox(); //recall functions that are unable to operate after new DOM element is added change_to_pw(); clear_on_focus(); } ); }); $('#btn_pulldown').html("\"\"My Account"); // change page data to reflect logged-in status $("input[name='author']").val(id); $("input[name='from']").val(full_name); $(".comment_form.message").hide(); $("div.comment_form").children("div.message").hide(); $("div.comment_form").children("form.form_add_comment").show(); if(auth<3) { // enable the admin stylesheet document.styleSheets[4].disabled = false; } } }); }); } }); // bind 'form_login' and provide a callback function $('form#form_login').ajaxForm({ target: '#login_result', success: function() { $('#login_result').fadeIn(300,function() { $('#login_result').fadeOut(2000,function() { id = ""; id = $("input[name='login_id']#login_id").val(); var auth = $("input[name='auth']#auth").val(); var full_name = $("input[name='full_name']#full_name").val(); var nickname = $("input[name='nickname']#nickname").val(); if(id) { //hide the login/register forms $("div#login").fadeOut(300); $("div#register").fadeOut(300,function() { //show the account form $.get("index.php",{'ajax_form_my_account':id}, function(form_my_account) { //replace the my account div with the updated form content $("div#my_account").html(form_my_account); $("div#my_account").fadeIn(300); // bind 'form_my_account' and provide a callback function bind_form_my_account(); jQuery('.btn_facebox_change_img').facebox(); //recall functions that are unable to operate after new DOM element is added change_to_pw(); clear_on_focus(); } ); }); $('#btn_pulldown').html("\"\"My Account"); // change page data to reflect logged-in status $("input[name='author']").val(id); $("input[name='from']").val(full_name); $("div.comment_form").children("div.message").hide(); $("div.comment_form").children("form.form_add_comment").show(); if(auth<3) { // enable the admin stylesheet document.styleSheets[4].disabled = false; } } }); }); } }); // bind 'form_contact' and provide a callback function $('form#form_contact').ajaxForm({ target: '#contact_result', success: function() { } }); // bind 'form_add_comment' and provide a callback function $('form.form_add_comment').ajaxForm(function() { $.get("index.php",{'ajax_comment_count':association_id, 'ajax_show_comments_type':comment_type}, function(comment_count) { $(tmp_this).prev("span.show_comments").html("\"\" " + comment_count + " comments"); } ); }); // bind 'form_share_this' and provide a callback function $('form.form_share_this').ajaxForm({ success: function(responseText) { var to_email = $(tmp_this).parents().siblings("input[name='to_email']").val(); $(tmp_this).parents().siblings("span.share_this").html(responseText); $(tmp_this).parents().siblings("span.share_this").fadeOut(2000,function() { $(tmp_this).parents().siblings("span.share_this").html("\"\"share this"); $(tmp_this).parents().siblings("span.share_this").fadeIn(300); }); } }); $("button#btn_logout").live('click', function() { $.get("index.php",{'ajax_logout':'1'}, function() { // revert the My Account link to login/register $("#btn_pulldown").hide(); $("#btn_pulldown").html("\"Login\"Login or Register"); $("#btn_pulldown").fadeIn(300); //change page data to reflect logout onload_auth = undefined; id = undefined; // disable the admin stylesheet document.styleSheets[4].disabled = true; $('.editor_recover').remove(); $("div.comment_form").children("div.message").show(); $("div.comment_form").children("form.form_add_comment").hide(); $("div#my_account").fadeOut(300,function() { $("div#register").fadeIn(300); $("div#login").fadeIn(300); }); //reset the forms $("form.form_add_comment").each(function() { this.reset(); }); $("form.form_share_this").each(function() { this.reset(); }); } ); }); clear_on_focus(); //change class="change_to_pw" to revert the type to password instead of text change_to_pw(); // when "read more" is clicked, hide "read more", show the rest of the article, and add "collapse" option $(".read_more").click(function() { $(this).parent().toggle(); $(this).parent().next().fadeIn(300); }); $(".collapse").click(function() { $(this).parent().toggle(); $(this).parent().prev().fadeIn(300); }); // social share $("span.share_this").click(function() { $(this).hide(); $(this).siblings("span.add_comment").fadeIn(300); $(this).siblings("span.show_comments").fadeIn(300); $(this).siblings("div.comment_form").hide(); $(this).siblings("div.comments").hide(); $(this).siblings("div.share_form").fadeIn(300); }); $("span.add_comment").click(function() { $(this).hide(); $(this).siblings("span.share_this").fadeIn(300); $(this).siblings("span.show_comments").fadeIn(300); $(this).siblings("div.share_form").hide(); $(this).siblings("div.comments").hide(); $(this).siblings("div.comment_form").fadeIn(300); comment_type = $(this).siblings("div.comment_form").children("form.form_add_comment").children("input[name='type']").val(); association_id = $(this).siblings("div.comment_form").children("form.form_add_comment").children("input[name='association_id']").val(); tmp_this = this; }); $("span.show_comments").click(function() { $(this).hide(); $(this).siblings("span.add_comment").fadeIn(300); $(this).siblings("span.share_this").fadeIn(300); $(this).siblings("div.share_form").hide(); $(this).siblings("div.comment_form").hide(); comment_type = $(this).siblings("div.comment_form").children("form.form_add_comment").children("input[name='type']").val(); association_id = $(this).siblings("div.comment_form").children("form.form_add_comment").children("input[name='association_id']").val(); tmp_this = this; $.get("index.php",{'ajax_show_comments':association_id, 'ajax_show_comments_type':comment_type}, function(comments) { $(tmp_this).siblings("div.comments").children("div.comment_data").html(comments); jQuery('.comments_facebox').facebox(); } ); $(this).siblings("div.comments").fadeIn(300); }); $("button.negative.comment").click(function() { $(this).parents("div.hide").fadeOut(100); $("span.add_comment").show(); }); $("button.positive.comment").click(function() { $(this).parents("div.hide").fadeOut(100); $("span.add_comment").show(); $(tmp_this).prev("span.show_comments").html ( "\"\" \"\" comments" ); }); $("button.negative.share").click(function() { $(this).parents("div.hide").fadeOut(100); $("span.share_this").show(); }); $("button.positive.share").click(function() { $(this).parents("div.hide").fadeOut(100); $(this).parents().siblings("span.share_this").html("\"\" sharing..."); $(this).parents().siblings("span.share_this").show(); tmp_this = this; }); $(".collapse_comments").click(function() { $(this).parent(".hide").fadeOut(100); $("span.show_comments").show(); }); $("div.buttons button").live('click', function() { $(this).ajaxStart(function() { //when all page ajax functions start, do this: if(jQuery("img", this).attr("src") != "images/ajax_loader_green.gif") { jQuery("img", this).data('prev_img',jQuery("img", this).attr("src")); } jQuery("img", this).attr("src","images/ajax_loader_green.gif"); }); $(this).ajaxComplete(function() { //when all page ajax functions stop, do this: jQuery("img", this).attr("src",jQuery("img", this).data('prev_img')); $(this).unbind("ajaxStart"); $(this).unbind("ajaxComplete"); }); }); jQuery('.btn_facebox').facebox(); jQuery('.btn_facebox_change_img').facebox(); $(document).bind('reveal.facebox', function() { clear_on_focus(); bind_form_post_dream(); bind_form_share_dreams(); bind_form_fulfill_dream(); bind_form_change_user_img(); jQuery('.2nd_facebox').facebox(); }); $('a.facebox_login_required').click(function() { if(!onload_auth && !id) { $('html, body').animate({scrollTop:0}, 'slow', function() { if(!login_pulled) { $("div#panel").animate({ height: "310px" }) .animate({ height: "275px" }, "fast", function() { }); $("div.panel_button").toggle(); login_pulled = true; } $("div#login_required").fadeIn(2000,function() { $(this).fadeOut(4000); // change the login panel area to indicate the user must login to continue }); }); } else { var rel = $(this).attr("rel"); jQuery.facebox({ ajax: rel }); } }); }); //these jquery functions exist because jquery is unable to see new DOM elements added after initial load //these functions are called after new DOM elements are added //live(); does not currently support important interactions like focus, blur, etc function add_tinymce() { $('textarea.tinymce').tinymce( { // Location of TinyMCE script script_url : 'js/tiny_mce/tiny_mce_gzip.js', // General options theme : "advanced", skin : "thebigreason", disk_cache : true, debug : false, plugins : "safari,advimage,advlink,iespell,inlinepopups,media,contextmenu,paste,fullscreen,visualchars,nonbreaking,xhtmlxtras", // Theme options theme_advanced_buttons1 : "formatselect,bold,italic,underline,strikethrough,|,bullist,numlist,blockquote,|,link,media,charmap,pasteword,code,fullscreen", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "css/content.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "lists/template_list.js", external_link_list_url : "lists/link_list.js", external_image_list_url : "lists/image_list.js", media_external_list_url : "lists/media_list.js" }); } function editor_tools() { // edit featured scholarship title $('h1.editor_edit img.edit_this_featured_scholarship').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //title edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var title = $(this).parent().html(); title = title.split("'); $(this).parent().prev().find('input[name=edit_title]').focus(); $(this).parent().hide(); bind_form_edit_featured_scholarship_title(); }); // edit event title $('h1.editor_edit img.edit_this_event').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //title edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var title = $(this).parent().html(); title = title.split("
Cancel
'); $(this).parent().prev().find('input[name=edit_title]').focus(); $(this).parent().hide(); bind_form_edit_event_title(); }); // edit data title $('h1.editor_edit img.edit_this_data').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //title edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var title = $(this).parent().html(); title = title.split("
Cancel
'); $(this).parent().prev().find('input[name=edit_title]').focus(); $(this).parent().hide(); bind_form_edit_title(); }); // edit article title $('h2.editor_edit img.edit_this').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //title edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var title = $(this).parent().html(); title = title.split("
Cancel
'); $(this).parent().prev().find('input[name=edit_title]').focus(); $(this).parent().hide(); bind_form_edit_title(); }); // edit article content $('div.editor_edit img.edit_this').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //content edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var content = $(this).prev().html(); content = content.split('

Cancel
'); $(this).parent().prev().find('textarea').focus(); bind_form_edit_content(); add_tinymce(); }); // edit featured_scholarship data $('div.editor_edit img.edit_this_featured_scholarship').live("click",function() { //hide other edits in process $('.editor_edit_content:hidden').toggle(); $('.editor_edit_content:visible').prev('.edit_container').remove(); //content edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var content = $(this).parent().html(); content = content.split("'); $(this).parent().prev().find('textarea').focus(); bind_form_edit_featured_scholarship_content(); add_tinymce(); }); // edit event data $('div.editor_edit img.edit_this_event').live("click",function() { //hide other edits in process $('.editor_edit_content:hidden').toggle(); $('.editor_edit_content:visible').prev('.edit_container').remove(); //content edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var content = $(this).parent().html(); content = content.split("

Cancel
'); $(this).parent().prev().find('textarea').focus(); bind_form_edit_event_content(); add_tinymce(); }); // edit article author, date, tag $('span.editor_edit img.edit_this').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //author edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var author = $(this).parent().html(); author = author.split("'+months[i]+''; else months[i] = ''; } $(this).parent().before('
Cancel
'); $(this).parent().hide(); $(this).parent().prev().find('select').focus(); bind_form_edit_author(); }); // edit featured scholarship date $('h5.editor_edit img.edit_this_featured_scholarship').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //author edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var author = $(this).parent().html(); author = author.split("'+months[i]+''; else months[i] = ''; } $(this).parent().before('
'); $(this).parent().hide(); $(this).parent().prev().find('select').focus(); bind_form_edit_featured_scholarship_date(); }); // edit event location and date $('h5.editor_edit img.edit_this_event').live("click",function() { //hide other edits in process $('.editor_edit:hidden').toggle(); $('.editor_edit:visible').prev('.edit_container').remove(); //author edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var author = $(this).parent().html(); author = author.split("'+months[i]+''; else months[i] = ''; } $(this).parent().before('
at :Cancel
'); $(this).parent().hide(); $(this).parent().prev().find('select').focus(); bind_form_edit_event_location(); }); // edit content data $('div.editor_edit img.edit_this_data').live("click",function() { //hide other edits in process $('.editor_edit_content:hidden').toggle(); $('.editor_edit_content:visible').prev('.edit_container').remove(); //content edit var parent_id = $(this).parent().parent().attr('id'); parent_id = parent_id.split("id_"); var content = $(this).parent().html(); content = content.split("

Cancel
'); $(this).parent().prev().find('textarea').focus(); bind_form_edit_data(); add_tinymce(); }); $('img#edit_cancel').live("click",function() { $(this).parent().parent().parent().siblings(':hidden').toggle(); $(this).parent().parent().parent().remove(); }); $('img#add_cancel').live("click",function() { $(this).parent().parent().parent().parent().remove(); }); $('#edit_publish').live("click",function() { $(this).data('prev_img',$(this).attr("src")); $(this).attr("src", "/images/icons/ajax_loader.gif"); }); $('#add_publish').live("click",function() { $(this).data('prev_img',$(this).attr("src")); $(this).attr("src", "/images/icons/ajax_loader.gif"); }); // delete process $('img.delete_this_comment').live("click",function() { var parent_id = $(this).parent().attr('id'); parent_id = parent_id.split("id_"); $(this).parent().children(":not(img)").fadeTo('slow',0.1); $(this).before('Recover This Comment'); $(this).remove(); $.get("/dev/index.php",{'do':'26','id':parent_id},function(responseText) { //return }); }); // recover the deleted item $('img.recover_this_comment').live("click",function() { var parent_id = $(this).parent().attr('id'); parent_id = parent_id.split("id_"); $(this).siblings().fadeTo('slow',1.0); $(this).before('Delete This Comment'); $(this).remove(); $.get("/dev/index.php",{'do':'27','id':parent_id},function(responseText) { //return }); }); // delete post process $('img.delete_this').live("click",function() { var parent_id = $(this).parent().attr('id'); parent_id = parent_id.split("id_"); $(this).parent().children(":not(img)").fadeTo('slow',0.1); $(this).before('Recover This Post'); $(this).remove(); $.get("/dev/index.php",{'do':'17','id':parent_id},function(responseText) { //return }); }); // recover the deleted item $('img.recover_this').live("click",function() { var parent_id = $(this).parent().attr('id'); parent_id = parent_id.split("id_"); $(this).siblings().fadeTo('slow',1.0); $(this).before('Delete This Post'); $(this).remove(); $.get("/dev/index.php",{'do':'18','id':parent_id},function(responseText) { //return }); }); // create new post $('img.add_new').live("click",function() { var date = new Date(); var year = date.getYear()+1900; var day = date.getDate(); var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); for (var i=0; i < months.length;++i) { month_value = i+1; if(i == date.getMonth()) months[i] = ''; else months[i] = ''; } var add_form = '
Cancel
'; $(this).parent().before(add_form); $('form.form_add_post').find('input.add_title').focus(); bind_form_add_post(); add_tinymce(); }); // create new featured scholarship $('img.add_new_featured_scholarship').live("click",function() { var date = new Date(); var year = date.getYear()+1900; var day = date.getDate(); var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); for (var i=0; i < months.length;++i) { month_value = i+1; if(i == date.getMonth()) months[i] = ''; else months[i] = ''; } var add_form = ''; $(this).parent().before(add_form); $('form.form_add_featured_scholarship').find('input.add_title').focus(); bind_form_add_featured_scholarship(); add_tinymce(); }); // create new event $('img.add_new_event').live("click",function() { var date = new Date(); var year = date.getYear()+1900; var day = date.getDate(); var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); for (var i=0; i < months.length;++i) { month_value = i+1; if(i == date.getMonth()) months[i] = ''; else months[i] = ''; } var add_form = '
at :
Cancel
'; $(this).parent().before(add_form); $('form.form_add_event').find('input.add_title').focus(); bind_form_add_event(); add_tinymce(); }); } // bind 'form_add_post' and provide a callback function function bind_form_add_post() { $('form.form_add_post').ajaxForm({ success: function(responseText) { $('#article_id_new').fadeOut(300,function() { $('#article_id_new').remove(); $('#news_column').prepend(responseText); }); } }); $('form.form_add_post').bind('form-pre-serialize', function(event, $form, options) { tinyMCE.triggerSave(); }); } // bind 'form_add_featured_scholarship' and provide a callback function function bind_form_add_featured_scholarship() { $('form.form_add_featured_scholarship').ajaxForm({ success: function(responseText) { $('#featured_scholarship_id_new').fadeOut(300,function() { $('#featured_scholarship_id_new').remove(); $('.announcement_container ul.featured_scholarship_dates').prepend(responseText); }); } }); $('form.form_add_featured_scholarship').bind('form-pre-serialize', function(featured_scholarship, $form, options) { tinyMCE.triggerSave(); }); } // bind 'form_add_event' and provide a callback function function bind_form_add_event() { $('form.form_add_event').ajaxForm({ success: function(responseText) { $('#event_id_new').fadeOut(300,function() { $('#event_id_new').remove(); $('.announcement_container ul.event_dates').prepend(responseText); }); } }); $('form.form_add_event').bind('form-pre-serialize', function(event, $form, options) { tinyMCE.triggerSave(); }); } // bind 'form_edit_author' and provide a callback function function bind_form_edit_author() { $('form.form_edit_author').ajaxForm({ success: function(responseText) { var old_author = $('.edit_container').next().html(); old_author = old_author.split('