Merge pull request #7 from xuexb/master

添加demo页面
pull/13/head
贤心 2014-11-01 19:28:34 +08:00
commit 0dfe347add
4 changed files with 90 additions and 1 deletions

View File

@ -115,6 +115,13 @@ Dates.shde = function(elem, type){
//简易选择器
Dates.query = function(node){
if(node && node.nodeType === 1){
if(node.tagName.toLowerCase() !== 'input'){
throw new Error('选择器elem错误');
}
return node;
}
var node = (Dates.trim(node)).split(' '), elemId = doc[byid](node[0].substr(1)), arr;
if(!elemId){
return;
@ -825,7 +832,9 @@ Dates.events = function(){
}).on(doc, 'keydown', function(event){
event = event || win.event;
var codes = event.keyCode;
if(codes === 13){
//如果在日期显示的时候按回车
if(codes === 13 && Dates.elem){
Dates.creation([Dates.ymd[0], Dates.ymd[1]+1, Dates.ymd[2]]);
}
});

54
test/demo1.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Demo1</title>
<style type="text/css">
.demo1{
height:300px;
}
</style>
</head>
<body>
<div style="height:500px;"></div>
<div class="demo1">
方本框:<input type="text" id="J-xl">
</div>
<div class="demo1">
按钮触发:<input type="text" id="J-xl-2"><input type="button" id="J-xl-2-btn" value="打开">
</div>
<div class="demo1">
<label for="J-xl-3">Label触发</label><input type="text" id="J-xl-3" >
</div>
<div class="demo1">
直接传dom<input type="text" id="J-xl-4" >
</div>
<script type="text/javascript" src="../laydate.dev.js"></script>
<script type="text/javascript">
laydate({
elem: '#J-xl'
});
document.getElementById('J-xl-2-btn').onclick = function(){
laydate({
elem: '#J-xl-2'
});
}
laydate({
elem: '#J-xl-3'
});
laydate({
elem: document.getElementById('J-xl-4')
});
</script>
</body>
</html>

19
test/demo2.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Demo2 for Seajs</title>
</head>
<body>
<div style="height:300px;"></div>
<input type="text" id="J-xl">
<script type="text/javascript" src="//libs.useso.com/js/seajs/2.2.1/sea.js"></script>
<script type="text/javascript" src="../laydate.dev.js"></script>
<script type="text/javascript">
seajs.use('./demo2');
</script>
</body>
</html>

7
test/demo2.js Normal file
View File

@ -0,0 +1,7 @@
define(function(){
'use strict';
laydate({
elem: '#J-xl'
});
});