<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: previous code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 07 Sep 2008 17:01:54 GMT</pubDate>
    <description>DZone Snippets: previous code</description>
    <item>
      <title>Code to disable YUI calendar previous and next month links icons</title>
      <link>http://snippets.dzone.com/posts/show/5198</link>
      <description>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 and a namespace called your_app.&lt;br /&gt;&lt;br /&gt;1) attach an onRender event when you configure the calendar and before you call render&lt;br /&gt;&lt;br /&gt;&lt;code&gt;calendar.renderEvent.subscribe(YAHOO.your_app.calendar().initArrows, calendar);&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;2) add the following function:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;YAHOO.your_app.calendar = function() {&lt;br /&gt;	&lt;br /&gt;	var addDays = function(date, days) {&lt;br /&gt;		return YAHOO.widget.DateMath.add(date, YAHOO.widget.DateMath.DAY, days);&lt;br /&gt;	};&lt;br /&gt;	&lt;br /&gt;	var showPreviousArrow = function(cal) {&lt;br /&gt;		return showArrow(cal, cal.toDate(cal.cellDates[0]), 1);&lt;br /&gt;	};&lt;br /&gt;&lt;br /&gt;	var showNextArrow = function(cal) {&lt;br /&gt;		return showArrow(cal, cal.toDate(cal.cellDates[cal.cellDates.length-1]), -1);&lt;br /&gt;	};&lt;br /&gt;	&lt;br /&gt;	var showArrow = function(cal, startingDate, step) {&lt;br /&gt;		if (!cal.isDateOOM(startingDate)) { //ie not overlapping&lt;br /&gt;			return !cal.isDateOOB(addDays(startingDate, (-1 * step)));&lt;br /&gt;		}&lt;br /&gt;		for (var i=0; (i * step) &lt; 7; i += step) { //iterate forwards for previous month check, backwards for next month check&lt;br /&gt;			var date = addDays(startingDate, i);&lt;br /&gt;			if (!cal.isDateOOM(date)) { //shortcut exit; as soon as we find an in month date we can supress the arrow&lt;br /&gt;				return false;&lt;br /&gt;			} else if (!cal.isDateOOB(date)) {&lt;br /&gt;				return true;&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;		return false;&lt;br /&gt;	};&lt;br /&gt;	&lt;br /&gt;	return {&lt;br /&gt;		initArrows: function(type, args, cal) {&lt;br /&gt;			if (!showPreviousArrow(cal)) {&lt;br /&gt;				hideArrow(cal, cal.Style.CSS_NAV_LEFT);&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			if (!showNextArrow(cal)) {&lt;br /&gt;				hideArrow(cal, cal.Style.CSS_NAV_RIGHT);&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;	};&lt;br /&gt;};&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 03 Mar 2008 20:57:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5198</guid>
      <author>robd (Rob Dupuis)</author>
    </item>
    <item>
      <title>OnlyOneOfClass: Extension to prototype library allowing AJAX calls to supercede / abort / cancel previous calls within a given class.</title>
      <link>http://snippets.dzone.com/posts/show/1367</link>
      <description>&lt;code&gt;&lt;br /&gt;// Extension to Ajax allowing for classes of requests of which only one (the latest) is ever active at a time&lt;br /&gt;// - stops queues of now-redundant requests building up / allows you to supercede one request with another easily.&lt;br /&gt;&lt;br /&gt;// just pass in onlyLatestOfClass: 'classname' in the options of the request&lt;br /&gt;&lt;br /&gt;Ajax.currentRequests = {};&lt;br /&gt;&lt;br /&gt;Ajax.Responders.register({&lt;br /&gt;	onCreate: function(request) {&lt;br /&gt;		if (request.options.onlyLatestOfClass &amp;&amp; Ajax.currentRequests[request.options.onlyLatestOfClass]) {&lt;br /&gt;			// if a request of this class is already in progress, attempt to abort it before launching this new request&lt;br /&gt;			try { Ajax.currentRequests[request.options.onlyLatestOfClass].transport.abort(); } catch(e) {}&lt;br /&gt;		}&lt;br /&gt;		// keep note of this request object so we can cancel it if superceded&lt;br /&gt;		Ajax.currentRequests[request.options.onlyLatestOfClass] = request;&lt;br /&gt;	},&lt;br /&gt;	onComplete: function(request) {&lt;br /&gt;		if (request.options.onlyLatestOfClass) {&lt;br /&gt;			// remove the request from our cache once completed so it can be garbage collected&lt;br /&gt;			Ajax.currentRequests[request.options.onlyLatestOfClass] = null;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;});&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 06 Feb 2006 22:34:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1367</guid>
      <author>matth (Matthew)</author>
    </item>
  </channel>
</rss>
