var sermon_class = function(){ this.read_sermon=function(url, target_canvass){ $.post(url, function(data){ $(target_canvass).html(data); }); } this.find_sermons_from_date=function(url, selector, category, target_canvass){ $.post(url, {sermon_date:$(selector).val(),category:$(category).val()}, function(data){ $(target_canvass).html(data); }) } this.close_comments=function(selector){ $(selector).html(''); $('#view_comments_link').show(); } this.close_comment_form=function(selector){ $(selector).html(''); $('#add_comments_link').show(); } this.show_comments = function(url, render_canvass_selector){ $.post(url, function(data){ $(render_canvass_selector).html(data); $('#view_comments_link').hide(); }); } this.add_sermon_comment = function(url, on_success_func, on_fail_func){ var sermon_id = $("input[name='sermon_id']").val(); var params = {sermon_id: $("input[name='sermon_id']").val(), sermon_comment: $("textarea[name='sermon_comment']").val(), sermon_comment_created_by: $("input[name='sermon_comment_created_by']").val()} $.post(url, params, function(data){ var result = $.evalJSON(data); if(result.result != '1'){ on_fail_func(); }else{ on_success_func(); if($('#view_comments_link').css('display')=='none'){ sermon.show_comments('http://calvarygrace.net/index.php/sermons_public/sermon_comments/'+sermon_id, '#sermon_comments_wrapper'); } } }); } this.show_sermon_comment_form = function(url, target_canvass_selector){ $.post(url, function(data){ $(target_canvass_selector).html(data); $('#add_comments_link').hide(); }); } } var sermon = new sermon_class(); var sermons_class = function(){ this.add = function(selector, formActionURL, sermon_id){ var url = 'http://calvarygrace.net/index.php/sermons_public/add/'+formActionURL+'/'+sermon_id; $.post(url, function(data){ $(selector).html(data); }); } this.show_history = function(selector, sermon_id){ var url = 'http://calvarygrace.net/index.php/sermons_public/show_history/'+sermon_id; $.post(url, function(data){ $(selector).html(data); }); } }