Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
glDatePicker-mod
============
###### v1.1.3
Adds four additional options to the glDatePicker library which all take a callback function allowing for extendable features. Each function returns the full date of the first day in the month/year being changed to (monthFirstDate).

### onNextMonthClick(monthFirstDate)
### onPrevMonthClick(monthFirstDate)

- Callback functions which will execute when next or previous buttons are clicked.

### onMonthYearSelect(monthFirstDate)

- Callback function that executes when the user changes the month through the options.

### onOutDayClick(monthFirstDate)

- Callback function that exectues when a user clicks on a date not part of the current month.

### onCalendarRefresh(monthFirstDate)

- Callback function that combines all four of the previous features into a single option.

Example
---------------
``` html
<!DOCTYPE html>
<html>
<head>
<title>On Month Change Example</title>
<link href="styles/glDatePicker-mod.default.css" rel="stylesheet" type="text/css">
</head>
<body>
<input type="text" id="example1" />
<input type="text" id="example2" />

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="glDatePicker-mod.min.js"></script>

<script type="text/javascript">
$(window).load(function(){

// Both of these examples will return the same results:

$('#example1').glDatePicker({
onNextMonthClick: onMonthChange,
onPrevMonthClick: onMonthChange,
onMonthYearSelect: onMonthChange
});

$('#example2').glDatePicker({
onCalendarRefresh: onMonthChange
});

function onMonthChange(monthFirstDate){
console.log('The first day of this month is: ' + monthFirstDate);
}
});
</script>
</body>
</html>
```

Download
---------------
``` shell
bower install glDatePicker-mod
```


glDatePicker
============

Expand Down
21 changes: 21 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "gl-datepicker-mod",
"description": "Adds additional features to the glDatePicker jQuery library.",
"main": "glDatePicker-mod.js",
"authors": [
"Gautam Lad."
],
"license": "MIT",
"keywords": [
"jQuery"
],
"homepage": "https://github.com/typicalmike002/glDatePicker-mod",
"version": "1.1.3",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
69 changes: 69 additions & 0 deletions glDatePicker-mod.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/gldatepicker/gldatepicker.d.ts
interface GlDatePickerOffset {
x: number;
y: number;
}

interface GlDatePickerDate {
date: Date;
repeatMonth?: boolean;
repeatYear?: boolean;
}

interface GlDatePickerDateRange {
from: Date;
to?: Date;
repeatYear?: boolean;
}

interface GlDatePickerSpecialDate extends GlDatePickerDate {
data?: any;
cssClass?: string;
}

interface GlDatePickerOptions {
cssName?: string;
zIndex?: number;
borderSize?: number;
calendarOffset?: GlDatePickerOffset;
showAlways?: boolean;
hideOnClick?: boolean;
allowMonthSelect?: boolean;
allowYearSelect?: boolean;
todayDate?: Date;
selectedDate?: Date;
prevArrow?: string;
nextArrow?: string;
selectableDates?: GlDatePickerDate[];
selectableDateRange?: GlDatePickerDateRange[];
specialDates?: GlDatePickerSpecialDate[];
onNextMonthClick?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
onPrevMonthClick?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
onMonthYearSelect?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
onOutDayClick?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
onCalendarRefresh?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
selectableMonths?: number[];
selectableYears?: number[];
selectableDOW?: number[];
monthNames?: string[];
dowNames?: string[];
dowOffset?: number;
onClick?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
onHover?: (inputElement: JQuery, cell: JQuery, date: Date, data: any) => void;
onShow?: (calendar: JQuery) => void;
onHide?: (calendar: JQuery) => void;
}

interface GlDatePicker {
options: GlDatePickerOptions;

show(): void;
hide(): void;
render(renderCallback?: () => void): void;
}

interface JQuery {
glDatePicker(ret: boolean): GlDatePicker;
glDatePicker(options?: GlDatePickerOptions): JQuery;
}
54 changes: 45 additions & 9 deletions glDatePicker.js → glDatePicker-mod.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*!
* glDatePicker v2.0
* http://glad.github.com/glDatePicker/
*
* Copyright (c) 2013 Gautam Lad. All rights reserved.
* Released under the MIT license.
*
* Date: Tue Jan 1 2013
*/
;(function() {
* glDatePicker v2.0
* http://glad.github.com/glDatePicker/
*
* Copyright (c) 2013 Gautam Lad. All rights reserved.
* Released under the MIT license.
*
* Date: Tue Jan 1 2013
*/

;(function() {
$.fn.glDatePicker = function(options) {
var pluginName = 'glDatePicker';

Expand Down Expand Up @@ -180,6 +181,26 @@
// You can use this callback to animate the hiding of the calendar.
onHide: function(calendar) { calendar.hide(); },

// Callback that will trigger when the user clicks next.
// The argument will return the first date of the month.
onNextMonthClick: function(monthFirstDate){},

// Callback that will trigger when the user clicks previous.
// The argument will return the first date of the month.
onPrevMonthClick: function(monthFirstDate){},

// Callback that triggers when user uses options to change the month/year.
// The argument will return the first date of the month.
onMonthYearSelect: function(monthFirstDate){},

// Callback that triggers whenever the calendar month changes due to user
// click on a date that isn't equal to the same month as the current view.
onOutDayClick: function(monthFirstDate){},

// Callback that triggers whenever the calendar changes.
// The argument will return the first date of the month.
onCalendarRefresh: function(monthFirstDate){},

// First date of the month.
firstDate: null
};
Expand Down Expand Up @@ -472,6 +493,9 @@
if(options.prevArrow != '' && showPrev) {
e.stopPropagation();
setFirstDate(prevFirstDate);

options.onPrevMonthClick(prevFirstDate);
options.onCalendarRefresh(prevFirstDate);
}
});

Expand Down Expand Up @@ -507,6 +531,9 @@
if(options.nextArrow != '' && showNext) {
e.stopPropagation();
setFirstDate(nextFirstDate);

options.onNextMonthClick(nextFirstDate);
options.onCalendarRefresh(nextFirstDate);
}
});

Expand Down Expand Up @@ -649,6 +676,13 @@

// Call callback
options.onClick(el, $(this), clickedData.date, clickedData.data);

// Callback for when clicking an outday changes the current month.
if ($(this).hasClass('outday')) {
setFirstDate(clickedData.date);
options.onOutDayClick(options.firstDate);
options.onCalendarRefresh(options.firstDate);
}
});
}
}
Expand Down Expand Up @@ -697,6 +731,8 @@
// Helper function when select is updated
var onYearMonthSelect = function() {
options.firstDate = new Date(yearSelect.val(), monthSelect.val(), 1);
options.onMonthYearSelect(options.firstDate);
options.onCalendarRefresh(options.firstDate);
self.render();
};

Expand Down
1 change: 1 addition & 0 deletions glDatePicker-mod.min.js

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

Loading