can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[ljcom] r10704: LJSUP-9138: All links are active in cale...

Committer: dpetrov
LJSUP-9138: All links are active in calendar in controlstrip on the user's home page
U   trunk/htdocs/js/s2.js
Modified: trunk/htdocs/js/s2.js
===================================================================
--- trunk/htdocs/js/s2.js	2011-06-28 03:07:23 UTC (rev 10703)
+++ trunk/htdocs/js/s2.js	2011-06-28 06:15:04 UTC (rev 10704)
@@ -1,74 +1,24 @@
 jQuery( function( $ ) {
-	var calendarWidget = {
-		init: function( node ) {
-			var widget = this;
-			this.events = Site.journal_calendar;
-			this.calendar = node;
+	$( '.sidebar-cal' ).inlineCalendar( {
+		selectors: {
+			month: '.sbar-cal-nav-month',
+			year:  '.sbar-cal-nav-year',
 
-			this.calendar.inlineCalendar( {
-				selectors: {
-					prevMonth: '.sbar-cal-nav-month .sbar-cal-nav-prev',
-					nextMonth: '.sbar-cal-nav-month .sbar-cal-nav-next',
-					prevYear:  '.sbar-cal-nav-year .sbar-cal-nav-prev',
-					nextYear:  '.sbar-cal-nav-year .sbar-cal-nav-next',
+			prevMonth: '.sbar-cal-nav-month .sbar-cal-nav-prev',
+			nextMonth: '.sbar-cal-nav-month .sbar-cal-nav-next',
+			prevYear:  '.sbar-cal-nav-year .sbar-cal-nav-prev',
+			nextYear:  '.sbar-cal-nav-year .sbar-cal-nav-next',
 
-					monthLabel: '.sbar-cal-nav-month .sbar-cal-month',
-					yearLabel: '.sbar-cal-nav-year .sbar-cal-year'
-				},
-				classNames: {
-					current  : 'today',
-					nextDisabled : 'disabled',
-					prevDisabled : 'disabled'
-				},
-				events: this.getEvents( this.events.year, this.events.month, this.events.days ),
-				monthRef: '/%Y/%M',
-				yearRef: '/%Y',
-				startAtSunday: true
-			} ).bind( 'dateChange', function( ev ) {
-				var type = ( ev.moveForward ) ? "next_" : "prev_";
-				type += ( ev.switchType === "year" ) ? "year" : "month";
-
-				if( widget.events[ type ] ) {
-					ev.date.setFullYear( widget.events[ type ][ 0 ] );
-					ev.date.setMonth( widget.events[ type ][ 1 ] -1 );
-
-					widget.fetchEvents( widget.events[ type ][ 0 ], widget.events[ type ][ 1 ] );
-				}
-			} );
-
-			this.fixBounds();
+			monthLabel: '.sbar-cal-nav-month .sbar-cal-month',
+			yearLabel: '.sbar-cal-nav-year .sbar-cal-year'
 		},
-		getEvents: function( year, month, days ) {
-			var result = {};
-			result[ +year ] = {};
-			result[ +year ][ +month -1 ] = days;
-
-			return result;
+		classNames: {
+			current  : 'today',
+			nextDisabled : 'disabled',
+			prevDisabled : 'disabled'
 		},
-
-		fetchEvents: function( year, month ) {
-			var widget = this;
-			var curMonth = this.calendar.inlineCalendar( 'option', 'displayedMonth' );
-			$.getJSON( LiveJournal.getAjaxUrl( 'calendar' ), { year: year, month: month },
-					function( answer ) {
-						widget.events = answer;
-						widget.fixBounds();
-						widget.calendar.inlineCalendar( 'option', 'events',
-							widget.getEvents( widget.events.year, widget.events.month, widget.events.days )  );
-					}
-			);
-		},
-
-		fixBounds: function() {
-			var curMonth = this.calendar.inlineCalendar( 'option', 'displayedMonth' );
-			var next = this.events.next_year || this.events.next_month;
-			var prev = this.events.prev_year || this.events.prev_month;
-			this.calendar.inlineCalendar( 'option', 'endMonth', ( next ) ?
-					new Date( next[0], next[1] - 1, 1 ) : curMonth );
-			this.calendar.inlineCalendar( 'option', 'startMonth', ( prev ) ?
-					new Date( prev[0], prev[1] - 1, 1 ) : curMonth );
-		}
-	}
-
-	calendarWidget.init( $( '.sidebar-cal' ) );
+		monthRef: '/%Y/%M',
+		yearRef: '/%Y',
+		startAtSunday: true
+	} ).calendarEvents( { calendarType: "inlineCalendar" } );
 });

Tags: can3p, js, ljcom
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments