$j(function() { active_auto_forcus_feedcomment(); /*active_del_feed_comment_fuc();*/ /*active_hover_feed_item();*/ jQuery('.feed-js-expand').live('click', function(event){ event.preventDefault(); var divBind = jQuery(this); var feed_id = divBind.attr('id').replace('imgupload-thumb-',''); var src_Imgfull = jQuery('#feed-js-expand-'+feed_id).html(); var expandComment = divBind.parent().children('.feed-item-action'); //Expand full image if(!(divBind.hasClass('imgloaded'))){ divBind.html('' + src_Imgfull + '').addClass('imgloaded').addClass('imgfull').css({'display':'none'}).fadeIn('fast'); expandComment.removeClass('feed-comment-horizontal'); }else{ if(divBind.hasClass('imgfull')){ divBind.removeClass('imgfull').children('img').css({'width':'120px','display':'none'}).fadeIn('fast'); expandComment.addClass('feed-comment-horizontal'); }else{ divBind.addClass('imgfull').children('img').css({'width':'100%','display':'none'}).fadeIn('fast'); expandComment.removeClass('feed-comment-horizontal'); } } }); if(page_name == 'feed' || page_name == 'feed_detail'){ var lh_postblast = jQuery('#postblast'); var lh_txtpostblast = jQuery('#txtpostblast'); var lh_postblastsetting = jQuery('#postblastsetting'); lh_postblast.click(function(){ lh_postblast.addClass('active'); }); lh_txtpostblast.focusin(function(){ if(lh_txtpostblast.val() == 'Bạn muốn nói gì?'){ lh_txtpostblast.val(''); } lh_postblast.addClass('active'); }); lh_postblastsetting.click(function(){ if(jQuery(this).parent().hasClass('active')){ jQuery(this).parent().removeClass('active'); }else{ jQuery(this).parent().addClass('active'); } }); //Attach var lh_box_attach_img = jQuery('#box_attach_img'); jQuery('#attach_img').click(function(){ if(lh_box_attach_img.css('display') == 'none'){ lh_box_attach_img.show(); }else { lh_box_attach_img.hide(); } }); var lh_area_upload = jQuery('#area_upload'); var lh_area_typeurl = jQuery('#area_typeurl'); var lh_change_upload_img = jQuery('#change_upload_img'); var lh_change_typeurl_img = jQuery('#change_typeurl_img'); lh_change_typeurl_img.click(function(){ lh_area_typeurl.show(); lh_area_upload.hide(); jQuery(this).hide(); lh_change_upload_img.show(); }); lh_change_upload_img.click(function(){ lh_area_upload.show(); lh_area_typeurl.hide(); jQuery(this).hide(); lh_change_typeurl_img.show(); }); jQuery('#close_attach').click(function(){ //Hide jQuery(this).hide(); jQuery('#upload_img_thumb').hide(); //show form lh_area_upload.show(); jQuery('#another_option_img').show(); }); var btn_attach_img = jQuery('#btn_attach_image'); btn_attach_img.click(function(){ //Validate url var attachment_url_val = jQuery('#attachment_url').val(); if(attachment_url_val == ''){ alert('Bạn chưa nhập liên kết ảnh'); return; } lh_area_typeurl.hide(); jQuery('#another_option_img').hide(); jQuery('#upload_img_process').show(); jQuery.post(my_pligg_base+"/actions/feed/attachImageBlast.php", {attachment_url:attachment_url_val}, function(result) { result = jQuery.parseJSON(result); if(result.error == 1){ alert(result.msg); jQuery('#upload_img_process').hide(); lh_area_typeurl.show(); jQuery('#another_option_img').show(); }else{ //Process callback jQuery('#attachment_url').val(''); jQuery('#upload_img_process').hide(); jQuery('#thumb_view_blast').html('thumb view'); jQuery('#upload_img_thumb').show(); //Show delete to attach another image jQuery('#close_attach').show(); } } ); }); jQuery('#btn_submit_blast').click(function(){ var blast = jQuery("#txtpostblast").val(); var btnSmb = jQuery(this); btnSmb.attr("disabled", "disabled"); jQuery("div#ajaxLoading").show(); var t = "no"; //t for twitter var f = "no"; //f for facebook var y = "no"; //y for yahoo if(jQuery( '#facebook_setting' ).is(':checked')){ f = "yes"; } if(jQuery( '#twitter_setting' ).is(':checked')){ t = "yes"; } if(jQuery( '#yahoo_setting' ).is(':checked')){ y = "yes"; } jQuery.post(my_base_url+my_pligg_base+"/actions/feed/postBlast.php", {blast:blast,twitter_setting:t,facebook_setting:f,yahoo_setting:y}, function(result) { result = jQuery.parseJSON(result); if(result.error == 1){ window.alert(result.msg); btnSmb.attr("disabled", ""); jQuery("div#ajaxLoading").hide(); return false; } else { jQuery("#txtpostblast").val(''); //jQuery("#blast_update").html(result.msg); btnSmb.attr("disabled", ""); jQuery("div#ajaxLoading").hide(); jQuery("#postblast").removeClass('active'); jQuery('#upload_img_thumb').hide(); jQuery('#close_attach').hide(); lh_change_upload_img.hide(); lh_area_upload.show(); lh_change_typeurl_img.show(); jQuery('#another_option_img').show(); if(jQuery('#page_current_process').val() == 'feed'){ //Update feed detail var feed_detail = buildBlastData(result.id,result.blast_user,result.feed_title,result.feed_attachment,result.to,result.avatar_extreme); jQuery('ul.feed-stream').prepend(feed_detail); //Bind event /*active_hover_feed_item();*/ /*active_del_feed_comment_fuc();*/ active_auto_forcus_feedcomment(); } } } ); }); jQuery('#form_blast_submit').fileUpload({}); } //Autoresize jQuery('.DOMControl_autogrow').autoResize({ // More extra space: extraSpace : 0 }); }); 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_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 buildBlastData(R_id,R_blast_user,R_feed_title,R_feed_attachment,R_to,R_avatar_extreme){ var strHTML = ''; strHTML += ''+ '
  • '+ '
    '+ '
    '+ ' '+ '
    '+ '
    '+ '
    '+ '
    '+ ''+R_blast_user+''+ ' '+R_feed_title+''; strHTML += '
    '+ '
    '; if(R_feed_attachment != null){ strHTML += '
    '+ ''+R_feed_attachment+''+ '
    '; } strHTML += '
    '+ ''+ '
    '+ ''+ '
    '+ '
    '+ '
    '+ '
    '+ '
    '+ '
  • '; return strHTML; } /*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'); } 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) { 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); cur_textarea.removeAttr('style'); 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); cur_textarea.removeAttr('style'); 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).remove(); } 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,return_id,from_service) { 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); if(from_service != null){ $j('.feed_comment_' + result.message_id).hide(); } else { $j('#' + return_id).hide('fast', function(){ $j(this).remove(); }); } } 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("#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(feed_id,from_src) { var cf = confirm('Bạn thực sự muốn xóa tin này?'); if(cf) { $j("#ajaxLoading").show(); query = "feed_id="+feed_id; $j.post(my_base_url+my_pligg_base+"/ajaxFeedDelete", query, function(result) { if(from_src == null){ $j("#feed_item_" + feed_id).parent().remove(); }else if(from_src == "note_list"){ $j("#note_list_item_" + feed_id).hide(); }else if(from_src == "note_view"){ alert("Đã xóa note!"); window.location = result; } $j("#ajaxLoading").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 a.loantin').remove(); }else{ document.getElementById('feed_group_'+feed_id).style.display = ''; $j("#loantin_" + feed_id).addClass("wallpost"); $j("#loantin_" + feed_id).html(result); var cur_textarea = $j("#add_comment_text_1900_"+feed_id); cur_textarea.attr('total_reshare',1); } } },"text"); return false } function ajaxFeedToiGetMore() { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; $j("#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 user_id = parseInt($j("#feed_toi_user_id").val()); var filter = $j("#feed_toi_filter_name").val(); var query = ""; query = 'act=more_feed_toi&feed_toi_page='+feed_toi_page+'&total_feed_toi='+total_feed_toi+'&user_id='+user_id+'&filter_name='+filter; $j.get(my_base_url+my_pligg_base+"/ajaxFeed", query, function(result) { post_feed_comment_active = 0; $j("ul.feed-stream").append(result.feed_more); $j("#feed_toi_page").val(result.feed_toi_page); $j("#total_feed_toi").val(result.total_feed_toi) /*active_hover_feed_item();*/ /*active_del_feed_comment_fuc();*/ active_auto_forcus_feedcomment(); if (result.show_more_feed_toi == 1) { $j('#fc_toi_next').parents(':first').hide(); } $j("#ajax-feedcomment-loading-b").hide(); }, "json" ); } return false; } function ajaxFeedBanbeGetMore() { if (post_feed_comment_active == 0) { post_feed_comment_active = 1; $j("#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 filter_name = $j("#feed_banbetoi_filter_name").val(); var query=""; query = 'act=more_feed_banbetoi&feed_banbetoi_page='+feed_banbetoi_page+'&total_feed_banbetoi='+total_feed_banbetoi+'&filter_name='+filter_name; $j.get(my_base_url+my_pligg_base+"/ajaxFeed", query, function(result) { post_feed_comment_active = 0; //$j("div.feed_benbetoi_tpl_more").append(result.feed_more); $j("ul.feed-stream").append(result.feed_more); $j("input#feed_banbetoi_page").val(result.feed_banbetoi_page); $j("#total_feed_banbetoi").val(result.total_feed_banbetoi); /*active_hover_feed_item();*/ /*active_del_feed_comment_fuc();*/ active_auto_forcus_feedcomment(); if (result.show_more_feed_banbetoi == 1 || jQuery.trim(result.feed_more) == ''){ $j('#fc_banbetoi_next').parents('.view-more').append('More'); $j('#fc_banbetoi_next').remove(); } $j("#ajax-feedcomment-banbe-loading-b").hide(); }, "json" ); } return false; } function feedToggleEmbed(id){ var div_embed = $j("#embed_"+id); var control = $j("#embed_control_"+id); if(div_embed.css("display")=="none"){ div_embed.show(); control.css("background-position","0 -16px"); }else{ div_embed.hide(); control.css("background-position","0 0"); } return false; } function getFeeds(filter_name){ var query = ""; var image_loading = my_pligg_base + '/templates/images/loading/global.gif'; query = 'filter_name=' + filter_name; $j("#feed-update").addClass("feed-update-loading"); $j("#feed-update").html(''); $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; } function check_setting_big4(type){ var service = ""; if( type == 2 ){ if( $j( '#facebook_setting' ).is(':checked') ){ if(!has_facebook){ openLoginSetting( 2 ); } } }else if( type == 3 ){ if( $j( '#twitter_setting' ).is(':checked') ){ if(!has_twitter){ openLoginSetting( 3 ); } } }else if( type == 5 ){ if( $j( '#yahoo_setting' ).is(':checked') ){ if(!has_yahoo){ openLoginSetting( 5 ); } } } } function openLoginSetting(type){ var _width = 550; var Xpos = ( (screen.availWidth - _width)/2 ); var _height = 410; var Ypos = ( (screen.availHeight - _height)/2 ); if( type == 2 ){ window.facebookWindow = window.open(my_base_url + my_pligg_base + '/libs/oauthfacebook/request.php?type=4','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos); facebookWindow.focus(); has_facebook = 1; return false; }else if( type == 3 ){ window.twitterWindow = window.open(my_base_url + my_pligg_base + '/libs/oauthtwitter/request.php?type=4','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos); twitterWindow.focus(); has_twitter = 1; return false; }else if( type == 5 ){ window.yahooWindow = window.open(my_base_url + my_pligg_base + '/libs/oauthyahoo/request.php?type=4','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos); yahooWindow.focus(); has_yahoo = 1; return false; } }