Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove jquery dependency #20

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
],
"dependencies": {
"component/range": "*",
"component/jquery": "*",
"component/domify": "*",
"component/classes": "*",
"component/emitter": "*",
"component/in-groups-of": "*"
},
Expand All @@ -28,4 +29,4 @@
"lib/days.js"
],
"license": "MIT"
}
}
5 changes: 2 additions & 3 deletions lib/calendar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

/**
* Module dependencies.
*/

var o = require('jquery')
var domify = require('domify')
, Emitter = require('emitter')
, template = require('./template')
, Days = require('./days')
Expand Down Expand Up @@ -33,7 +32,7 @@ module.exports = Calendar;
function Calendar(date) {
Emitter.call(this);
var self = this;
this.el = o('<div class=calendar></div>');
this.el = domify('<div class=calendar></div>')[0];
this.days = new Days;
this.el.append(this.days.el);
this.on('change', this.show.bind(this));
Expand Down
16 changes: 8 additions & 8 deletions lib/days.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/**
* Module dependencies.
*/

var o = require('jquery')
var domify = require('domify')
, classes = require('classes')
, Emitter = require('emitter')
, template = require('./template')
, inGroupsOf = require('in-groups-of')
Expand Down Expand Up @@ -69,15 +69,15 @@ module.exports = Days;
function Days() {
Emitter.call(this);
var self = this;
this.el = o(template).addClass('calendar-days');
this.el = classes(domify(template)[0]).add('calendar-days');
this.head = this.el.find('thead');
this.body = this.el.find('tbody');
this.title = this.head.find('.title');
this.select(new Date);

// emit "day"
this.body.on('click', 'a', function(e){
var el = o(e.target);
var el = domify(e.target)[0];
var day = parseInt(el.text(), 10);
var data = el.data('date').split('-');
var year = data[0];
Expand Down Expand Up @@ -227,7 +227,7 @@ Days.prototype.renderHeading = function(len){
var rows = '<tr class=subheading>' + days.map(function(day){
return '<th>' + day.slice(0, len) + '</th>';
}).join('') + '</tr>';
return o(rows);
return domify(rows)[0];
};

/**
Expand All @@ -243,7 +243,7 @@ Days.prototype.renderDays = function(date){
var html = rows.map(function(row){
return '<tr>' + row.join('') + '</tr>';
}).join('\n');
return o(html);
return domify(html)[0];
};

/**
Expand Down Expand Up @@ -387,7 +387,7 @@ function nextMonthDay(year, month, day) {

function yearDropdown(from, to) {
var years = range(from, to, 'inclusive');
var options = o.map(years, yearOption).join('');
var options = years.map(yearOption).join('');
return '<select class="calendar-select">' + options + '</select>';
}

Expand All @@ -396,7 +396,7 @@ function yearDropdown(from, to) {
*/

function monthDropdown() {
var options = o.map(months, monthOption).join('');
var options = months.map(monthOption).join('');
return '<select class="calendar-select">' + options + '</select>';
}

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"version": "0.0.3",
"keywords": ["calendar", "date", "ui"],
"dependencies": {
"jquery-component": "*",
"domify-component": "*",
"emitter-component": "*",
"in-groups-of": "*"
"in-groups-of": "*",
"classes-component": "*"
},
"component": {
"styles": ["lib/calendar.css"],
Expand All @@ -18,4 +19,4 @@
"calendar/lib/days.js": "lib/days.js"
}
}
}
}