Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Code to disable YUI calendar previous and next month links icons (See related posts)

WARNING: THIS CODE DOES NOT WORK WITH SOME EDGE CASES. Sometimes, particularly with overlapping end of months, this code will show an arrow even when all dates on the previous / next pane are out of bounds.

This solution does not require modifying the yui source and works on YUI version 2.5.0. It will disable the next and previous arrows based on the out of bounds dates you specify with mindate and maxdate when you configure the calendar. Requires YUI dom.

1) attach an onRender event when you configure the calendar and before you call render

oCal.renderEvent.subscribe(hideOOBArrows, oCal);


2) add the following function:

function hideOOBArrows(type, args, oCal) {
	var lastDateOnThisPane = oCal.toDate(oCal.cellDates[oCal.cellDates.length-1]);
	var firstDateOnNextPane = new Date(lastDateOnThisPane);
	firstDateOnNextPane.setDate(lastDateOnThisPane.getDate()+(oCal.isDateOOM(lastDateOnThisPane) ? -6 : 1));

	if (oCal.isDateOOB(firstDateOnNextPane)) {
		var rightArrow = YAHOO.util.Dom.getElementsByClassName(oCal.Style.CSS_NAV_RIGHT, "a", oCal.oDomContainer)[0];
		YAHOO.util.Dom.setStyle(rightArrow, "display", "none");
	}

	var firstDateOnThisPane = oCal.toDate(oCal.cellDates[0]);
	var lastDateOnPreviousPane = new Date(firstDateOnThisPane);
	lastDateOnPreviousPane.setDate(firstDateOnThisPane.getDate() + (oCal.isDateOOM(firstDateOnThisPane) ? 6 : -1));
	if (oCal.isDateOOB(lastDateOnPreviousPane)) {
		var leftArrow = YAHOO.util.Dom.getElementsByClassName(oCal.Style.CSS_NAV_LEFT, "a", oCal.oDomContainer)[0];
		YAHOO.util.Dom.setStyle(leftArrow, "display", "none");
	}
}

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts