[richfaces-svn-commits] JBoss Rich Faces SVN: r6065 - trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Feb 13 11:15:00 EST 2008


Author: pyaschenko
Date: 2008-02-13 11:15:00 -0500 (Wed, 13 Feb 2008)
New Revision: 6065

Modified:
   trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-2172

Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js	2008-02-13 15:54:10 UTC (rev 6064)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js	2008-02-13 16:15:00 UTC (rev 6065)
@@ -637,6 +637,10 @@
 		this.TIME_EDITOR_LAYOUT_ID = this.id+'TimeEditorLayout';
 		this.DATE_EDITOR_LAYOUT_ID = this.id+'DateEditorLayout';
 		this.EDITOR_LAYOUT_SHADOW_ID = this.id+'EditorLayoutShadow';
+		this.TIME_EDITOR_BUTTON_OK = this.id+'TimeEditorButtonOk';
+		this.TIME_EDITOR_BUTTON_CANCEL = this.id+'TimeEditorButtonCancel';
+		this.DATE_EDITOR_BUTTON_OK = this.id+'DateEditorButtonOk';
+		this.DATE_EDITOR_BUTTON_CANCEL = this.id+'DateEditorButtonCancel';
 		
 		
 		//this.popupIntervalId=null;
@@ -889,9 +893,11 @@
 		editor.style.zIndex = parseInt(zindex,10)+1;
 
 		this.isEditorCreated = true;
+
+		return editor;
 	},
 
-	createTimeEditorLayout: function()
+	createTimeEditorLayout: function(editor)
 	{
 		Element.insert(this.EDITOR_LAYOUT_SHADOW_ID, {after:this.evaluateMarkup(this.calendarContext.timeEditorLayout, this.calendarContext)});
 
@@ -910,9 +916,30 @@
 		}
 		sbjQuery(tm).SpinButton({digits:2,min:0,max:59});
 		
+		this.correctEditorButtons(editor, this.TIME_EDITOR_BUTTON_OK, this.TIME_EDITOR_BUTTON_CANCEL);
+		
 		this.isTimeEditorLayoutCreated = true;
 	},
 	
+	correctEditorButtons: function(editor, buttonID1, buttonID2)
+	{
+		var button1 = $(buttonID1);
+		var button2 = $(buttonID2);
+		editor.style.visibility = "hidden";
+		editor.style.display = "";
+		var width1 = Richfaces.Calendar.getOffsetDimensions(button1.firstChild).width; 
+		var width2 = Richfaces.Calendar.getOffsetDimensions(button2.firstChild).width;
+		editor.style.display = "none";
+		editor.style.visibility = "";
+
+		var styleWidth = Richfaces.getComputedStyleSize(button1,'width')
+				
+		if (width1>styleWidth || width2>styleWidth)
+		{
+			button1.style.width = button2.style.width = (width1>width2 ? width1 : width2)+"px";
+		}
+	},
+	
 	createDECell: function(id, value, buttonType, param, className)
 	{
 		if (buttonType==0)
@@ -929,25 +956,25 @@
 		}
 	},
 
-	createDateEditorLayout: function()
+	createDateEditorLayout: function(editor)
 	{
 		var htmlBegin = '<table id="'+this.DATE_EDITOR_LAYOUT_ID+'" class="rich-calendar-date-layout" border="0" cellpadding="0" cellspacing="0"><tbody><tr id="'+this.DATE_EDITOR_LAYOUT_ID+'TR">';
 		var htmlEnd = '</tr></tbody></table>';
 		var month = 0;
 		this.dateEditorYear = this.getCurrentYear();
 		var year = this.dateEditorStartYear = this.dateEditorYear-4;
-		var htmlContent = '<td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
-						 +'<td class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
-						 +'<td>'+this.createDECell('','&lt;', 0, -1)+'</td>'
-						 +'<td>'+this.createDECell('','&gt;', 0, 1)+'</td>';
+		var htmlContent = '<td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
+						 +'<td align="center" class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
+						 +'<td align="center">'+this.createDECell('','&lt;', 0, -1)+'</td>'
+						 +'<td align="center">'+this.createDECell('','&gt;', 0, 1)+'</td>';
 			month++;
 		
 		for (var i=0;i<5;i++)
 		{
-			htmlContent+='</tr><tr><td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
-						+'<td class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
-						+'<td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+i, year, 2, i, (i==4 ? 'rich-calendar-editor-btn-selected' : ''))+'</td>'
-						+'<td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+(i+5), year+5, 2, i+5)+'</td>';
+			htmlContent+='</tr><tr><td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
+						+'<td align="center" class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
+						+'<td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+i, year, 2, i, (i==4 ? 'rich-calendar-editor-btn-selected' : ''))+'</td>'
+						+'<td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+(i+5), year+5, 2, i+5)+'</td>';
 			month++;
 			year++;
 		}
@@ -956,9 +983,9 @@
 		this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
 		
 		htmlContent+='</tr><tr><td colspan="2" class="rich-calendar-date-layout-ok">'+
-					 '<div class="rich-calendar-time-btn" style="float:right;" onmousedown="Element.addClassName(this, \'rich-calendar-time-btn-press\');" onmouseout="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onmouseup="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onclick="$(\''+this.id+'\').component.hideDateEditor(true);">'+this.params.labels.ok+'</div>'+
+					 '<div id="'+this.DATE_EDITOR_BUTTON_OK+'" class="rich-calendar-time-btn" style="float:right;" onmousedown="Element.addClassName(this, \'rich-calendar-time-btn-press\');" onmouseout="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onmouseup="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onclick="$(\''+this.id+'\').component.hideDateEditor(true);"><span>'+this.params.labels.ok+'</span></div>'+
 					 '</td><td colspan="2" class="rich-calendar-date-layout-cancel">'+
-					 '<div class="rich-calendar-time-btn" style="float:left;" onmousedown="Element.addClassName(this, \'rich-calendar-time-btn-press\');" onmouseout="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onmouseup="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onclick="$(\''+this.id+'\').component.hideDateEditor(false);">'+this.params.labels.cancel+'</div>'+
+					 '<div id="'+this.DATE_EDITOR_BUTTON_CANCEL+'" class="rich-calendar-time-btn" style="float:left;" onmousedown="Element.addClassName(this, \'rich-calendar-time-btn-press\');" onmouseout="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onmouseup="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onclick="$(\''+this.id+'\').component.hideDateEditor(false);"><span>'+this.params.labels.cancel+'</span></div>'+
 					 '</td>';
 
 
@@ -966,6 +993,8 @@
 		
 		Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
 		
+		this.correctEditorButtons(editor, this.DATE_EDITOR_BUTTON_OK, this.DATE_EDITOR_BUTTON_CANCEL);
+		
 		this.isDateEditorLayoutCreated = true;
 	},	
 	
@@ -1976,13 +2005,14 @@
 	
 	showTimeEditor: function()
 	{
+		var editor;
 		if (this.timeType==0) return;
-		if (!this.isEditorCreated) this.createEditor();
-		if (!this.isTimeEditorLayoutCreated) this.createTimeEditorLayout();
+		if (!this.isEditorCreated) editor = this.createEditor();
+		else editor = $(this.EDITOR_ID);
+		if (!this.isTimeEditorLayoutCreated) this.createTimeEditorLayout(editor);
 		
 		$(this.TIME_EDITOR_LAYOUT_ID).show();
 		
-		var editor = $(this.EDITOR_ID);
 		var editor_shadow = $(this.EDITOR_SHADOW_ID);
 		
 		this.setEditorPosition($(this.id), editor, editor_shadow);
@@ -1990,6 +2020,7 @@
 		this.updateTimeEditor();
 		
 		editor_shadow.show();
+		
 		editor.show();
 		
 		Element.clonePosition(this.EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
@@ -2036,13 +2067,14 @@
 	
 	showDateEditor: function()
 	{
-		if (!this.isEditorCreated) this.createEditor();
-		if (!this.isDateEditorLayoutCreated) this.createDateEditorLayout();
+		var editor;
+		if (!this.isEditorCreated) editor = this.createEditor();
+		else editor = $(this.EDITOR_ID);
+		if (!this.isDateEditorLayoutCreated) this.createDateEditorLayout(editor);
 		else this.updateDateEditor();
 
 		$(this.DATE_EDITOR_LAYOUT_ID).show();
 		
-		var editor = $(this.EDITOR_ID);
 		var editor_shadow = $(this.EDITOR_SHADOW_ID);
 		
 		this.setEditorPosition($(this.id), editor, editor_shadow);
@@ -2200,17 +2232,23 @@
 				[
 					new E('td',{'class': 'rich-calendar-time-layout-ok'},
 					[
-						new E('div',{'class': 'rich-calendar-time-btn', 'style': 'float:right;', 'onmousedown': "Element.addClassName(this, 'rich-calendar-time-btn-press');", 'onmouseout': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onmouseup': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onclick': function(context){return "$('"+context.calendar.id+"').component.hideTimeEditor(true)";}},
+						new E('div',{'id': function(context){return context.calendar.TIME_EDITOR_BUTTON_OK}, 'class': 'rich-calendar-time-btn', 'style': 'float:right;', 'onmousedown': "Element.addClassName(this, 'rich-calendar-time-btn-press');", 'onmouseout': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onmouseup': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onclick': function(context){return "$('"+context.calendar.id+"').component.hideTimeEditor(true)";}},
 						[
-							new ET(function (context) { return context.controlLabels.ok; })
+							new E('span',{},
+							[
+								new ET(function (context) { return context.controlLabels.ok; })
+							])
 						])
 					])
 					,
 					new E('td',{'class': 'rich-calendar-time-layout-cancel'},
 					[
-						new E('div',{'class': 'rich-calendar-time-btn', 'style': 'float:left;', 'onmousedown': "Element.addClassName(this, 'rich-calendar-time-btn-press');", 'onmouseout': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onmouseup': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onclick': function(context){return "$('"+context.calendar.id+"').component.hideTimeEditor(false)";}},
+						new E('div',{'id': function(context){return context.calendar.TIME_EDITOR_BUTTON_CANCEL}, 'class': 'rich-calendar-time-btn', 'style': 'float:left;', 'onmousedown': "Element.addClassName(this, 'rich-calendar-time-btn-press');", 'onmouseout': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onmouseup': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onclick': function(context){return "$('"+context.calendar.id+"').component.hideTimeEditor(false)";}},
 						[
-							new ET(function (context) { return context.controlLabels.cancel; })
+							new E('span',{},
+							[
+								new ET(function (context) { return context.controlLabels.cancel; })
+							])
 						])
 					])
 				])




More information about the richfaces-svn-commits mailing list