$j(function() { active_auto_forcus_feedcomment(); active_del_feed_comment_fuc(); active_hover_feed_item(); $j("#blast-content").focus(function(){ var current_form = $j("input:hidden[name='form_current']"); var blast_content_status = $j("input:hidden[name='blast_content_status']"); if(parseInt(blast_content_status.val())==0){ //$j(this).val(""); } if($j(this).val()=='Bạn muốn nói gì?'){ $j(this).val(""); } $j("#share-box").addClass("blast_form_expan"); $j(".nkt_composer_tabs").slideDown("normal"); if(current_form.val()=="blast"){ $j("#blast_tweet").show(); if($j("#blast_tweet > input:checked").val() != null) { $j("#blast_tweet_acc").show(); } } return false; }); $j("#container").click(function(e){ getEvent(e); }); $j("#share_box_menu").find("a.tab_link").click(function(){ var current_form = $j("input:hidden[name='form_current']"); var current_id = $j(this).attr("id"); if(current_form.val()==current_id) { if(current_form.val()=="blast"){ if($j("#blast-content").val()==""){ setFocus("blast-content"); return false; } } else if(current_form.val()=="note"){ if($j("#note-title > input").val()==""){ setFocus("note-title > input"); return false; } } } else { switch(current_id) { case 'blast': $j("#note-title").hide(); $j("#blast_tweet").show(); if($j("#blast_tweet > input:checked").val() != null) { $j("#blast_tweet_acc").show(); } $j("#blast").parent().addClass("blast-selected"); $j("#note").parent().removeClass("note-selected"); setFocus("blast-content"); current_form.val("blast"); break; case 'note': $j("#note-title").show(); $j("#blast_tweet").hide(); $j("#blast_tweet_acc").hide(); $j("#note").parent().addClass("note-selected"); $j("#blast").parent().removeClass("blast-selected"); setFocus("note-title > input"); current_form.val("note"); break; } } return false; }); $j("#share-box > form").submit(function(){ var current_form = $j("input:hidden[name='form_current']"); var current_blast = $j("#blast-current"); if(current_form.val()=="blast"){ if($j("#blast-content").val()=="" || $j("#blast-content").val()=="Bạn muốn nói gì?"){ alert("Vui lòng nhập nội dung Blast!"); setFocus("blast-content"); return false; } else { var blast = $j("#blast-content").val(); var tp = ""; var t = "no"; var r = "no"; $j("#blast-submit").attr("disabled", "disabled"); $j("#ajaxLoading").show(); if($j("#blast_tweet > input:checked").val() != null) { t = "yes"; tp = $j("#twitter_pass").val(); } if($j("#pwd_remember:checked").val() != null) { r = "yes"; } var query = "blast=" + encodeURIComponent(blast) + "&t=" + t + "&remember=" + r + "&tp=" + encodeURIComponent(tp); $j.post(my_base_url+my_pligg_base+"/ajaxBlast?page=feed", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); $j("#blast-submit").attr("disabled", ""); $j("div#ajaxLoading").hide(); return false; } else { $j("#blast_update").html(result); $j("#blast-submit").attr("disabled", ""); $j("div#ajaxLoading").hide(); $j("textarea#blast-content").val("Bạn muốn nói gì?"); $j("#share-box").removeClass("blast_form_expan"); $j(".nkt_composer_tabs").hide(); $j("#blast_tweet_acc").hide(); $j("input:hidden[name='form_current']").val("blast"); $j("#blast").parent().addClass("blast-selected"); $j("#note").parent().removeClass("note-selected"); } } ); } } else if(current_form.val()=="note"){ if($j("#note-title > input").val()==""){ setFocus("note-title > input"); return false; } else{ var note_title = $j("#note-title > input").val(); var note_content = $j("#blast-content").val(); if(note_title == '' || note_content == '') { alert('Bạn chưa nhập dữ liệu'); return false; } window.location = my_base_url+my_pligg_base+"/note/submit?note_title=" + encodeURIComponent(note_title) + "¬e_content=" + encodeURIComponent(note_content) + "&action=create"; } } return false; }); }); var getEvent = function(e){ var x1 = $j("#share-box").x(); var y1 = $j("#share-box").y(); var x2 = x1 + $j("#share-box").width(); var y2 = y1 + $j("#share-box").height(); var x = e.pageX; var y = e.pageY; if (x1 <= x && x <= x2 && y1 <= y && y <= y2) { return; } else { if ($j("#blast-content").val()=="") { $j("#blast-content").val("Bạn muốn nói gì?"); } if ($j("#note-title").css("display")=="block") { $j("#note-title").hide(); } //$j("#blast_tweet").hide(); $j("#blast_tweet_acc").hide(); $j("#share-box").removeClass("blast_form_expan"); $j(".nkt_composer_tabs").hide(); $j("input:hidden[name='form_current']").val("blast"); $j("#blast").parent().addClass("blast-selected"); $j("#note").parent().removeClass("note-selected"); return false; } } function active_hover_feed_item(){ $j("div.feed-item").mouseover(function(){ $j(this).addClass('feed-item-hover'); }) .mouseout(function(){ $j(this).removeClass('feed-item-hover'); }); } function toggleTweet(id){ if($j("#blast_tweet_acc").css("display")=="none"){ $j("#blast_tweet_acc").show(); $j("#chkTweet").attr('checked','true'); //alert($j("#chkTweet").attr('checked')); } else { $j("#blast_tweet_acc").hide(); $j("#chkTweet").attr('checked',''); } return false; } function setChecked(id){ var checkbox_checked = $j("#"+id).attr('checked'); if(checkbox_checked){ $j("#"+id).attr('checked',''); }else{ $j("#"+id).attr('checked','true'); } return false; } 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 && e.attr('total_reshare') == 0) { //if (e.attr('total_cmt') <= 0) { var feed_id = e.attr('feed_id'); document.getElementById('feed_group_'+feed_id).style.display = 'none'; } } } //Post wall reply var post_wall_reply_active = 0; function updateWallPostReply(sender_id,wallpost_id,list_result_id) { if (post_wall_reply_active == 0) { $j("#ajaxLoading").show(); post_wall_reply_active = 1; var content = $j(wallpost_id+sender_id).val(); var query = ""; query = "act=addone&m_content=" + encodeURIComponent(content)+'&receiver='+sender_id; $j.post(my_base_url+my_pligg_base+"/ajaxWallPost", query, function(result) { if (/ERROR/.test(result)) { post_wall_reply_active = 0; result = result.substring(7, result.length); window.alert(result); }else{ var cur_textarea = $j("#add_wall_post_1900_"+sender_id); var cur_textarea_total_wall = cur_textarea.attr('total_wall') + 1; cur_textarea.attr('total_wall', cur_textarea_total_wall); close_feedCommentBlastBox('', cur_textarea); $j(list_result_id + sender_id).append(result); $j(list_result_id + sender_id + ' > .wall_posts:last-child').slideDown("slow"); active_del_feed_comment_fuc(); } $j("#ajaxLoading").hide(); post_wall_reply_active = 0; },"text"); } else { window.alert('Hệ thống đang xử lý, xin vui lòng đợi trong giây lát.'); } } // Update Feed_comment for Blast Feed var post_feed_comment_active = 0; // COMMENT BLAST function updateFeedComment(feed_to,feed_id, title_id, list_result_id) { if (post_feed_comment_active == 0) { $j("#ajaxLoading").show(); 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 + '&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 { var cur_textarea = $j("#add_comment_text_1900_"+feed_id); var cur_textarea_total_cmt = cur_textarea.attr('total_cmt') + 1; 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(); } $j("#ajaxLoading").hide(); 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; } function goto_wallpost_form(wallpost_group_id,text_area_id) { var div_wallpost_group = document.getElementById(wallpost_group_id); if (div_wallpost_group.style.display == '') { div_wallpost_group.style.display = 'none'; } else { div_wallpost_group.style.display = ''; document.getElementById(text_area_id).focus(); } } 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'); var total_reshare = $j('#'+text_area_id).attr('total_reshare'); if (div_feed_group.style.display == '' && total_cmt <= 0 && total_reshare==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_another_wallpost(sender_id) { $j('.more_wall_show_btt_'+sender_id).hide(); $j('.more_wall_show_'+sender_id).fadeIn(); 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{ 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 delete_wall_post(sender_id,receiver_id,message_id) { var cf = confirm('Bạn có thực sự muốn xóa lưu bút này?'); if (cf) { if (post_wall_reply_active == 0) { post_wall_reply_active = 1; var query=""; query = "sender_id="+ sender_id + "&receiver_id=" + receiver_id +'&message_id='+message_id; $j.post(my_base_url+my_pligg_base+"/ajaxWallDel", query, function(result) { if (/ERROR/.test(result)) { post_wall_reply_active = 0; result = result.substring(7, result.length); window.alert(result); }else{ eval("var result="+result); $j('.feed_comment_' + result.message_id).hide(); } post_wall_reply_active = 0; },"text"); } else { alert('Hệ thống đang xử lý, xin vui lòng đợi trong giây lát.'); } } return false; } function delete_feed_blast(feed_id,blast_id,target) { var cf = confirm('Bạn thực sự muốn xóa blast này?'); if(cf) { $j("#ajaxLoading").show(); query = "feed_id="+feed_id + "&blast_id=" + blast_id + "&target=" + target; $j.post(my_base_url+my_pligg_base+"/ajaxBlastDelete", query, function(result) { $j("#blast_update").html(result); //$j("#feed_item_" + feed_id).hide(); $j("#ajaxLoading").hide(); },"text"); } return false; } function click_receive_feed(setting_id,is_check) { value = 0; if(is_check == true) value = 0; else value = 1; query = "setting_id="+setting_id + "&value=" + value; $j.post(my_base_url+my_pligg_base+"/ajaxFeedSetting", query, function(result) { $j("#feed_setting_notice_" + setting_id).html(result); },"text"); } function delete_feed_onnet(feed_id,onnet_item_id) { var cf = confirm('Bạn thực sự muốn xóa tin này?'); if(cf) { query = "feed_id="+feed_id + "&onnet_item_id=" + onnet_item_id; $j.post(my_base_url+my_pligg_base+"/ajaxFeedOnnetDelete", query, function(result) { $j("#feed_item_" + feed_id).hide(); },"text"); } return false; } function ajaxHideFeed(feed_id,friend_id,feed_action,username) { var cf = confirm('Bạn muốn bỏ loại thông tin này?'); if(cf) { query = "feed_id="+feed_id + "&friend_id=" + friend_id + "&hide=hide"; $j.post(my_base_url+my_pligg_base+"/ajaxFeedHide", query, function(result) { eval("var result="+result); $j("#feed_item_" + feed_id).html(result.result_hide); var array_string = result.del_hide; if(array_string != null) { for(i=0;i'); $j.get(my_base_url+my_pligg_base+"/ajaxFeedTab", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { $j("#feed-update").removeClass("feed-update-loading"); $j("#feed-update").html(result); $j(".feed-filter > ul > li").removeClass("selected"); if(filter_name.length==0){ $j("li.all").addClass("selected"); $j("li.all > a").attr("href","#"); $j("li.all > a").attr("onclick",""); } else { $j("li."+filter_name).addClass("selected"); $j("li."+filter_name+" > a").atrr("href","#"); $j("li."+filter_name+" > a").attr("onclick",""); } active_hover_feed_item(); active_del_feed_comment_fuc(); active_auto_forcus_feedcomment(); } } ); return false; }