Skip to content

Commit

Permalink
v0.3.1: Adds npm package. Adds some minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduludi committed May 26, 2015
1 parent 5e1415a commit 6c3fc7d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 33 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery-yacal",
"version": "0.2.0",
"version": "0.3.1",
"homepage": "https://github.com/eduludi/jquery-yacal",
"authors": [
"Eduardo Ludi <eduludi@gmail.com>"
Expand Down
14 changes: 7 additions & 7 deletions dist/jquery.yacal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jquery.yacal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions package.json
@@ -0,0 +1,28 @@
{
"name": "jquery-yacaljs",
"version": "0.3.1",
"description": "Yet Another Calendar plugin for jQuery",
"main": "dist/jquery.yacal.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/eduludi/jquery-yacal.git"
},
"keywords": [
"jquery-plugin",
"calendar",
"jquery",
"plugin",
"lightweight",
"i18n",
"templates"
],
"author": "Eduardo Ludi <edu.ludi@gmail.com> (https://www.npmjs.com/~eduludi)",
"license": "MIT",
"bugs": {
"url": "https://github.com/eduludi/jquery-yacal/issues"
},
"homepage": "https://github.com/eduludi/jquery-yacal"
}
42 changes: 18 additions & 24 deletions src/jquery.yacal.coffee
Expand Up @@ -15,12 +15,13 @@ Released under the MIT license
"use strict"

_name = 'yacal' # plugin's name
_version = '0.3.1'

_msInDay = 86400000 # milliseconds in a day
_eStr = '' # empty string

# placeholders
_ph = {
_ph =
d: '#day#'
dt: '#time#'
dw: '#dayWeek#'
Expand All @@ -39,7 +40,6 @@ Released under the MIT license
nav: '#nav#'
prev: '#prev#'
next: '#next#'
}

isDate = (obj) ->
(/Date/).test(Object.prototype.toString.call(obj)) and !isNaN(obj.getTime())
Expand Down Expand Up @@ -104,10 +104,8 @@ Released under the MIT license
# _d = Current date, _s = Selected date
_d = _s = null

# template settings
# template & internationalization settings
_tpl = {}

# internationalization settings
_i18n = {}

# other settings
Expand Down Expand Up @@ -137,11 +135,11 @@ Released under the MIT license
.replace(_ph.a, if inRange(date,_minDate,_maxDate) then ' active' else _eStr)

renderMonth = (date,nav=false) ->
totalDays = getDaysInMonth(date.getYear(),date.getMonth())
d = 0
out = _eStr
month = date.getMonth()
year = date.getFullYear()
out = _eStr
d = 0
totalDays = getDaysInMonth(date.getYear(),date.getMonth())

# weekdays
if _showWD
Expand Down Expand Up @@ -170,7 +168,6 @@ Released under the MIT license
if (d == totalDays || day.getDay() == 6)
out += _weekPart[1]


# replace placeholders and return the output
_monthPart[0].replace(_ph.m,month)
.replace(_ph.mnam,_i18n.months[month])
Expand Down Expand Up @@ -224,11 +221,11 @@ Released under the MIT license
_d = _s = new Date(opts.date) # Ensures get a date
_tpl = opts.tpl
_i18n = opts.i18n
_nearMonths = parseInt(opts.nearMonths)
_nearMonths = +opts.nearMonths
_showWD = !!opts.showWeekdays
_minDate = new Date(opts.minDate) if opts.minDate
_maxDate = new Date(opts.maxDate) if opts.maxDate
_firstDay = parseInt(opts.firstDay) # TODO
# _firstDay = +opts.firstDay # TODO

_weekPart = _tpl.week.split('|')
_monthPart = _tpl.month.split('|')
Expand All @@ -237,14 +234,14 @@ Released under the MIT license
)

# Defaults
$.fn.yacal.defaults = {
date: new Date(),
nearMonths: 0,
showWeekdays: 1,
minDate: null,
maxDate: null,
firstDay: 0,
tpl: {
$.fn.yacal.defaults =
date: new Date()
nearMonths: 0
showWeekdays: 1
minDate: null
maxDate: null
firstDay: 0
tpl:
day: tag('a','day d'+_ph.dw+''+_ph.we+''+_ph.t+''+_ph.s+''+_ph.a,
_ph.d,'time="'+_ph.dt+'"')
weekday: tag('i','wday wd'+_ph.wd,_ph.wdn)
Expand All @@ -255,18 +252,15 @@ Released under the MIT license
tag('a','next',tag('span',null,_ph.next)))
wrap: tag('div','wrap')
clearfix: tag('div','clearfix')
}
i18n: {
i18n:
weekdays: ['Su','Mo','Tu','We','Th','Fr','Sa'],
months: ['Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec'],
prev: 'prev',
next: 'next',
}
}

# Version number
$.fn.yacal.version = '0.3.0';
$.fn.yacal.version = _version;

# Autoinitialize .yacal elements on load
$('.' + _name).yacal()
Expand Down

0 comments on commit 6c3fc7d

Please sign in to comment.