JQuery
view release on metacpan or search on metacpan
lib/JQuery/jquery_js/plugins/datePicker/datePicker_source.js view on Meta::CPAN
d = dIn;
d.setDate(1);
}
// check that date is within allowed limits:
if ((d.getMonth() < _firstDate.getMonth() && d.getFullYear() == _firstDate.getFullYear()) || d.getFullYear() < _firstDate.getFullYear()) {
d = new Date(_firstDate.getFullYear(), _firstDate.getMonth(), 1);;
} else if ((d.getMonth() > _lastDate.getMonth() && d.getFullYear() == _lastDate.getFullYear()) || d.getFullYear() > _lastDate.getFullYear()) {
d = new Date(_lastDate.getFullYear(), _lastDate.getMonth(), 1);;
}
var jCalDiv = jQuery("<div></div>").attr('class','popup-calendar');
var firstMonth = true;
var firstDate = _firstDate.getDate();
// create prev and next links
var prevLinkDiv = '';
if (!(d.getMonth() == _firstDate.getMonth() && d.getFullYear() == _firstDate.getFullYear())) {
// not in first display month so show a previous link
firstMonth = false;
var lastMonth = d.getMonth() == 0 ? new Date(d.getFullYear()-1, 11, 1) : new Date(d.getFullYear(), d.getMonth()-1, 1);
var prevLink = jQuery("<a></a>").attr('href', 'javascript:;').html(navLinks.p).click(function()
lib/JQuery/jquery_js/plugins/datePicker/datePicker_source.js view on Meta::CPAN
};
var _draw = function(c)
{
// explicitly empty the calendar before removing it to reduce the (MASSIVE!) memory leak in IE
// still not perfect but a lot better!
// Strangely if you chain the methods it reacts differently - when chained opening the calendar on
// IE uses a bunch of memory and pressing next/prev doubles this memory. When you close the calendar
// the memory is freed. If they aren't chained then pressing next or previous doesn't double the used
// memory so only one chunk of memory is used when you open the calendar (which is also freed when you
// close the calendar).
jQuery('div.popup-calendar a', _openCal[0]).unbind();
jQuery('div.popup-calendar', _openCal[0]).empty();
jQuery('div.popup-calendar', _openCal[0]).remove();
_openCal.append(c);
};
var _closeDatePicker = function()
{
jQuery('div.popup-calendar a', _openCal).unbind();
jQuery('div.popup-calendar', _openCal).empty();
jQuery('div.popup-calendar', _openCal).css({'display':'none'});
/*
if (jQuery.browser.msie) {
_openCal.unbind('keypress', _handleKeys);
} else {
jQuery(window).unbind('keypress', _handleKeys);
}
*/
jQuery(document).unbind('mousedown', _checkMouse);
delete _openCal;
lib/JQuery/jquery_js/plugins/datePicker/datePicker_source.js view on Meta::CPAN
if (key == 27) {
_closeDatePicker();
}
return false;
};
var _checkMouse = function(e)
{
if (!_drawingMonth) {
var target = jQuery.browser.msie ? window.event.srcElement : e.target;
console.log(jQuery(target));
var cp = jQuery(target).findClosestParent('div.popup-calendar-wrapper');
if (cp.get(0).className != 'date-picker-holder') {
_closeDatePicker();
}
}
};
return {
getChooseDateStr: function()
{
return navLinks.b;
lib/JQuery/jquery_js/plugins/datePicker/datePicker_source.js view on Meta::CPAN
{
if (_openCal) {
_closeDatePicker();
}
this.blur();
var input = jQuery('input', jQuery(this).findClosestParent('input')[0])[0];
_firstDate = input._startDate;
_lastDate = input._endDate;
_firstDayOfWeek = input._firstDayOfWeek;
_openCal = jQuery(this).parent().find('>div.popup-calendar-wrapper');
var d = jQuery(input).val();
if (d != '') {
if (_dateToStr(_strToDate(d)) == d) {
_selectedDate = d;
_draw(_getCalendarDiv(_strToDate(d)));
} else {
// invalid date in the input field - just default to this month
_selectedDate = false;
_draw(_getCalendarDiv());
lib/JQuery/jquery_js/plugins/datePicker/datePicker_source.js view on Meta::CPAN
calBut = jQuery(this).attr('title', chooseDate).addClass('date-picker');
}
else {
calBut = jQuery("<a></a>").attr({'href':'javascript:;',
'class':'date-picker', 'title':chooseDate})
.append("<span>" + chooseDate + "</span>");
}
jQuery(this).wrap(
'<div class="date-picker-holder"></div>'
).after(
jQuery('<div></div>').attr('class', 'popup-calendar-wrapper').append(
jQuery("<div></div>").attr({'class':'popup-calendar'})
),
calBut
);
calBut.bind('click', jQuery.datePicker.show);
jQuery.datePicker.setInited(this);
}
});
return this;
};
/*
<!-- Generated calendar HTML looks like this - style with CSS -->
<div class="popup-calendar">
<div class="link-close"><a href="#">Close</a></div>
<h3>July 2006</h3>
<table cellspacing="2">
<thead>
<tr>
<th scope="col" abbr="Monday" title="Monday" class="weekday">M</th>
<th scope="col" abbr="Tuesday" title="Tuesday" class="weekday">T</th>
<th scope="col" abbr="Wednesday" title="Wednesday" class="weekday">W</th>
<th scope="col" abbr="Thursday" title="Thursday" class="weekday">T</th>
<th scope="col" abbr="Friday" title="Friday" class="weekday">F</th>
( run in 0.667 second using v1.01-cache-2.11-cpan-364913b4093 )