Skip to content

Commit

Permalink
add range dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 17, 2012
1 parent daaca35 commit 84a45ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
1 change: 1 addition & 0 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "0.0.3",
"keywords": ["calendar", "date", "ui"],
"dependencies": {
"component/range": "*",
"component/jquery": "*",
"component/emitter": "*",
"component/in-groups-of": "*"
Expand Down
26 changes: 3 additions & 23 deletions lib/days.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var o = require('jquery')
, Emitter = require('emitter')
, template = require('./template')
, inGroupsOf = require('in-groups-of')
, clamp = require('./utils').clamp;
, clamp = require('./utils').clamp
, range = require('range')

/**
* Days.
Expand Down Expand Up @@ -378,7 +379,7 @@ function nextMonthDay(year, month, day) {
*/

function yearDropdown(from, to) {
var years = range(from, to);
var years = range(from, to, 'inclusive');
var options = o.map(years, yearOption).join('');
return '<select class="calendar-select">'+options+'</select>';
}
Expand Down Expand Up @@ -407,24 +408,3 @@ function yearOption(year) {
function monthOption(month, i) {
return '<option value="'+i+'">'+month+'</option>';
}

/**
* Return an array of the values between 2 integers.
* With a blank at the start.
*/

function range(from, to) {
if (from > to) {
var reverseTo = to;
to = from;
from = reverseTo;
};
var rangeArray = [];
rangeArray.push('');
for (var i = from; i <= to; i++) {
rangeArray.push(i);
};
if (reverseTo) rangeArray.reverse();
return rangeArray;
}

2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>Calendar</h1>
<script src="../build/build.js"></script>
<script>
var Calendar = require('calendar');
var one = (new Calendar).monthMenu().yearMenu();
var one = new Calendar().monthMenu().yearMenu();

one.on('view change', function(date, action){
console.log(action);
Expand Down

0 comments on commit 84a45ff

Please sign in to comment.