Authored by 周奇琪

初始化项目

exports.Dic={
//email为空
emailEmpty_jian:"请输入Email!",
emailEmpty_fan:"請輸入Email!",
//email格式错误
emailError_jian:"输入的Email格式不对!",
emailError_fan:"輸入的Email格式不對!",
//评论内容不能为空
commentEmpty_jian:"评论内容不能为空!",
commentEmpty_fan:"評論內容不能為空!",
//评论内容太多
commentToMuch_jian:"文字超过限制,请删改至100个字以内!",
commentToMuch_fan:"文字超過限制,請刪改至100個字以內!",
//系统繁忙请稍后再试
systemBus_jian:"系统繁忙,请稍候再试!",
systemBus_fan:"系統繁忙,請稍候再試!",
//意见反馈为空
feedbackEmpty_jian:"请输入内容后再发送!",
feedbackEmpty_fan:"請輸入內容后再發送!",
//意见反馈发布成功
publishFeedback_jian:"意见反馈发送成功!",
publishFeedback_fan:"意見反饋發送成功!",
//刪除意见反馈
deleteFeedback_jian:"是否删除此条反馈意见?",
deleteFeedback_fan:"是否刪除此條反饋意見?",
//留言内容不能为空
editEmpty_jian:"留言内容不能为空!",
editEmpty_fan:"留言內容不能為空!",
//留言发布成功
editPublishSuccess_jian:"留言发送成功!",
editPublishSuccess_fan:"留言發送成功!",
//刪除留言
deleteEdit_jian:"你确定要删除该留言吗?",
deleteEdit_fan:"你確定要刪除該留言嗎",
//账号密码错误
loginError_jian:"您输入的账号或密码不正确",
loginError_fan:"您輸入的賬號或密碼不正確",
//评论发布成功
publishSuccess_jian:"评论发送成功!",
publishSuccess_fan:"評論發送成功!",
//登录接口
thirdLoginFeedback_jian:"第三方评论",
thirdLoginFeedback_fan:"第三方評論",
//第三方登录提示
thirdLogin_jian:"已注册过有货、SHOW、友和市集,可直接登录",
thirdLogin_fan:"已註冊過有貨、SHOW、友和市集,可直接登錄",
//登录
login_jian:"登录",
login_fan:"登錄",
//退出登录
logout_jian:"是否退出登录?",
logout_fan:"是否退出登錄",
//密码
yohoPwd_jian:"密码",
yohoPwd_fan:"密碼",
//yoho账号
yohoAccount_jian:"YOHO账号",
yohoAccount_fan:"YOHO賬號",
//说点什么
textareaPlaceholder_jian:"说点什么...",
textareaPlaceholder_fan:"說點什麼...",
//刪除评论
deleteComment_jian:"你确定要删除该评论吗?",
deleteComment_fan:"你確定要刪除該評論嗎",
//重新登录
relogin_jian:"请重新登录!",
relogin_fan:"請重新登錄!",
//5分钟内不能评论相同内容
notSameContent_jian:'5分钟内不能评论相同内容!',
notSameContent_fan:'5分鐘內不能評論相同內容!'
};
\ No newline at end of file
... ...
# YOHO!插件库
## 概念
插件简言之就是在一个应用中通用的组件,但是其抽象程度,没有到通用组件的高度,只适用于当前的项目
... ...
/**
* @fileOverview 弹出层组件
* @author:Hbomb(zhouqq@yoho.cn)
* @date:2012-08-07
*/
var $ = require("jquery");
var tools = require("yoho-tools");
var html_front =
'<div class="comfirm">\n\
<div class="comfirm-head">\n\
<a href="javascript:void(0);" class="iconfont close" title="close">&#xe64d;</a>\n\
</div>\n\
<div class="comfirm-content">\n\
<p class="comfirm-text">';
var html_end =
'</p>\n\
</div>\n\
<div class="comfirm-foot">\n\
<div class="comfirm-line"></div>\n\
<div class="comfirm-ctrl clearfix">\n\
<a href="javascript:void(0);" class="cancel">取消</a>\n\
<a href="javascript:void(0);" class="ok">确定</a>\n\
</div>\n\
</div>\n\
</div>';
var zhHK = {
'晕了晕了...明明是空的!':'暈了暈了...明明是空的!',
'请输入有效的邮箱或手机号!':'請輸入有效的郵箱或手機號!',
'密码不得小于6位字符':'密碼不得小於6位字符',
'账号或密码不正确!':'賬號或密碼不正確!',
'你确定要删除该评论吗?':'妳確定要刪除該評論嗎?',
'评论内容不能为空!':'評論內容不能為空!',
'评论内容超过上限60个字!':'評論內容超過上限60個字!',
'系统繁忙,请稍候再试!':'系統繁忙,請稍候再試!',
'请输入Email!':'請輸入Email!',
'输入的Email格式不对!':'輸入的Email格式不對!',
'密码不正确,请重新输入':'密碼不正確,請重新輸入',
'5分钟内不能评论重复内容':'5分鐘內不能評論重復內容'
};
var setPos = function()
{
var _dialog = $(".comfirm");
var wH = $(window).height();
var dialogH = _dialog.height();
var w = $(window).width();
var t = $(window).scrollTop();
var ww = _dialog.outerWidth();
_dialog.css({"top":(wH-dialogH)/2,"left":(w/2-ww/2)+"px",'z-index':10000000000,'position': 'absolute'});
if (!($.browser.msie&&$.browser.version=='6.0'))
{
_dialog.css({"position":"fixed"});
}
else
{
_dialog.css({"top":t+"px"});
}
};
$(window).resize(function () {
setTimeout(function () {
setPos();
},500);
});
/**
* 弹出提示框
*
* @param string message 弹出的提示消息内容
* @param int delay 当需要几秒后自动关闭时,设置该值
*/
exports.alert = function(message, delay,callback)
{
message = translate(message);
if ($(".comfirm").length > 0)
{
$(".confirm").remove();
}
$("body").append(html_front + message + html_end);
$('.comfirm .cancel').hide();
setPos();
$(".close,.ok").click(function()
{
$(".comfirm").remove();
if (callback) {
callback();
}
return false;
});
if (delay && !isNaN(delay))
{
window.setTimeout(function()
{
$(".comfirm").remove();
}, delay * 1000);
}
};
/**
* 弹出确认对话框
*
* @param string message 弹出的提示消息内容
* @param int delay 当需要几秒后自动关闭时,设置该值
*/
exports.confirm = function(message, callback, delay)
{
message = translate(message);
if ($(".comfirm").length > 0)
{
$(".confirm").remove();
}
$("body").append(html_front + message + html_end);
setPos();
$(".cancel,.close").click(function()
{
$('.comfirm .ok').unbind('click');
$(".comfirm").remove();
});
if (callback)
{
$('.comfirm .ok').click(function()
{
$(".comfirm").remove();
callback();
});
}
if (delay && !isNaN(delay))
{
window.setTimeout(function()
{
$(".comfirm").remove();
}, delay * 1000);
}
};
/**
* 转换消息简繁体
*
* @param string message
* @returns string
*/
function translate(message)
{
var lang = tools.cookie('yh_language');
if (!lang)
{
return message;
}
if (lang == 'zh-hk' && zhHK[message])
{
message = zhHK[message];
}
return message;
}
\ No newline at end of file
... ...
/*
评论及登录插件
author:liuyue
date:2015-01-07
*/
var $=require("jquery");
var validate = require("./validate");
var box = require("./box");
var tools = require("yoho-tools");
var tips=require("./tips");
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"),
isFeedback:false,
isEdit:false,
isMobile:false,
login:''
};
Comment.prototype = {
constructor: Comment,
init:function(){
if($(".comments-list").size()>0 || $(".comment-textarea").size()>0) return;
// 组件的创建主函数。
this._creat();
},
// 主函数,主要是创建节点,绑定事件。
_creat: function(){
// 创建节点
this._creatCommentDom();
this._creatTextareaDom();
if(this.options.isFeedback){
this._creatFeedbackLogin();
}
// 绑定事件
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;
var commentsList = $('<ul class="comments-list"></ul>'),
commentsItem = '';
commentsList.prependTo(that.$element);
if(data.length == 0) return;
var total = data.total,
viewMoreNum = total-5;
viewMore = $('<div class="view-more"><a href="javascript:;">View&nbsp;<span>'+viewMoreNum+'</span>&nbsp;more</a></div>'),
commentArr = data.comment,
commentLen = commentArr.length;
for (var i = 0; i < commentLen; i++){
if(commentArr[i].isSelf == true){
commentsItem = $('<li class="clearfix">\n\
<div class="userimg">\n\
<img src="'+commentArr[i].userimg+'" alt="">\n\
<i class="'+commentArr[i].partnerType+'"></i>\n\
</div>\n\
<div class="userinfo">\n\
<h6>'+commentArr[i].username+'</h6>\n\
<p class="comment-text">'+commentArr[i].content+'</p>\n\
<a class="delete-comment" href="javascript:;" pid="'+commentArr[i].id+'"></a>\n\
</div>\n\
</li>');
}else{
commentsItem = $('<li class="clearfix">\n\
<div class="userimg">\n\
<img src="'+commentArr[i].userimg+'" alt="">\n\
<i class="'+commentArr[i].partnerType+'"></i>\n\
</div>\n\
<div class="userinfo">\n\
<h6>'+commentArr[i].username+'</h6>\n\
<p class="comment-text">'+commentArr[i].content+'</p>\n\
</div>\n\
</li>');
}
commentsList.append(commentsItem);
}
if(commentLen>5){
var string = viewMoreNum+'';
var num =string.slice(0,1);
commentsList.find("li").eq(4).nextAll().hide();
commentsList.after(viewMore);
if(string.length == 4){
$(".view-more").find("span").text(num+'k+');
}else if(string.length == 5){
$(".view-more").find("span").text(num+'w+');
};
}
if(data.page){
var commentPage = data.page;
var pageWrap = $('<div style="display:none" class="pager-content comment-pager-content"></div>');
var pageIcon = $('<div class="channel-index-pager">'+commentPage+'</div>')
commentsList.after(pageWrap);
pageIcon.appendTo(pageWrap);
}
}
});
},
//创建评论文本域
_creatTextareaDom:function(){
data = this.options.login;
var textarea = $('<div class="comment-textarea"><textarea placeholder="'+tips.getTips("textareaPlaceholder")+'" cid='+this.options.cid+'></textarea></div>'),
loginarea = $('<div class="login-status clearfix">\n\
<div class="userimg">\n\
<img src="'+YohoConfig.resUrl+'/res/new/boys/images/detail/user-img.png" alt="">\n\
<i></i>\n\
</div>\n\
<div class="userinfo">\n\
<span></span>\n\
<a class="exit-btn" href="javascript:;">退出</a>\n\
</div>\n\
<div class="publish">\n\
<a class="publish-btn" href="javascript:;">Publish</a>\n\
</div>\n\
</div>');
textarea.appendTo(this.$element);
loginarea.appendTo(textarea);
if(this.options.isFeedback){
var anonymous = $('<div class="anonymous">YohoBoy</div>');
$(".login-status .userimg").after(anonymous);
}
if(!data){
$(".login-status .userinfo").hide();
}
},
_creatFeedbackLogin:function(){
var $feedbackLogin = '';
if(tips.isJian){
$feedbackLogin = $('<div class="feedback-login clearfix">\n\
<span>'+tips.getTips("thirdLoginFeedback")+'</span>\n\
<a class="qq" ref="/passport/partner/index/oauth/qq" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-qq.png" alt="" /></a>\n\
<a class="yoho" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-yoho.png" alt="" /></a>\n\
<a class="sina" ref="/passport/partner/index/oauth/sina" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-sina.png" alt="" /></a>\n\
</div>');
}else{
$feedbackLogin = $('<div class="feedback-login clearfix">\n\
<span>'+tips.getTips("thirdLoginFeedback")+'</span>\n\
<a class="fb" ref="/passport/partner/index/oauth/facebook" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-facebook.png" alt="" /></a>\n\
<a class="yoho" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-yoho.png" alt="" /></a>\n\
<a class="sina" ref="/passport/partner/index/oauth/sina" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-sina.png" alt="" /></a>\n\
<a class="qq" ref="/passport/partner/index/oauth/qq" href="javascript:;"><img src="'+YohoConfig.resUrl+'/res/new/boys/images/about/thirdbtn-qq.png" alt="" /></a>\n\
</div>');
}
$feedbackLogin.appendTo(this.$element);
},
//事件绑定
_bindEvent: function(){
var that = this;
//查看更多评论
this.$element.on("click.comment",".view-more",function(){
that.$element.find("li").show(); //显示第一页后五条
that.$element.find(".pager-content").show(); //显示分页按钮
that.$element.find(".view-more").remove(); //移除view more
});
//弹出登录框
$(this).login();
this.$element.on("click.login",".publish-btn",function(){
if(that.options.isFeedback) return;
$(this).login("loginBoxAnimate");
});
//发表评论
this.$element.on("click.publish",".publish-btn",function(){
if($(".login-status").hasClass("login-success") || that.options.isFeedback){
//if($(".comment-textarea textarea").val() == '') return;
var $textarea = that.$element.find("textarea");
var comment = $textarea.val();
if (!!!comment || $.trim(comment) === '')
{
var valEmpty = tips.getTips("commentEmpty");
if(that.options.isFeedback){
valEmpty = tips.getTips("feedbackEmpty");
}else if(that.options.isEdit){
valEmpty = tips.getTips("editEmpty");
}
box.alert(valEmpty, 5,function(){
$textarea.focus();
});
return false;
}
if (comment.length > 100)
{
box.alert(tips.getTips("commentToMuch"), 5);
return false;
}
var cid = $textarea.attr('cid');
if (!cid)
{
return false;
}
/*
var sync = [];
if ($('.sync').length > 0)
{
$('.sync:checked').each(function()
{
sync.push($(this).val());
});
}*/
//var title = $(".detail-title h1").text()+" "+$(".detail-title h2").text();
var data = {id:cid,comment:comment,sync:'222',title:'111'};
$.ajax
({
type:'POST',
url:YohoConfig.mainUrl+that.options.publishUrl,
data: data,
dataType:'json',
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 $target = $(".comments-list");
var commentItem = '<li class="clearfix">'+
'<div class="userimg">'+
'<img src="'+response.data.headpic+'" alt="">'+
'<i class="'+response.data.partnerType+'"></i>'+
'</div>'+
'<div class="userinfo">'+
'<h6>'+response.data.nick+'</h6>'+
'<p class="comment-text">'+response.data.content+'</p>'+
'<a class="delete-comment" href="javascript:;" pid="'+response.data.id+'"></a>'+
'</div>'+
'</li>';
if(that.options.isFeedback && $(".login-status .anonymous").css("display") != "none"){
commentItem = '<li class="clearfix">'+
'<div class="userimg">'+
'<img src="'+response.data.headpic+'" alt="">'+
'<i class="'+response.data.partnerType+'"></i>'+
'</div>'+
'<div class="userinfo">'+
'<h6>'+response.data.nick+'</h6>'+
'<p class="comment-text">'+response.data.content+'</p>'+
'</div>'+
'</li>';
}
if($target.find("li").size()==0){
$target.html(commentItem);
}else{
$target.find("li").eq(0).before(commentItem);
}
if(that.options.isFeedback){
box.alert(tips.getTips("publishFeedback"), 5);
}else if(that.options.isEdit){
box.alert(tips.getTips("editPublishSuccess"), 5);
}else{
box.alert(tips.getTips("publishSuccess"), 5);
}
$(".comment-textarea textarea").val('');
var comments = 1;
if(!!parseInt(that.options.commentNum.eq(0).text())){
comments = parseInt(that.options.commentNum.eq(0).text())+1;
};
that.options.commentNum.text(comments);
}
else if(900000 == response.code){
box.alert(tips.getTips("notSameContent"), 5);
}
else
{
box.alert(tips.getTips("systemBus"), 5);
}
}
});
}
});
//评论翻页
this.$element.on("click.commentPage",".pager-item",function(){
var url = $(this).attr("href");
var $_this = $(this);
$.ajax({
type:'GET',
url:url,
success:function(response)
{
var data = response.data;
var commentArr = data.comment,
commentLen = commentArr.length,
commentsItem = '',
commentPage = data.page;
var pageIcon = $('<div class="channel-index-pager">'+commentPage+'</div>');
$(".comments-list").empty();
for (var i = 0; i < commentLen; i++){
if(commentArr[i].isSelf == true){
commentsItem = $('<li class="clearfix">\n\
<div class="userimg">\n\
<img src="'+commentArr[i].userimg+'" alt="">\n\
<i class="'+commentArr[i].partnerType+'"></i>\n\
</div>\n\
<div class="userinfo">\n\
<h6>'+commentArr[i].username+'</h6>\n\
<p class="comment-text">'+commentArr[i].content+'</p>\n\
<a class="delete-comment" href="javascript:;" pid="'+commentArr[i].id+'"></a>\n\
</div>\n\
</li>');
}else{
commentsItem = $('<li class="clearfix">\n\
<div class="userimg">\n\
<img src="'+commentArr[i].userimg+'" alt="">\n\
<i class="'+commentArr[i].partnerType+'"></i>\n\
</div>\n\
<div class="userinfo">\n\
<h6>'+commentArr[i].username+'</h6>\n\
<p class="comment-text">'+commentArr[i].content+'</p>\n\
</div>\n\
</li>');
}
$(".comments-list").append(commentsItem);
}
$(".comment-pager-content").html(pageIcon);
var commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
$(window).scrollTop(commentListTop);
}
});
return false;
});
//显示删除按钮
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.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+'/res/new/boys/images/mobile/comment-mobile.png">');
$(".comment-num.zero").text(0);
$(".comment-num.edit-comment").text('留言');
}
}
}
});
});
});
$(".feedback-login").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;
})
$(".feedback-login").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)));
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
$.fn.comment = Plugin;
$.fn.comment.Constructor = Comment;
})(this);
\ No newline at end of file
... ...
/**
* @description 根据水平线分页
* @author ly yue.liu@yoho.cn
* @since 2014-12-17
*/
var $=require("jquery");
var slide = require("./photoslide");
var flip = require("./flip");
(function(global, undefined) {
var ContentPaging = function(element, options) {
this.options = options;
this.$element = $(element);
this.$contentWrap = this.$element.find(this.options.pageContentWrap);
this.$coverPic = this.$element.find(this.options.coverPic);
this.dataArr = this.$contentWrap.html().split("<hr>");
this.len = this.dataArr.length;
this.init();
};
ContentPaging.DEFAULTS = {
coverPic:".pic-body",
pageContentWrap:".text-body"
};
ContentPaging.prototype = {
constructor: ContentPaging,
init:function(){
//this.$contentWrap.text(this.$contentWrap.html());
this._browserjuge();
this._creat();
this._bindEvent();
this.pagination(0);
},
//兼容ie8
_browserjuge:function(){
//检测ie版本,ie8采用1024分辨率
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=b_version.split(";");
var trim_Version=version[1].replace(/[ ]/g,"");
if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE8.0" || browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0"){
this.dataArr = this.$contentWrap.html().split("<HR>");
this.len = this.dataArr.length;
}
},
// 主函数,主要是创建节点,绑定事件。
_creat: function(){
// 创建分页按钮
this._creatPagination();
},
_creatPagination: function(){
if(this.len<=1) return;
var $paginationWrap = $('<div class="pager-content detail-pagination"><div class="channel-index-pager"></div></div>');
var $paginationItem;
this.$contentWrap.after($paginationWrap);
for(var i=0;i<this.len;i++){
$paginationItem = $('<a class="pager-item" href="javascript:;">'+(i+1)+'</a>');
$(".detail-pagination .channel-index-pager").append($paginationItem);
}
},
/*
* 分页函数
*/
pagination: function(index) {
if(this.len<=1) return;
//除了第一页,均不显示封面图
if(index == 0){
this.$coverPic.show();
}else{
this.$coverPic.hide();
}
this.$contentWrap.html(this.dataArr[index]);
$(".detail-pagination .channel-index-pager").find("a").removeClass("pager-item-choosen").eq(index).addClass("pager-item-choosen");
$("body").animate({scrollTop:0},10);
$(document.documentElement).animate({scrollTop:0},10);
},
/*
* 插件事件绑定
*/
_bindEvent: function(){
var that = this;
$(".detail-pagination .channel-index-pager").on("click","a",function(){
var index = $(this).index();
that.pagination(index);
});
},
/**跳转到某一个分页**/
jumpTo: function(index){
pagination(index);
}
};
function Plugin(option, _relatedTarget) {
return this.each(function() {
var $this = $(this);
var data = $this.data('yoho.ContentPaging');
var options = $.extend({}, ContentPaging.DEFAULTS, $this.data(), typeof option == 'object' && option);
// 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
if (!data) $this.data('yoho.ContentPaging', (data = new ContentPaging(this, options)));
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
$.fn.contentPaging = Plugin;
$.fn.contentPaging.Constructor = ContentPaging;
})(this);
\ No newline at end of file
... ...
/**
* @fileOverview 实现图片翻转控件
* @author ww
* @date 2014-07-22
*/
var $ = require("jquery");
require("yoho-rotate2d");
var height;
var scrollTop;
var windowHeight=$(window).height();
var delay,returnDelay,isPlaying=false;
//翻转当前对象动画
function RevolvePic(target){
//延时对象
var timeHandler1,timeHandler2,timeHandler3,timeHandler4;
var Y = target.offset().top;
height=target.height();
//分别判断图片小于屏幕和大于屏幕的情况
var last=target.find("a[pic='last']");//第二章图片对象
last.bind("webkitAnimationEnd",function(){
isPlaying=false;
});
//当图片高度小于屏幕高度:滚动高度+屏幕高度>=图片顶端位置+图片高度的三分之二(当三分之二的图片进入屏幕范围即可开始旋转),滚动高度<空间顶端位置+控件高度的三分之二(说明向上滚动)
if ((scrollTop+windowHeight>=Y+height/3*2&&scrollTop<Y+height/3*2)//图片小于屏幕
||
//当图片高度大于屏幕时分别判断:图片顶端位置+图片高度<=滚动高度+屏幕高度(说明图片已经滚动到底)以及 图片顶端位置-50<=滚动高度(说明图片顶端接近屏幕顶端)
//以上两种判断分别对应:向上滚动、向下滚动
(height>=windowHeight&&Y-50<=scrollTop)||(height>=windowHeight&&Y+height<=scrollTop+windowHeight)) {//当图片大于屏幕时执行
isStayLong=true;//用户在该显示区域已经停留了足够长的时间,1S
//判断是否已经增加过了旋转样式,如果没有增加就追加
if (target.attr("RevolvePic")==undefined) {
var eleBack = null, eleFront = null,
// 两张被翻转的图片元素
eleList = target.find(".img");
// 确定前面与后面元素
var funBackOrFront = function() {
eleList.each(function() {
if ($(this).hasClass("out")) {
eleBack = $(this);
} else {
eleFront = $(this);
}
});
};
window.setTimeout(function(){
//根据动画播放完毕的回调事件判断动画播放不会重叠
if (!isPlaying) {
isPlaying=true;
funBackOrFront();
timeHandler1=window.setTimeout(function(){
eleFront.addClass("out").removeClass("in");
timeHandler2=setTimeout(function() {
eleBack.addClass("in").removeClass("out");
// 重新确定正反元素
funBackOrFront();
},155);
},delay-1000);
timeHandler3=window.setTimeout(function(){
eleFront.addClass("out").removeClass("in");
timeHandler4=setTimeout(function() {
eleBack.addClass("in").removeClass("out");
// 重新确定正反元素
funBackOrFront();
target.find(".imga:first").removeClass("out").removeClass("in");
target.find(".imga:last").addClass("out");
},155);
},delay+returnDelay-1000);
target.attr("RevolvePic","RevolvePic");
}
},1000);
}
}
else
{
//页面被拉动到其他区域后
isStayLong=false;
//移出当前区域后解除对target对象的标记
if (target.attr("RevolvePic")!=undefined) {
target.removeAttr("RevolvePic");
}
//清除四个定时器
window.clearTimeout(timeHandler1);
window.clearTimeout(timeHandler2);
window.clearTimeout(timeHandler3);
window.clearTimeout(timeHandler4);
}
}
exports.init=function(info){
/**
* target:被翻转图片的父级DIV元素
* height:图片高度
* delay:从静止到开始动画的等待时间
* returnDelay:从第二幅图片翻转至第一幅图片的等待时间
*/
var defaults={
operate:"auto",//auto:进入显示区域自动翻转;mouse:鼠标hover翻转一次,鼠标离开再次翻转
delay:2000,
returnDelay:2000,
wrapClass: '.lifestyle-flip'
}
var opts = $.extend(defaults, info);
var targets=null;
targets=$(opts.wrapClass);
height=opts.height ;
delay=opts.delay;
returnDelay=opts.returnDelay;
//当前滚动条的位置
scrollTop=$(document).scrollTop();
//是否单次播放完毕
var isPlaying=false;
var isStayLong=false;
if(opts.operate=="auto")
{
//获取到前后面的图片
targets.each(function(index,obj){
RevolvePic($(obj));
});
$(window).scroll(function(){
scrollTop=$(document).scrollTop();
targets.each(function(index,obj){
RevolvePic($(obj));
});
});
}
else if(opts.operate=="mouse")
{
var eleBack = null, eleFront = null;
// 确定前面与后面元素
var funBackOrFront = function(tmpobj) {
eleList = tmpobj.find(".img");
eleList.each(function() {
if ($(this).hasClass("out")) {
eleBack = $(this);
} else {
eleFront = $(this);
}
});
};
targets.each(function(index,obj){
$(obj).dbRotate2D();
});
}
};
\ No newline at end of file
... ...
var $=require("jquery");
require('./lazyloadImage');
;
(function(global, undefined) {
var ImgSlider = function(element, options) {
this.options = options;
this.$wrap = $(element);
this.$element = $(element).find("ul");
this.$lis = this.$element.find("li");
this.$ctrl = $(this.options.slideCtrl).appendTo(this.$wrap);
this.$btnPrev = this.$ctrl.find('.slide-ctrl-prev');//上一张按钮
this.$btnNext = this.$ctrl.find('.slide-ctrl-next');//下一张按钮
this.len = this.$lis.length;
this.width = this.$lis.width() + parseInt(this.$lis.css("margin-right"));
this.index = 1;
this.page = 1;
this.init();
};
ImgSlider.DEFAULTS = {
slideCtrl:'<div class="slide-ctrl"><a class="slide-ctrl-prev" href="javascript:;"></a><a class="slide-ctrl-next" href="javascript:;"></a></div>',
pageNum :4,
itemClass:''
};
ImgSlider.prototype = {
constructor: ImgSlider,
init:function(){
var _this = this;
if(this.len<=4) return;
this._calculationWidth(this.len,this.width);
this.$btnPrev.hide();
// 绑定事件
this._bindEvent();
},
/*
* next
*/
next:function(){
this.$btnPrev.show();
this.index ++;
this._animate(-this.width);
},
/*
* prev
*/
prev:function(){
this.$btnNext.show();
this.index --;
this._animate(this.width);
},
/*
* 添加节点
*/
_addDom:function(){
var _this = this;
if(!this.$element.data("url")) return;
$.ajax({
type:'GET',
url:YohoConfig.mainUrl+_this.$element.data("url")+_this.page,
dataType:'json',
success:function(data){
var item = '',
msg = data.data,
len = msg.length;
for(var i=0;i<len;i++){
item += '<li class="'+_this.options.itemClass+'"><a href="javascript:;"><img src="" data-slide="'+msg[i].pics+'" data-original="'+msg[i].cover+'" data-imgzoom="'+msg[i].dynamic+'"/><span>'+msg[i].title+'</span></a></li>'
}
$(item).appendTo(_this.$element);
//添加节点后重新计算宽度
if(_this.options.itemClass != ''){
_this.len = _this.$element.find("li."+_this.options.itemClass).length;
}else{
_this.len = _this.$element.find("li").length;
}
_this._calculationWidth(_this.len,_this.width);
_this.page++;
}
});
},
/*
* 插件事件绑定
*/
_bindEvent: function(){
var _this = this;
this.$btnNext.on("click",function(){
if (_this.$element.is(':animated')) return;
_this.next();
_this.$element.find("img").lazyload();
if (_this.index == _this.len-_this.options.pageNum+1) {
$(this).hide();
};
if((Math.ceil(_this.index/_this.options.pageNum))%3 == 0 && (Math.ceil((_this.index-1)/_this.options.pageNum))%3 != 0){
_this._addDom();
}
});
this.$btnPrev.on("click",function(){
if (_this.$element.is(':animated')) return;
_this.prev();
if (_this.index == 1) {
$(this).hide();
};
});
},
/*
* 动画
*/
_animate: function(offset) {
var left = parseInt(this.$element.css('left')) + offset;
var _this = this;
if (offset>0) {
offset = '+=' + offset;
}
else {
offset = '-=' + Math.abs(offset);
}
this.$element.stop().animate({'left': offset}, 300);
},
//计算宽度
_calculationWidth: function(len,width){
this.$element.width(len*width);
},
//resize
resize:function(){
this.width = this.$lis.width() + parseInt(this.$lis.css("margin-right"));
if(this.options.itemClass != ''){
this.len = this.$element.find("li."+this.options.itemClass).length;
}else{
this.len = this.$element.find("li").length;
}
this._calculationWidth(this.len,this.width);
this.$element.css({'left': -(this.index-1)*this.width});
}
};
function Plugin(option, _relatedTarget) {
return this.each(function() {
var $this = $(this);
var data = $this.data('yoho.ImgSlider');
var options = $.extend({}, ImgSlider.DEFAULTS, $this.data(), typeof option == 'object' && option);
// 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
if (!data) $this.data('yoho.ImgSlider', (data = new ImgSlider(this, options)));
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
$.fn.imgSlider = Plugin;
$.fn.imgSlider.Constructor = ImgSlider;
})($);
... ...
var $=require("jquery");
+function($){
'use strict';
function ImgZoom(element,options){
this.$element = $(element);
if(!options){
this.options = this.getDefaults();
}else{
this.options = $.extend(true,this.getDefaults(),options);
}
this.init();
};
ImgZoom.DEFAULTS = {
isContainFather: false,
overlay: true,
template:'<div class="imgZoom" onselectstart="return false" unselecttable="on">'+
'<img src="" />'+
'<a href="javascript:;" class="close"></a>'+
'<a href="javascript:;" class="guideBtn prev"></a>'+
'<a href="javascript:;" class="guideBtn next"></a>'+
'</div>'+
'<div class="overlay"></div>',
imgSrcAttr:'data-original'
};
ImgZoom.prototype.getDefaults = function () {
return ImgZoom.DEFAULTS
};
//初始化
ImgZoom.prototype.init = function(){
this.overlay = this.options.overlay;
var $template = $('.imgZoom,.overlay');
this.$template = !!$template.size() ? $template : ($(this.options.template).appendTo("body"));//Dom对象
this.$box = this.$template.filter('.imgZoom');//相册对象
this.$overlayObj = this.$template.filter('.overlay');//遮罩对象
this.$btnPrev = this.$template.find('.guideBtn.prev');//上一张按钮
this.$btnNext = this.$template.find('.guideBtn.next');//下一张按钮
this.$btnClose = this.$template.find('.close');//关闭按钮
this.currentObj = 'currentPhoto';//当前图片的标识类
this.event();
if(this.options.isContainFather){
this.$element.find('['+this.options.imgSrcAttr+']').eq(0).trigger('click.imgzoom');
}
};
//事件绑定集合
ImgZoom.prototype.event = function(){
var _this = this;
this.btnClick();
this.photoClick();
this.$overlayObj.on('click',function(){
_this.close();
});
};
//左右按钮点击事件
ImgZoom.prototype.btnClick = function(){
var _this = this;
this.$btnPrev.off('click');
this.$btnNext.off('click');
this.$btnPrev.on("click",function(){
var that = _this.$template.data('target');
that.photoSwitch(that.$element.find('['+_this.options.imgSrcAttr+']').index(that.$element.find("."+that.currentObj)),"left");
});
this.$btnNext.on("click",function(){
var that = _this.$template.data('target');
that.photoSwitch(that.$element.find('['+_this.options.imgSrcAttr+']').index(that.$element.find("."+that.currentObj)),"right");
//console.log(_this.$element);
});
};
//图片点击事件
ImgZoom.prototype.photoClick = function(){
var _this = this;
this.$element.on("click.imgzoom",'['+_this.options.imgSrcAttr+']',function(){
_this.$element.find("."+_this.currentObj).removeClass(_this.currentObj);
$(this).addClass(_this.currentObj);
_this.$template.data('target', _this);
_this.photoEfficiency();
});
};
//图片左右切换事件
ImgZoom.prototype.photoSwitch = function(index,direction){
this.$element.find("."+this.currentObj).removeClass(this.currentObj);
if(direction=="left"){
var _index = index - 1;
}else{
var _index = index + 1;
}
this.$element.find("["+this.options.imgSrcAttr+"]:eq("+_index+")").addClass(this.currentObj);
this.photoEfficiency();
};
//检测首尾状态
ImgZoom.prototype.getArrowState = function(){
if(this.$element.find('['+this.options.imgSrcAttr+']').index(this.$element.find("."+this.currentObj))==0){
this.$btnPrev.hide();
}else{
this.$btnPrev.show();
}
if(this.$element.find('['+this.options.imgSrcAttr+']').index(this.$element.find("."+this.currentObj))==this.$element.find('['+this.options.imgSrcAttr+']').size()-1){
this.$btnNext.hide();
}else{
this.$btnNext.show();
}
};
//图片显示效果
ImgZoom.prototype.photoEfficiency = function(){
var _this = this;
var hiddenImg = $('<img src="'+_this.$element.find("."+this.currentObj).attr(this.options.imgSrcAttr)+'">').appendTo("body").css({"position":"fixed",'left':'-9999px','top':'-9999px'});
this.loadImg(hiddenImg.attr("src"), function(){
_this.$box.find("img").remove().end().prepend(hiddenImg.removeAttr("style"));
if(!_this.$box.hasClass("show")){
_this.open();
}
if(!_this.$box.hasClass("complete")){
_this.$box.addClass("complete")
}
_this.$box.css("margin-top",-_this.$box.outerHeight()/2);
_this.$box.css("margin-left",-_this.$box.outerWidth()/2);
})
_this.getArrowState();
};
ImgZoom.prototype.loadImg = function(src, callback){
var img = new Image();
if($.browser.msie){
obj.onreadystatechange=function(){
if(this.readyState=="complete"){
callback.call(img);//将回调函数的this替换为Image对象
img = null;
}
}
}else{
img.onload = function () { //图片下载完毕时异步调用callback函数。
callback.call(img);//将回调函数的this替换为Image对象
img = null;
};
}
img.src = src;
};
//打开事件
ImgZoom.prototype.open = function(){
this.$box.addClass("show");
if(this.options.overlay){
this.$overlayObj.fadeIn(100);
}
};
//关闭事件
ImgZoom.prototype.close = function(){
this.$box.removeClass("show complete");
if(this.options.overlay){
this.$overlayObj.fadeOut(100);
}
};
//组件封装处理
function Plugin(option,object){
this.each(function(){
var $this = $(this),
data = $this.data('hc.ImgZoom'),
options = typeof option == 'object' && option;
if(!data){
$this.data('hc.ImgZoom',(data = new ImgZoom($this,options)));
}
if(typeof option =='string'){
data[option](object);
}
return $this;
});
};
var old = $.fn.ImgZoom;
$.fn.ImgZoom = Plugin;
$.fn.ImgZoom.Constructor = ImgZoom;
$.fn.ImgZoom.noConflict = function () {
$.fn.ImgZoom = old;
return this;
};
}($);
... ...
/**
* @fileOverview 图片懒加载的组件
* @author fei.hong@yoho.cn
* @date 2014-05-14
*/
//require("lib/util/jquery.scrollev");
require("lazyload");
var $ = require("jquery");
var settings =
{
threshold : 0, // 灵敏度. 提前加载, 值为像素值
failure_limit : 0, // 容差范围. 检查是否在显示区域内,默认找到第 1 张不可见的图片时,就终止遍历
event : "scroll", // 自定义触发事件 默认为 scroll. 如scrollstop
effect : "fadeIn", // 自定义显示效果, 默认为show. 如show, fadeIn, slideDown
container : window, // 图片插入到的容器,默认为window
data_attribute : "original", // 真实图片地址的 data 属性后缀
skip_invisible : true, // 加载不可见图像, 默认true是不会加载隐藏的不可见图像
appear : null, // 图片加载时的事件 (Function)
load : null, // 图片加载后的事件 (Function)
placeholder : "data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="
};
/**
* 初始化页面的图片
*
* 实现懒加载需要修改的HTML代码:
* 需要在页面的img图片标签加上"data-original"属性, 值为需要懒加载的图片地址
*
* @param string className class样式名称
* @param object options 配置项
* @return void
*/
exports.init = function(className, options)
{
$.extend(settings, options || {});
$('img.'+className).lazyload(options);
};
... ...
/*
登录插件
author:liuyue
date:2015-01-07
*/
var $=require("jquery");
var validate = require("./validate");
var box = require("./box");
var tools = require("yoho-tools");
var tips=require("./tips");
;
(function(global, undefined) {
var Login = function(element, options) {
this.options = options;
this.$element = $(element);
this.init();
};
Login.DEFAULTS = {
};
Login.prototype = {
constructor: Login,
init:function(){
if($(".login-box").size()<=0){
this.creatLoginBox();
this._bindEvent();
}
this.initLoginState();
if(!$(".cookieList").size() >0){
var cookieList = $('<ul class="cookieList"></ul>').appendTo($(".accountwrap"));
}
this.cookieAccount();
},
creatLoginBox:function(){
var $loginBox = $('<div class="login-box">'+
'<h2>登录</h2>'+
'<div class="input-box">'+
'<p class="accountwrap"><input class="yoho-account" type="text" placeholder="'+tips.getTips("yohoAccount")+'"></p>'+
'<p><input class="yoho-pwd" type="password" placeholder="'+tips.getTips("yohoPwd")+'" style="display:none;" /><input class="yoho-pwd-text" type="text" placeholder="'+tips.getTips("yohoPwd")+'" /></p>'+
'</div>'+
'<div class="warn">'+tips.getTips("loginError")+'</div>'+
'<div class="login-btn">'+
'<a id="login" href="javascript:;">'+tips.getTips("login")+'</a>'+
'</div>'+
'<div class="third-login">'+
'<p>'+tips.getTips("thirdLogin")+'</p>'+
'<div class="third-btn clearfix">'+
'<a class="sina" ref="/passport/partner/index/oauth/sina" href="javascript:;"></a>'+
'<a class="qq" ref="/passport/partner/index/oauth/qq" href="javascript:;"></a>'+
'<a class="fb" ref="/passport/partner/index/oauth/facebook" href="javascript:;"></a>'+
'</div>'+
'</div>'+
'<div class="close-btn"></div>'+
'</div>'+
'<div class="login-shadow"></div>').appendTo("body");
},
_bindEvent:function(){
var that = this;
//关闭登录框
$(document).on("click.closeLogin",function(event){
if($(event.target).is(".publish-btn") || $(event.target).is(".login-box") || $(event.target).parents(".login-box").length>=1 ||$(event.target).is(".yoho")||$(event.target).parents(".yoho").length>=1||$(event.target).is(".side-bar-header")) return;
that.closeLoginBox();
event.stopPropagation();
});
$(".login-box").on("click.closeLoginBox",".close-btn",function(){
that.closeLoginBox();
});
//输入账号时登录按钮样式变化
$(".login-box").on("focus",".yoho-account",function(){
$(".login-box").find("#login").addClass("login");
});
//账号密码输入框默认提示
$('.yoho-account').val(tips.getTips("yohoAccount")).addClass("default-tip");
$('.yoho-pwd-text').val(tips.getTips("yohoPwd")).addClass("default-tip");
$('.yoho-account').on("focus",function()
{
if ($(this).val() == tips.getTips("yohoAccount"))
{
$(this).removeClass("default-tip");
$(this).val('');
}
}).on("blur",function()
{
if ($(this).val() == '')
{
$(this).addClass("default-tip");
$(this).val(tips.getTips("yohoAccount"));
}
});
$('.yoho-pwd-text').on("focus",function()
{
if ($(this).val() == '' || $(this).val() == tips.getTips("yohoPwd"))
{
$('.yoho-pwd').val('').show().focus();
$(this).hide();
$(this).removeClass("default-tip");
}
});
$('.yoho-pwd').on("blur",function()
{
if ($(this).val() == '')
{
$(this).hide();
$('.yoho-pwd-text').addClass("default-tip");
$('.yoho-pwd-text').val(tips.getTips("yohoPwd")).show();
}
});
//登录按钮点击事件
$(".login-box").on("click.login","#login",function()
{
var $this = $(this);
var account = $('.yoho-account').val();
var password = $('.yoho-pwd').val();
$.ajax
({
type:'POST',
url:YohoConfig.mainUrl+'/passport/partner/yoho',
data:{'account':account,'password':password},
dataType:'json',
success:function(response)
{
if (response&&response.status && response.data)
{
var userName;
var currentUserName=tools.cookie('userName');
var account = $(".yoho-account").val();
if(currentUserName==null||currentUserName==undefined){
tools.cookie('userName',account,{expires:5,path: '/'});
}else{
tools.cookie('userName',currentUserName+","+account,{expires:5,path: '/'});
}
that.cookieAccount();
that.setLogin(response.data);
$(".login-box").find(".warn").css({"visibility":"hidden"});
that.closeLoginBox();
$this.comment("publishComment");
}
else if (response&&response.message != '')
{
$(".login-box").find(".warn").css({"visibility":"visible"});
}
else
{
$(".login-box").find(".warn").css({"visibility":"visible"});
}
}
});
});
//回车执行登录
$(".login-box").find(".yoho-pwd").keyup(function(e)
{
var e = e || window.event;
var k = e.keyCode || e.which;
if (k == 13)
{
$('#login').trigger("click.login");
}
});
$(".third-btn").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");
that.closeLoginBox();
return false;
});
},
//滑出登录框
loginBoxAnimate:function(){
if($(".login-status").hasClass("login-success")) return;
if($(".side-bar-header").hasClass("login-success")) return;
var height = $(".login-box").outerHeight();
$(".login-shadow").show();
$("body").find(".login-box").animate({"top":"50%","margin-top":-height/2},200);
},
//隐藏登录框
closeLoginBox:function(){
var height = $(".login-box").outerHeight();
$(".login-box").css({"top":-height,"margin-top":0});
$(".login-shadow").hide();
},
//初始化登录状态
initLoginState:function()
{
var state = tools.cookie('yh_state');
var syncs = tools.cookie('yh_syncs');
if (state && syncs)
{
var data = $.parseJSON(syncs);
if (data && data.nick)
{
this.setLogin(data);
}
}
},
//更新登录信息
updateLoginState:function()
{
this.initLoginState();
},
//登录
setLogin:function(data){
var that = this;
$(".login-status .userimg").find("i").attr("class",data.type);
$(".login-status .userinfo").find("span").text(data.nick);
//用户头像
if (data.headpic)
{
$(".login-status .userimg").find("img").attr("src",data.headpic);
}
//手机版
if (data.headpic)
{
$(".user-avatar").find("img").attr("src",data.headpic);
}
$(".login-username").text(data.nick);
$(".side-bar-header").addClass("login-success");
$(".login-status .userinfo").show();
$(".login-status").addClass("login-success");
//隐藏匿名
if($(".login-status .anonymous").size()>0){
$(".login-status .anonymous").hide();
}
//隐藏意见反馈页登录按钮
if($(".feedback-login").size()>0){
$(".feedback-login").hide();
}
$(".exit-btn").on("click",function(){
box.confirm(tips.getTips("logout"), function(){
that.setLogout();
});
});
},
//登出
setLogout:function(){
$(".login-status").removeClass("login-success");
$(".login-status .userimg").find("img").attr("src",YohoConfig.resUrl+"/res/new/boys/images/detail/user-img.png");
$(".login-status .userinfo").hide();
$(".login-status .userimg").find("i").attr("class",'');
$(".comments-list").find(".delete-comment").remove();
//手机版
$(".side-bar-header").removeClass("login-success");
$(".user-avatar").find("img").attr("src",YohoConfig.resUrl+"/res/new/boys/images/detail/user-img.png");
$(".login-username").text("登录");
//显示匿名
if($(".login-status .anonymous").size()>0){
$(".login-status .anonymous").show();
}
//显示意见反馈页登录按钮
if($(".feedback-login").size()>0){
$(".feedback-login").show();
}
$.ajax
({
type:'GET',
url:YohoConfig.mainUrl+'/passport/partner/logout',
dataType:'json'
});
},
//cookie记入账号
cookieAccount:function(){
//cookie
var getCookie,
arrCookie;
getCookie = decodeURIComponent(tools.cookie('userName'));
if(!!tools.cookie('userName'))
{
arrCookie = tools.unique(getCookie.split(','));
$(".cookieList").empty();
for (var i=0;i<arrCookie.length;i++) {
$(".cookieList").append($('<li><a href="javascript:;">'+arrCookie[i]+'</a></li>'));
}
$(".login-box").click(function(e){
if($(e.target).is(".yoho-account")||$(e.target).is(".cookieList")|| $(e.target).closest(".cookieList").size()>0){
$(".cookieList").show();
}else{
$(".cookieList").hide();
}
})
$(".cookieList").on("click","li",function(){
$(".yoho-account").val($(this).find("a").text()).removeClass("default-tip");
$(".cookieList").hide();
return false;
});
}
}
};
function Plugin(option, _relatedTarget) {
return this.each(function() {
var $this = $(this);
var data = $this.data('yoho.Login');
var options = $.extend({}, Login.DEFAULTS, $this.data(), typeof option == 'object' && option);
// 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
if (!data) $this.data('yoho.Login', (data = new Login(this, options)));
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
$.fn.login = Plugin;
$.fn.login.Constructor = Login;
})(this);
\ No newline at end of file
... ...
window.lineHeightDatabase={};
var $=require("jquery");
exports.init=function(){
/*获取一段文本共计多少行*/
$.fn.getTextLineNumber=function(keyword){
//省略后加上title
var $this=$(this);
var fontSize ;
if(!window.lineHeightDatabase[keyword]){
window.lineHeightDatabase[keyword]={fontSize:0,lineHeight:0};
}
if(window.lineHeightDatabase[keyword].fontSize!=0)
{
fontSize=window.lineHeightDatabase[keyword].fontSize;
}
else
{
fontSize= getFinalStyle(this[0],"fontSize");
window.lineHeightDatabase[keyword].fontSize=fontSize;
}
//获取计算后的样式
if(window.lineHeightDatabase[keyword].lineHeight!=0)
{
lineHeight=window.lineHeightDatabase[keyword].lineHeight;
window.lineHeightDatabase[keyword].lineHeight=lineHeight;
}
else
{
if(/msie/i.test(navigator.userAgent)){
var lineHeight = getFinalStyle(this[0],"lineHeight",fontSize);
}
else{
var lineHeight = getFinalStyle(this[0],"lineHeight");
}
}
if(this[0]==null)
return;
var height = this[0].clientHeight;
if(lineHeight == "norm"){
lineHeight = Number(fontSize*1.5);
var nowStyle = $this.attr("style")||"";
this[0].setAttribute("style",nowStyle+";line-height:"+lineHeight+"px");
}
else{lineHeight = Number(lineHeight);}
return parseInt(height/lineHeight);
}
$.fn.mlellipsis=function(row,keyword){
//省略后加上title
var $this=$(this);
var title = $this.attr("_title");
if(!title){
$this.attr("_title",$this.text());
}
else{
$this.text(title);
}
//获取计算后的样式
var fontSize ;
if(!window.lineHeightDatabase[keyword]){
window.lineHeightDatabase[keyword]={fontSize:0,lineHeight:0};
}
if(window.lineHeightDatabase[keyword].fontSize!=0)
{
fontSize=window.lineHeightDatabase[keyword].fontSize;
}
else
{
var fontSize= getFinalStyle(this[0],"fontSize");
window.lineHeightDatabase[keyword].fontSize=fontSize;
}
//获取计算后的样式
if(window.lineHeightDatabase[keyword].lineHeight!=0)
{
lineHeight=window.lineHeightDatabase[keyword].lineHeight;
}
else
{
if(/msie/i.test(navigator.userAgent)){
var lineHeight = getFinalStyle(this[0],"lineHeight",fontSize);
}
else{
var lineHeight = getFinalStyle(this[0],"lineHeight");
//window.lineHeightDatabase[keyword].lineHeight=lineHeight;
}
}
if(!this[0])
return;
var height = this[0].clientHeight;
if(lineHeight == "norm"){
lineHeight = Number(fontSize*1.5);
var nowStyle = $this.attr("style")||"";
this[0].setAttribute("style",nowStyle+";line-height:"+lineHeight+"px");
}
else{lineHeight = Number(lineHeight);}
//若高度足够,则不用省略
var dheight = Math.floor(row*lineHeight);
if(height >= dheight)
{
var str = this.text();
while(dheight*3<this[0].clientHeight){
$this.text(str.substring(0,str.length/2));
str = $this.text();
}
//减去末尾文字
while(dheight<this[0].clientHeight){
str = $this.text();
$this.text(str.replace(/(\s)*([a-zA-Z0-9]?|\W)(\.\.\.)?$/,"..."));
}
return row;
}
else
{
return parseInt(height/lineHeight);
}
}
$.fn.fillText=function(keyword){
//省略后加上title
var $this=$(this);
var title = $this.attr("_title");
if(!title){
$this.attr("_title",$this.text());
}
else{
$this.text(title);
}
//获取计算后的样式
var fontSize ;
if(!window.lineHeightDatabase[keyword]){
window.lineHeightDatabase[keyword]={fontSize:0,lineHeight:0};
}
if(window.lineHeightDatabase[keyword].fontSize!=0)
{
fontSize=window.lineHeightDatabase[keyword].fontSize;
}
else
{
var fontSize= getFinalStyle(this[0],"fontSize");
window.lineHeightDatabase[keyword].fontSize=fontSize;
}
//获取计算后的样式
if(window.lineHeightDatabase[keyword].lineHeight!=0)
{
lineHeight=window.lineHeightDatabase[keyword].lineHeight;
}
else
{
if(/msie/i.test(navigator.userAgent)){
var lineHeight = getFinalStyle(this[0],"lineHeight",fontSize);
}
else{
var lineHeight = getFinalStyle(this[0],"lineHeight");
//window.lineHeightDatabase[keyword].lineHeight=lineHeight;
}
}
if(!this[0])
return;
var height = this[0].clientHeight;
if(lineHeight == "norm"){
lineHeight = Number(fontSize*1.5);
var nowStyle = $this.attr("style")||"";
this[0].setAttribute("style",nowStyle+";line-height:"+lineHeight+"px");
}
else{lineHeight = Number(lineHeight);}
//若高度足够,则不用省略
if(height>5*lineHeight)
{
row=5;
}
else
{
row=(Math.floor(height/lineHeight)-1);
}
var titleHeight=$this.parent().find(".a-title").height()/30;
var subTitleHeight=$this.parent().find(".a-subtitle").height()/30;
if(titleHeight+subTitleHeight>=4)
{
row=4;
}
var dheight = Math.floor(row*lineHeight);
if(height >= dheight)
{
var str = this.text();
while(dheight*3<this[0].clientHeight){
$this.text(str.substring(0,str.length/2));
str = $this.text();
}
//减去末尾文字
while(dheight<this[0].clientHeight){
str = $this.text();
$this.text(str.replace(/(\s)*([a-zA-Z0-9]?|\W)(\.\.\.)?$/,"..."));
}
return row;
}
}
}
function getFinalStyle( obj, property,fontSize)
{
var s;
if(obj!=null&&obj.currentStyle){
s = parseInt(obj.currentStyle[property].replace("px",""));
}
else
if(window.getComputedStyle&&obj!=null){
s = window.getComputedStyle(obj, null)[property].replace("px","");
}
//兼容IEbug:IE解析getComputedStyle或currentStyle,然而若line-height=1.5,它会获取计算后是1.5,而其他浏览器获得1.5*line-height
/*if(fontSize!=undefined){
s = s*fontSize ;
}*/
return s;
}
... ...
This diff could not be displayed because it is too large.
/**
* @package plugin/photoslide.js
* @author:ww(wei.wang@yoho.cn)
* @date:2014-08-19
*/
var $=require("jquery");
require("jquery.imagesLoaded");
var tmpInfo=null;
window.onresize=function(){
if (tmpInfo!=null) {
exports.initSlide(tmpInfo);
}
}
exports.initSlide=function(info){
tmpInfo=info;
var defaults={
isMobile:false,
mobileStartDrage:window.photoSlide_StartDrage||function(){},
mobileEndDrage:function(){},
isAndroid:false //是否为安卓客户端程序
}
var opts=$.extend(defaults,info);
var isMobile=opts.isMobile;
var photos=$(".photoslider_moused_over");
if(photos.length>0)
{
var maxWidth={},maxHeight={};
var brow=getBrowType();
photos.each(function(index,obj){
//alert(index);
var tmpId="photoslider_moused_over_"+index;
$(obj).attr("id",tmpId);
var imgs={};
$(obj).find(".photoslider_right_image").find("img:first").css({"max-width":"100%"}).imagesLoaded(function(){
imgs[tmpId]=$(this).attr("src");
maxWidth[tmpId]=$(this).width();
maxHeight[tmpId]=$(this).height();
$(obj).find(".photoslider_left_image img").css({
"max-width":maxWidth[tmpId],
"max-height":maxHeight[tmpId],
"min-width":maxWidth[tmpId],
"min-height":maxHeight[tmpId],
"width":maxWidth[tmpId],
"height":maxHeight[tmpId]
}).show();
$(".photoslider_drag_message")
.html("← SLIDE →")
.show();
var u = navigator.userAgent;
if(isMobile&&$(obj).find(".drageObject")[0]==null||brow.bIsIpad||brow.bIsAndroid)
{
$("<div/>").css({
position:"absolute",
height:maxHeight[tmpId]*0.2,
width:maxWidth[tmpId],
top:0,
left:0,
"z-index":100
}).attr("noslider","yes").appendTo(obj);
$("<div/>").css({
position:"absolute",
height:maxHeight[tmpId]*0.3,
width:maxWidth[tmpId],
bottom:0,
left:0,
"z-index":100
//background:"#f00"
}).attr("noslider","yes").appendTo(obj);
var drageObject=$("<div/>").attr("class","drageObject").css({
width:20,
height:"100%",
margin:"0 0 0 -10px",
top:0,
left:"50%",
//background:"#f00",
position:"absolute",
"z-index":9999
}).appendTo(obj);
drageObject.bind({
"touchstart":function(){
$(this).parent().find(".photoslider_drag_message").fadeOut();
//opts.mobileStartDrage();
if(opts.isAndroid===true)
{
try{
window.yohoboy.clickOnAndroid(true);
}catch(e){}
}
},
"touchmove":function(event){
var pointX = event.originalEvent.changedTouches[0].pageX;
var left=$(this).parent().offset().left;
var mouseX=pointX-left;
if(mouseX<$(this).parent().parent().width()&&mouseX>0)
{
$(this).parent().find(".photoslider_left_image").width(mouseX);
$(this).css({left:mouseX});
//return false;
}
return false;
},
"touchend":function(){
if(opts.isAndroid===true)
{
try{
window.yohoboy.clickOnAndroid(false);
}catch(e){}
}
}
});
var self=this;
}
});
});
if(isMobile||brow.bIsIpad||brow.bIsAndroid)
{
window.onresize=function(){
exports.initSlide(info);
//var tmpHtml=$(this).parent().parent().parent().html();
}
}
if(isMobile===false)
photos.bind({
"mousemove":function(event){
var pointX = event.pageX;
var left=$(this).offset().left;
var mouseX=pointX-left;
if(mouseX<maxWidth[this.id]&&(!isMobile))
{
$(this).find(".photoslider_left_image").width(mouseX);
//$(this).find(".photoslider_drag_message").css({left:mouseX});
}
},
"mouseover":function(){
var drag_handler=$(this).find(".photoslider_drag_message");
drag_handler.fadeOut();
},
mouseout:function(event){
var x=event.pageX;
if(x-$(this).offset().left>maxWidth[this.id])
{
$(this).find(".photoslider_left_image").width(maxWidth[this.id]);
}
else if(x-$(this).offset().left<0){
$(this).find(".photoslider_left_image").width(0);
}
}
});
}
}
function getBrowType(){
var info={};
var sUserAgent = navigator.userAgent.toLowerCase();
info.bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
info.bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
info.bIsMidp = sUserAgent.match(/midp/i) == "midp";
info.bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
info.bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
info.bIsAndroid = sUserAgent.match(/android/i) == "android";
info.bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
info.bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
return info;
}
... ...
/**
* @author DELL
*/
/**
* @fileOverview 弹出层组件
* @author:王威
* @date:2014-09-19
* yohoo-share-button-sina
* yohoo-share-button-facebook
* yohoo-share-button-tweet
* fbAppId:YohoConfig.girl.fbAppId,'657464311006064',
fbUrl:YohoConfig.girl.mainUrl+'/channel/yohood/closedialog',
*/
var $=require("jquery");
exports.init=function(info){
var defaults={
width:800,
height:500,
img:"",
imgFunction:null,
sinaText:"",
sinaTextFunction:null,
tweetText:"",
tweetTextFunction:null,
fbCaption:"",
fbDescription:"",
fbName:"",
fbTextFunction:null,
shareUrl:"",
shareUrlFunction:null,
fbAppId:"",
fbUrl:"",
qqText:""
}
var options=$.extend(defaults,info);
$(".yohoo-share-button-sina").unbind().on("click", function()
{
if(options.sinaTextFunction!=null)
{
options.sinaText=(function(){
return options.sinaTextFunction.apply($(".yohoo-share-button-sina"));
})();
}
options.sinaText=options.sinaText.replace(/[ ]/g, "%20")
.replace(/[&]/g,"%26")
.replace(/[#]/g,"%23")
.replace(/[+]/g,"%2B");
window.sharetitle = options.sinaText;
if(options.imgFunction!=null)
{
options.img=(function(){
return options.imgFunction.apply($(".yohoo-share-button-sina"));
})();
}
window.shareUrl = options.img
share();
});
if(options.shareUrlFunction!=null)
{
options.shareUrl=(function(){
return options.shareUrlFunction.apply({sina:$(".yohoo-share-button-sina"),
facebook:$(".yohoo-share-button-facebook"),
tweet:$(".yohoo-share-button-tweet")});
})();
}
else
{
options.shareUrl=options.shareUrl==""?document.location.href:options.shareUrl;
}
function share()
{
(function(s, d, e) {
try {
} catch (e) {
}
var f = 'http://v.t.sina.com.cn/share/share.php?', u = options.shareUrl, p = ['url=', e(u), '&title=', e(window.sharetitle+' @YOHO潮流志'), '&appkey=2924220432', '&pic=', e(window.shareUrl)].join('');
function a() {
if (!window.open([f, p].join(''), 'mb', ['toolbar=0,status=0,resizable=1,width=620,height=450,left=', (s.width - 620) / 2, ',top=', (s.height - 450) / 2].join('')))
u.href = [f, p].join('');
};
if (/Firefox/.test(navigator.userAgent)) {
setTimeout(a, 0)
} else {
a()
}
})(screen, document, encodeURIComponent);
}
var iTop = (window.screen.availHeight - 30 - options.height) / 2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth - 10 - options.width) / 2; //获得窗口的水平位置;
$(".yohoo-share-button-facebook").unbind().on("click",function() {
if(options.imgFunction!=null)
{
options.img=(function(){
return options.imgFunction.apply($(".yohoo-share-button-facebook"));
})();
}
var tmpResult={des:"",name:"",caption:""};
if(options.fbTextFunction!=null)
{
tmpResult=(function(){
return options.fbTextFunction.apply($(".yohoo-share-button-facebook"));
})();
if (!tmpResult.url)
{
options.fbCaption=tmpResult.caption;
options.fbDescription=tmpResult.des;
options.fbName=tmpResult.name;
}
else
{
options.fbUrl = tmpResult.url;
}
}
if (options.fbUrl)
{
window.open("https://www.facebook.com/sharer/sharer.php?u=" + options.fbUrl, "",
"height="+options.height+",width="+options.width+",left=" + iLeft + ",top=" + iTop);
}
else
{
options.fbCaption=options.fbCaption.replace(/[ ]/g, "%20")
.replace(/[&]/g,"%26")
.replace(/[#]/g,"%23")
.replace(/[+]/g,"%2B");
options.fbDescription=tmpResult.des.replace(/[ ]/g, "%20")
.replace(/[&]/g,"%26")
.replace(/[#]/g,"%23")
.replace(/[+]/g,"%2B");
options.fbName=tmpResult.name.replace(/[ ]/g, "%20")
.replace(/[&]/g,"%26")
.replace(/[#]/g,"%23")
.replace(/[+]/g,"%2B");
window.open("http://www.facebook.com/dialog/feed?app_id=1431491300468916&redirect_uri=http://www.yohoboys.com/channel/yohood/closedialog&" +
"link=" + options.shareUrl +
"&picture=" + options.img+
"&caption=" +options.fbName+
"&description="+options.fbDescription+(options.fbDescription==""?"":"(分享自 @yohoboy)")+
"&name="+options.fbCaption,
"",
"height="+options.height+",width="+options.width+",left=" + iLeft + ",top=" + iTop);
}
});
$(".yohoo-share-button-tweet").unbind().on("click",function() {
if(options.tweetTextFunction!=null)
{
options.tweetText=(function(){
return options.tweetTextFunction.apply($(".yohoo-share-button-tweet"));
})();
}
options.tweetText=options.tweetText.replace(/[ ]/g, "%20")
.replace(/[&]/g,"%26")
.replace(/[#]/g,"%23")
.replace(/[+]/g,"%2B");
window.open("http://twitter.com/intent/tweet?url=" + options.shareUrl +
"&text="+options.tweetText,
"",
"height="+options.height+",width="+options.width+",left=" + iLeft + ",top=" + iTop);
});
$(".yohoo-share-button-qq").unbind().on("click",function(){
window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+ encodeURIComponent(location.href)+
'&title='+options.qqText+
'&pics='+options.img,'_blank','height='+options.height+',width='+options.width+',left='+iLeft+',top='+iTop);
});
};
$(".yohoo-share-button-wx").on("mouseover",function(){
$(".wx-qrcode-dialog").show();
}).on("mouseout",function(){
$(".wx-qrcode-dialog").hide();
});
//ipad微信
$(".detail-container").on("click.closeWxDialog",function(event){
if($(event.target).is(".yohoo-share-button-wx") || $(event.target).parents(".yohoo-share-button-wx").size()>0){
$(".wx-qrcode-dialog").show();
}else{
$(".wx-qrcode-dialog").hide();
}
})
$(".bottom-content").on("click.closeWxDialog",function(){
$(".detail-container").trigger("click.closeWxDialog");
})
$(".enterprise").on("click.closeWxDialog",function(){
$(".detail-container").trigger("click.closeWxDialog");
})
... ...
/*
评论及登录插件
author:liuyue
date:2015-01-07
*/
var $=require("jquery");
require('./lazyloadImage');
;
(function(global, undefined) {
var Slider = function(element, options) {
this.options = options;
this.$element = $(element);
this.$lis = this.$element.children();
this.len = this.$lis.length;
this.timer = null;
this.width = this.$lis.width();
this.index = 0;
this.ctrlIndex = 0;
this.ctrl = this.options.pageCtrl;
this.ctrlEle = this.options.pageCtrl.children();
this.ctrlLen = this.ctrlEle.length;
this.ctrlWidth = this.ctrlEle.width() + parseInt(this.ctrlEle.eq(1).css("marginLeft"));
this.init();
this.ctrlMaxLeft = this.ctrl.width()-this.ctrl.parent().width()-parseInt(this.ctrlEle.eq(1).css("marginLeft"));
this.excessWidth = this.ctrlMaxLeft - this.ctrlWidth*(this.ctrlLen -this.options.ctrlShowNum);
};
Slider.DEFAULTS = {
pageCtrl:'',
ctrlShowNum:6,
prevBtn:$(".detail-slide-ctrl-prev"),
nextBtn:$(".detail-slide-ctrl-next")
};
Slider.prototype = {
init:function(){
this.setWidth();
if(this.options.autoPlay){
this.play();
}
this.cloneDom();
this.bindEvent();
this.addIndex();
if(this.ctrlLen<=this.options.ctrlShowNum){
this.options.prevBtn.hide();
this.options.nextBtn.hide();
}
},
setWidth:function(){
this.$element.width(this.len*this.width);
this.options.pageCtrl.width(this.ctrlWidth*this.ctrlLen);
this.ctrlMaxLeft = this.ctrl.width()-this.ctrl.parent().width()-parseInt(this.ctrlEle.eq(1).css("marginLeft"));
this.excessWidth = this.ctrlMaxLeft - this.ctrlWidth*(this.ctrlLen -this.options.ctrlShowNum);
},
cloneDom:function(){
if(this.$element.children().length > this.len) return;
},
addIndex:function(){
this.options.pageCtrl.children().each(function(i,value){
$(this).attr("index",i);
})
},
bindEvent:function(){
var _this =this;
this.options.pageCtrl.children().on("click",function(){
if (_this.$element.is(':animated') || $(this).attr('class')=='current') {
return;
}
var myIndex = parseInt($(this).attr("index"));
var offset = -_this.width * (myIndex - _this.index);
_this.animate(offset);
clearTimeout(_this.timer);
_this.index = myIndex;
if(_this.options.autoPlay){
_this.play();
}
_this.showButton();
var left = Math.abs(parseInt($(".detail-slide-ctrl-tabs").css("left")));
if($(this).index() == _this.options.ctrlShowNum-1+parseInt(left/_this.ctrlWidth) && left< _this.ctrlMaxLeft){
_this.options.nextBtn.trigger("click.next");
}else if($(this).index() == parseInt(left/_this.ctrlWidth) && left>0){
_this.options.prevBtn.trigger("click.prev");
}
});
this.options.prevBtn.on("click.prev",function(){
if (_this.options.pageCtrl.is(':animated')) {
return;
}
_this.prev();
});
this.options.nextBtn.on("click.next",function(){
if (_this.options.pageCtrl.is(':animated')) {
return;
}
_this.next();
});
},
prev:function(){
var excessWidth = this.excessWidth;
var maxCtrlIndex = this.ctrlLen -this.options.ctrlShowNum;
this.ctrlIndex--;
if(this.ctrlIndex < 0){
this.ctrlIndex = maxCtrlIndex;
}
if(this.ctrlIndex == 0){
this.options.pageCtrl.stop().animate({"left":0});
}else{
this.options.pageCtrl.stop().animate({"left":-this.ctrlWidth*this.ctrlIndex-excessWidth});
}
},
next:function(){
var maxCtrlIndex = this.ctrlLen -this.options.ctrlShowNum;
if(this.ctrlIndex < maxCtrlIndex){
this.ctrlIndex++;
}else{
this.ctrlIndex=0;
}
if(this.ctrlIndex == maxCtrlIndex && this.ctrlMaxLeft>0){
this.options.pageCtrl.stop().animate({"left":-this.ctrlMaxLeft});
}else{
this.options.pageCtrl.stop().animate({"left":-this.ctrlWidth*this.ctrlIndex});
}
},
showButton: function() {
this.options.pageCtrl.children().eq(this.index).addClass('current').siblings().removeClass('current');
},
animate:function(offset){
var left = parseInt(this.$element.css('left')) + offset;
var _this = this;
if (offset>0) {
offset = '+=' + offset;
}
else {
offset = '-=' + Math.abs(offset);
}
this.$element.stop().animate({'left': offset}, 300);
_this.$element.find(".lazy").lazyload();
},
//屏幕改变大小时重新计算
resize:function(){
this.width = this.$lis.width();
this.ctrlWidth = this.ctrlEle.width() + parseInt(this.ctrlEle.eq(1).css("marginLeft"));
this.setWidth();
this.$element.css({'left': -this.index*this.width});
if(this.ctrlIndex == 0) return;
this.options.pageCtrl.css({"left":-this.ctrlWidth*this.ctrlIndex-this.excessWidth});
}
}
function Plugin(option, _relatedTarget) {
return this.each(function() {
var $this = $(this);
var data = $this.data('yoho.Slider');
var options = $.extend({}, Slider.DEFAULTS, $this.data(), typeof option == 'object' && option);
// 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
if (!data) $this.data('yoho.Slider', (data = new Slider(this, options)));
// 如果传递的options是一个字符串,则表示调用改对象的原型方法。
if (typeof option == 'string') data[option](_relatedTarget);
});
};
$.fn.slider = Plugin;
$.fn.slider.Constructor = Slider;
})(this);
\ No newline at end of file
... ...
var dic=require("./DicTips");
exports.getTips=function(key){
if(isJian())
{
return dic.Dic[key+"_jian"];
}
else
{
return dic.Dic[key+"_fan"];
}
};
exports.isJian=isJian;
function isJian(){
var currentDomain=YohoConfig.mainUrl;
if(currentDomain.indexOf("hk")>=0)
{
return false;//false,繁体
}
return true;//简体,
}
window.DicTips={
}
... ...
/**
* @fileOverview 发布组件
* @author:xmg
* @date:2013-01-14
*/
//邮箱检测
exports.isEmail = function (val)
{
var mailValid = /^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;
return mailValid.test(val);
};
//手机检测
exports.isMobile = function (val)
{
//var mobileValid = /^(1)([0-9]{10})$/;
var mobileValid = /^1[3|4|5|8][0-9]\d{8}$/ ;
return mobileValid.test(val);
};
//昵称检测
exports.isNickname = function (val)
{
valid = /^[\u4E00-\u9FA5A-Za-z0-9_-]{2,32}$/;
return valid.test(val);
};
//是否整数
exports.isInt = function (val)
{
var mobileValid = /^\d$/ ;
return mobileValid.test(val);
};
//是否浮点数
exports.isFloat = function (val)
{
var mobileValid = /^\d+(\.\d+)?$/ ;
return mobileValid.test(val);
};
... ...