var template_directory = 'http://bnok.vn/tanng/wp-content/themes/bnok3cols';
var wpurl = 'http://bnok.vn/tanng';
var is_guest = true;
var npage = 2;
var tab_filter= '';
var x_gmenu = 0;
var x_pmenu = 0;
jQuery(function($) {
//The my_menu
var menu_blog = jQuery('#menu_blog1');
jQuery('#my_menu').click(function(e){
//Display menu under the Mouse
if(x_pmenu <= 0){
x_pmenu = getXMouse(e);
}
menu_blog.css('left',x_pmenu).toggle();
});
//The group list menu
jQuery('#g_menu').click(function(e){
//Display menu under the Mouse
if(x_gmenu <= 0){
x_gmenu = getXMouse(e);
}
var g_menu = jQuery('#group_menu');
g_menu.css('left',x_gmenu).toggle();
jQuery('span.view_all_group a', g_menu).unbind().click(function(){
g_menu.hide();
});
});
//The Img resize
jQuery('div.entry img').each(function (i) {
var objImg = jQuery(this);
var w = objImg.width();
if(w>600){
objImg.width(600);
objImg.wrap('');
}
});
//The right feed
jQuery('div.comment_feed_container').each(function() {
var ga_dicuss_item = this;
jQuery(this).hover(
function () {
jQuery('div.feed_icon a',this).show();
},
function () {
jQuery('div.feed_icon a',this).hide();
}
);
jQuery('div.feed_icon a',ga_dicuss_item).click(function(){
var collapsed_text = jQuery('div.feed_comment_expand',ga_dicuss_item);
collapsed_text.toggle();
jQuery('div.feed_comment_collapse',ga_dicuss_item).toggle();
//Change the +/- button
if(collapsed_text.css('display')=='none'){
jQuery('div.feed_icon img', this).attr('src', imgPath+'ico_expand.gif');
}else{
jQuery('div.feed_icon img', this).attr('src', imgPath+ 'ico_collapse.gif');
}
});
});
//The add to favourite blog
jQuery('#bt_add_fav_blog').click(addFavBlog);
//Blast mouse over
if(is_blog_owner){
jQuery('span.blast_content').hover(
function () {
$(this).addClass('blast_content_hover');
},
function () {
$(this).removeClass('blast_content_hover');
}
);
}
});
//Overwrite
testimonialInit = function() {
//check permission
if(!is_guest){
checkTestimonial();
}
};
//Overwrite
updateBlastStats = function(jo) {
//Update the blast
jQuery('.blast_content').attr('id',jo.blast_id).html(jo.comment);
//Update the replies list
jQuery('.reply_blast').html('');
//Update the blast replies counter
//var bl_num = jQuery('#blast_reply_num');
///bl_num.html('0');
};
//Overwrite
sendTestimonialComplete = function(msg){
alert('Đã lưu Nhận Xét thành công!');
location.reload(true);
};
function getXMouse(e){
var x_val = 0;
if (!e){ e = window.event;}
if (typeof e.pageY == "number"){
x_val = e.pageX-80;
} else {
x_val = e.clientX-80;
}
return x_val;
}
addFavBlog = function(){
var url = wpurl+"/wp-content/mu-plugins/friend-list/php/plugin-ajax.php";
var content = jQuery(this).attr('href');
content = content.substr(1,content.length);
jQuery.ajax({
type: "GET",
url: url,
data: 'a=add&v='+content,
error: errorHandle,
success: function(){
alert('Đã thêm vào danh sách Blog yêu thích của bạn!');
disableFavBlog();
}
});
};
disableFavBlog = function(){
var bt_add_fav_blog = jQuery('#bt_add_fav_blog');
bt_add_fav_blog.unbind('click');
bt_add_fav_blog.css('color','#A0A0A0');
};
underContruction = function(){
alert('Xin lỗi bạn, chức năng này đang trong quá trình xây dựng.');
};
// Surrounds the selected text with text1 and text2.
function surroundText(text1, text2, textarea) {
if (typeof textarea.caretPos != "undefined" && textarea.createTextRange) {
var caretPos = textarea.caretPos, temp_length = caretPos.text.length;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? text1 + caretPos.text + text2 + " " : text1 + caretPos.text + text2;
if (temp_length == 0) {
caretPos.moveStart("character", - text2.length);
caretPos.moveEnd("character", - text2.length);
caretPos.select();
} else {
textarea.focus(caretPos);
}
} else if (typeof textarea.selectionStart != "undefined") {
var begin = textarea.value.substr(0, textarea.selectionStart);
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
var end = textarea.value.substr(textarea.selectionEnd);
var newCursorPos = textarea.selectionStart;
var scrollPos = textarea.scrollTop;
textarea.value = begin + text1 + selection + text2 + end;
if (textarea.setSelectionRange) {
if (selection.length == 0) {
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
} else {
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
}
textarea.focus();
}
textarea.scrollTop = scrollPos;
} else {
textarea.value += text1 + text2;
textarea.focus(textarea.value.length - 1);
}
}
getMoreRecentFeed = function() {
var url = template_directory + "/ajax_utils.php";
npage += 1;
jQuery.ajax({
type: "GET",
url: url,
data: 'a=get_more_recent_feed&g='+ g_id +'&p='+npage+'&filter='+tab_filter,
success: function(jo){
if(jo==''){
jQuery('#view_more_feed_button').hide();
}else{
jQuery('#more_recent_feed').before('').before(jo);
addCommentEvent();
location.href = '#last_insert_feed_'+npage;
}
}
});
};
function addCommentEvent(){
//The comment feed
jQuery('div.full_feed_comment').each(function() {
var ga_dicuss_item = jQuery(this);
ga_dicuss_item.unbind().hover(
function () {
jQuery('div.feed_icon_full a',this).show();
},
function () {
jQuery('div.feed_icon_full a',this).hide();
}
);
jQuery('div.feed_icon_full a',ga_dicuss_item).unbind().click(function(){
jQuery('div.feed_comment_collapse_full',ga_dicuss_item).toggle();
jQuery('div.feed_comment_expand_full',ga_dicuss_item).toggle();
if(jQuery('div.feed_comment_collapse_full',ga_dicuss_item).css('display')=='none'){
jQuery('img', this).attr('src', imgPath+'ico_expand.gif');
}else{
jQuery('img', this).attr('src', imgPath+ 'ico_collapse.gif');
}
});
});
}