$j(document).ready(function(){ $j("div.hide-feed").mouseover(function(){ $j(this).find("a").css("background-position","right top"); }) .mouseout(function(){ $j(this).find("a").css("background-position","left top"); }); $j("#profile-detail-head").click(function(){//open profile detail on sidebar var div_detail = $j("#profile-detail").css("display"); var div_head = $j("#profile-detail-head"); if(div_detail=="none"){ $j("#profile-detail").slideDown("normal"); div_head.removeClass("detaildown"); div_head.addClass("detailup"); }else{ $j("#profile-detail").slideUp("normal"); div_head.removeClass("detailup"); div_head.addClass("detaildown"); } }); //For Feed's page active_auto_forcus_feedcomment(); active_del_feed_comment_fuc(); $j("#status-label").mouseover(function(){ $j(this).addClass('hightlight'); }) .mouseout(function(){ $j(this).removeClass('hightlight'); }) .click(function(){ $j(this).parent().hide(); $j("#status-form").show(); $j("#blast-title").focus(); }); $j("#status_cancel").click(function(){ $j("#status-label").parent().show(); $j("#status-form").hide(); }); }); /* Feed LinkHayv2 */ function active_auto_forcus_feedcomment() { $j("textarea.DOMControl_autogrow").focus(function(){ var txt_area_val = $j(this).val(); if (txt_area_val =='Viết bình luận...') { $j(this).val(''); } $j(this).parent().removeClass("one_row_add_box"); $j(this).parent().parent().removeClass("hidden_add_button"); }) .blur(function() { var txt_area_val = $j(this).val(); close_feedCommentBlastBox(txt_area_val, $j(this)); }); } function active_del_feed_comment_fuc() { $j("div.wall_posts").mouseover(function(){ $j(this).find("div > a.feed-comment-del").css("display","block"); }) .mouseout(function(){ $j(this).find("div > a.feed-comment-del").css("display","none"); }); } function close_feedCommentBlastBox (txt_area_val, e) { if (txt_area_val =='Viết bình luận...' || txt_area_val == '') { e.parent().addClass("one_row_add_box"); e.parent().parent().addClass("hidden_add_button"); e.val('Viết bình luận...'); if (e.attr('total_cmt') <= 0) { var feed_id = e.attr('feed_id'); document.getElementById('feed_group_'+feed_id).style.display = 'none'; } } } /* Update Feed_comment for Blast Feed * Author: DUC-NH */ // COMMENT BLAST var post_feed_comment_active = 0; function updateFeedComment(feed_id, title_id, list_result_id) { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; var title = $j(title_id+feed_id).val(); var query=""; query = "act=add&title=" + encodeURIComponent(title)+'&feed_id='+feed_id; $j.post(my_base_url+my_pligg_base+"/ajaxFeedComment", query, function(result) { if (/ERROR/.test(result)) { post_feed_comment_active = 0; result = result.substring(7, result.length); window.alert(result); }else{ var cur_textarea = $j("#add_comment_text_1900_"+feed_id); var cur_textarea_total_cmt = cur_textarea.attr('total_cmt') + 1; /*document.getElementById('feed_vtl_'+feed_id).style.display = 'none'; document.getElementById('feed_tttl_'+feed_id).style.display = '';*/ cur_textarea.attr('total_cmt', cur_textarea_total_cmt); close_feedCommentBlastBox('', cur_textarea); $j(list_result_id + feed_id).append(result); $j(list_result_id + feed_id + ' > .wall_posts:last-child').slideDown("slow"); active_del_feed_comment_fuc(); } post_feed_comment_active = 0; },"text"); }else { window.alert('Hệ thống đang xử lý, xin vui lòng đợi trong giây lát!'); } return false; } // JUMP TO COMMENT BOX function goto_comment_form(id, text_area_id, feed_group_id, feed_id) { var div_feed_group = document.getElementById(feed_group_id); var total_cmt = $j('#'+text_area_id).attr('total_cmt'); if (div_feed_group.style.display == '' && total_cmt <= 0) { div_feed_group.style.display = 'none'; }else { div_feed_group.style.display = ''; if ( total_cmt > 5 && $j('.more_feed_comment_'+feed_id).css('display') != 'none') { smooth_scroll(id); } document.getElementById(text_area_id).focus(); } } function remove_feed_item(feed_id) { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; var query=""; query = 'act=remove&feed_id='+feed_id; $j.post(my_base_url+my_pligg_base+"/ajaxFeed", query, function(result, feed_id) { if (/ERROR/.test(result)) { post_feed_comment_active = 0; result = result.substring(7, result.length); window.alert(result); }else{ $j('.feed_item_' + result).fadeOut(); } post_feed_comment_active = 0; },"text"); }else { alert('Hệ thống đang xử lý, xin vui lòng đợi trong giây lát!'); } return false; } function show_more_feed_comment(feed_id) { $j('.more_feed_comment_btt_'+feed_id).hide(); $j('.more_feed_comment_'+feed_id).fadeIn(); return false; } function delete_comment_feed(feed_id, feed_comment_id, feed_to) { var cf = confirm('Bạn có thực sự muốn xóa bình luận này?'); if (cf) { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; var query=""; query = "act=del&feed_id=" + feed_id +'&feed_comment_id='+feed_comment_id+'&feed_to='+feed_to; $j.post(my_base_url+my_pligg_base+"/ajaxFeedComment", query, function(result) { if (/ERROR/.test(result)) { post_feed_comment_active = 0; result = result.substring(7, result.length); window.alert(result); }else{ //$j('.feed_comment_75').append(result); eval("var result="+result); $j('.feed_comment_' + result.feed_comment_id).hide(); } post_feed_comment_active = 0; },"text"); }else { alert('Hệ thống đang xử lý, xin vui lòng đợi trong giây lát!'); } } return false; } function ajaxFeedToiGetMore() { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; $j("div#ajax-feedcomment-loading-b").show(); var feed_toi_page = parseInt($j("#feed_toi_page").val()); var total_feed_toi = parseInt($j("#total_feed_toi").val()); var query=""; query = 'act=more_feed_toi&feed_toi_page='+feed_toi_page+'&total_feed_toi='+total_feed_toi; $j.get(my_base_url+my_pligg_base+"/ajaxFeed", query, function(result) { if (/ERROR/.test(result)) { post_feed_comment_active = 0; result = result.substring(7, result.length); window.alert(result); } else { eval("var result="+result); post_feed_comment_active = 0; $j("div.feed_toi_tpl_more").append(result.feed_toi_more); $j("#feed_toi_page").val(result.feed_toi_page); $j("#total_feed_toi").val(result.total_feed_toi) active_del_feed_comment_fuc(); active_auto_forcus_feedcomment(); smooth_scroll('.feed_item_'+result.top_feedid); if (result.show_more_feed == 1) { $j('#fc_toi_next').hide(); } } $j("div#ajax-feedcomment-loading-b").hide(); } ); } return false; } function ajaxFeedBanbeGetMore() { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; $j("div#ajax-feedcomment-banbe-loading-b").show(); var feed_banbetoi_page = parseInt($j("input#feed_banbetoi_page").val()); var total_feed_banbetoi = parseInt($j("#total_feed_banbetoi").val()); var query=""; query = 'act=more_feed_banbetoi&feed_banbetoi_page='+feed_banbetoi_page+'&total_feed_banbetoi='+total_feed_banbetoi; $j.get(my_base_url+my_pligg_base+"/ajaxFeed", query, function(result) { if (/ERROR/.test(result)) { post_feed_comment_active = 0; result = result.substring(7, result.length); window.alert(result); } else { eval("var result="+result); post_feed_comment_active = 0; $j("div.feed_benbetoi_tpl_more").append(result.feed_more); $j("input#feed_banbetoi_page").val(result.feed_banbetoi_page); $j("#total_feed_banbetoi").val(result.total_feed_banbetoi) active_del_feed_comment_fuc(); active_auto_forcus_feedcomment(); smooth_scroll('.feed_item_'+result.top_feedid); if (result.show_more_feed_banbetoi == 1) { $j('#fc_banbetoi_next').hide(); } } $j("div#ajax-feedcomment-banbe-loading-b").hide(); } ); } return false; } //Send a message appendid = 1; function sendMessage(){ var receiver=$j("input#user_current_view_id").val(); var m_content=$j("textarea#mcontent").val(); if(m_content.length==0){ alert('Vui lòng nhập nội dung cần gửi!'); $j("textarea#mcontent").focus(); return false; } $j("div#ajax-message-loading").show(); var query=""; query = "appendid=" + appendid + "&act=addtwo&receiver="+receiver+"&m_content="+encodeURIComponent(m_content); $j.post(my_base_url+my_pligg_base+"/ajaxWallPost", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { $j("textarea#mcontent").val(""); $j("div#insert_before_append_" + appendid).append(result); appendid++; $j("div.hide-feed").mouseover(function(){ $j(this).find("a").css("background-position","right top"); }) .mouseout(function(){ $j(this).find("a").css("background-position","left top"); }); } $j("div#no_testimonial_wall").remove(); $j("div#ajax-message-loading").hide(); } ); return false; } //send privateMasage function sendPrivateMessage(message_sender,message_receiver,returnid){ var query = ''; var title = $j("#message_title").val(); var body = $j("#message_body").val(); if(title.length == 0 ){ alert('Bạn chưa nhập tiêu đề tin nhắn!'); return false; } if(body.length == 0 ){ alert('Bạn chưa nhập nội dung tin nhắn!'); return false; } query += 'message_sender='+message_sender+'&message_receiver='+message_receiver+'&title='+title+'&body='+body; $j.post(my_base_url+my_pligg_base+'/ajaxUserPrivateMessage',query, function(result) { sendPrivateMessageCallback(result,returnid); } ); return false; } function sendPrivateMessageCallback(result,returnid){ $j("#result_message") .fadeIn('fast') .animate({opacity: 1.0}, 1000) .fadeOut('fast', function() {$j(this).css("display","none");}); $j("#message_body").val(""); } //Filter message function ajaxWallGet(m_type){ $j("div#ajax-message-loading").show(); var receiver=$j("input#user_current_view_id").val(); var query=""; query = "receiver="+receiver+"&m_type="+m_type; $j.post(my_base_url+my_pligg_base+"/ajaxWallFilter", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { //window.alert(result); $j("div#user-message").html(result); $j("div.hide-feed").mouseover(function(){ $j(this).find("a").css("background-position","right top"); }) .mouseout(function(){ $j(this).find("a").css("background-position","left top"); }); } $j("div#ajax-message-loading").hide(); } ); return false; } function ajaxWallGetMore(){ $j("div#ajax-message-loading-b").show(); var receiver = $j("input#user_current_view_id").val(); var n = parseInt($j("input#number_message").val()); var query=""; query = "n="+n+"&receiver="+receiver; $j.post(my_base_url+my_pligg_base+"/ajaxWallGetMore", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { //window.alert(result); $j("div#view_more").remove(""); $j("div#next_message").append(result); /*$j("div.hide-feed").mouseover(function(){ $j(this).find("a").css("background-position","right top"); }) .mouseout(function(){ $j(this).find("a").css("background-position","left top"); });*/ active_hover_feed_item(); active_del_feed_comment_fuc(); active_auto_forcus_feedcomment(); } $j("div#ajax-message-loading-b").hide(); } ); return false; } //Mach luu but function getTestimonialStream(id){ $j("div#ajax-message-loading").show(); var receiver=$j("input#user_current_view_id").val(); var query=""; query = "receiver="+receiver+"&id="+id; $j.post(my_base_url+my_pligg_base+"/ajaxWallToWall", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { $j("div#user-message").html(result); } $j("div#ajax-message-loading").hide(); } ); return false; } //Xoa message function delMessage(id){ if(window.confirm("Bạn có chắc chắn muốn xóa tin nhắn này?")){ var m_type = $j("#message_type").val(); var query=""; query = "id="+id+"&type="+m_type; $j.post(my_base_url+my_pligg_base+"/ajaxWallDel", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { $j("div#user-message").html(result); $j("div.hide-feed").mouseover(function(){ $j(this).find("a").css("background-position","right top"); }) .mouseout(function(){ $j(this).find("a").css("background-position","left top"); }); } } ); return false; } }