增加了插件 在初始化的时候,控制 年月日,和结束 年月日
$(time_createobj).siblings(".xtw_budget_userdatafn_hide").shijian({
showNowTime:false,
startYear:,
startMonh:'',
startDay:'',
val:,
endYear:,
endMonh:'',
endDay:'',
Year:true,//是否显示年//
Month:true,//是否显示月//
Day:true,//是否显示日//
Hour:false,
Hour2:false,
Minute:false,
h:"",
h2:"",
yyyy: nowyear, //设置起始值//
mm: nowmonth,
dd: nowday,
alwaysShow:true,
timeElm:$(".time-box"),//sjObj表示当前对象 也可以使用 sjObj 用字符串
//timeElm:"sjObj.prev()",// 也可以使用 sjObj 用字符串 sjObj 表示当前input
})
jjs 源码:
(function () {
function fillZero(x) {
if (x < 10) {
return x = "0" + x;
} else {
return "" + x;
}
};$.fn.shijian = function (opt) {
function cPlugin(o, emlnum) {
var sjObj = o;
console.log(sjObj)
sjObj.defaults = {
type: "time",
Format: "yyyy-mm-dd",
timeFormat: "hⓂ️s",
width: 60,
height: 32,
Year: true,
Month: true,
Day: true,
Hour: true,
Hour2: true,
Minute: true,
Seconds: false,
yyArr: [],
mmArr: [],
ddArr: [],
hArr: [],
mArr: [],
sArr: [],
yyyy: "2000",
mm: "01",
dd: "01",
h: "01",
m: "01",
s: "01",
val: null,
// yearText: "年",
// monthText: "月",
// dayText: '日',
// hourText: '时',
// minuteText: '分',
// secondsText: '秒',
okText: "确认",
cancelText: "取消",
thisElm: null,
showNowTime: true,
alwaysShow: false,
timeElm: null,
isparseInt: false,
finalshow: true,
boxClassName: "",
onfun: function (sjObj) {
},
okfun: function (sjObj) {
},
t_box: null,
df_persp: function () {
return $("
" + sjObj.opt.buildAmPmStr() + " |
var mubiao = day - l;
// 增加
if (mubiao > 0) {
for (var i = 0; i < mubiao; i++) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[l + i\]).removeClass("df-hide").addClass("df-show")
}
} else {
// 减少
var naomovey = getTranslateY(sjObj.opt.timeElm.find('\[data-class="dd"\]'))
for (var i = 0; i > mubiao; i--) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[l - 1 + i\]).removeClass("df-show").addClass("df-hide")
}
if (naomovey > (day - 1 - 2) \* sjObj.opt.height) {
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transform": "translate(0," + -(day - 1 - 2) \* sjObj.opt.height + "px)"})
}
}
// 自定义的 起始月事件
sjObj.opt.setstartMont(name);
// 自定义的 结束月事件
sjObj.opt.setendMont(name);
};
// 自定义的起始天
sjObj.opt.setstartDay(name);
// 自定义的结束天
sjObj.opt.setendDay(name);
},
// 自定义的 起始月事件
setstartMont:function(name){
if(name=='yyyy'){
if(sjObj.opt.yyyy==sjObj.opt.startYear){
var naomovey\_mm = getTranslateY(sjObj.opt.timeElm.find('\[data-class="mm"\]'))
for (var i = 0; i < 11; i++) {
$(sjObj.opt.timeElm.find('\[data-class="mm"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show")
}
for (var i = 0; i < sjObj.opt.startMonh-1; i++) {
$(sjObj.opt.timeElm.find('\[data-class="mm"\]').find(".df-li")\[i\]).removeClass("df-show").addClass("df-hide");
}
if ( naomovey\_mm<= (sjObj.opt.startMonh-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transform": "translate(0," + -(sjObj.opt.startMonh-3)\* sjObj.opt.height + "px)"})
}
}else{
if(sjObj.opt.yyyy!=sjObj.opt.endYear) {
for (var i = 0; i < 11; i++) {
$(sjObj.opt.timeElm.find('\[data-class="mm"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show")
}
}
}
}
if(name=='mm'){
if(sjObj.opt.yyyy==sjObj.opt.startYear){
var naomovey\_mm = getTranslateY(sjObj.opt.timeElm.find('\[data-class="mm"\]'))
// console.log(naomovey\_mm+'xxxxxxxxxxxxxx')
if ( naomovey\_mm<= (sjObj.opt.startMonh-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transform": "translate(0," + -(sjObj.opt.startMonh-3)\* sjObj.opt.height + "px)"})
}
}
}
},
// 自定义的起始天
setstartDay:function(name){
if(name=='mm'||name=='yyyy'){
if(sjObj.opt.yyyy==sjObj.opt.startYear&&sjObj.opt.mm==sjObj.opt.startMonh){
var naomovey\_dd = getTranslateY(sjObj.opt.timeElm.find('\[data-class="dd"\]'))
for (var i = 0; i < sjObj.opt.startDay-1; i++) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[i\]).removeClass("df-show").addClass("df-hide");
}
if ( naomovey\_dd<= (sjObj.opt.startDay-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transform": "translate(0," + -(sjObj.opt.startDay-3)\* sjObj.opt.height + "px)"})
}
}else {
if(sjObj.opt.yyyy!=sjObj.opt.endYear&&sjObj.opt.mm!=sjObj.opt.endMonh){
var cdays = new Date(sjObj.opt.yyyy, sjObj.opt.mm, 0).getDate();
for (var i = 0; i < cdays; i++) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show")
}
}
}
}
if(name=='dd'){
if(sjObj.opt.yyyy==sjObj.opt.startYear&&sjObj.opt.mm==sjObj.opt.startMonh){
var naomovey\_dd = getTranslateY(sjObj.opt.timeElm.find('\[data-class="dd"\]'))
// console.log(naomovey\_dd+'xxxxxxxxxxxxxx')
if ( naomovey\_dd<= (sjObj.opt.startDay-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transform": "translate(0," + -(sjObj.opt.startDay-3)\* sjObj.opt.height + "px)"})
}
}
}
},
// 自定义的 结束月事件
setendMont:function(name){
if(name=='yyyy'){
if(sjObj.opt.yyyy==sjObj.opt.endYear){
var naomovey\_mmend = getTranslateY(sjObj.opt.timeElm.find('\[data-class="mm"\]'))
for (var i = 0; i < 11; i++) {
$(sjObj.opt.timeElm.find('\[data-class="mm"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show")
}
for (var i = parseFloat(sjObj.opt.endMonh); i < 11; i++) {
$(sjObj.opt.timeElm.find('\[data-class="mm"\]').find(".df-li")\[i\]).removeClass("df-show").addClass("df-hide");
}
if ( naomovey\_mmend> (sjObj.opt.endMonh-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transform": "translate(0," + -(sjObj.opt.endMonh-3)\* sjObj.opt.height + "px)"})
}
}else{
if(sjObj.opt.yyyy!=sjObj.opt.startYear){
for (var i = 0; i < 11; i++) {
$(sjObj.opt.timeElm.find('\[data-class="mm"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show")
}
}
}
}
if(name=='mm'){
if(sjObj.opt.yyyy==sjObj.opt.endYear){
var naomovey\_mmend = getTranslateY(sjObj.opt.timeElm.find('\[data-class="mm"\]'))
console.log(naomovey\_mmend+'xxxxxxxxxxxxxx')
if ( naomovey\_mmend> (sjObj.opt.endMonh-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="mm"\]').css({"transform": "translate(0," + -(sjObj.opt.endMonh-3)\* sjObj.opt.height + "px)"})
}
}
}
},
// 自定义的结束天
setendDay:function(name){
if(name=='mm'||name=='yyyy'){
// console.log(sjObj.opt.mm)
if(sjObj.opt.yyyy==sjObj.opt.endYear&&sjObj.opt.mm==parseFloat(sjObj.opt.endMonh)){
var naomovey\_dd\_day = getTranslateY(sjObj.opt.timeElm.find('\[data-class="dd"\]'))
for (var i = 0; i < 31; i++) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show");
}
for (var i = parseFloat(sjObj.opt.endDay); i < 31; i++) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[i\]).removeClass("df-show").addClass("df-hide");
}
if ( naomovey\_dd\_day>= (sjObj.opt.endDay-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transform": "translate(0," + -(sjObj.opt.endDay-3)\* sjObj.opt.height + "px)"})
}
}else {
if(sjObj.opt.yyyy!=sjObj.opt.startYear&&sjObj.opt.mm!=sjObj.opt.startMonh) {
var cdays = new Date(sjObj.opt.yyyy, sjObj.opt.mm, 0).getDate();
for (var i = 0; i < cdays; i++) {
$(sjObj.opt.timeElm.find('\[data-class="dd"\]').find(".df-li")\[i\]).removeClass("df-hide").addClass("df-show")
}
}
}
}
if(name=='dd'){
if(sjObj.opt.yyyy==sjObj.opt.endYear&&sjObj.opt.mm==sjObj.opt.endMonh){
var naomovey\_dd\_day = getTranslateY(sjObj.opt.timeElm.find('\[data-class="dd"\]'))
// console.log(naomovey\_dd\_day+'xxxxxxxxxxxxxx')
if ( naomovey\_dd\_day>= (sjObj.opt.endDay-3)\* sjObj.opt.height ) {
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transition": "all .5s"})
sjObj.opt.timeElm.find('\[data-class="dd"\]').css({"transform": "translate(0," + -(sjObj.opt.endDay-3)\* sjObj.opt.height + "px)"})
}
}
}
},
moveElm: function (eml) {
var classNameyyy=$(eml\[0\].offsetParent).find('ul').attr('data-class');
var classNamemm=$(eml\[1\].offsetParent).find('ul').attr('data-class');
var classNamedd=$(eml\[2\].offsetParent).find('ul').attr('data-class');
return $(eml).each(function () {
var sX = null, sY = null, mX = null, mY = null, eX = null, eY = null, sTime = null,
eTime = null, mTime = null, nTime = null, nY = 0, drt = null, nowElm = null,
canStart = true, canMove = false, canEnd = false, emlLang = null, maxY = null, minY = null,
lastY = null, nowY = null, moveY = null, stopInertiaMove = false, SE = null, ME = null,
EE = null, moveCy = 0;
var stop = function (e) {
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
var moveStart = function (e) {
// console.log(e);
stop(e);
if (!canStart) {
return
}
if (e.originalEvent.touches) {
SE = e.originalEvent.targetTouches\[0\]
} else {
SE = e;
}
sX = SE.pageX;
sY = SE.pageY;
nowElm = $(this).prev(".df-ul");
emlLang = nowElm.find(".df-show").length;
lastY = sY;
nY = getTranslateY(nowElm);
// console.log("移动开始时", e,nY);
sTime = new Date().getTime();
if (!canMove && canEnd) {
return false
}
canStart = false
canMove = false;
stopInertiaMove = true;
$(window).on("touchmove", function (e) {
if (stopInertiaMove) {
e.preventDefault();
}
})
};
var moveing = function (e) {
stop(e);
if (e.originalEvent.touches) {
ME = e.originalEvent.targetTouches\[0\]
} else {
ME = e;
}
mTime = new Date().getTime();
mX = ME.pageX;
mY = ME.pageY;
drt = GetSlideDirection(sX, sY, mX, mY);
if ((drt == 1 || drt == 2) && !canStart) {
canMove = true;
canEnd = true;
stopInertiaMove = true;
}
if (canMove) {
nowElm.css({"transition": "none"})
nowElm.css({"transform": "translate(0," + -(nY - (mY - sY)) + "px)"})
sjObj.opt.getFinal();
}
if (mTime - sTime > 300) {
// console.log("移动后加速")
sTime = mTime;
lastY = mY;
}
};
var moveEnd = function (e) {
stop(e);
// 我们根据 event事件 找到滑动的 是 年还是月 还是日
// console.log($(e.currentTarget).siblings('.df-ul').attr('data-class'))
var etarget=$(e.currentTarget).siblings('.df-ul').attr('data-class');
if (e.originalEvent.touches) {
EE = e.originalEvent.changedTouches\[0\]
} else {
EE = e;
}
eX = EE.pageX;
eY = EE.pageY;
maxY = sjObj.opt.height \* 2;
// minY = -(emlLang - 3) \* sjObj.opt.height;
// 1dian 这里是控制最大下拉距离的
if(sjObj.opt.yyyy==sjObj.opt.startYear&&etarget=='mm'){
minY = -(12 - 3) \* sjObj.opt.height;
} else if(sjObj.opt.yyyy==sjObj.opt.startYear&&sjObj.opt.mm==sjObj.opt.startMonh&&etarget=='dd'){
var cday = new Date(sjObj.opt.yyyy, sjObj.opt.startMonh, 0).getDate();
minY = -(cday - 3) \* sjObj.opt.height;
}
else if(sjObj.opt.yyyy==sjObj.opt.endYear&&etarget=='mm'){
minY = -(sjObj.opt.endMonh-3)\* sjObj.opt.height;
}
else if(sjObj.opt.yyyy==sjObj.opt.endYear&&sjObj.opt.mm==sjObj.opt.endMonh&&etarget=='dd'){
var cday = new Date(sjObj.opt.yyyy, sjObj.opt.endMonh, 0).getDate();
minY = -(cday - 3) \* sjObj.opt.height;
}else{
minY = -(emlLang - 3) \* sjObj.opt.height;
}
if (canEnd) {
canMove = false;
canEnd = false;
canStart = true;
nY = -(nY - (mY - sY));
nowY = eY;
if (nY > maxY) {
nowElm.css({"transition": "all .5s"})
nowElm.css({"transform": "translate(0," + maxY + "px)"})
} else if (nY < minY) {
nowElm.css({"transition": "all .5s"})
nowElm.css({"transform": "translate(0," + minY + "px)"})
return ;
} else {
eTime = new Date().getTime();
var speed = ((nowY - lastY) / (eTime - sTime));
stopInertiaMove = false;
(function (v, startTime, contentY) {
// contentY 滑动的距离
// dir -1往上滑
// dir 1往下滑
var dir = v > 0 ? -1 : 1;
var deceleration = dir \* 0.001;
function inertiaMove() {
if (stopInertiaMove)
return;
var nowTime = new Date().getTime();
// t 是时间差
var t = nowTime - startTime;
// nowY 是现在的速度
var nowV = v + t \* deceleration;
// 移动的距离 sudu
var moveY = (v + nowV) / 2 \* t;
if (dir \* nowV > 0) {
// console.log(moveCy,minY,sjObj.opt.minY)
if (moveCy > sjObj.opt.maxY) {
console.log('moveCy大于'+moveCy)
nowElm.css({"transition": "all .5s"})
sjObj.opt.nowElm.css({"transform": "translate(0," + sjObj.opt.maxY + "px)"})
} else if (moveCy < sjObj.opt.minY) {
console.log('moveCy小于'+moveCy)
nowElm.css({"transition": "all .5s"})
nowElm.css({"transform": "translate(0," + sjObj.opt.minY + "px)"})
} else {
var MC = Math.round(moveCy / sjObj.opt.height)
// console.log('MC:'+MC)
// 2dian 这里是第二个关键点
if(sjObj.opt.yyyy==sjObj.opt.startYear&&etarget=='mm'){
if (MC > 2) {
MC = 2
} else if (MC < -(12 - 1) + 2) {
MC = -(12 - 1) + 2
}
// console.log('mm+,'+MC)
}else if(sjObj.opt.yyyy==sjObj.opt.endYear&&etarget=='mm'){
if (MC > 2) {
MC = 2
} else if (MC < -sjObj.opt.endMonh) {
MC = -(sjObj.opt.endMonh-3)
}
console.log('endmonth:'+MC)
}
else if(sjObj.opt.yyyy==sjObj.opt.startYear&&sjObj.opt.mm==sjObj.opt.startMonh&&etarget=='dd'){
var cday = new Date(sjObj.opt.yyyy, sjObj.opt.startMonh, 0).getDate();
if (MC > 2) {
MC = 2
} else if (MC < -(cday-1 ) + 2) {
MC = -(cday-1) + 2
}
// console.log('dd:'+MC,cday)
}
else if(sjObj.opt.yyyy==sjObj.opt.endYear&&sjObj.opt.mm==sjObj.opt.endtMonh&&etarget=='dd'){
var cday = new Date(sjObj.opt.yyyy, sjObj.opt.endMonh, 0).getDate();
if (MC > 2) {
MC = 2
} else if (MC < -(cday-1 ) + 2) {
MC = -(cday-1) + 2
}
console.log('eeenddd:'+MC,cday)
}
else{
if (MC > 2) {
MC = 2
} else if (MC < -(emlLang - 1) + 2) {
MC = -(emlLang - 1) + 2
}
// console.log('else:'+MC,cday)
}
console.log('reslut:'+MC)
nowElm.css({"transition": "all .4s"});
nowElm.css({"transform": "translate(0," + sjObj.opt.height \* MC + "px)"})
}
sjObj.opt.getFinal();
return
}
moveCy = (contentY + moveY)
// console.log('moveCy'+moveCy)
if (moveCy > (maxY + (sjObj.opt.height \* 2))) {
nowElm.css({"transition": "all .5s"})
nowElm.css({"transform": "translate(0," + maxY + "px)"})
return
} else if (moveCy < (minY - (sjObj.opt.height \* 2))) {
nowElm.css({"transition": "all .5s"})
nowElm.css({"transform": "translate(0," + minY + "px)"})
return
}
nowElm.css({"transform": "translate(0," + moveCy + "px)"})
sjObj.opt.getFinal();
var timers = setTimeout(inertiaMove, 10);
}
inertiaMove();
})(speed, eTime, nY);
}
// console.log("移动结束", EE)
}
}
// console.log("开始绑定事件", $(this))
$(this).unbind("touchstart mousedown").on("touchstart mousedown", moveStart)
$(this).unbind("touchmove").on("touchmove", moveing)
$(this).unbind("touchend").on("touchend", moveEnd)
$(document).on("mousemove", moveing)
$(document).on("mouseup", moveEnd)
})
},
};
sjObj.opt = $.extend({}, sjObj.defaults, opt);
var GetSlideAngle = function (dx, dy) {
return Math.atan2(dy, dx) \* 180 / Math.PI;
};
function getnyrstr(str) {
var r = sjObj.opt.Format;
var valarr = str.split("-");
console.log(valarr, str);
if (valarr.length == 3) {
r = r.replace("yyyy", valarr\[0\]);
r = r.replace("mm", valarr\[1\]);
r = r.replace("dd", valarr\[2\]);
} else if (valarr.length == 2) {
if (sjObj.opt.Year && !sjObj.opt.Month) {
r = r.replace("yyyy", valarr\[0\]);
r = r.replace("mm", sjObj.opt.mm);
r = r.replace("dd", valarr\[1\]);
} else if (sjObj.opt.Year && !sjObj.opt.Day) {
r = r.replace("yyyy", valarr\[0\]);
r = r.replace("mm", valarr\[1\]);
r = r.replace("dd", sjObj.opt.dd);
} else if (!sjObj.opt.Year) {
r = r.replace("yyyy", sjObj.opt.yyyy);
r = r.replace("mm", valarr\[0\]);
r = r.replace("dd", valarr\[1\]);
}
} else if (valarr.length == 1) {
if (sjObj.opt.Year) {
r = r.replace("yyyy", valarr\[0\]);
r = r.replace("mm", sjObj.opt.mm);
r = r.replace("dd", sjObj.opt.dd);
} else if (sjObj.opt.Month) {
r = r.replace("yyyy", sjObj.opt.yyyy);
r = r.replace("mm", valarr\[0\]);
r = r.replace("dd", sjObj.opt.dd);
} else if (sjObj.opt.Day) {
r = r.replace("yyyy", sjObj.opt.yyyy);
r = r.replace("mm", sjObj.opt.mm);
r = r.replace("dd", valarr\[0\]);
} else {
r = r.replace("yyyy", sjObj.opt.yyyy);
r = r.replace("mm", sjObj.opt.mm);
r = r.replace("dd", sjObj.opt.dd);
}
}
;console.log("返回年月日", r);
return r;
}
function getsfmstr(str) {
var r = sjObj.opt.timeFormat;
console.log(r);
var valarr = str.split(":");
if (valarr.length == 3) {
r = r.replace("h", valarr\[0\]);
r = r.replace("m", valarr\[1\]);
r = r.replace("s", valarr\[2\]);
} else if (valarr.length == 2) {
if (sjObj.opt.Hour && !sjObj.opt.Minute) {
r = r.replace("h", valarr\[0\]);
r = r.replace("m", sjObj.opt.m);
r = r.replace("s", valarr\[1\]);
} else if (sjObj.opt.Hour && !sjObj.opt.Seconds) {
r = r.replace("h", valarr\[0\]);
r = r.replace("m", valarr\[1\]);
r = r.replace("s", sjObj.opt.s);
} else if (!sjObj.opt.Hour) {
r = r.replace("h", sjObj.opt.h);
r = r.replace("m", valarr\[0\]);
r = r.replace("s", valarr\[1\]);
}
} else if (valarr.length == 1) {
if (sjObj.opt.Hour) {
r = r.replace("h", valarr\[0\]);
r = r.replace("m", sjObj.opt.m);
r = r.replace("s", sjObj.opt.s);
} else if (sjObj.opt.Minute) {
r = r.replace("h", sjObj.opt.h);
r = r.replace("m", valarr\[0\]);
r = r.replace("s", sjObj.opt.s);
} else if (sjObj.opt.Hour) {
r = r.replace("h", sjObj.opt.h);
r = r.replace("m", sjObj.opt.m);
r = r.replace("s", valarr\[0\]);
} else {
r = r.replace("h", sjObj.opt.h);
r = r.replace("m", sjObj.opt.m);
r = r.replace("s", sjObj.opt.s);
}
}
;console.log("返回时分秒", r);
return r;
}
var GetSlideDirection = function (startX, startY, endX, endY) {
var dy = startY - endY;
var dx = endX - startX;
var result = 0;
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
return result;
}
var angle = GetSlideAngle(dx, dy);
if (angle >= -45 && angle < 45) {
result = 4;
} else if (angle >= 45 && angle < 135) {
result = 1;
} else if (angle >= -135 && angle < -45) {
result = 2;
}
else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
result = 3;
}
return result;
};
var getTranslateY = function (eml) {
var matrix = $(eml).css("transform");
// console.log("获取到的transform", matrix)
var T;
if (matrix == "none") {
T = 0;
} else {
var arr = matrix.split(",")
T = -(arr\[5\].split(")")\[0\]);
}
// console.log("返回的transform", T)
return T
}
sjObj.innt = function () {
if (!sjObj.opt.alwaysShow) {
$(this).on("click", function (e) {
e.stopPropagation();
sjObj.opt.thisElm = this;
switch (sjObj.opt.type) {
case "time":
$("html").addClass("ov\_hi");
$(this).blur();
sjObj.opt.getYear();
sjObj.opt.buildHTml();
sjObj.opt.getFinal();
break;
}
})
} else {
sjObj.opt.thisElm = this;
// console.log("直接显示")
sjObj.opt.getYear();
sjObj.opt.buildHTml();
}
$(window).on("resize", function () {
// console.log("窗口大小改变")
sjObj.opt.setCenter()
})
}
sjObj.innt();
return sjObj
}
if (this.length > 1) {
console.log("多个")
var arr = \[\]
$.each(this, function () {
arr.push(cPlugin(this, true))
})
return arr
} else {
// console.log("一个")
obj = cPlugin(this);
// console.log("一个时间对象", obj);
return obj
}
}
})(jQuery)
手机扫一扫
移动阅读更方便
你可能感兴趣的文章