var d = document var Sdate=function(el,opts){ if(!opts){opts={}} this.id=el; this.acceptId=$(opts.acceptId); this.showId=$(opts.showId); this.hourId = opts.hourId; this.minId = opts.minId; this.secId = opts.secId; this.endHour=opts.endHour || 24; this.createDateBox() }; Sdate.prototype={constructor:Sdate, createDateBox:function(){ var that = this; var hourId = that.hourId var minId = that.minId var secId = that.secId createDate(hourId,minId,secId,that.endHour,that.acceptId); var hour; var min; var sec; var indexH = 1; var indexM = 1; var indexS = 1; if(hourId){ hour = new iScroll(hourId,{snap:"li",vScrollbar:false,onScrollEnd:function(){ indexH = Math.ceil(this.y/26*-1+1); var hourLi = $('#'+hourId+' li') hourLi.css('color','#6C6C6C') hourLi.eq(indexH + 1).css('color','#141E55') var H = hourLi.eq(indexH + 1).text() $(that.showId).attr('data-hour',H); if(that.id){ if(indexH + indexM + indexS > 3){ $(that.id).addClass('TActive'); }else{ $(that.id).removeClass('TActive'); } } // console.log(indexH,indexM,indexS) }}) } min = new iScroll(minId,{snap:"li",vScrollbar:false,onScrollEnd:function(){ indexM = Math.ceil(this.y/26*-1+1); var minLi = $('#'+minId+' li') minLi.css('color','#6C6C6C'); minLi.eq(indexM + 1).css('color','#141E55'); var M = minLi.eq(indexM + 1).text(); $(that.showId).attr('data-min',M); if(that.id){ if(indexH + indexM + indexS > 3){ $(that.id).addClass('TActive'); }else{ $(that.id).removeClass('TActive'); } } }}); sec = new iScroll(secId,{snap:"li",vScrollbar:false,onScrollEnd:function(){ indexS = Math.ceil(this.y/26*-1+1); var secLi = $('#'+secId+' li') secLi.css('color','#6C6C6C'); secLi.eq(indexS + 1).css('color','#141E55'); var S = secLi.eq(indexS + 1).text(); $(that.showId).attr('data-sec',S); if(that.id){ if(indexH + indexM + indexS > 3){ $(that.id).addClass('TActive'); }else{ $(that.id).removeClass('TActive'); } } }}); }} function createDate(hourId,minId,secId,endHour,acceptId){ var mStr = ""; var sStr = ""; var hStr = ""; var str = ""; for(var i = 0; i < 60; i++){ var index1 = i // var index1 = i < 10 ? ("0" + i) : i; mStr += "
  • " + index1 + "
  • "; sStr += "
  • " + index1 + "
  • "; } mStr = '
    ' sStr = '
    ' if(hourId){ for(var j = 0; j < endHour; j++){ var index2 = j // var index2 = j < 10 ? ("0" + j) : j; hStr += "
  • " + index2 + "
  • "; } hStr = '
    ' str = '
    ' + hStr + mStr + sStr + '
    '; }else{ str = '
    ' + mStr + sStr + '
    '; } $(acceptId).html(str) } // var Sopen=function(el,opts){ // if(!opts){opts={}} // this.id=el; // this.acceptId=$(opts.acceptId); // this.showId=$(opts.showId); // this.createOpenBox() // }; // Sopen.prototype={constructor:Sopen, // createOpenBox:function(){ // var that = this; // var str = '
    ' // $(that.acceptId).html(str) // var open = new iScroll('isOpen',{snap:"li",vScrollbar:false,onScrollEnd:function(){ // var index = Math.ceil(this.y/28*-1+1); // var val = $('#isOpen li').eq(index).text(); // $('#isOpen li').css('color','#6C6C6C'); // $('#isOpen li').eq(index).css('color','#000A47'); // $(that.showId).attr('data-sw',val); // }}) // }}