Skip to content

Commit

Permalink
month format
Browse files Browse the repository at this point in the history
  • Loading branch information
yscoder committed Jan 4, 2017
1 parent b11f054 commit 9a9dae5
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 145 deletions.
107 changes: 55 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Calendar
A calendar component, based on jQuery. [Demo](http://yscoder.github.io/Calendar/demo.html)
A calendar component, based on jQuery. [Demo](//yscoder.github.io/Calendar/index.html)

---

Expand Down Expand Up @@ -33,74 +33,77 @@ $('#ca').calendar({

## Options

* **width: 280**
```js
{

calendar width
* **height: 280**
// width
width: 280,

calendar height
* **zIndex: 1**
// height,
height: 280,

calendar zIndex
* **trigger: null**
// zIndex
zIndex: 1,

Set the trigger selector
* **offset: [0, 1]**
// set the trigger selector
trigger: null,

offset position
* **customClass: ''**
// offset position
offset: [0, 1],

override class
* **view: 'date'**
// override class
customClass: '',

set display view, optional date or month
* **date: new Date()**
// set display view, optional date or month
view: 'date',

set today
* **format: 'yyyy/mm/dd'**
// set current date
date: new Date(),

date format
* **startWeek: 0**
// date format
format: 'yyyy/mm/dd',

default 0, first day of the week
* **weekArray: ['日', '一', '二', '三', '四', '五', '六']**
// first day of the week
startWeek: 0,

can change to other
* **selectedRang: null**
// week format
weekArray: ['', '', '', '', '', '', ''],

The optional time range.
// month format
monthArray: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],

format: [ start date, end date]
// optional date range
// value: `[ start date[, end date] ]`
// Fixed date range: [new Date(2016, 0, 1), new Date(2016, 11, 31)] or ['2016/1/1', '2016/12/1']
// Starting today: [new Date(), null] or [new Date()]
selectedRang: null,

set today do not choose before: [new Date(), null] or ['2015/11/27']
* **data: null**
// display data when mouse enter
// value: `[{ date: String || Date, value: object }, ... ]`
// example: [ { date: '2016/1/1', value: 'A new Year'} ] or [ { date: new Date(), value: 'What to do'} ]
data: null,

Date of linked data.
// data label format
// No display is set to `false`
label: '{d}\n{v}',

[{ date: string, value: object }, ... ]
// arrow characters
prev: '<',
next: '>',

* **label: '{d}\n{v}'**
// callback function when view changed
// params: view, y, m
viewChange: $.noop,

data show format, set false don't show.
// callback function when selected
onSelected: function (view, date, value) {
// body...
},

parameters: {d} date, {m} view, {v}, data
* **prev: '<'**
* **next: '>'**

arrow characters
* **viewChange: $.noop**

event callback for view change.

parameters: view
* **onSelected: $.noop**

event callback for selected.

parameters: view, date, data
* **onMouseenter: $.noop**
* **onClose: $.noop**

event callback for selected.
parameters as above.
// callback function when mouseenter
onMouseenter: $.noop,

// callback function when closed
onClose: $.noop
}
```
4 changes: 2 additions & 2 deletions dist/calendar.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ gulp.task('dev', () => {
browserSync.init({
server: {
baseDir: './'
},
startPath: 'demo.html'
}
})

gulp.watch(['demo.html', src + '*.*'], browserSync.reload)
gulp.watch(['index.html', src + '*.*'], browserSync.reload)
})
18 changes: 9 additions & 9 deletions demo.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<title>Examples</title>
<title>Calendar demo</title>
<link rel="stylesheet" href="src/calendar.css">
<style type="text/css">
html {
Expand Down Expand Up @@ -60,7 +60,7 @@ <h2>Trigger calendar</h2>
<div id="two"></div>
<p><button type="button" id="add">Add input</button></p>
</div>
<script src="http://apps.bdimg.com/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdn.bootcss.com/jquery/1.9.0/jquery.min.js"></script>
<script src="src/calendar.js"></script>
<script>
var now = new Date();
Expand Down Expand Up @@ -92,12 +92,12 @@ <h2>Trigger calendar</h2>
// selectedRang: [new Date(), null],
data: data,
date: new Date(2016, 9, 31),
onSelected: function(view, date, data) {
onSelected: function (view, date, data) {
console.log('view:' + view)
console.log('date:' + date)
console.log('data:' + (data || '无'));
},
viewChange: function(view, y, m) {
viewChange: function (view, y, m) {
console.log(view, y, m)

}
Expand All @@ -109,10 +109,10 @@ <h2>Trigger calendar</h2>
// offset: [0, 1],
zIndex: 999,
data: data,
onSelected: function(view, date, data) {
onSelected: function (view, date, data) {
console.log('event: onSelected')
},
onClose: function(view, date, data) {
onClose: function (view, date, data) {
console.log('event: onClose')
console.log('view:' + view)
console.log('date:' + date)
Expand All @@ -123,10 +123,10 @@ <h2>Trigger calendar</h2>
// Dynamic elements
var $demo = $('#demo');
var UID = 1;
$('#add').click(function() {
$demo.append('<input id="input-'+ UID +'"><div id="ca-'+ UID +'"></div>');
$('#add').click(function () {
$demo.append('<input id="input-' + UID + '"><div id="ca-' + UID + '"></div>');
$('#ca-' + UID).calendar({
trigger: '#input-'+ UID++
trigger: '#input-' + UID++
})
})
</script>
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"name": "flip-calendar-picker",
"version": "1.1.0",
"description": "A calendar component, based on jQuery. ",
"version": "1.2.0",
"description": "A calendar component, based on jQuery.",
"main": "./src/calendar.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yscoder/Calendar.git"
Expand Down
Loading

0 comments on commit 9a9dae5

Please sign in to comment.