can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[ljcom] r10696: 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/bin/upgrading/s2layers/sup/layout.s2
U   trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js
Modified: trunk/bin/upgrading/s2layers/sup/layout.s2
===================================================================
--- trunk/bin/upgrading/s2layers/sup/layout.s2	2011-06-24 03:52:20 UTC (rev 10695)
+++ trunk/bin/upgrading/s2layers/sup/layout.s2	2011-06-24 07:11:46 UTC (rev 10696)
@@ -745,7 +745,7 @@
 
     _print_CSS();
     
-    $p->need_res(["js/s2.js"]);
+    $p->need_res(["js/jquery/jquery.lj.inlineCalendar.js", "js/jquery/jquery.calendarEvents.js", "js/s2.js"]);
     $p->print_head();
 
     if ($*linked_stylesheet) {

Modified: trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js	2011-06-24 03:52:20 UTC (rev 10695)
+++ trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js	2011-06-24 07:11:46 UTC (rev 10696)
@@ -75,6 +75,9 @@
 			title: 'h5',
 			tbody: 'tbody',
 
+			month: '.cal-nav-month',
+			year:  '.cal-nav-year',
+
 			prevMonth: '.cal-nav-month .cal-nav-prev',
 			nextMonth: '.cal-nav-month .cal-nav-next',
 			prevYear:  '.cal-nav-year .cal-nav-prev',
@@ -95,9 +98,9 @@
 		},
 
 		ml: {
-			monthNamesShort: [ "January", "February", "March", "April", "May", "June", "July",
+			monthNamesLong: [ "January", "February", "March", "April", "May", "June", "July",
 							 "August", "September", "October", "November", "December"],
-			monthNamesLong: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+			monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
 			caption: "Calendar"
 		}
 	};
@@ -211,21 +214,29 @@
 		this.catchTableStructure = function() {
 			var tbody = nodes.tbody[0];
 			nodes.daysCells = [];
+			nodes.daysSpans = [];
 
 			var row, rowsCount = tbody.rows.length, cell, cellsCount;
 
 			var toAdd = 6 - rowsCount;
+
+			var rowStr = '<tr>';
+			for( var i = 0; i < 7; ++i ) { rowStr += '<td><span></span></td>'; }
+			rowStr += '</tr>';
+
 			while( toAdd-- > 0 ) {
 				//add missing rows if server has rendered not enough markup
-				$( '<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>' ).appendTo( nodes.tbody );
+				$( rowStr ).appendTo( nodes.tbody );
 			}
 			rowsCount = 6;
 			nodes.lastRow = jQuery( tbody.rows[ tbody.rows.length - 1 ] );
 
 			for( row = 0; row < rowsCount; ++row ) {
 				for( cell = 0, cellsCount = tbody.rows[ row ].cells.length; cell < cellsCount; ++cell ) {
+					// take into account span inside td
 					var node = jQuery( tbody.rows[ row ].cells[ cell ] );
 					nodes.daysCells.push( node );
+					nodes.daysSpans.push( node.children() );
 				}
 			}
 
@@ -254,9 +265,11 @@
 			d.setDate( 1 - offset );
 
 			for( var i = 0, l = nodes.daysCells.length; i < l; ++i ) {
-				var cell = nodes.daysCells[ i ];
-				this.formDayString( d, cell, hasEvents( d ), this.isActiveDate( d, monthDate ) );
+				var cell = nodes.daysCells[ i ],
+					span = nodes.daysSpans[ i ];
 
+				this.formDayString( d, cell, span, hasEvents( d ), this.isActiveDate( d, monthDate ) );
+
 				d.setDate( d.getDate() + 1 );
 			}
 
@@ -281,41 +294,34 @@
 			return isActive;
 		};
 
-		this.formDayString = function( d, label, hasEvents, isActive )
+		this.formDayString = function( d, cell, span, hasEvents, isActive )
 		{
 			d = new Date( d );
-			var oldDay = label.data( 'day' ),
-				oldHasEvents = label.data( 'hasEvents' ),
-				oldIsActive = label.data( 'isActive' );
+			var oldDay = cell.data( 'day' ),
+				oldHasEvents = cell.data( 'hasEvents' ),
+				oldIsActive = cell.data( 'isActive' );
 
 			var isCurrentDay = ( getDateNumber( d ) === getDateNumber( o.currentDate ) );
 
-			label.data( 'day', d );
-			label.data( 'isActive', isActive );
-			label.data( 'hasEvents', hasEvents );
+			cell.data( 'day', d );
+			cell.data( 'isActive', isActive );
+			cell.data( 'hasEvents', hasEvents );
 
-			label[isCurrentDay ? 'addClass' : 'removeClass']( styles.current );
-			label.removeClass( styles.cellHover );
+			cell[isCurrentDay ? 'addClass' : 'removeClass']( styles.current );
+			cell.removeClass( styles.cellHover );
 
-			//do not modify dom if nothing changed
-			if( oldIsActive && ( oldIsActive === isActive ) &&
-					oldDay && ( getDateNumber( d ) === getDateNumber( oldDay ) ) &&
-					oldHasEvents && ( oldHasEvents === hasEvents )
-			) {
-				return;
-			}
-
 			if( !isActive ) {
-				label.addClass( styles.inactive ).html(d.getDate());
+				cell.addClass( styles.inactive );
+				span.html(d.getDate());
 			} else if( hasEvents || o.allRefs ) {
-				label
-					.removeClass( styles.inactive )
-					.html( jQuery( '<a />', {
+				cell.removeClass( styles.inactive )
+				span.html( jQuery( '<a />', {
 						html: d.getDate(),
 						href: Calendar._formatDate( d, o.dayRef )
 					} ) );
 			} else {
-				label.removeClass( styles.inactive ).html(d.getDate());
+				cell.removeClass( styles.inactive );
+				span.html(d.getDate());
 			}
 		};
 
@@ -403,7 +409,7 @@
 			event.date = new Date( this.options.displayedMonth );
 			event.date.setMonth( event.date.getMonth() + go );
 
-			this._nodes.container.trigger( event );
+			this._nodes.root.trigger( event );
 			this._setOption( 'displayedMonth', event.date );
 		},
 
@@ -505,8 +511,14 @@
 					this._invalidateDisplay();
 					break;
 				case 'displayedMonth':
-					this.options.displayedMonth = this._fitDate( new Date( value ) );
-					this._invalidateDisplay();
+					var newDate = this._fitDate( new Date( value ) ),
+						isCurrentMonth = ( getDateNumber( newDate, true )
+								=== getDateNumber( this.options.displayedMonth ) );
+
+					if( !isCurrentMonth ) {
+						this.options.displayedMonth = this._fitDate( new Date( value ) );
+						this._invalidateDisplay();
+					}
 					break;
 				case 'startMonth':
 					this.options.startMonth = new Date( value );
@@ -519,6 +531,14 @@
 			}
 		},
 
+		getElement: function( name ) {
+			if( name in this._nodes ) {
+				return this._nodes[ name ];
+			} else { 
+				return null;
+			}
+		},
+
 		/**
 		 * Serialize date to string according the format string.
 		 * We suppose that every token takes place in the string only once.

Tags: can3p, js, ljcom, s2
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