Authored by xuqi

build tip plugin

... ... @@ -8,7 +8,7 @@ var $ = require('yoho.zepto'),
ellipsis = require('mlellipsis'),
lazyLoad = require('yoho.lazyload');
var api = require('../api');
var tip = require('../plugin/tip');
ellipsis.init();
... ... @@ -33,10 +33,10 @@ function initInfosEvt($container) {
if (code === 200) {
$likeBtn.next('.like-count').text(data.data);
} else if (code === 400) {
api.alert('未登录');
tip.show('未登录');
}
}, function() {
api.alert('网络断开连接了~');
tip.show('网络断开连接了~');
});
});
}
... ...
... ... @@ -12,7 +12,7 @@ var $intro = $('#intro'),
$imt = $('#intro-more-txt'),
$infosContainer = $('#related-infos-container');
var infoApi = require('./info');
var info = require('./info');
var mIntro, aIntro;
... ... @@ -30,8 +30,8 @@ setTimeout(function() {
aIntro = $intro.attr('title');
});
infoApi.initInfosEvt($infosContainer);
infoApi.setLazyLoadAndMellipsis($infosContainer.find('.guang-info'));
info.initInfosEvt($infosContainer);
info.setLazyLoadAndMellipsis($infosContainer.find('.guang-info'));
//文字介绍收起与展开
$('#more-intro').bind('touchstart', function() {
... ...
... ... @@ -25,46 +25,6 @@ var phoneRegx = {
'+61': /^[0-9]{11}$/
};
//错误验证
var $errTip,
tipTime;
/**
* 初始化错误提示
*/
function initErrTip() {
var errTipHtml = '<div id="err-tip" class="err-tip"></div>';
//插入错误提示HTML
$('.passport-page').append(errTipHtml);
$errTip = $('#err-tip');
$errTip.on('touchstart', function() {
$errTip.fadeOut();
//清除Timeout
clearTimeout(tipTime);
});
}
/**
* 显示错误提示
*/
function showErrTip(content) {
if (typeof $errTip === 'undefined') {
return;
}
$errTip.text(content).show();
//若2秒内未点击则自动消失
tipTime = setTimeout(function() {
if ($errTip.css('display') === 'block') {
$errTip.fadeOut();
}
}, 2000);
}
//密码显示隐藏
function bindEyesEvt() {
var $hasEye = $('.has-eye'),
... ... @@ -161,8 +121,6 @@ function selectCssHack($countrySelect) {
module.exports = {
emailRegx: emailRegx,
phoneRegx: phoneRegx,
initErrTip: initErrTip,
showErrTip: showErrTip,
bindEyesEvt: bindEyesEvt,
bindClearEvt: bindClearEvt,
pwdValidate: pwdValidate,
... ...
... ... @@ -8,10 +8,8 @@ var $ = require('yoho.zepto');
var $resend = $('#resend');
var api = require('../api'),
showErrTip = api.showErrTip;
api.initErrTip();
var tip = require('../../plugin/tip'),
showErrTip = tip.show;
$resend.on('touchstart', function(e) {
e.preventDefault();
... ...
... ... @@ -9,11 +9,10 @@ var $email = $('#email'),
$btnSure = $('#btn-sure');
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
api.initErrTip();
var showErrTip = tip.show;
api.bindClearEvt();
... ...
... ... @@ -11,11 +11,10 @@ var $phoneNum = $('#phone-num'),
$btnNext = $('#btn-next');
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
api.initErrTip();
var showErrTip = tip.show;
api.bindClearEvt();
... ...
... ... @@ -9,11 +9,10 @@ var $pwd = $('#pwd'),
$btnOk = $('#btn-ok');
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
api.initErrTip();
var showErrTip = tip.show;
api.bindEyesEvt();
... ...
... ... @@ -11,9 +11,10 @@ module.exports = function(useInRegister) {
$captchaTip = $('#captcha-tip');
var api = require('./api');
var tip = require('../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
var showErrTip = tip.show;
var urlMid = useInRegister ? 'register' : 'back';
... ... @@ -31,8 +32,6 @@ module.exports = function(useInRegister) {
}, 1000);
}
api.initErrTip();
api.bindClearEvt();
$captcha.bind('input', function() {
... ...
... ... @@ -15,9 +15,10 @@ var $phoneNum = $('#phone-num'),
pwdPass = false;
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
var showErrTip = tip.show;
//登录按钮状态切换
function switchLoginBtnStatus() {
... ... @@ -31,9 +32,6 @@ function switchLoginBtnStatus() {
//Android-UC下显示select的direction:rtl无效的临时解决办法
api.selectCssHack($countrySelect);
//初始化ErrTip
api.initErrTip();
//显示隐藏密码
api.bindEyesEvt();
... ...
... ... @@ -16,9 +16,10 @@ var $account = $('#account'),
pwdPass = false;
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
var showErrTip = tip.show;
//登录按钮状态切换
function switchLoginBtnStatus() {
... ... @@ -41,9 +42,6 @@ function hideRetrivePanel() {
$ways.slideUp();
}
//初始化ErrTip
api.initErrTip();
//密码显示与隐藏
api.bindEyesEvt();
... ...
... ... @@ -9,11 +9,10 @@ var $pwd = $('#pwd'),
$btnSure = $('#btn-sure');
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
api.initErrTip();
var showErrTip = tip.show;
api.bindEyesEvt();
... ...
... ... @@ -11,11 +11,10 @@ var $phoneNum = $('#phone-num'),
$btnNext = $('#btn-next');
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = api.showErrTip;
api.initErrTip();
var showErrTip = tip.show;
api.bindClearEvt();
... ...
/**
* 弹框提示
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/10
*/
var $ = require('yoho.zepto');
var $tip, tipItime;
/**
* 初始化提示框
*/
(function() {
var tipHtml = '<div id="yoho-tip" class="yoho-tip"></div>';
//插入提示HTML
$('.yoho-page').append(tipHtml);
$tip = $('#yoho-tip');
$tip.on('touchstart', function() {
$tip.hide();
//清除Timeout
clearTimeout(tipItime);
});
}());
/**
* 显示提示
*/
function show(con, dur) {
var content, duration;
if (typeof con === 'undefined') {
return;
}
content = con.toString();
duration = (dur && dur > 0) ? dur : 2000;
$tip.text(content).show();
tipItime = setTimeout(function() {
if ($tip.css('display') === 'block') {
$tip.hide();
}
}, duration);
}
exports.show = show;
\ No newline at end of file
... ...
... ... @@ -66,4 +66,22 @@ a {
-moz-osx-font-smoothing: grayscale;
}
.yoho-tip {
position: absolute;
display: none;
text-align: center;
width: 70%;
padding: 34px 0;
top: 50%;
left: 50%;
margin-left: -35%;
margin-top: -45px;
background-color: #000;
opacity: 0.7;
color: #fff;
font-size: 18px;
border: none;
@include border-radius(10px);
}
@import "layout/header", "layout/footer", "good", "passport/index", "guang/index";
\ No newline at end of file
... ...
... ... @@ -159,22 +159,4 @@ body.passport-body {
.row {
margin-bottom: 10px;
}
.err-tip {
position: absolute;
display: none;
text-align: center;
width: 70%;
padding: 34px 0;
top: 50%;
left: 50%;
margin-left: -35%;
margin-top: -45px;
background-color: #000;
opacity: 0.7;
color: #fff;
font-size: 18px;
border: none;
@include border-radius(10px);
}
}
\ No newline at end of file
... ...