Authored by 2586703@qq.com

comment插件冲突

... ... @@ -7,12 +7,11 @@
var $ = require('jquery'),
share = require('../plugin/share'),
box = require('../plugin/box'),
imgZoom = require('../plugin/imgZoom'),
tools = require('yoho-tools'),
mustache = require('mustache'),
mulLine = require('mlellipsis');
require('lazyload');
require('../plugin/slider');
require('../plugin/comment');
... ... @@ -58,7 +57,6 @@ exports.init = function() {
//初始化截行插件
mulLine.init();
//分享
share.init({
shareUrl: shareUrl,
... ... @@ -93,225 +91,6 @@ exports.init = function() {
//box.alert(tips.getTips("emailError"),5);
box.alert(22);
return;
}
window.open('/passport/subscribe/index?email=' + input.val());
});
$(".focus-us .textbox input").keydown(function(event) {
if (event.keyCode === 13) {
$(this).next().trigger("click");
}
});
//图片轮播
if ($(".detail-slide-body").size() > 0) {
$(".detail-slide-ctrl-tabs").find("img.lazy").lazyload();
$(".detail-slide-body").imgZoom({
styleClass: 'detail-zoom'
});
$(".detail-slide-piclist").slider({
pageCtrl: $(".detail-slide-ctrl-tabs"),
pageCtrlAnimate: true
});
};
//调用评论插件
$(".stats-btn").on("click", ".comments", function() {
cidNum = $(".comments-box").attr("cid");
if ($(".comments-box").find(".comment-textarea").size() > 0) {
if ($(".comments-box").css("display") === "none") {
$(".comments-box").show();
} else {
$(".comments-box").hide();
}
} else {
$(".comments-box").comment({
cid: cidNum,
thirdLogin: true,
commentPageUrl: '/comment/default/list',
publishUrl: '/comment/default/publish',
deleteUrl: '/comment/default/delete'
});
}
});
//ajax参数
ajaxParam = {
id: $(".comments-box").attr("cid"),
type: $(".comments-box").attr("ctype"),
c: $(".comments-box").attr("cc"),
twoc: $(".comments-box").attr("ctwoc")
};
//右侧side的数据获取
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + '/channel/detail/getright', //?id=' + ajaxParam.id + '&type=' + ajaxParam.type + '&c=' + ajaxParam.c + '&twoc=' + ajaxParam.twoc,
success: function(response) {
console.log(response);
var data = response.data;
var sidePost = data.mosts,
video = data.video,
banner = data.banners;
//广告
var adItem = '';
for (var i = 0; i < banner.length; i++) {
adItem += '<a href="' + banner[i].link + '" target="_blank"><img src="' + banner[i].img + '" alt="" /></a>'
}
$(".detail-ad").html(adItem);
//没有广告去掉margin
if (banner.length == 0) {
$(".detail-side .app-download").css("margin", 0);
}
//视频
if (video.length != 0) {
var $flash = $('<object width="100%" id="newestvideo" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">\n\
<param name="movie" value="' + YohoConfig.resUrl + '/res/new/boys/swf/util/VideoPlayerSmall.swf?url=' + video.video + '&amp;language=' + video.language + '&amp;title1=【Yoho!Boys】' + video.title + '\r\n' + video.subtitle + '&amp;shareurl=' + video.link + '&amp;sharepic=' + video.cover + '&amp;coverpic=' + video.cover + '">\n\
<param name="quality" value="high">\n\
<param name="bgcolor" value="#ffffff">\n\
<param value="true" name="allowFullScreen">\n\
<param name="allowScriptAccess" value="always">\n\
<param name="wmode" value="transparent">\n\
<embed align="middle" width="100%" src="' + YohoConfig.resUrl + '/res/new/boys/swf/util/VideoPlayerSmall.swf?url=' + video.video + '&amp;language=' + video.language + '&amp;title1=【Yoho!Boys】' + video.title + '\r\n' + video.subtitle + '&amp;shareurl=' + video.link + '&amp;shareurl=' + video.link + '&amp;sharepic=' + video.cover + '&amp;coverpic=' + video.cover + '" name="vMessage" wmode="transparent" quality="high" bgcolor="#ffffff" play="true" loop="false" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="flash">\n\
</object>');
var $ipadVideo = $('<video id="side-video-ipad" style="display:none;" controls="controls" preload="auto" poster="' + video.cover + '"><source src="' + video.video + '" type="video/mp4"></video>');
$(".side-video").find("img").hide();
$(".side-video").find("h3").text(video.title);
$(".side-video").find("p").text(video.subtitle);
$(".side-video").find("a").attr("href", video.link);
$(".video-area").append($flash);
$(".video-area").append($ipadVideo);
$(".side-video").show();
if (navigator.userAgent.indexOf("iPad") !== -1) {
// 封面视频播放器替换为H5的VIDEO标签
if (!!$(".video-area").find("object").size()) {
$(".video-area").find("object").hide();
$("#side-video-ipad").show();
}
}
}
//热播
if (sidePost.length > 0) {
var sidePostItem = '';
for (var i = 0; i < sidePost.length; i++) {
if (sidePost[i].isVideo) {
sidePostItem = '<li>' +
'<a class="clearfix" href="' + sidePost[i].link + '" onclick="hotClickEvent();">' +
'<div class="pic"><img src="' + sidePost[i].coverImage + '" alt="" /><span class="play-icon"></span></div>' +
'<div class="post-title"><h4>' + sidePost[i].title + '</h4><p>' + sidePost[i].subtitle + '</p></div>' +
'</a>' +
'</li>';
} else {
sidePostItem = '<li>' +
'<a class="clearfix" href="' + sidePost[i].link + '" onclick="hotClickEvent();">' +
'<div class="pic"><img src="' + sidePost[i].coverImage + '" alt="" /></div>' +
'<div class="post-title"><h4>' + sidePost[i].title + '</h4><p>' + sidePost[i].subtitle + '</p></div>' +
'</a>' +
'</li>';
}
$(".side-postslist").append($(sidePostItem));
}
$(".side-related-posts").show();
//热播根据行数截取字符
var citems = $(".side-related-posts li");
var totalLineNum = 3;
if (citems.length > 0) {
citems.each(function(index, obj) {
var self = $(obj);
var titleLineNum = self.find("h4").getTextLineNumber("title");
var subTitleLineNum = self.find("p").getTextLineNumber("subtitle");
if (titleLineNum > 2) {
self.find("h4").mlellipsis(2);
titleLineNum = 2;
}
if (subTitleLineNum > totalLineNum - titleLineNum) {
self.find("p").mlellipsis(totalLineNum - titleLineNum, "detail");
}
});
}
}
//滑出小视频播放区域暂停小视频
var relatedPostsOffsetTop = $(".side-related-posts").offset().top - $("#minEnterprise").outerHeight(),
relatedPostsTop = $("#minEnterprise").outerHeight(),
relatedPostsMarginLeft = $(".detail-container").width() / 2 - $(".side-related-posts").outerWidth();
$(window).resize(function() {
relatedPostsOffsetTop = $(".side-related-posts").offset().top - $("#minEnterprise").outerHeight(),
relatedPostsTop = $("#minEnterprise").outerHeight(),
relatedPostsMarginLeft = $(".detail-container").width() / 2 - $(".side-related-posts").outerWidth();
});
$(window).bind("scroll", function() {
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
if ($(".side-video").size() > 0) {
if ($(window).scrollTop() >= $(".side-video").offset().top || $(window).scrollTop() < $(".side-video").offset().top - $(window).height()) {
try {
if (navigator.appName.indexOf("Microsoft") != -1) {
//$(".detail-right-video").find("object").get(0).StopMovie();
thisMovie("newestvideo").StopMovie();
} else if (navigator.userAgent.indexOf("iPad") !== -1) {
var videoId = document.getElementById("side-video-ipad");
videoId.pause();
} else {
$(".side-video").find("embed").get(0).StopMovie();
}
} catch (e) {}
}
}
if ($(window).scrollTop() >= relatedPostsOffsetTop && $(".side-related-posts").css("display") != "none") {
if (navigator.userAgent.indexOf("iPad") !== -1) return;
//right_tab_toped=true;
$(".side-related-posts").css({
"position": "fixed",
"left": "50%",
"margin-left": relatedPostsMarginLeft,
"top": relatedPostsTop
});
//热播位置
var detailBodyOffsetTop = $(".detail-body").offset().top;
var relatedPostsOffsetHeightTop, distance, eleTop;
var height = $(".detail-body").outerHeight();
relatedPostsOffsetHeightTop = $('.side-related-posts').offset().top + $('.side-related-posts').outerHeight();
distance = height + detailBodyOffsetTop;
eleTop = distance - $('.side-related-posts').outerHeight();
if (relatedPostsOffsetHeightTop >= distance) {
$('.side-related-posts').css({
"position": "absolute",
"top": eleTop - relatedPostsTop
});
}
if ($('.side-related-posts').offset().top - $(window).scrollTop() > relatedPostsTop) {
$('.side-related-posts').css({
"position": "fixed",
"top": relatedPostsTop
});
}
} else if ($(window).scrollTop() < relatedPostsOffsetTop && $(".side-related-posts").css("display") != "none") {
//right_tab_toped=false;
$(".side-related-posts").removeAttr("style").show();
}
});
}
window.open('/passport/subscribe/index?email=' + input.val());
});
... ... @@ -408,7 +187,7 @@ exports.init = function() {
$('.detail-side').append($(sidePostHtml));
//边栏related-post根据行数截取字符
relatedPost = relatedPost;
relatedPost = $('.side-related-posts');
postList = relatedPost.find("li");
if (postList.length > 0) {
totalLineNum = 3;
... ...
... ... @@ -2,15 +2,6 @@
* 评论及登录插件
* author:liuyue
* date:2015-01-07
<<<<<<< HEAD
*/
var $ = require("jquery"),
validate = require("./validate"),
box = require("./box"),
tools = require("yoho-tools"),
tips = require("./tips");
mustache = require("mustache");
=======
*/
var $ = require("jquery"),
validate = require("./validate"),
... ... @@ -18,248 +9,244 @@ var $ = require("jquery"),
tools = require("yoho-tools"),
tips = require("./tips");
mustache = require("mustache");
>>>>>>> develop
require("./login");
(function(global, undefined) {
var Comment = function(element, options) {
this.options = options;
this.$element = $(element);
//this.$loginBox = $(this.options.loginbox).appendTo("body");
this.init();
};
Comment.DEFAULTS = {
cid: '',
commentPageUrl: '/writer/default/comment',
publishUrl: '/writer/default/publish',
deleteUrl: '/writer/default/delete',
commentNum: $(".comment-num"),
commentItemTpl: '<li class="clearfix">' +
'<div class="userimg">' +
'<img src="\{{userimg}}" alt="">' +
'<i class="\{{partnerType}}"></i>' +
'</div>' +
'<div class="userinfo">' +
'<h6>\{{username}}</h6> ' +
'<p class="comment-text">\{{content}}</p>' +
'\{{# isSelf}}' +
'<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
'\{{/ isSelf}} ' +
'</div>' +
'</li>',
thirdLogin: false,
isEdit: false,
isMobile: false,
login: ''
};
Comment.prototype = {
constructor: Comment,
init: function() {
// 组件的创建主函数。
this._creat();
},
// 主函数,主要是创建节点,绑定事件。
_creat: function() {
if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
// 创建节点
this._creatCommentDom();
this._creatThirdLogin();
// 绑定事件
this._bindEvent();
},
_creatCommentDom: function() {
var that = this;
//var id = {id:this.options.cid};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + this.options.commentPageUrl,
/*data: id,
dataType:'json',*/
success: function(response) {
var data = response.data, //返回数据的data
viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
moreString = viewMoreNum + '', //剩余评论数量转为字符串
moreFirstnum = moreString.slice(0, 1), //评论数量的首数字
commentTpl = $('#comment-tpl').html(), //引入评论html模板
commentPage, //分页数据
commentHtml, //用数据渲染后的html
commentData; //评论数据
if (data.length === 0) return;
commentData = {
comment: data.comment
};
<<<<<<< HEAD
var Comment = function(element, options) {
this.options = options;
this.$element = $(element);
//this.$loginBox = $(this.options.loginbox).appendTo("body");
this.init();
};
Comment.DEFAULTS = {
cid: '',
commentPageUrl: '/writer/default/comment',
publishUrl: '/writer/default/publish',
deleteUrl: '/writer/default/delete',
commentNum: $(".comment-num"),
commentItemTpl: '<li class="clearfix">'+
'<div class="userimg">'+
'<img src="\{{userimg}}" alt="">'+
'<i class="\{{partnerType}}"></i>'+
'</div>'+
'<div class="userinfo">'+
'<h6>\{{username}}</h6> '+
'<p class="comment-text">\{{content}}</p>'+
'\{{# isSelf}}'+
'<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>'+
'\{{/ isSelf}} '+
'</div>'+
'</li>',
thirdLogin: false,
isEdit: false,
isMobile: false,
login: ''
};
Comment.prototype = {
constructor: Comment,
init:function() {
// 组件的创建主函数。
this._creat();
},
// 主函数,主要是创建节点,绑定事件。
_creat: function() {
if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
// 创建节点
this._creatCommentDom();
this._creatThirdLogin();
// 绑定事件
this._bindEvent();
},
_creatCommentDom:function() {
var that = this;
//var id = {id:this.options.cid};
$.ajax({
type:'GET',
url:YohoConfig.mainUrl + this.options.commentPageUrl,
/*data: id,
dataType:'json',*/
success:function(response) {
var data = response.data, //返回数据的data
viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
moreString = viewMoreNum + '', //剩余评论数量转为字符串
moreFirstnum = moreString.slice(0,1), //评论数量的首数字
commentTpl = $('#comment-tpl').html(), //引入评论html模板
commentPage, //分页数据
commentHtml, //用数据渲染后的html
commentData; //评论数据
if(data.length === 0) return;
commentData = {
comment: data.comment
};
//评论多于五条,渲染more节点
if (viewMoreNum > 0) {
commentData = {
comment: data.comment,
more: {
moreNum : viewMoreNum
}
}
}
//如果分页数据不为空和undefined,渲染分页
if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
commentPage = data.page;
commentData = {
comment: data.comment,
more: {
moreNum : viewMoreNum
},
page: commentPage
}
}
commentHtml = mustache.render(commentTpl, commentData, {
html: commentPage
});
that.$element.prepend($(commentHtml));
//5条后的评论隐藏
that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
//评论总数上千显示k+,上万显示w+
if (moreString.length === 4) {
$(".view-more").find("span").text(moreFirstnum + 'k+');
} else if (moreString.length === 5) {
$(".view-more").find("span").text(moreFirstnum + 'w+');
}
=======
var Comment = function(element, options) {
this.options = options;
this.$element = $(element);
//this.$loginBox = $(this.options.loginbox).appendTo("body");
this.init();
};
Comment.DEFAULTS = {
cid: '',
commentPageUrl: '/writer/default/comment',
publishUrl: '/writer/default/publish',
deleteUrl: '/writer/default/delete',
commentNum: $(".comment-num"),
commentItemTpl: '<li class="clearfix">' +
'<div class="userimg">' +
'<img src="\{{userimg}}" alt="">' +
'<i class="\{{partnerType}}"></i>' +
'</div>' +
'<div class="userinfo">' +
'<h6>\{{username}}</h6> ' +
'<p class="comment-text">\{{content}}</p>' +
'\{{# isSelf}}' +
'<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
'\{{/ isSelf}} ' +
'</div>' +
'</li>',
thirdLogin: false,
isEdit: false,
isMobile: false,
login: ''
};
Comment.prototype = {
constructor: Comment,
init: function() {
// 组件的创建主函数。
this._creat();
},
// 主函数,主要是创建节点,绑定事件。
_creat: function() {
if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
// 创建节点
this._creatCommentDom();
//评论多于五条,渲染more节点
if (viewMoreNum > 0) {
commentData = {
comment: data.comment,
more: {
moreNum: viewMoreNum
}
}
}
this._creatThirdLogin();
//如果分页数据不为空和undefined,渲染分页
if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
commentPage = data.page;
commentData = {
comment: data.comment,
more: {
moreNum: viewMoreNum
},
page: commentPage
}
}
commentHtml = mustache.render(commentTpl, commentData, {
html: commentPage
});
that.$element.prepend($(commentHtml));
//5条后的评论隐藏
that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
//评论总数上千显示k+,上万显示w+
if (moreString.length === 4) {
$(".view-more").find("span").text(moreFirstnum + 'k+');
} else if (moreString.length === 5) {
$(".view-more").find("span").text(moreFirstnum + 'w+');
}
var Comment = function(element, options) {
this.options = options;
this.$element = $(element);
//this.$loginBox = $(this.options.loginbox).appendTo("body");
this.init();
};
// 绑定事件
this._bindEvent();
},
_creatCommentDom: function() {
var that = this;
//var id = {id:this.options.cid};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + this.options.commentPageUrl,
/*data: id,
dataType:'json',*/
success: function(response) {
var data = response.data, //返回数据的data
viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
moreString = viewMoreNum + '', //剩余评论数量转为字符串
moreFirstnum = moreString.slice(0, 1), //评论数量的首数字
commentTpl = $('#comment-tpl').html(), //引入评论html模板
commentPage, //分页数据
commentHtml, //用数据渲染后的html
commentData; //评论数据
if (data.length === 0) return;
commentData = {
comment: data.comment
};
//评论多于五条,渲染more节点
if (viewMoreNum > 0) {
commentData = {
comment: data.comment,
more: {
moreNum: viewMoreNum
}
}
}
//如果分页数据不为空和undefined,渲染分页
if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
commentPage = data.page;
commentData = {
comment: data.comment,
more: {
moreNum: viewMoreNum
},
page: commentPage
}
}
commentHtml = mustache.render(commentTpl, commentData, {
html: commentPage
});
that.$element.prepend($(commentHtml));
//5条后的评论隐藏
that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
//评论总数上千显示k+,上万显示w+
if (moreString.length === 4) {
$(".view-more").find("span").text(moreFirstnum + 'k+');
} else if (moreString.length === 5) {
$(".view-more").find("span").text(moreFirstnum + 'w+');
}
>>>>>>> develop
}
});
},
Comment.DEFAULTS = {
cid: '',
commentPageUrl: '/writer/default/comment',
publishUrl: '/writer/default/publish',
deleteUrl: '/writer/default/delete',
commentNum: $(".comment-num"),
commentItemTpl: '<li class="clearfix">' +
'<div class="userimg">' +
'<img src="\{{userimg}}" alt="">' +
'<i class="\{{partnerType}}"></i>' +
'</div>' +
'<div class="userinfo">' +
'<h6>\{{username}}</h6> ' +
'<p class="comment-text">\{{content}}</p>' +
'\{{# isSelf}}' +
'<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
'\{{/ isSelf}} ' +
'</div>' +
'</li>',
thirdLogin: false,
isEdit: false,
isMobile: false,
login: ''
};
<<<<<<< HEAD
//创建评论文本域
/*_creatTextareaDom:function(){
Comment.prototype = {
constructor: Comment,
init: function() {
// 组件的创建主函数。
this._creat();
},
// 主函数,主要是创建节点,绑定事件。
_creat: function() {
if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
// 创建节点
this._creatCommentDom();
this._creatThirdLogin();
// 绑定事件
this._bindEvent();
},
_creatCommentDom: function() {
var that = this;
//var id = {id:this.options.cid};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + this.options.commentPageUrl,
/*data: id,
dataType:'json',*/
success: function(response) {
var data = response.data, //返回数据的data
viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
moreString = viewMoreNum + '', //剩余评论数量转为字符串
moreFirstnum = moreString.slice(0, 1), //评论数量的首数字
commentTpl = $('#comment-tpl').html(), //引入评论html模板
commentPage, //分页数据
commentHtml, //用数据渲染后的html
commentData; //评论数据
if (data.length === 0) return;
commentData = {
comment: data.comment
};
//评论多于五条,渲染more节点
if (viewMoreNum > 0) {
commentData = {
comment: data.comment,
more: {
moreNum: viewMoreNum
}
}
}
//如果分页数据不为空和undefined,渲染分页
if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
commentPage = data.page;
commentData = {
comment: data.comment,
more: {
moreNum: viewMoreNum
},
page: commentPage
}
}
commentHtml = mustache.render(commentTpl, commentData, {
html: commentPage
});
that.$element.prepend($(commentHtml));
//5条后的评论隐藏
that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
//评论总数上千显示k+,上万显示w+
if (moreString.length === 4) {
$(".view-more").find("span").text(moreFirstnum + 'k+');
} else if (moreString.length === 5) {
$(".view-more").find("span").text(moreFirstnum + 'w+');
} >>> >>> > develop
}
});
},
<< << << < HEAD
//创建评论文本域
/*_creatTextareaDom:function(){
=======
//创建评论文本域
/*_creatTextareaDom:function(){
... ... @@ -291,29 +278,29 @@ require("./login");
},*/
<<<<<<< HEAD
//创建第三方登录
_creatThirdLogin:function(){
var thirdLoginTpl = $("#third-login-tpl").html();
if (this.options.thirdLogin === true) {
$(thirdLoginTpl).appendTo(this.$element);
//this.$element.html(thirdLoginTpl);
}
},
//事件绑定
_bindEvent: function(){
var that = this;
//查看更多评论
this.$element.on("click.comment",".view-more",function() {
that.$element.find("li").show(); //显示第一页后五条
that.$element.find(".comment-pager-content").show(); //显示分页按钮
that.$element.find(".view-more").remove(); //移除view more
});
//弹出登录框
/*$(this).login();
<< << << < HEAD
//创建第三方登录
_creatThirdLogin: function() {
var thirdLoginTpl = $("#third-login-tpl").html();
if (this.options.thirdLogin === true) {
$(thirdLoginTpl).appendTo(this.$element);
//this.$element.html(thirdLoginTpl);
}
},
//事件绑定
_bindEvent: function() {
var that = this;
//查看更多评论
this.$element.on("click.comment", ".view-more", function() {
that.$element.find("li").show(); //显示第一页后五条
that.$element.find(".comment-pager-content").show(); //显示分页按钮
that.$element.find(".view-more").remove(); //移除view more
});
//弹出登录框
/*$(this).login();
=======
//创建第三方登录
_creatThirdLogin: function() {
... ... @@ -343,136 +330,134 @@ require("./login");
$(this).login("loginBoxAnimate");
});*/
<<<<<<< HEAD
//显示删除按钮
if (this.options.isMobile) {
this.$element.find(".delete-comment").show();
} else {
this.$element.on("mouseenter","li",function() {
$(this).find(".delete-comment").show();
}).on("mouseleave","li",function(){
$(this).find(".delete-comment").hide();
});
}
//发表评论
this.$element.on("click.publish",".publish-btn",function() {
var $textarea = that.$element.find("textarea"),
nameInput = that.$element.find(".name-input"),
emailInput = that.$element.find(".email-input"),
comment = $textarea.val(),
=======
//显示删除按钮
if (this.options.isMobile) {
this.$element.find(".delete-comment").show();
} else {
this.$element.on("mouseenter", "li", function() {
$(this).find(".delete-comment").show();
}).on("mouseleave", "li", function() {
$(this).find(".delete-comment").hide();
});
}
//发表评论
this.$element.on("click.publish", ".publish-btn", function() {
var $textarea = that.$element.find("textarea"),
nameInput = that.$element.find(".name-input"),
emailInput = that.$element.find(".email-input"),
comment = $textarea.val(),
>>>>>>> develop
cid,
data,
commentsNum,
commentsList,
publishHtml;
//验证名字
if (!tools.IYOHO_isUserName(nameInput.val())) {
box.alert(tips.getTips("commentUncompleted"), 5, function() {
nameInput.focus();
<<<<<<< HEAD
});
=======
});
>>>>>>> develop
return false;
};
//验证邮箱
if (emailInput.val() !== '' && !tools.IYOHO_isEmail(emailInput.val())) {
box.alert(tips.getTips("commentUncompleted"), 5, function() {
emailInput.focus();
<<<<<<< HEAD
});
=======
});
>>>>>>> develop
return false;
};
//验证评论
if (typeof(comment) === 'undefined' || $.trim(comment) === '') {
box.alert(tips.getTips("commentUncompleted"), 5, function() {
$textarea.focus();
<<<<<<< HEAD
});
return false;
};
if (comment.length > 100) {
box.alert(tips.getTips("commentToMuch"), 5);
return false;
};
cid = that.$element.attr('cid');
if (!cid) {
return false;
};
data = {id:cid,comment:comment,sync:'222',title:'111'};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + that.options.publishUrl,
success: function(response) {
if (response.code === '800000') {
box.alert(tips.getTips("relogin"), 5);
that.$element.login("setLogout");
return false;
};
if (response.status && response.data) {
var $commentsList = $(".comments-list");
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
if ($commentsList .find("li").size() === 0){
$commentsList.html(publishHtml);
} else {
$commentsList.find("li").eq(0).before(publishHtml);
}
box.alert(tips.getTips("publishSuccess"), 5);
$(".comment-textarea textarea").val('');
commentsNum = 1;
if(!!parseInt(that.options.commentNum.eq(0).text())){
commentsNum = parseInt(that.options.commentNum.eq(0).text())+1;
};
that.options.commentNum.text(commentsNum);
} else if (900000 === response.code) {
box.alert(tips.getTips("notSameContent"), 5);
} else {
box.alert(tips.getTips("systemBus"), 5);
}
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
that.$element.find(".comments-list").prepend(publishHtml);
}
})
/*$.ajax({
<< << << < HEAD
//显示删除按钮
if (this.options.isMobile) {
this.$element.find(".delete-comment").show();
} else {
this.$element.on("mouseenter", "li", function() {
$(this).find(".delete-comment").show();
}).on("mouseleave", "li", function() {
$(this).find(".delete-comment").hide();
});
}
//发表评论
this.$element.on("click.publish", ".publish-btn", function() {
var $textarea = that.$element.find("textarea"),
nameInput = that.$element.find(".name-input"),
emailInput = that.$element.find(".email-input"),
comment = $textarea.val(),
=== === =
//显示删除按钮
if (this.options.isMobile) {
this.$element.find(".delete-comment").show();
} else {
this.$element.on("mouseenter", "li", function() {
$(this).find(".delete-comment").show();
}).on("mouseleave", "li", function() {
$(this).find(".delete-comment").hide();
});
}
//发表评论
this.$element.on("click.publish", ".publish-btn", function() {
var $textarea = that.$element.find("textarea"),
nameInput = that.$element.find(".name-input"),
emailInput = that.$element.find(".email-input"),
comment = $textarea.val(),
>>> >>> > develop
cid,
data,
commentsNum,
commentsList,
publishHtml;
//验证名字
if (!tools.IYOHO_isUserName(nameInput.val())) {
box.alert(tips.getTips("commentUncompleted"), 5, function() {
nameInput.focus(); << << << < HEAD
}); === === =
}); >>> >>> > develop
return false;
};
//验证邮箱
if (emailInput.val() !== '' && !tools.IYOHO_isEmail(emailInput.val())) {
box.alert(tips.getTips("commentUncompleted"), 5, function() {
emailInput.focus(); << << << < HEAD
}); === === =
}); >>> >>> > develop
return false;
};
//验证评论
if (typeof(comment) === 'undefined' || $.trim(comment) === '') {
box.alert(tips.getTips("commentUncompleted"), 5, function() {
$textarea.focus(); << << << < HEAD
});
return false;
};
if (comment.length > 100) {
box.alert(tips.getTips("commentToMuch"), 5);
return false;
};
cid = that.$element.attr('cid');
if (!cid) {
return false;
};
data = {
id: cid,
comment: comment,
sync: '222',
title: '111'
};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + that.options.publishUrl,
success: function(response) {
if (response.code === '800000') {
box.alert(tips.getTips("relogin"), 5);
that.$element.login("setLogout");
return false;
};
if (response.status && response.data) {
var $commentsList = $(".comments-list");
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
if ($commentsList.find("li").size() === 0) {
$commentsList.html(publishHtml);
} else {
$commentsList.find("li").eq(0).before(publishHtml);
}
box.alert(tips.getTips("publishSuccess"), 5);
$(".comment-textarea textarea").val('');
commentsNum = 1;
if (!!parseInt(that.options.commentNum.eq(0).text())) {
commentsNum = parseInt(that.options.commentNum.eq(0).text()) + 1;
};
that.options.commentNum.text(commentsNum);
} else if (900000 === response.code) {
box.alert(tips.getTips("notSameContent"), 5);
} else {
box.alert(tips.getTips("systemBus"), 5);
}
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
that.$element.find(".comments-list").prepend(publishHtml);
}
})
/*$.ajax({
type:'POST',
url:YohoConfig.mainUrl + that.options.publishUrl,
data: data,
... ... @@ -537,116 +522,113 @@ require("./login");
}
}
}); */
});
//评论翻页
this.$element.on("click.commentPage",".pager-item",function(){
var url = $(this).attr("href"),
pageHtml,
pageIcon,
commentListTop;
$.ajax({
type: 'GET',
url: url,
success: function(response) {
$(".comments-list").empty();
pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
$(".comments-list").html(pageHtml);
pageIcon = $('<div class="channel-index-pager">'+response.data.page+'</div>');
$(".comment-pager-content").html(pageIcon);
commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
$(window).scrollTop(commentListTop);
}
});
return false;
});
//删除评论
this.$element.on("click.deleteComment",".delete-comment",function(){
var _this = $(this);
var id = _this.attr('pid');
var deleteTip = tips.getTips("deleteComment");
if(that.options.isFeedback){
deleteTip = tips.getTips("deleteFeedback");
}else if(that.options.isEdit){
deleteTip = tips.getTips("deleteEdit");
}
box.confirm(deleteTip, function()
{
$.ajax
({
type:'POST',
url:YohoConfig.mainUrl+that.options.deleteUrl,
data:'id='+id,
dataType:'json',
success:function(response)
=======
});
return false;
};
if (comment.length > 100) {
box.alert(tips.getTips("commentToMuch"), 5);
return false;
};
cid = that.$element.attr('cid');
if (!cid) {
return false;
};
data = {
id: cid,
comment: comment,
sync: '222',
title: '111'
};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + that.options.publishUrl,
success: function(response) {
if (response.code === '800000') {
box.alert(tips.getTips("relogin"), 5);
that.$element.login("setLogout");
return false;
};
if (response.status && response.data) {
var $commentsList = $(".comments-list");
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
if ($commentsList.find("li").size() === 0) {
$commentsList.html(publishHtml);
} else {
$commentsList.find("li").eq(0).before(publishHtml);
}
box.alert(tips.getTips("publishSuccess"), 5);
$(".comment-textarea textarea").val('');
commentsNum = 1;
if (!!parseInt(that.options.commentNum.eq(0).text())) {
commentsNum = parseInt(that.options.commentNum.eq(0).text()) + 1;
};
that.options.commentNum.text(commentsNum);
} else if (900000 === response.code) {
box.alert(tips.getTips("notSameContent"), 5);
} else {
box.alert(tips.getTips("systemBus"), 5);
}
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
that.$element.find(".comments-list").prepend(publishHtml);
}
})
/*$.ajax({
});
//评论翻页
this.$element.on("click.commentPage", ".pager-item", function() {
var url = $(this).attr("href"),
pageHtml,
pageIcon,
commentListTop;
$.ajax({
type: 'GET',
url: url,
success: function(response) {
$(".comments-list").empty();
pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
$(".comments-list").html(pageHtml);
pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
$(".comment-pager-content").html(pageIcon);
commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
$(window).scrollTop(commentListTop);
}
});
return false;
});
//删除评论
this.$element.on("click.deleteComment", ".delete-comment", function() {
var _this = $(this);
var id = _this.attr('pid');
var deleteTip = tips.getTips("deleteComment");
if (that.options.isFeedback) {
deleteTip = tips.getTips("deleteFeedback");
} else if (that.options.isEdit) {
deleteTip = tips.getTips("deleteEdit");
}
box.confirm(deleteTip, function() {
$.ajax({
type: 'POST',
url: YohoConfig.mainUrl + that.options.deleteUrl,
data: 'id=' + id,
dataType: 'json',
success: function(response) === === =
});
return false;
};
if (comment.length > 100) {
box.alert(tips.getTips("commentToMuch"), 5);
return false;
};
cid = that.$element.attr('cid');
if (!cid) {
return false;
};
data = {
id: cid,
comment: comment,
sync: '222',
title: '111'
};
$.ajax({
type: 'GET',
url: YohoConfig.mainUrl + that.options.publishUrl,
success: function(response) {
if (response.code === '800000') {
box.alert(tips.getTips("relogin"), 5);
that.$element.login("setLogout");
return false;
};
if (response.status && response.data) {
var $commentsList = $(".comments-list");
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
if ($commentsList.find("li").size() === 0) {
$commentsList.html(publishHtml);
} else {
$commentsList.find("li").eq(0).before(publishHtml);
}
box.alert(tips.getTips("publishSuccess"), 5);
$(".comment-textarea textarea").val('');
commentsNum = 1;
if (!!parseInt(that.options.commentNum.eq(0).text())) {
commentsNum = parseInt(that.options.commentNum.eq(0).text()) + 1;
};
that.options.commentNum.text(commentsNum);
} else if (900000 === response.code) {
box.alert(tips.getTips("notSameContent"), 5);
} else {
box.alert(tips.getTips("systemBus"), 5);
}
publishHtml = mustache.render(that.options.commentItemTpl, response.data);
that.$element.find(".comments-list").prepend(publishHtml);
}
})
/*$.ajax({
type:'POST',
url:YohoConfig.mainUrl + that.options.publishUrl,
data: data,
... ... @@ -735,106 +717,104 @@ require("./login");
=======
}
}); */
});
>>>>>>> develop
//评论翻页
this.$element.on("click.commentPage", ".pager-item", function() {
var url = $(this).attr("href"),
pageHtml,
pageIcon,
commentListTop;
$.ajax({
type: 'GET',
url: url,
success: function(response) {
$(".comments-list").empty();
pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
$(".comments-list").html(pageHtml);
pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
$(".comment-pager-content").html(pageIcon);
commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
$(window).scrollTop(commentListTop);
}
});
return false;
});
}); >>> >>> > develop
//评论翻页
this.$element.on("click.commentPage", ".pager-item", function() {
var url = $(this).attr("href"),
pageHtml,
pageIcon,
commentListTop;
$.ajax({
type: 'GET',
url: url,
success: function(response) {
$(".comments-list").empty();
pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
$(".comments-list").html(pageHtml);
pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
$(".comment-pager-content").html(pageIcon);
commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
$(window).scrollTop(commentListTop);
}
});
return false;
});
//删除评论
this.$element.on("click.deleteComment", ".delete-comment", function() {
var _this = $(this);
var id = _this.attr('pid');
var deleteTip = tips.getTips("deleteComment");
if (that.options.isFeedback) {
deleteTip = tips.getTips("deleteFeedback");
} else if (that.options.isEdit) {
deleteTip = tips.getTips("deleteEdit");
}
box.confirm(deleteTip, function() {
$.ajax({
type: 'POST',
url: YohoConfig.mainUrl + that.options.deleteUrl,
data: 'id=' + id,
dataType: 'json',
success: function(response) {
if (response.status) {
_this.parents("li").remove();
var comments = parseInt($(".comment-num").eq(0).text()) - 1;
if (comments > 0) {
that.options.commentNum.text(comments);
} else {
that.options.commentNum.html('<img src="' + YohoConfig.resUrl + 'boysweb/assets/images/mobile/comment-mobile.png">');
$(".comment-num.zero").text(0);
$(".comment-num.edit-comment").text('留言');
}
}
}
});
});
});
$(".third-login-box").on("click", "a", function() {
var _this = $(this);
if (!_this.attr('ref')) return;
window.open(_this.attr('ref'), "", "width=760,height=650,top=300,left=300");
return false;
}) $(".third-login-box").on("click", "a.yoho", function() {
$(this).login("loginBoxAnimate");
})
},
publishComment: function() {
var textareaVal = $(".comment-textarea").find("textarea").val();
if (!!!textareaVal || $.trim(textareaVal) === '') return;
if (this.options.isFeedback) return;
$(".publish-btn").trigger("click.publish");
}
//删除评论
this.$element.on("click.deleteComment", ".delete-comment", function() {
var _this = $(this);
var id = _this.attr('pid');
var deleteTip = tips.getTips("deleteComment");
if (that.options.isFeedback) {
deleteTip = tips.getTips("deleteFeedback");
} else if (that.options.isEdit) {
deleteTip = tips.getTips("deleteEdit");
}
box.confirm(deleteTip, function() {
$.ajax({
type: 'POST',
url: YohoConfig.mainUrl + that.options.deleteUrl,
data: 'id=' + id,
dataType: 'json',
success: function(response) {
if (response.status) {
_this.parents("li").remove();
var comments = parseInt($(".comment-num").eq(0).text()) - 1;
if (comments > 0) {
that.options.commentNum.text(comments);
} else {
that.options.commentNum.html('<img src="' + YohoConfig.resUrl + 'boysweb/assets/images/mobile/comment-mobile.png">');
$(".comment-num.zero").text(0);
$(".comment-num.edit-comment").text('留言');
}
}
}
});
});
});
$(".third-login-box").on("click", "a", function() {
var _this = $(this);
if (!_this.attr('ref')) return;
window.open(_this.attr('ref'), "", "width=760,height=650,top=300,left=300");
return false;
})
$(".third-login-box").on("click", "a.yoho", function() {
$(this).login("loginBoxAnimate");
})
},
publishComment: function() {
var textareaVal = $(".comment-textarea").find("textarea").val();
if (!!!textareaVal || $.trim(textareaVal) === '') return;
if (this.options.isFeedback) return;
$(".publish-btn").trigger("click.publish");
}
};
};
function Plugin(option, _relatedTarget) {
return this.each(function() {
var $this = $(this);
var data = $this.data('yoho.Comment');
var options = $.extend({}, Comment.DEFAULTS, $this.data(), typeof option == 'object' && option);
// 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
if (!data) $this.data('yoho.Comment', (data = new Comment(this, options)));
function Plugin(option, _relatedTarget) {
return this.each(function() {
var $this = $(this);
var data = $this.data('yoho.Comment');
var options = $.extend({}, Comment.DEFAULTS, $this.data(), typeof option == 'object' && option);
// 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
if (!data) $this.data('yoho.Comment', (data = new Comment(this, options)));
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
$.fn.comment = Plugin;
$.fn.comment.Constructor = Comment;
$.fn.comment = Plugin;
$.fn.comment.Constructor = Comment;
})(this);
\ No newline at end of file
})(this);
\ No newline at end of file
... ...