/*
+------------------------------------------
| 搴旀煇浜鸿姹傦紝灏嗕笢瑗块兘鐢╦Q灏佽
| By Zinn
+------------------------------------------
*/
$.extend({
/**************************************************
$.T({str:'', type:'btn', mask:1});
**************************************************/
T:function(v){
var a = $.extend({
main: '.T-bo',
bo: '.TIPs' + new Date().getTime() + Math.ceil(Math.random()*100),
css: 'T-Bin',
outcss: 'hide',
bgoutcss: 'hide',
str: '',
url: '',
mask: 1,
type: 'btn',
time: 0,
title: '',
at: 'body',
of: '',
close: 0,
scroll: 'no',
offset: '',
color: '',
bgcolor: '',
icon: 0,
icolor: '',
wh: [],
xy: [0,0],
style: '',
min: '',
max: '',
click: function(){}
}, v),
t = {
init: function()
{
t.bo = a.bo.substr(1);
t.main = a.main.substr(1);
if(a.type=='bar' && a.color=='') a.color='#fff';
if(a.type=='tv' && a.close==0) a.close=4;
if(a.type=='iframe' && a.close==0) a.close=2;
if(a.title) a.type='';
t.make(); t.view(); t.act();
if(a.move) t.move($(a.bo).find('.T-Bd'));
t.move($(a.bo).find('.T-Bd .T-Tit'));
return t;
},
act: function(){
var bo = $(a.bo),
bc = bo.find('.close,.T-Close'),
bg = bo.find('.T-Bg');
t.obj = bo;
if(a.time>0) t.CloseTime = setTimeout(function(){t.close();}, a.time+700);
setTimeout(function(){t.offset()}, 1);
$(a.bo).find('.T-Bd').addClass(a.css);
$(window).resize(function(){t.offset()});
if($.IsIOS && a.position!='absolute'){
$(window).scroll(function(){t.offset()});
}
if(a.click!='none'&&a.click!='null'){
t.onclose(bg);
$(document).on('keypress', function(e){
var k=(e.keyCode ? e.keyCode : e.which);
if(k=='13') bc.trigger('click');
});
}
if(a.type=='img') t.onclose(bo);
t.onclose(bc);
if(typeof a.yes=='function') bo.find('.btnclose .yes').on('click', function(){a.yes()});
if(typeof a.no=='function') bo.find('.btnclose .no').on('click', function(){a.no()});
bo.find('.T-Con,.T-Tit,.btnclose,.T-Close,.T-Bg').I();
},
onclose: function(o){
o.on('click',function(){
t.close();
});
},
str: function(str){
$(a.bo).find('.T-Con > div').html(str);
// t.act();
return t;
},
view: function(){
var cl='
',
ic=['','','','','',''],
mi=a.min!='' ? ('-
') : '',
mx=a.max!='' ? ('+
') : '',
ht;
ht = '' +
(a.mask ? '' : '') +
''
+ mi + mx + cl +
(a.type=='btn' ? '
OK
' : '') +
(a.type=='confirm' ? '
' : '') +
(a.type=='confirm' ? '
YES' : '') +
(a.type=='confirm' ? '
NO' : '') +
(a.type=='confirm' ? '
' : '') +
(a.title ? '
'+ a.title + mi + mx + cl + '
' : '') +
'
' +
'
' +
'
' +
(a.icon ? '
' + ic[a.icon] + '
':'' ) +
(a.type=='iframe' || a.type=='tv'
? '
'
: '
' + a.str + '
') +
'
' +
'
'
;
if(a.type=='img'){
ht ='' +
'' +
'' +
'
' +
'
'
;
}
$(a.bo).html(ht);
$(a.bo).find('.T-Bg').addClass('bg'+a.mask);
$(a.bo).find('.T-Bd').addClass(a.type+(a.at!='body'?' isAp':'')+(a.title?' T-Tit':' NotT-Tit'));
if(a.type=='bar'||a.type=='tip'||a.type=='btn'||a.type=='confirm'||a.title!='') a.close=0;
else if(a.close==0) a.close=1;
$(a.bo).find('.T-Close').addClass('c'+a.close);
$(a.bo).find('.T-Min').addClass('c'+a.close);
$(a.bo).find('.T-Msg, .close, .tip-icon, .T-Min').css({'color': a.color});
if(a.bgcolor){
$(a.bo).find('.T-Bd-bg').addClass('isbg');
$(a.bo).find('.T-Bd-bg').css({'background': a.bgcolor});
}
if(a.icon){
$(a.bo).find('.T-Con').addClass('T-Font T-Font'+a.icon);
}
$(a.bo).find('.T-Con').css({
'width': a.wh[0] ? a.wh[0] : '',
'height': a.wh[1] ? a.wh[1] : '',
'overflow': a.scroll=='yes' ? 'auto' : (a.scroll=='no'&&a.type!='null' ? 'hidden' : '')
});
},
offset: function(){
a.wh[1] = parseInt(a.wh[1]);
if((a.wh[1]=='auto' || !a.wh[1]) && a.type!='tv' && a.type!='iframe'){
$(a.bo).find('.T-Con').css({height:'auto'});
}
var bd=$(a.bo).find('.T-Bd'),
wW=parseInt($(window).width()),
wH=parseInt($(window).height()),
sT=document.body.scrollTop || document.documentElement.scrollTop,
bw=parseInt(bd.outerWidth()),
bh=parseInt(bd.outerHeight()),
ht=parseInt(bd.find('.T-Tit').outerHeight()),
hm=parseInt(bd.find('.T-Msg').outerHeight()),
left,top;
if(a.at!='body'){
wW=$(a.at).outerWidth();
wH=$(a.at).outerHeight();
}
hm=(a.wh[1]>hm||a.wh[1]0 ? a.wh[1] : hm;
if(a.type!='tv'){
bh = hm<=wH*0.94?hm:wH*0.94;
bd.find('.T-Con').height(bh);
}
if(hm>bh) $(a.bo).find('.T-Con').css({'overflow':'auto'});
top=wH*((wH/2.6>bh)?0.38:(wH/2>bh?0.46:0.5))-bh/2;
left=wW/2-bw/2;
if(a.top) top=a.top;
if(a.left) left=a.left;
if(a.bottom) top=wH-bh-ht-a.bottom;
if(a.right) left=wW-bw-a.right;
if(typeof a.xy=='object'){
top+=a.xy[1]; left+=a.xy[0];
}
top=top<0?0:(top>(wH-bh)?(wH-bh):top);
if(a.position=='absolute'||($.IsIOS&&a.type!='iframe'&&a.type!='tv'&&a.type!='img')){
top=parseFloat(sT)+parseFloat(wH/2.5-bh/2);
bd.css({'position':'absolute','max-height':''});
}else{
// $('input').blur();
}
bd.css({'top':top, 'left':left});
},
make: function(){
$(a.at).append('');
if(a.type!='tv' && a.type!='iframe' && a.title==''){
$(a.at).find(a.main+'.isAalert').attr({'isqiangzhi':'1'}).find('.close').click(); //灏嗘彁绀烘€у脊绐楀幓鎺
$(a.bo).addClass('isAalert');
}
if(a.type=='img') $(a.bo).find('.close').click();
},
move: function(obj){
var bd=$(a.bo).find('.T-Bd'), x0, y0, x1, y1, t0, l0, left, top,
w0, h0, w1, h1;
obj.addClass('move notcopy').on('mousedown',function(e0){
x0=e0.pageX;
y0=e0.pageY;
t0=parseInt(bd.css('top'));
l0=parseInt(bd.css('left'));
bd.addClass('notcopy');
w0=$(window).width(), h0=$(window).height(), w1=bd.outerWidth(), h1=bd.outerHeight();
if(a.at!='body'){
w0=$(a.at).outerWidth();
h0=$(a.at).outerHeight();
}
$(window).off('mousemove').on('mousemove', function(e1){
x1=e1.pageX;
y1=e1.pageY;
left=l0+(x1-x0);
top=t0+(y1-y0);
if(left>0 && left0 && top '
);
f.obj.attr({'target':'UFIframe','action':f.url,'method':f.type,'enctype':'multipart/form-data'});
var iframe = $('#UFIframe')[0];
if(iframe.attachEvent){
iframe.attachEvent('onreadystatechange', function() {
//姝や簨浠跺湪鍐呭娌℃湁琚浇鍏ユ椂鍊欎篃浼氳瑙﹀彂锛屾墍浠ユ垜浠鍒ゆ柇鐘舵€
//鏈夋椂鍊欎細姣旇緝鎬紓 readyState鐘舵€佷細璺宠繃 complete 鎵€浠ユ垜浠琹oaded鐘舵€佷篃瑕佸垽鏂
if (iframe.readyState==='complete' || iframe.readyState=='loaded') {
//瑕佹竻闄ゆ帀浜嬩欢
iframe.detachEvent('onreadystatechange', arguments.callee);
//杩欓噷鏄洖璋冨嚱鏁
f.over(iframe.contentWindow.document.body.innerHTML);
}
});
}else{
iframe.addEventListener('load', function() {
//浠g爜鑳芥墽琛屽埌杩欓噷璇存槑宸茬粡杞藉叆鎴愬姛瀹屾瘯浜
this.removeEventListener('load', arguments.call, false);
//杩欓噷鏄洖璋冨嚱鏁
f.over(iframe.contentWindow.document.body.innerHTML);
}, false);
}
});
return false;
},
over: function(data){
$('[name="UFIframe"]').remove();
if(f.data=='json') data = $.parseJSON(data);
if(typeof f.end=='function' && data) f.end(data, f);
},
reset: function(bool){
if(bool) $(f.obj)[0].reset();
else f.obj.find('input[type="text"],input[type="password"],input[check],textarea').val('');
}
}, v);
f.init();
return this;
},
/**************************************************
琛ㄥ崟妫€鏌
$('form').C({});
**************************************************/
C:function(v){
var check = [], v = v || {}, obj=this,
email = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,
mobile= /^1[0-9]{10}$/,
phone = /^\d{7,8}$/;
obj.find('[check]').each(function(i,e){
var isgo, type, val, num, name,
one = $(this),
sty = one.attr('check'),
val = one.val() || '',
tip = one.attr('tip') && one.attr('tip').replace(/\{val\}/g, '"'+val+'"'),
to = one.attr('to') ? $('['+one.attr('to')+']') : '';
if(sty){
sty = sty.split('|');
sty[0] = sty[0].split('-');
sty[0].length>1 || sty[0].push(1);
name = sty[1]||'';
type = sty[0][0];
num = sty[0][1] = parseInt(sty[0][1]) || 1;
if(type=='str') isgo = val.length>=num || -1;
else if(type=='email') isgo = email.test(val) || -1;
else if(type=='mobile') isgo = mobile.test(val) || -1;
else if(type=='phone') isgo = phone.test(val) || -1;
else if(type=='pwd') isgo = val==obj.find('[name="'+name+'"]:last').val() || -1;
else if(type=='tip') isgo = val.length>=num || -1;
else if(type=='float') isgo = parseFloat(val)==val || -1;
else if(type=='int') isgo = parseInt(val)==val || -1;
if(one.attr('type')=='radio'||one.attr('type')=='checkbox'){
isgo = $('[name="'+one.attr('name')+'"]:checked').length>=num || -1;
}
if(isgo==-1){
check.push({'obj':one, 'tip':tip, 'to':to, 'type':type});
to && to.html(tip).show();
}
if(one.attr('type')=='radio'||one.attr('type')=='checkbox'){
one.parent().parent().on('click',function(){
to && to.hide().html('');
});
}else{
one.on('keyup',function(){
to && to.hide().html('');
});
}
}
});
if(check.length>0){
v.of=check[0].obj;
v.str=check[0].tip;
if(check[0].to) check[0].to.html(check[0].tip);
else $.T(v);
}
return check.length>0?check:0;
},
/**************************************************
鏁板瓧绱(鏈夊緟浼樺寲)
0
1000
$('.count-num').N({});
**************************************************/
N:function(v){
var a = $.extend({
obj: this,
multipleTime: 10,
endTime: 10*1000,
time: 1000,
slpTime: '',
over: 0
}, v),
g = {
init:function(){
if(a.obj.length<=0) return g;
g.attr();
a.obj.S({end:function(){}});
g.num();
a.slpTime=setInterval(g.num, a.multipleTime);
},
attr:function(){
$(a.obj).each(function(i,e) {
var s=parseInt($(this).attr('num-start')),
e=parseInt($(this).attr('num-end')),
t=parseInt($(this).attr('num-time'))||a.time;
var multiple=Math.ceil(e/(t/a.multipleTime));
$(this).attr({'num-multiple':multiple});
if(a.maxTime10?(m-10):0);
if(type=='plus'&&run=='1'){
var num=n+m;
if(num>e){ num=e; }
else a.over=0;
}else if(type=='minus'&&run=='1'){
var num=n-m;
if(num
$('[name="RiQi[]"]').Date();
**************************************************/
Date:function(){
var o=new Date('1900').format('yyyy'), n=new Date().format('yyyy'), y='', m='', d='', month,
yy=this.eq(0), mm=this.eq(1), dd=this.eq(2), y3=yy.html(), m3=mm.html(), d3=dd.html();
for(var i=o; i<=n; i++){
y += '';
}
for(var i=1; i<13; i++){
m += '';
}
for(var i=1; i<32; i++){
d += '';
}
yy.html(y).on('change', function(e){
ymd();
});
mm.html(m).on('change', function(e){
ymd();
});
dd.html(d);
var ymd = function(){
d=''; m3=mm.val(); y3=yy.val(); d3=dd.val();
month=new Date(y3,m3,0).getDate();
for(var i=1; i<=month; i++){
d += '';
}
dd.html(d);
}
return this;
},
/**************************************************
璁㈠崟甯哥敤鐨勬暟閲忛€夋嫨鍣
$('.q').Q();
**************************************************/
Q:function(v){
return this.each(function(){
var q = {
m: $(this).find('[minus]'),
p: $(this).find('[plus]'),
i: $(this).find('input'),
s: function(){
q.min = parseInt(q.i.attr('min')) || 0;
q.max = parseInt(q.i.attr('max')) || 0;
q.m.addClass('notcopy').on('click', function(){
q.n = parseInt(q.i.val());
q.i.val(q.n>q.min?q.n-1:q.min).trigger('keyup');
});
q.p.addClass('notcopy').on('click', function(){
q.n = parseInt(q.i.val());
q.i.val(q.nq.max){
q.i.val(q.max);
return false;
}
q.i.val(q.n= thsT && thsS!='1'){
$(this).attr({'scDiv':'1'});
a.end(this);
}
});
}
}
s.i();
return this;
},
/**************************************************
鍔犺浇鍒嗛〉
鍐呭鍖哄煙
$('.lsPro').P({type:'scroll'}); //div婊氬姩鍒板彲瑙嗗尯鍩?鐒跺悗鍔犺浇鍒嗛〉
$('.lsPro').P({type:'click'}); //鐐瑰嚮,鐒跺悗鍔犺浇鍒嗛〉
**************************************************/
P:function(v){
var a = $.extend({
obj: this,
type: ''
}, v);
btn = a.obj.attr('btn');
if(a.type=='click'){
btn.click(function(e){
var e = this;
a.obj.PAGEHtmlLoad(e);
});
}else{
btn.S({
end:function(e){
a.obj.PAGEHtmlLoad(e);
}
});
}
return this;
},
PAGEHtmlLoad:function(e){
var e = $(e),
u = e.attr('url')||'/default.html',
p = e.attr('page'),
c = e.attr('cate'),
s = e.attr('sty'),
k = e.attr('keyword'),
z = $(this),
load = z.attr('load');
load.removeClass('n').slideDown();
$.get(u, { page:p, CateId:c, sty:s, keyword:k }, function(data){
if(data&&data!='1'){
z.attr('page',parseInt(p)+1);
z.append(''+data+'
');
setTimeout(function(){
z.find('.xPage-'+p).slideDown(500);
load.slideUp(500);
e.attr({'scDiv':'0'}); // 鍒濆鍖栧彲瑙嗗嚱鏁扮殑鍒ゆ柇灞炴€
},400);
}else{
load.addClass('n').html('鍒板敖澶翠簡');
}
}, 'html');
},
/**************************************************
鐭俊楠岃瘉鐮佷緥瀛
$('div').SMS({url:'/ajax/w.sms.php', mobile:'', code:'sCode'});
杩斿洖json鏍煎紡 鈥榹r:0,t:100,m:'鎻愮ず淇℃伅'}鈥 re鏄繑鍥炵殑鐘舵€侊紝 t鏄凡缁忚繃鍘荤殑绉掓暟
**************************************************/
SMS:function(v){
var m = /^(1+\d{10})$/,
e = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,
setIntT='',
obj = this,
a = $.extend({
time: 300,
url: '/ajax/w.sms.php',
mobile: '',
email: '',
type: 'mobile'
}, v);
if(a.type=='mobile' && !m.test(a.mobile)){
$.T({str:'"'+a.mobile+'" is not a correct phone number!',mask:1});
return false;
}else if(a.type=='email' && !e.test(a.email)){
$.T({str:'"'+a.email+'" is not a correct mailbox address!',mask:1});
return false;
}
if(obj.attr('n')=='1'){
return false;
}
obj.html('loading...');
$.post(a.url, v, function(data){
if(data){
if(data.r==1 || data.r==-100){
obj.attr({'t':data.r==-100?data.t:0, 'n':'1'});
clearInterval(setIntT);
setIntT=setInterval(function(){
var t = parseInt(obj.attr('t'))||0;
t++;
var ht= a.time-t;
if(ht<1){
obj.attr({'t':'0', 'n':'0'}).html('Get the verifying code');
clearInterval(setIntT);
}
else obj.html('Get back after '+ht+' seconds').attr('t',t);
}, 1000);
}else{
obj.html('Please get it again');
if(data.m) alert(data.m);
}
}else{
obj.html('Please get it again');
alert('Error!');
}
},'json');
return this;
}
});
// 鎵╁睍鏍煎紡鍖栨椂闂
Date.prototype.format=function(fmt) {
var o = {
"M+" : this.getMonth()+1, //鏈堜唤
"d+" : this.getDate(), //鏃
"h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //灏忔椂
"H+" : this.getHours(), //灏忔椂
"m+" : this.getMinutes(), //鍒
"s+" : this.getSeconds(), //绉
"q+" : Math.floor((this.getMonth()+3)/3), //瀛e害
"S" : this.getMilliseconds() //姣
};
var week = {
"0" : "鏃?,
"1" : "涓€",
"2" : "浜?,
"3" : "涓?,
"4" : "鍥?,
"5" : "浜?,
"6" : "鍏?
};
if(/(y+)/.test(fmt)){
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
if(/(E+)/.test(fmt)){
fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "鏄熸湡" : "鍛?) : "")+week[this.getDay()+""]);
}
for(var k in o){
if(new RegExp("("+ k +")").test(fmt)){
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
}
}
return fmt;
}