|
|
<!DOCTYPE html>
|
|
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
|
|
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
|
|
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
|
|
<!--[if gt IE 8]><!-->
|
|
|
<html class="no-js">
|
|
|
<!--<![endif]-->
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
|
<title>多功能jQuery日期控件asDatepicker - 素材家园(www.sucaijiayuan.com)</title>
|
|
|
<meta name="description" content="">
|
|
|
<meta name="viewport" content="width=device-width">
|
|
|
<link rel="stylesheet" href="css/normalize.css">
|
|
|
<link rel="stylesheet" href="css/main.css">
|
|
|
<link rel="stylesheet" href="css/prism.css">
|
|
|
<link rel="stylesheet" href="../css/asDatepicker.css">
|
|
|
</head>
|
|
|
<body>
|
|
|
<div id="toc"></div>
|
|
|
<div class="container">
|
|
|
<h1>jQuery.asDatepicker</h1>
|
|
|
<section>
|
|
|
<h2>Examples</h2>
|
|
|
<p>You can pass these options as key/value object to $.asDatepicker() method. </p>
|
|
|
<section>
|
|
|
<h3>default single</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$("#calendar").asDatepicker();
|
|
|
});
|
|
|
<script></code></pre>
|
|
|
<div class="example">
|
|
|
<!-- <input type="text" id="calendar" data-range-mode="section" data-selectable-year="2001>2010,2013,2015>2018"> -->
|
|
|
<input type="text" id="calendar">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>range</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar2">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$("#calendar2").asDatepicker({mode: 'range'});
|
|
|
});
|
|
|
<script></code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar2" style="width:170px;">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>multiple</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar3">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$("#calendar3").asDatepicker({mode: 'multiple', calendars: '4'});
|
|
|
});
|
|
|
<script></code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar3">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>Data attributes</h3>
|
|
|
<p>Any option of the asDatepicker can also be set via data-attributes.</p>
|
|
|
<p>Such as:</p>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar4" data-mode="range" data-range-mode="section" data-selectable-year="2001>2010,2012,2014>2016">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$("#calendar4").asDatepicker();
|
|
|
});
|
|
|
<script></code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar4" data-mode="range" data-range-mode="section" data-selectable-year="2001>2010,2012,2014>2016">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>Mobile Single</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar-mobile-single">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$('#calendar-mobile-single').asDatepicker({
|
|
|
mobileMode: true
|
|
|
});
|
|
|
});
|
|
|
<script>
|
|
|
</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar-mobile-single">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>Mobile Range</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar-mobile-range">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$('#calendar-mobile-range').asDatepicker({
|
|
|
mode: 'range',
|
|
|
mobileMode: true
|
|
|
});
|
|
|
});
|
|
|
<script>
|
|
|
</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar-mobile-range">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>Mobile Multiple</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
<input type="text" id="calendar-mobile-multiple">
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
$('#calendar-mobile-multiple').asDatepicker({
|
|
|
mode: 'multiple',
|
|
|
mobileMode: true
|
|
|
});
|
|
|
});
|
|
|
<script>
|
|
|
</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar-mobile-multiple">
|
|
|
</div>
|
|
|
</section>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h2>Keyboard navigation</h2>
|
|
|
<p> <span>left arrow ----- </span> highlights previous day </p>
|
|
|
<p> <span>right arrow ----- </span> highlights next day </p>
|
|
|
<p> <span>up arrow ----- </span> highlights same day from the previous week </p>
|
|
|
<p> <span>down arrow ----- </span> highlights same day from the next week </p>
|
|
|
<p> <span>ctrl + left arrow ----- </span> navigates to previous month </p>
|
|
|
<p> <span>ctrl + right arrow ----- </span> navigates to next month </p>
|
|
|
<p> <span>ctrl + up arrow ----- </span> navigates to higher view </p>
|
|
|
<p> <span>ctrl + down arrow ----- </span> navigates to lower view </p>
|
|
|
<p> <span>alt + left arrow ----- </span> focus in previous calendar </p>
|
|
|
<p> <span>alt + right arrow ----- </span> focus in next calendar </p>
|
|
|
<p> <span>enter ----- </span> if in "days" view selects the highlighted day. In other views navigates to a lower view </p>
|
|
|
<p> <span>esc ----- </span> closes the popup </p>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h2>Available options</h2>
|
|
|
<p>You can pass these options as key/value object to $.asDatepicker() method. </p>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h2>API</h2>
|
|
|
<section>
|
|
|
<h3>DisplayMode</h3>
|
|
|
<p>With default dropdown and inline</p>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$("#calendar-api-displayMode").asDatepicker({displayMode: 'inline'});</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" id="calendar-api-displayMode">
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>show()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$('#calendar-api-show').asDatepicker('show');</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" class="asDatepicker" id="calendar-api-show">
|
|
|
<a href="#" id="calendar-api-show-click">Click to show calendar</a> </div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>hide()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$('#calendar-api-show').asDatepicker('hide');</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" class="asDatepicker" id="calendar-api-hide">
|
|
|
<a href="#" id="calendar-api-hide-click">Click to hide calendar</a> </div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>multipleClear()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$('#calendar-api-multipleClear').asDatepicker('multipleClear');</code></pre>
|
|
|
<div class="example">
|
|
|
<input type="text" class="calendar-multiple" id="calendar-api-multipleClear">
|
|
|
<button id="api-multipleClear-click">Clear</button>
|
|
|
</div>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>getWrap()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$.asDatepicker('getWrap');</code></pre>
|
|
|
<div class="example">
|
|
|
<p>Returns the wrapper of the calendar.</p>
|
|
|
</div>
|
|
|
<section>
|
|
|
<h3>getInput()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$.asDatepicker('getInput');</code></pre>
|
|
|
<div class="example"> Returns the input field. </div>
|
|
|
<section>
|
|
|
<h3>getDate()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$('#calendar-api-getDate').asDatepicker('getDate');</code></pre>
|
|
|
<div class="example">
|
|
|
<p>Returns the currently selected date.</p>
|
|
|
<input type="text" class="asDatepicker" id="calendar-api-getDate">
|
|
|
<button id="api-getDate-click">getDate</button>
|
|
|
</div>
|
|
|
<div class="example info">
|
|
|
<div class="content" id="api-getDate-info"></div>
|
|
|
</div>
|
|
|
<section>
|
|
|
<h3>getDate(format)</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$('#calendar-api-getDate-format').asDatepicker('getDate', 'yyyy-mm-dd');</code></pre>
|
|
|
<div class="example">
|
|
|
<p>Returns the current date, formatted with the pattern given as the argument.</p>
|
|
|
<input type="text" class="asDatepicker" id="calendar-api-getDate-format">
|
|
|
<button id="api-getDate-format-click">getDate</button>
|
|
|
</div>
|
|
|
<div class="example info">
|
|
|
<div class="content" id="api-getDate-format-info"></div>
|
|
|
</div>
|
|
|
<section>
|
|
|
<h3>update()</h3>
|
|
|
<pre class="has-example"><code class="language-markup">
|
|
|
$('#calendar-api-update').asDatepicker();
|
|
|
$('#calendar-api-update').asDatepicker('update', {mode: 'range'});</code></pre>
|
|
|
<div class="example">
|
|
|
<p>Sets one or more options for the asDatepicker.</p>
|
|
|
<input type="text" class="asDatepicker" id="calendar-api-update">
|
|
|
<button id="api-update-click">update</button>
|
|
|
</div>
|
|
|
<section> </section>
|
|
|
<section>
|
|
|
<h2>Events</h2>
|
|
|
<section>
|
|
|
<h3>on_show</h3>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>on_before_show</h3>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>on_hide</h3>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>on_change</h3>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h3>on_render</h3>
|
|
|
</section>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h2>Skin</h2>
|
|
|
</section>
|
|
|
<section>
|
|
|
<h2>Location</h2>
|
|
|
</section>
|
|
|
</div>
|
|
|
<script src="js/jquery.js"></script>
|
|
|
<script src="js/jquery.mobile.custom.js"></script>
|
|
|
<script src="js/jquery.toc.min.js"></script>
|
|
|
<script src="js/prism.js"></script>
|
|
|
<script src="../js/jquery-asDatepicker.js"></script>
|
|
|
<script>
|
|
|
$(document).ready(function(){
|
|
|
(function(){
|
|
|
$('#toc').toc();
|
|
|
})();
|
|
|
$("#calendar").asDatepicker({
|
|
|
namespace: 'calendar',
|
|
|
lang: 'zh',
|
|
|
position: 'bottom'
|
|
|
});
|
|
|
|
|
|
$("#calendar2").asDatepicker({
|
|
|
mode: 'range',
|
|
|
namespace: 'calendar',
|
|
|
lang: 'zh',
|
|
|
position: 'bottom'
|
|
|
});
|
|
|
|
|
|
$("#calendar3").asDatepicker({
|
|
|
mode: 'multiple',
|
|
|
calendars: 4,
|
|
|
});
|
|
|
|
|
|
$("#calendar4").asDatepicker();
|
|
|
|
|
|
$('#calendar-mobile-single').asDatepicker({
|
|
|
mobileMode: true
|
|
|
});
|
|
|
$('#calendar-mobile-range').asDatepicker({
|
|
|
mode: 'range',
|
|
|
mobileMode: true
|
|
|
});
|
|
|
$('#calendar-mobile-multiple').asDatepicker({
|
|
|
mode: 'multiple',
|
|
|
mobileMode: true
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('.asDatepicker').asDatepicker();
|
|
|
$('.calendar-multiple').asDatepicker({mode: 'multiple', calendars: 3});
|
|
|
|
|
|
$('#calendar-api-displayMode').asDatepicker({displayMode: 'inline'});
|
|
|
|
|
|
$('#calendar-api-show-click').click(function(){
|
|
|
$('#calendar-api-show').asDatepicker('show');
|
|
|
return false;
|
|
|
});
|
|
|
$('#calendar-api-hide-click').click(function(){
|
|
|
$('#calendar-api-hide').asDatepicker('hide');
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$('#api-multipleClear-click').click(function() {
|
|
|
$("#calendar-api-multipleClear").asDatepicker('multipleClear');
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$('#api-getDate-click').click(function() {
|
|
|
var html = '<div>' + $('#calendar-api-getDate').asDatepicker('getDate') + '</div>';
|
|
|
$(html).prependTo($('#api-getDate-info'));
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$('#api-getDate-format-click').click(function() {
|
|
|
var html = '<div>' + $('#calendar-api-getDate-format').asDatepicker('getDate', 'yyyy-mm-dd') + '</div>';
|
|
|
$(html).prependTo($('#api-getDate-format-info'));
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$('#api-update-click').click(function() {
|
|
|
$('#calendar-api-update').asDatepicker('update', {mode: 'range'});
|
|
|
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
|
|
|
});
|
|
|
</script>
|
|
|
</body>
|
|
|
</html> |