update
authorJason Zhou <zzyss86@qq.com>
Sun, 16 Feb 2014 11:35:13 +0000 (19:35 +0800)
committerJason Zhou <zzyss86@qq.com>
Sun, 16 Feb 2014 11:35:13 +0000 (19:35 +0800)
demo/calendar/index.html
demo/calendar/js/calendar.js
demo/calendar/js/calendar.min.js

index 450ae3d..b333e35 100644 (file)
@@ -64,6 +64,6 @@
 <script type="text/javascript" src="http://cdn.tuijs.com/js/hammer.min.js"></script>
 <script type="text/javascript" src="http://cdn.tuijs.com/js/jquery.hammer.min.js"></script>
 <script type="text/javascript" src="http://cdn.tuijs.com/js/LunarCalendar.min.js?v=20140216"></script>
-<script type="text/javascript" src="http://cdn.tuijs.com/js/calendar.min.js?v=20140216"></script>
+<script type="text/javascript" src="http://cdn.tuijs.com/js/calendar.min.js?v=2014021601"></script>
 </body>
 </html>
index a9a4732..421b510 100644 (file)
@@ -378,13 +378,11 @@ var Calendar = (function(){
        
        function initPageElm(){
                pageWidth = $(document).width();
-               var panelElm0 = $('.date_list').eq(0);
-               var panelElm1 = $('.date_list').eq(1);
-               panelElm0.css('width',pageWidth);
-               panelElm1.css({'width':pageWidth,'left':pageWidth});
+               $('.date_list').eq(0).css('width',pageWidth);
+               $('.date_list').eq(1).css({'width':pageWidth,'left':pageWidth});
                if(mobile.platform=='iOS'){//iOS启用3d,同时将子元素也设置一下,防止BUG
-                       setTranslate(panelElm0[0],0);
-                       setTranslate(panelElm0[1],0);
+                       setTranslate(document.getElementById('date_list_0'),0);
+                       setTranslate(document.getElementById('date_list_1'),0);
                }
        };
        
index 2ef1e44..9813077 100644 (file)
@@ -7,4 +7,4 @@
  * Author : JasonZhou
  * Email : zzyss86@qq.com
  */
-window.HuangLi=window.HuangLi||{},function(){var a={platform:"",version:0,Android:function(){return"Android"===this.platform},iOS:function(){return"iOS"===this.platform},init:function(){var a=navigator.userAgent;a.match(/Android/i)?(this.platform="Android",this.version=parseFloat(a.slice(a.indexOf("Android")+8))):a.match(/iPhone|iPad|iPod/i)&&(this.platform="iOS",this.version=parseFloat(a.slice(a.indexOf("OS")+3)))}};a.init(),this.mobile=a}(),function(){var a=function(a,b){var c=document.getElementsByTagName("head")[0],d=document.createElement("script");d.setAttribute("type","text/javascript"),d.setAttribute("src",a),c.appendChild(d);var e=function(){"function"==typeof b&&b()};document.all?d.onreadystatechange=function(){("loaded"==d.readyState||"complete"==d.readyState)&&e()}:d.onload=function(){e()}};Zepto&&($.getScript=a)}(),function(){var a=function(){},b={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};a.compile=function(a,c){var d=c||b,e="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";return new Function("obj",e)},a.template=function(b,c){var d=a.compile(b);return d(c)},"undefined"!=typeof exports?exports.Footprint=a:window.Footprint=a,Zepto&&($.template=a.template)}();var Calendar=function(){function a(){if(!w)return"";var a=w.year,b=w.month,c=w.day;return b=10>b?"0"+b:b,c=10>c?"0"+c:c,a+"-"+b+"-"+c}function b(a,b,c,d){w={year:a||v.getFullYear(),month:b||v.getMonth()+1,day:c||v.getDate(),pos:d||0}}function c(){if(HuangLi["y"+w.year]){var a=HuangLi["y"+w.year][B(w.month,w.day)];d(a)}else w.year>=q&&w.year<=r&&$.getScript(p+"hl"+w.year+".min.js",function(){var a=HuangLi["y"+w.year][B(w.month,w.day)];d(a)})}function d(a){a?($(".hl_y_content").html(a.y),$(".hl_j_content").html(a.j),$(".date_hl").show()):$(".date_hl").hide()}function e(b){var d=LunarCalendar.solarToLunar(w.year,w.month,w.day),e=new Date(w.year,w.month-1,w.day).getDay(),f=["日","一","二","三","四","五","六"];$("#toolbar h1").html(a()),$(".date_lunar_info").html("农历"+d.lunarMonthName+d.lunarDayName+" 星期"+f[e]),$(".date_gan_zhi").html(d.GanZhiYear+"年["+d.zodiac+"年] "+d.GanZhiMonth+"月 "+d.GanZhiDay+"日");var g=[];d.term&&g.push(d.term),d.lunarFestival&&g.push(d.lunarFestival),d.solarFestival&&g.push(d.solarFestival.split(" ")),$(".date_fetv").html(g.length>0?"节假日纪念日:"+g.join(","):""),b&&b.attr("class","date_item date_current"),c()}function f(){var a=$("#date_list_"+y[0]).find(".date_item").eq(w.pos);v.getFullYear()==w.year&&v.getMonth()+1==w.month&&v.getDate()==w.day?a.attr("class","date_item date_today"):a.attr("class","date_item")}function g(){x=LunarCalendar.calendar(w.year,w.month,!0);for(var a="",b=u.join(""),c=0;c<x.monthData.length;c++){var d=x.monthData[c];c%7==0&&(a+='<div class="date_row">');var f={index:c,itemCls:"",iconCls:d.worktime?1==d.worktime?" worktime":" holiday":"",iconText:d.worktime?1==d.worktime?"班":"休":"",fetvCls:d.lunarFestival||d.term?" lunar_fetv":d.solarFestival?" solar_fetv":"",lunar:""},g="";v.getFullYear()==d.year&&v.getMonth()+1==d.month&&v.getDate()==d.day&&(g=" date_today"),w.year==d.year&&w.month==d.month&&w.day==d.day&&(g=" date_current",w.pos=c),(c<x.firstDay||c>=x.firstDay+x.monthDays)&&(g=" date_other"),f.itemCls=g;var h=d.lunarDayName;d.solarFestival&&(h=d.solarFestival),d.lunarFestival&&(h=d.lunarFestival),d.term&&(h=d.term),f.lunar=h,$.extend(d,f),a+=$.template(b,d),c%7==6&&(a+="</div>")}$("#date_list_"+y[0]).html(a),e()}function h(a,c,d,e){var f,h,k;c&&d?(f=c,h=d):w.month+a<1?(f=w.year-1,h=12):w.month+a>12?(f=w.year+1,h=1):(f=w.year,h=w.month+a),k=e?e:w.day>LunarCalendar.getSolarMonthDays[h-1]?LunarCalendar.getSolarMonthDays[h-1]:w.day,s>f||f>t||(b(f,h,k),i(),g(),j(a))}function i(){var a=y.shift();y.push(a)}function j(a){A&&clearTimeout(A),k({time:0,pos:0}),$("#date_list_"+y[0]).css({left:a*z}),$("#date_list_"+y[1]).css({left:0}),A=a>0?setTimeout(function(){k({time:300,pos:-1*z})},50):setTimeout(function(){k({time:300,pos:z})},50)}function k(a){var b=$(".date_slide")[0];b.style.webkitTransitionDuration=a.time+"ms",l(b,a.pos)}function l(a,b){a.style.webkitTransform="iOS"==mobile.platform?"translate3d("+b+"px,0px,0px)":"translate("+b+"px,0px)"}function m(){$(".date_list").hammer().on("tap",".date_item",function(){var a=$(this).attr("data-index");a=parseInt(a,10);var c=x.monthData[a];a<x.firstDay?h(-1,c.year,c.month,c.day):a>=x.firstDay+x.monthDays?h(1,c.year,c.month,c.day):(f(),b(c.year,c.month,c.day,a),e($(this)))}),$(".today").hammer().on("tap",function(){return h(1,v.getFullYear(),v.getMonth()+1,v.getDate()),!1}),$(".slide_wrap").hammer().on("swipeleft",function(a){return h(1),a.preventDefault(),a.gesture.preventDefault(),!1}),$(".slide_wrap").hammer().on("swiperight",function(a){return h(-1),a.preventDefault(),a.gesture.preventDefault(),!1})}function n(){z=$(document).width();var a=$(".date_list").eq(0),b=$(".date_list").eq(1);a.css("width",z),b.css({width:z,left:z}),"iOS"==mobile.platform&&(l(a[0],0),l(a[1],0))}function o(){n(),m(),b(),g()}var p="http://cdn.tuijs.com/js/",q=2008,r=2020,s=1891,t=2100,u=['<div class="date_item<%=itemCls%>" data-index="<%=index%>">','   <span class="date_icon<%=iconCls%>"><%=iconText%></span>','     <span class="date_day"><%=day%></span>','       <span class="date_lunar<%=fetvCls%>"><%=lunar%></span>',"</div>"],v=new Date,w=null,x=null,y=[0,1],z=0,A=-1,B=function(a,b){return a+=1,a=10>a?"0"+a:a,b=10>b?"0"+b:b,"d"+a+b};return{init:o}}();$(function(){Calendar.init()});
\ No newline at end of file
+window.HuangLi=window.HuangLi||{},function(){var a={platform:"",version:0,Android:function(){return"Android"===this.platform},iOS:function(){return"iOS"===this.platform},init:function(){var a=navigator.userAgent;a.match(/Android/i)?(this.platform="Android",this.version=parseFloat(a.slice(a.indexOf("Android")+8))):a.match(/iPhone|iPad|iPod/i)&&(this.platform="iOS",this.version=parseFloat(a.slice(a.indexOf("OS")+3)))}};a.init(),this.mobile=a}(),function(){var a=function(a,b){var c=document.getElementsByTagName("head")[0],d=document.createElement("script");d.setAttribute("type","text/javascript"),d.setAttribute("src",a),c.appendChild(d);var e=function(){"function"==typeof b&&b()};document.all?d.onreadystatechange=function(){("loaded"==d.readyState||"complete"==d.readyState)&&e()}:d.onload=function(){e()}};Zepto&&($.getScript=a)}(),function(){var a=function(){},b={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};a.compile=function(a,c){var d=c||b,e="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";return new Function("obj",e)},a.template=function(b,c){var d=a.compile(b);return d(c)},"undefined"!=typeof exports?exports.Footprint=a:window.Footprint=a,Zepto&&($.template=a.template)}();var Calendar=function(){function a(){if(!w)return"";var a=w.year,b=w.month,c=w.day;return b=10>b?"0"+b:b,c=10>c?"0"+c:c,a+"-"+b+"-"+c}function b(a,b,c,d){w={year:a||v.getFullYear(),month:b||v.getMonth()+1,day:c||v.getDate(),pos:d||0}}function c(){if(HuangLi["y"+w.year]){var a=HuangLi["y"+w.year][B(w.month,w.day)];d(a)}else w.year>=q&&w.year<=r&&$.getScript(p+"hl"+w.year+".min.js",function(){var a=HuangLi["y"+w.year][B(w.month,w.day)];d(a)})}function d(a){a?($(".hl_y_content").html(a.y),$(".hl_j_content").html(a.j),$(".date_hl").show()):$(".date_hl").hide()}function e(b){var d=LunarCalendar.solarToLunar(w.year,w.month,w.day),e=new Date(w.year,w.month-1,w.day).getDay(),f=["日","一","二","三","四","五","六"];$("#toolbar h1").html(a()),$(".date_lunar_info").html("农历"+d.lunarMonthName+d.lunarDayName+" 星期"+f[e]),$(".date_gan_zhi").html(d.GanZhiYear+"年["+d.zodiac+"年] "+d.GanZhiMonth+"月 "+d.GanZhiDay+"日");var g=[];d.term&&g.push(d.term),d.lunarFestival&&g.push(d.lunarFestival),d.solarFestival&&g.push(d.solarFestival.split(" ")),$(".date_fetv").html(g.length>0?"节假日纪念日:"+g.join(","):""),b&&b.attr("class","date_item date_current"),c()}function f(){var a=$("#date_list_"+y[0]).find(".date_item").eq(w.pos);v.getFullYear()==w.year&&v.getMonth()+1==w.month&&v.getDate()==w.day?a.attr("class","date_item date_today"):a.attr("class","date_item")}function g(){x=LunarCalendar.calendar(w.year,w.month,!0);for(var a="",b=u.join(""),c=0;c<x.monthData.length;c++){var d=x.monthData[c];c%7==0&&(a+='<div class="date_row">');var f={index:c,itemCls:"",iconCls:d.worktime?1==d.worktime?" worktime":" holiday":"",iconText:d.worktime?1==d.worktime?"班":"休":"",fetvCls:d.lunarFestival||d.term?" lunar_fetv":d.solarFestival?" solar_fetv":"",lunar:""},g="";v.getFullYear()==d.year&&v.getMonth()+1==d.month&&v.getDate()==d.day&&(g=" date_today"),w.year==d.year&&w.month==d.month&&w.day==d.day&&(g=" date_current",w.pos=c),(c<x.firstDay||c>=x.firstDay+x.monthDays)&&(g=" date_other"),f.itemCls=g;var h=d.lunarDayName;d.solarFestival&&(h=d.solarFestival),d.lunarFestival&&(h=d.lunarFestival),d.term&&(h=d.term),f.lunar=h,$.extend(d,f),a+=$.template(b,d),c%7==6&&(a+="</div>")}$("#date_list_"+y[0]).html(a),e()}function h(a,c,d,e){var f,h,k;c&&d?(f=c,h=d):w.month+a<1?(f=w.year-1,h=12):w.month+a>12?(f=w.year+1,h=1):(f=w.year,h=w.month+a),k=e?e:w.day>LunarCalendar.getSolarMonthDays[h-1]?LunarCalendar.getSolarMonthDays[h-1]:w.day,s>f||f>t||(b(f,h,k),i(),g(),j(a))}function i(){var a=y.shift();y.push(a)}function j(a){A&&clearTimeout(A),k({time:0,pos:0}),$("#date_list_"+y[0]).css({left:a*z}),$("#date_list_"+y[1]).css({left:0}),A=a>0?setTimeout(function(){k({time:300,pos:-1*z})},50):setTimeout(function(){k({time:300,pos:z})},50)}function k(a){var b=$(".date_slide")[0];b.style.webkitTransitionDuration=a.time+"ms",l(b,a.pos)}function l(a,b){a.style.webkitTransform="iOS"==mobile.platform?"translate3d("+b+"px,0px,0px)":"translate("+b+"px,0px)"}function m(){$(".date_list").hammer().on("tap",".date_item",function(){var a=$(this).attr("data-index");a=parseInt(a,10);var c=x.monthData[a];a<x.firstDay?h(-1,c.year,c.month,c.day):a>=x.firstDay+x.monthDays?h(1,c.year,c.month,c.day):(f(),b(c.year,c.month,c.day,a),e($(this)))}),$(".today").hammer().on("tap",function(){return h(1,v.getFullYear(),v.getMonth()+1,v.getDate()),!1}),$(".slide_wrap").hammer().on("swipeleft",function(a){return h(1),a.preventDefault(),a.gesture.preventDefault(),!1}),$(".slide_wrap").hammer().on("swiperight",function(a){return h(-1),a.preventDefault(),a.gesture.preventDefault(),!1})}function n(){z=$(document).width(),$(".date_list").eq(0).css("width",z),$(".date_list").eq(1).css({width:z,left:z}),"iOS"==mobile.platform&&(l(document.getElementById("date_list_0"),0),l(document.getElementById("date_list_1"),0))}function o(){n(),m(),b(),g()}var p="http://cdn.tuijs.com/js/",q=2008,r=2020,s=1891,t=2100,u=['<div class="date_item<%=itemCls%>" data-index="<%=index%>">','   <span class="date_icon<%=iconCls%>"><%=iconText%></span>','     <span class="date_day"><%=day%></span>','       <span class="date_lunar<%=fetvCls%>"><%=lunar%></span>',"</div>"],v=new Date,w=null,x=null,y=[0,1],z=0,A=-1,B=function(a,b){return a+=1,a=10>a?"0"+a:a,b=10>b?"0"+b:b,"d"+a+b};return{init:o}}();$(function(){Calendar.init()});
\ No newline at end of file