From: Jason Zhou <zzyss86@qq.com>
Date: Sun, 16 Feb 2014 11:11:39 +0000 (+0800)
Subject: add demo
X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=966225a44fde0acc19336e17fe70710cc27b79cd;p=LunarCalendar.git

add demo
---

diff --git a/Gruntfile.js b/Gruntfile.js
index 29d64a2..b338b90 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -16,14 +16,30 @@ module.exports = function(grunt) {
                  src: '**/*.js',
                  dest: 'hl_build/',
                  ext: '.min.js'
+			},
+			buildDemo: {
+				src: 'demo/calendar/js/calendar.js',
+				dest: 'demo/calendar/js/calendar.min.js'
+			}
+		},
+		cssmin: {
+			options: {
+				keepSpecialComments: 0
+			},
+			compress: {
+				files:{
+					'demo/calendar/style.min.css' : ['demo/calendar/style.css']
+				}
 			}
 		}
 	});
 
 	// 加载包含 "uglify" 任务的插件。
 	grunt.loadNpmTasks('grunt-contrib-uglify');
+	grunt.loadNpmTasks('grunt-contrib-cssmin');
 
 	// 默认被执行的任务列表。
 	grunt.registerTask('default', ['uglify']);
 	grunt.registerTask('hl', ['uglify:buildhl']);
+	grunt.registerTask('demo', ['cssmin']);
 };
\ No newline at end of file
diff --git a/demo/calendar/images/icon.png b/demo/calendar/images/icon.png
new file mode 100644
index 0000000..bf64c02
Binary files /dev/null and b/demo/calendar/images/icon.png differ
diff --git a/demo/calendar/images/weixin_icon.png b/demo/calendar/images/weixin_icon.png
new file mode 100644
index 0000000..2767db1
Binary files /dev/null and b/demo/calendar/images/weixin_icon.png differ
diff --git a/demo/calendar/index.html b/demo/calendar/index.html
new file mode 100644
index 0000000..450ae3d
--- /dev/null
+++ b/demo/calendar/index.html
@@ -0,0 +1,69 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>小推万年历,简洁美观的手机日历(HTML5版)</title>
+<meta name="description" content="小推万年历,简洁美观的手机日历">
+<meta name="Keywords" content="万年历,万年历查询,黄历,黄历查询,日历,阳历,阴历,公历,老皇历,黄道吉日,手机日历" />
+<meta name="format-detection" content="telephone=no" />
+<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no" />
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="apple-mobile-web-app-capable" content="yes">
+<meta name="apple-mobile-web-app-status-bar-style" content="black">
+<link href="http://cdn.tuijs.com/css/style.min.css?v=20140216" rel="stylesheet" type="text/css">
+</head>
+
+<body>
+<header class="toolbar" id="toolbar">
+	<span class="icon icon_calendar"></span>
+	<h1></h1>
+    <div class="action"><a href="#" class="today">回今天</a></div>
+</header>
+
+<div class="wrapper" id="wrapper">
+	<div class="date_row date_week">
+        <div class="date_item">周日</div>
+        <div class="date_item">周一</div>
+        <div class="date_item">周二</div>
+        <div class="date_item">周三</div>
+        <div class="date_item">周四</div>
+        <div class="date_item">周五</div>
+        <div class="date_item">周六</div>
+    </div>
+    
+    <div class="slide_wrap">
+    	<div class="date_slide"> 
+            <div class="date_list" id="date_list_0">
+            </div><!--date_list-->
+            
+            <div class="date_list" id="date_list_1">
+            </div><!--date_list-->
+        </div>
+    </div>
+    
+    <div class="date_info">
+        <div class="date_lunar_info"></div>
+        <div class="date_fetv"></div>
+        <div class="date_gan_zhi"></div>
+        
+        <div class="date_hl">
+            <div class="date_hl_item">
+                <div class="hl_y circle">宜</div>
+                <span class="hl_y_content"></span>
+            </div>
+            
+            <div class="date_hl_item">
+                <div class="hl_j circle">忌</div>
+                <span class="hl_j_content"></span>
+            </div>
+        </div>
+    </div><!--date_info-->
+</div>
+<div style="overflow:hidden; width:0px; height:0px;"><img src="http://cdn.tuijs.com/upload/weixin_icon.png" /></div>
+<script type="text/javascript" src="http://cdn.tuijs.com/js/zepto.min.js"></script>
+<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>
+</body>
+</html>
diff --git a/demo/calendar/js/calendar.js b/demo/calendar/js/calendar.js
new file mode 100644
index 0000000..a9a4732
--- /dev/null
+++ b/demo/calendar/js/calendar.js
@@ -0,0 +1,405 @@
+window.HuangLi = window.HuangLi || {};
+
+(function () {
+    var mobile = {
+        platform: '',
+        version: 0,
+        Android: function () {
+            return this.platform === 'Android';
+        },
+        iOS: function () {
+            return this.platform === 'iOS';
+        },
+        init: function () {
+            var ua = navigator.userAgent;
+            if (ua.match(/Android/i)) {
+                this.platform = 'Android';
+                this.version = parseFloat(ua.slice(ua.indexOf("Android") + 8));
+            }
+            else if (ua.match(/iPhone|iPad|iPod/i)) {
+                this.platform = 'iOS';
+                this.version = parseFloat(ua.slice(ua.indexOf("OS") + 3));
+            }
+        }
+    };
+    mobile.init();
+    this.mobile = mobile;
+} ());
+
+(function() {
+    /**
+     * 动态加载js文件
+     * @param  {string}   url      js文件的url地址
+     * @param  {Function} callback 加载完成后的回调函数
+     */
+    var _getScript = function(url, callback) {
+        var head = document.getElementsByTagName('head')[0],
+            js = document.createElement('script');
+
+        js.setAttribute('type', 'text/javascript'); 
+        js.setAttribute('src', url); 
+
+        head.appendChild(js);
+
+        //执行回调
+        var callbackFn = function(){
+			if(typeof callback === 'function'){
+				callback();
+			}
+        };
+
+        if (document.all) { //IE
+            js.onreadystatechange = function() {
+                if (js.readyState == 'loaded' || js.readyState == 'complete') {
+                    callbackFn();
+                }
+            }
+        } else {
+            js.onload = function() {
+                callbackFn();
+            }
+        }
+    }
+
+    //如果使用的是zepto,就添加扩展函数
+    if(Zepto){
+        $.getScript = _getScript;
+    }
+})();
+
+
+(function () {
+    var Footprint = function () {};
+      // Default template settings, uses ASP/PHP/JSP delimiters, change the
+      // following template settings to use alternative delimiters.
+    var templateSettings = {
+        evaluate : /<%([\s\S]+?)%>/g,
+        interpolate : /<%=([\s\S]+?)%>/g
+    };
+
+      // JavaScript micro-templating, similar to John Resig's implementation.
+      // Underscore templating handles arbitrary delimiters, preserves whitespace,
+      // and correctly escapes quotes within interpolated code.
+    Footprint.compile = function(str, settings) {
+        var c = settings || templateSettings;
+        var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
+          'with(obj||{}){__p.push(\'' +
+          str.replace(/\\/g, '\\\\')
+             .replace(/'/g, "\\'")
+             .replace(c.interpolate, function(match, code) {
+               return "'," + code.replace(/\\'/g, "'") + ",'";
+             })
+             .replace(c.evaluate || null, function(match, code) {
+               return "');" + code.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', tmpl);
+    };
+
+    // Preserves template method for compatible with legacy call.
+    Footprint.template = function (str, data) {
+        var compilied = Footprint.compile(str);
+        return compilied(data);
+    };
+  
+    if (typeof exports !== "undefined") {
+        exports.Footprint = Footprint;
+    } else {
+        window.Footprint = Footprint;
+    }
+	
+	//如果使用的是zepto,就添加扩展函数
+    if(Zepto){
+        $.template = Footprint.template;
+    }
+}());
+
+var Calendar = (function(){
+	var hlurl = 'http://cdn.tuijs.com/js/';
+	var hlMinYear = 2008;
+	var hlMaxYear = 2020;
+	var minYear = 1891;//最小年限
+	var maxYear = 2100;//最大年限
+	var itemTemp = [
+		'<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>'
+	];
+	
+	var now = new Date();
+	var current = null;
+	var DATA = null;
+	var panel = [0,1]; //当前显示面板panel[0]
+	var pageWidth = 0; //设备宽度
+	var slideIng = false; //是否滑动中
+	var timer = -1;
+	
+	var formateDayD4 = function(month,day){
+		month = month+1;
+		month = month<10 ? '0'+month : month;
+		day = day<10 ? '0'+day : day;
+		return 'd'+month+day;
+	};
+	
+	function formatDate(){
+		if(!current)return '';
+		var year = current.year;
+		var month = current.month;
+		var day = current.day;
+		month = month<10 ? '0'+month : month;
+		day = day<10 ? '0'+day : day;
+		return year+'-'+month+'-'+day;
+	};
+	
+	function setCurrentByNow(year,month,day,pos){
+		current = {
+			year : year || now.getFullYear(),
+			month : month || now.getMonth()+1,
+			day : day || now.getDate(),
+			pos : pos || 0
+		};
+	};
+	
+	//黄历
+	function getHL(){
+		if(HuangLi['y'+current.year]){ //该年已有黄历数据
+			var hl = HuangLi['y'+current.year][formateDayD4(current.month,current.day)];
+			showHL(hl);
+		}else if(current.year>=hlMinYear && current.year<=hlMaxYear){
+			$.getScript(hlurl+'hl'+current.year+'.min.js',function(){
+				var hl = HuangLi['y'+current.year][formateDayD4(current.month,current.day)];
+				showHL(hl);
+			});
+		}
+	}
+	function showHL(hl){
+		if(hl){
+			$('.hl_y_content').html(hl.y);
+			$('.hl_j_content').html(hl.j);
+			$('.date_hl').show();
+		}else{
+			$('.date_hl').hide();
+		}
+	};
+	
+	function showInfo(_this){
+		var currentLunar = LunarCalendar.solarToLunar(current.year,current.month,current.day);
+		var weekday = new Date(current.year,current.month-1,current.day).getDay();
+		var weekList = ['日','一','二','三','四','五','六'];
+		$('#toolbar h1').html(formatDate());
+		$('.date_lunar_info').html('农历'+currentLunar.lunarMonthName+currentLunar.lunarDayName+' 星期'+weekList[weekday]);
+		$('.date_gan_zhi').html(currentLunar.GanZhiYear+'年['+currentLunar.zodiac+'年] '+currentLunar.GanZhiMonth+'月 '+currentLunar.GanZhiDay+'日');
+		
+		var fetv = [];
+		if(currentLunar.term) fetv.push(currentLunar.term);
+		if(currentLunar.lunarFestival) fetv.push(currentLunar.lunarFestival);
+		if(currentLunar.solarFestival) fetv.push(currentLunar.solarFestival.split(' '));
+		$('.date_fetv').html(fetv.length>0 ? '节假日纪念日:'+fetv.join(',') : '');
+		
+		//当前日期
+		if(_this){
+			_this.attr('class','date_item date_current');
+		}
+		
+		//拉取黄历
+		getHL();
+	};
+	
+	//恢复指定日期的状态信息
+	function resetInfo(){
+		//今天
+		var oldObj = $('#date_list_'+panel[0]).find('.date_item').eq(current.pos);
+		if(now.getFullYear()==current.year && now.getMonth()+1==current.month && now.getDate()==current.day){
+			oldObj.attr('class','date_item date_today');
+		}else{
+			oldObj.attr('class','date_item');
+		}
+	};
+	
+	function showDate(){
+		DATA = LunarCalendar.calendar(current.year,current.month,true);
+		
+		var dateHtml = '';
+		var temp = itemTemp.join('');
+		
+		for(var i=0;i<DATA.monthData.length;i++){
+			var itemData = DATA.monthData[i];
+			
+			if(i%7==0){ //某行第一列
+				dateHtml+='<div class="date_row">'
+			};
+			
+			var extendObj = {
+				index : i,
+				itemCls: '',
+				iconCls: itemData.worktime ? (itemData.worktime==1 ? ' worktime' : ' holiday') : '',
+				iconText: itemData.worktime ? (itemData.worktime==1 ? '班' : '休') : '',
+				fetvCls: (itemData.lunarFestival || itemData.term) ? ' lunar_fetv' : (itemData.solarFestival ? ' solar_fetv' : ''),
+				lunar: ''
+			};
+			
+			var itemCls = '';
+			if(now.getFullYear()==itemData.year && now.getMonth()+1==itemData.month && now.getDate()==itemData.day){
+				itemCls = ' date_today';
+			}
+			if(current.year==itemData.year && current.month==itemData.month && current.day==itemData.day){ //当前选中
+				itemCls = ' date_current';
+				current.pos = i;
+			}
+			if(i<DATA.firstDay || i>=DATA.firstDay+DATA.monthDays){ //非本月日期
+				itemCls = ' date_other';
+			}
+			extendObj.itemCls = itemCls;
+			
+			var lunar = itemData.lunarDayName;
+			//以下判断根据优先级
+			if(itemData.solarFestival) lunar = itemData.solarFestival;
+			if(itemData.lunarFestival) lunar = itemData.lunarFestival;
+			if(itemData.term) lunar = itemData.term;
+			extendObj.lunar = lunar;
+			
+			$.extend(itemData,extendObj);
+			
+			dateHtml += $.template(temp,itemData);
+			
+			if(i%7==6){//某行尾列
+				dateHtml+='</div>';
+			};
+		};
+		
+		$('#date_list_'+panel[0]).html(dateHtml);
+		
+		showInfo();
+	};
+	
+	//切换月份,可指定
+	function pageDate(offset,_year,_month,_day){
+		var year,month,day;
+		if(_year && _month){ //直接指定
+			year = _year;
+			month = _month;
+		}else{
+			if(current.month+offset<1){ //上一年
+				year = current.year-1;
+				month = 12;
+			}else if(current.month+offset>12){ //下一年
+				year = current.year+1;
+				month = 1;
+			}else{
+				year = current.year;
+				month = current.month+offset;
+			}
+		}
+		day = _day ? _day : (current.day > LunarCalendar.getSolarMonthDays[month-1] ? LunarCalendar.getSolarMonthDays[month-1] : current.day);
+		if(year<minYear || year>maxYear)return; //超过范围
+		
+		setCurrentByNow(year,month,day);
+		changePanel();
+		showDate();
+		
+		slide(offset);
+	};
+	function changePanel(){
+		var first = panel.shift();
+		panel.push(first);
+	};
+	//滑动
+	function slide(offset){
+		timer && clearTimeout(timer);
+		setSlidePos({time:0,pos:0});
+		$('#date_list_'+panel[0]).css({left:offset * pageWidth}); //将要显示
+		$('#date_list_'+panel[1]).css({left:0}); //当前显示
+		
+		if(offset>0){//左滑
+			timer = setTimeout(function(){
+				setSlidePos({time:300,pos:pageWidth * -1});
+			},50);
+		}else{ //右滑
+			timer = setTimeout(function(){
+				setSlidePos({time:300,pos:pageWidth});
+			},50);
+		}
+	};
+	function setSlidePos(opt){
+		var slide = $('.date_slide')[0];
+		slide.style.webkitTransitionDuration = opt.time+'ms';
+		setTranslate(slide,opt.pos);
+	};
+	function setTranslate(obj,pos){
+		if(mobile.platform=='iOS'){//iOS下启用3d加速,安卓下有BUG,使用2d
+			obj.style.webkitTransform = 'translate3d('+pos+'px,0px,0px)';
+		}else{
+			obj.style.webkitTransform = 'translate('+pos+'px,0px)';
+		}
+	};
+	
+	function addEvent(){ //base hammer.js
+		$('.date_list').hammer().on('tap','.date_item',function(){
+			var index = $(this).attr('data-index');
+			index = parseInt(index,10);
+			var itemData = DATA.monthData[index];
+			
+			if(index<DATA.firstDay){ //上一个月
+				pageDate(-1,itemData.year,itemData.month,itemData.day);
+			}else if(index>=DATA.firstDay+DATA.monthDays){//下一个月
+				pageDate(1,itemData.year,itemData.month,itemData.day);
+			}else{
+				resetInfo();
+				setCurrentByNow(itemData.year,itemData.month,itemData.day,index);
+				showInfo($(this));
+			}
+		});
+		
+		$('.today').hammer().on('tap',function(event){
+			pageDate(1,now.getFullYear(),now.getMonth()+1,now.getDate());
+			return false;
+		});
+		
+		$('.slide_wrap').hammer().on('swipeleft',function(event){
+			pageDate(1);
+			event.preventDefault();
+			event.gesture.preventDefault();
+			return false;
+		});
+		
+		$('.slide_wrap').hammer().on('swiperight',function(event){
+			pageDate(-1);
+			event.preventDefault();
+			event.gesture.preventDefault();
+			return false;
+		});
+	};
+	
+	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});
+		if(mobile.platform=='iOS'){//iOS启用3d,同时将子元素也设置一下,防止BUG
+			setTranslate(panelElm0[0],0);
+			setTranslate(panelElm0[1],0);
+		}
+	};
+	
+	function init(){
+		initPageElm();
+		addEvent();
+		setCurrentByNow();
+		showDate();
+	};
+	
+	return {
+		init : init
+	};
+})();
+
+$(function(){
+	Calendar.init();
+});
\ No newline at end of file
diff --git a/demo/calendar/js/calendar.min.js b/demo/calendar/js/calendar.min.js
new file mode 100644
index 0000000..2ef1e44
--- /dev/null
+++ b/demo/calendar/js/calendar.min.js
@@ -0,0 +1,10 @@
+/**
+ * 农历(阴历)万年历
+ * LunarCalendar;NPM NAME:lunar-calendar
+ * vervison : v0.1.4
+ * Github : https://github.com/zzyss86/LunarCalendar
+ * HomePage : http://www.tuijs.com/
+ * 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
diff --git a/demo/calendar/style.css b/demo/calendar/style.css
new file mode 100644
index 0000000..f133ba1
--- /dev/null
+++ b/demo/calendar/style.css
@@ -0,0 +1,290 @@
+@charset "utf-8";
+/* CSS Document */
+body {
+	font-family: "Helvetica Neue", Helvetica, STHeiTi, sans-serif;
+	word-wrap:break-word;
+}
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td,figure,time {
+	margin:0;
+	padding:0;
+	-webkit-text-size-adjust:none
+}
+table {
+	border-collapse:collapse;
+	border-spacing:0
+}
+fieldset,img {
+	border:0
+}
+address,caption,cite,code,dfn,em,strong,th,var {
+	font-style:normal;
+	font-weight:normal
+}
+ol,ul,li {
+	list-style:none
+}
+caption,th {
+	text-align:left
+}
+h1,h2,h3,h4,h5,h6 {
+	font-size:100%;
+	font-weight:normal
+}
+q:before,q:after {
+	content:''
+}
+abbr,acronym {
+	border:0
+}
+section,aside,article,nav {
+	display:block
+}
+a{
+	color:#246183;
+	text-decoration:none
+}
+html {
+	font-size:100%;
+	-webkit-text-size-adjust:100%;
+	-ms-text-size-adjust:100%
+}
+body {
+	margin:0;
+	font-size:14px;
+	line-height:1.231;
+	height:100%;
+	width:100%;
+	background:#e8e8e8;
+	padding-bottom:30px;
+}
+input,button {
+	-webkit-tap-highlight-color:rgba(0,0,0,0)
+}
+input,input:focus,select:focus {
+	border:none;
+	outline:none;
+	background-color:#fff
+}
+.org{ color: #ee4e00;}
+.blue{ color: #1a3181;}
+.red{ color:#F00;}
+.rred{ color:#aa0112;}
+.green{ color:#090;}
+.hide{ display:none;}
+.show{ display:block;}
+
+.icon{ background:url(http://cdn.tuijs.com/upload/icon.png) no-repeat; width:36px; height:36px; display:block;}
+.icon_set{ background-position:0 -64px;}
+
+.toolbar{
+	overflow:hidden;
+	width:100%;
+	position:relative;
+	left:0px;
+	top:0px;
+	z-index:999;
+	height: 46px;
+	background-image: -webkit-gradient(linear,center top,center bottom,from(#df481a), to(#c82713));
+	background-color:#d33716;
+	border-bottom:1px solid #ec6624;
+	display: -webkit-box; 
+    display: box;
+}
+.toolbar h1{
+	margin:5px 0 0 10px;
+	height:36px;
+	line-height:36px;
+	font-size:22px;
+	color:#FFF;
+	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
+	font-weight:bold;
+	-webkit-box-flex: 2; 
+    box-flex: 2;
+}
+.toolbar .icon_calendar{
+	margin:5px 0 0 10px;
+}
+.toolbar .action{
+	margin:5px 10px;
+	display:block;
+	height:36px;
+	line-height:36px;
+	font-size:20px;
+	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
+	font-weight:bold;
+	color:#FFF;
+	text-align:right;
+	-webkit-box-flex: 1; 
+    box-flex: 1;
+}
+.toolbar .action .today{
+	color:#FFF;
+}
+
+.wrapper{
+	width:100%;
+}
+.slide_wrap{
+	width:100%;
+	height:320px;
+	overflow:hidden;
+}
+.date_slide{
+	position:relative;
+	left:0px;
+	top:0px;
+	transform-origin:0 0;
+	-webkit-transform-origin:0 0;
+	/*-webkit-animation-timing-function: ease-in-out;
+	-webkit-transition-duration: 300ms;*/
+}
+.date_list{
+	font-family: "Courier New", "Helvetica Neue", Helvetica, STHeiTi, sans-serif;
+	position:absolute;
+	top:0px;
+	left:0px;
+	-webkit-transform-origin:0 0;
+}
+.date_row{
+	display: -webkit-box; 
+    display: box;
+	width:100%;
+}
+.date_row .date_item{
+	-webkit-box-flex: 1; 
+    box-flex: 1;
+	border-color:#cecece;
+	border-style:solid;
+	border-width:0 1px 1px 0;
+	color:#5b5b5b;
+	position:relative;
+	text-align:right;
+	overflow:hidden;
+	width: 0%;
+	padding:6px 5px;
+	height:40px;
+}
+.date_item:last-child{
+	border-right:none;
+}
+.date_item .date_day{
+	font-size:20px;
+	display:block;
+}
+.date_item .date_lunar{
+	height:16px;
+	line-height:16px;
+	font-size:12px;
+	color:#8a8a8a;
+	display:block;
+	overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    word-wrap: normal;
+}
+.date_item .lunar_fetv{
+	color:#14a700;
+}
+.date_item .solar_fetv{
+	color:#d43111;
+}
+.date_item .date_icon{
+	position:absolute;
+	left:0px;
+	top:0px;
+	padding:2px 3px;
+	color:#FFF;
+	font-size:12px;
+	display:none;
+}
+.date_item .holiday{
+	background-color:#cd3a37;
+	border:1px solid #a82220;
+	display:block;
+}
+.date_item .worktime{
+	background-color:#289ac9;
+	border:1px solid #87c7e2;
+	display:block;
+}
+.date_row .date_today{
+	background-color:#b8bdbf;
+	color:#FFF;
+}
+.date_row .date_today .date_lunar{
+	color:#FFF;
+}
+.date_row .date_current{
+	background-color:#c82713;
+	color:#FFF;
+}
+.date_row .date_current .date_lunar{
+	color:#FFF;
+}
+.date_row .date_other{
+	opacity:0.4;
+}
+.date_week .date_item{
+	line-height:30px;
+	height:30px;
+	border-right:none;
+	text-align:center;
+	font-size:16px;
+	padding:0px;
+}
+
+/*指定日期详情*/
+.date_info{
+	padding:10px;
+}
+.date_lunar_info{
+	color:#d96b6b;
+	font-size:24px;
+	line-height:38px;
+	text-align:center;
+}
+.date_fetv{
+	color:#666666;
+	line-height:22px;
+	font-size:16px;
+	margin-bottom:5px;
+}
+.date_gan_zhi{
+	line-height:30px;
+	background-color:#e68383;
+	text-align:center;
+	color:#FFF;
+	font-size:16px;
+}
+.date_hl{
+	display:none;
+}
+.date_hl_item{
+	margin-top:5px;
+	line-height:24px;
+}
+.circle {
+	width: 24px;
+	height: 24px;
+	background-color: transparent;
+	border: 1px #14a700 solid;
+	-webkit-border-radius: 13px;
+	text-align:center;
+	line-height:26px;
+	font-size:16px;
+	display:inline-block;
+	margin-right:5px;
+}
+.hl_y{
+	color:#14a700;
+}
+.hl_j{
+	color:#d43111;
+	border: 1px #d43111 solid;
+}
+.hl_y_content{
+	color:#14a700;
+}
+.hl_j_content{
+	color:#d43111;
+}
\ No newline at end of file
diff --git a/demo/calendar/style.min.css b/demo/calendar/style.min.css
new file mode 100644
index 0000000..ced7014
--- /dev/null
+++ b/demo/calendar/style.min.css
@@ -0,0 +1 @@
+@charset "utf-8";body{font-family:"Helvetica Neue",Helvetica,STHeiTi,sans-serif;word-wrap:break-word}blockquote,body,dd,div,dl,dt,fieldset,figure,form,h1,h2,h3,h4,h5,h6,input,li,ol,p,pre,td,textarea,th,time,ul{margin:0;padding:0;-webkit-text-size-adjust:none}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:400}li,ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:400}q:after,q:before{content:''}abbr,acronym{border:0}article,aside,nav,section{display:block}a{color:#246183;text-decoration:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0;font-size:14px;line-height:1.231;height:100%;width:100%;background:#e8e8e8;padding-bottom:30px}button,input{-webkit-tap-highlight-color:rgba(0,0,0,0)}input,input:focus,select:focus{border:0;outline:0;background-color:#fff}.org{color:#ee4e00}.blue{color:#1a3181}.red{color:red}.rred{color:#aa0112}.green{color:#090}.hide{display:none}.show{display:block}.icon{background:url(http://cdn.tuijs.com/upload/icon.png) no-repeat;width:36px;height:36px;display:block}.icon_set{background-position:0 -64px}.toolbar{overflow:hidden;width:100%;position:relative;left:0;top:0;z-index:999;height:46px;background-image:-webkit-gradient(linear,center top,center bottom,from(#df481a),to(#c82713));background-color:#d33716;border-bottom:1px solid #ec6624;display:-webkit-box;display:box}.toolbar h1{margin:5px 0 0 10px;height:36px;line-height:36px;font-size:22px;color:#FFF;text-shadow:0 1px 0 rgba(0,0,0,.3);font-weight:700;-webkit-box-flex:2;box-flex:2}.toolbar .icon_calendar{margin:5px 0 0 10px}.toolbar .action{margin:5px 10px;display:block;height:36px;line-height:36px;font-size:20px;text-shadow:0 1px 0 rgba(0,0,0,.3);font-weight:700;color:#FFF;text-align:right;-webkit-box-flex:1;box-flex:1}.toolbar .action .today{color:#FFF}.wrapper{width:100%}.slide_wrap{width:100%;height:320px;overflow:hidden}.date_slide{position:relative;left:0;top:0;transform-origin:0 0;-webkit-transform-origin:0 0}.date_list{font-family:"Courier New","Helvetica Neue",Helvetica,STHeiTi,sans-serif;position:absolute;top:0;left:0;-webkit-transform-origin:0 0}.date_row{display:-webkit-box;display:box;width:100%}.date_row .date_item{-webkit-box-flex:1;box-flex:1;border-color:#cecece;border-style:solid;border-width:0 1px 1px 0;color:#5b5b5b;position:relative;text-align:right;overflow:hidden;width:0;padding:6px 5px;height:40px}.date_item:last-child{border-right:0}.date_item .date_day{font-size:20px;display:block}.date_item .date_lunar{height:16px;line-height:16px;font-size:12px;color:#8a8a8a;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-wrap:normal}.date_item .lunar_fetv{color:#14a700}.date_item .solar_fetv{color:#d43111}.date_item .date_icon{position:absolute;left:0;top:0;padding:2px 3px;color:#FFF;font-size:12px;display:none}.date_item .holiday{background-color:#cd3a37;border:1px solid #a82220;display:block}.date_item .worktime{background-color:#289ac9;border:1px solid #87c7e2;display:block}.date_row .date_today{background-color:#b8bdbf;color:#FFF}.date_row .date_today .date_lunar{color:#FFF}.date_row .date_current{background-color:#c82713;color:#FFF}.date_row .date_current .date_lunar{color:#FFF}.date_row .date_other{opacity:.4}.date_week .date_item{line-height:30px;height:30px;border-right:0;text-align:center;font-size:16px;padding:0}.date_info{padding:10px}.date_lunar_info{color:#d96b6b;font-size:24px;line-height:38px;text-align:center}.date_fetv{color:#666;line-height:22px;font-size:16px;margin-bottom:5px}.date_gan_zhi{line-height:30px;background-color:#e68383;text-align:center;color:#FFF;font-size:16px}.date_hl{display:none}.date_hl_item{margin-top:5px;line-height:24px}.circle{width:24px;height:24px;background-color:transparent;border:1px #14a700 solid;-webkit-border-radius:13px;text-align:center;line-height:26px;font-size:16px;display:inline-block;margin-right:5px}.hl_y{color:#14a700}.hl_j{color:#d43111;border:1px #d43111 solid}.hl_y_content{color:#14a700}.hl_j_content{color:#d43111}
\ No newline at end of file
diff --git a/package.json b/package.json
index c00004b..65cf452 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
 	"devDependencies": {
 		"grunt": "0.4.2",
 		"grunt-contrib-uglify" : "0.3.2",
+		"grunt-contrib-cssmin": "0.7.0",
 		"mocha": "*",
 		"expect.js": "*"
 	},