js/datetime/calendar/calendar.js in rsence-pre-2.2.0.11 vs js/datetime/calendar/calendar.js in rsence-pre-2.2.0.12
- old
+ new
@@ -39,11 +39,12 @@
this.prevMonth();
}
},
/** = Description
- * Simple clickthrouct
+ * Simple clickthrough
+ **/
click: function(){
return false;
},
/** = Description
@@ -53,18 +54,20 @@
refreshLabel: function(){
if(!this['markupElemIds']){
return;
}
var _weekdays_localized = this.weekdaysLocalized(),
- _weekdays_width = Math.floor(this.rect.width/_weekdays_localized.length),
+ _availWidth = this.rect.width-2,
+ _weekdays_width = Math.floor(_availWidth/8),
+ _leftPlus = (_availWidth % 8)-1,
_weekdays_html = [],
i = 0,
_weekdays_html_pre = ['<div style="width:'+_weekdays_width+'px;left:','px">'],
_weekdays_html_suf = '</div>';
for(;i<_weekdays_localized.length;i++){
_weekdays_html.push([
- _weekdays_html_pre.join(i*_weekdays_width),
+ _weekdays_html_pre.join(i*_weekdays_width+_leftPlus),
_weekdays_localized[i],
_weekdays_html_suf
].join('') );
}
ELEM.setHTML(this.markupElemIds.label, _weekdays_html.join(''));
@@ -130,10 +133,90 @@
var _date = new Date( this.viewMonth[0], this.viewMonth[1]-1, 1 );
this.drawCalendar( new Date(_date.getTime() - this.tzMs(_date)) );
},
viewMonth: [1970,0],
+ monthMenu: function(){
+ if(!HPopupMenu){
+ console.log('HPopupMenu not included; cannot continue');
+ return;
+ }
+ var
+ _calendar = this,
+ _menu = HMiniMenu.extend({
+ refreshValue: function(){
+ this.base();
+ if( this._killAfterRefresh ){
+ this._killAfterRefresh = false;
+ var _menu = this;
+ _calendar.setValue( _calendar.setMonth( this.value ) );
+ if( _calendar.month() !== this.value ){
+ _calendar.setValue( _calendar.setMday( 30 ) );
+ _calendar.setValue( _calendar.setMonth( this.value ) );
+ }
+ if( _calendar.month() !== this.value ){
+ _calendar.setValue( _calendar.setMday( 29 ) );
+ _calendar.setValue( _calendar.setMonth( this.value ) );
+ }
+ if( _calendar.month() !== this.value ){
+ _calendar.setValue( _calendar.setMday( 28 ) );
+ _calendar.setValue( _calendar.setMonth( this.value ) );
+ }
+ COMM.Queue.push( function(){_menu.die();} );
+ }
+ },
+ _killAfterRefresh: false,
+ menuHide: function(){
+ this.base();
+ var _menu = this;
+ _menu._killAfterRefresh = true;
+ COMM.Queue.push( function(){_menu._killAfterRefresh && _menu.refreshValue();} );
+ return true;
+ }
+ }).nu( [24, 0, Math.round(this.rect.width*0.66)-24, 20 ], this, {
+ value: this.month(),
+ initialVisibility: true
+ } ),
+ _monthValues = [],
+ i = 0,
+ _monthNames = HLocale.dateTime.strings.monthsLong;
+ for(;i<_monthNames.length;i++){
+ _monthValues.push( [ i, _monthNames[i] ] );
+ }
+ _menu.setListItems( _monthValues );
+ },
+
+ yearMenu: function(){
+ var
+ _calendar = this,
+ _year = HNumericTextControl.extend({
+ refreshValue: function(){
+ this.base();
+ _calendar.setValue( _calendar.setYear( this.value ) );
+ },
+ textBlur: function(){
+ this.base();
+ COMM.Queue.push( function(){_year.die();} );
+ },
+ textEnter: function(){
+ this.base();
+ if( ( EVENT.status[ EVENT.keysDown ].indexOf( 13 ) !== -1 ) || ( EVENT.status[ EVENT.keysDown ].length === 0 ) ){
+ ELEM.get( this.markupElemIds.value ).blur();
+ }
+ }
+ }).nu(
+ HRect.nu(this.rect.width/2,0,this.rect.width-32,20),
+ this, {
+ value: this.year(),
+ minValue: -38399,
+ maxValue: 38400,
+ focusOnCreate: true,
+ refreshOnInput: false
+ }
+ );
+ },
+
/** = Description
* Draws the calendar with the date open given as input.
*
* = Parameters
* +_date+:: The date on which calendar UI is opened at.
@@ -144,14 +227,17 @@
var _calendarDateRange = this.calendarDateRange(_date),
_monthFirst = this.firstDateOfMonth(_date),
_monthLast = this.lastDateOfMonth(_date),
_firstDate = _calendarDateRange[0],
_lastDate = _calendarDateRange[1],
- _column_count = this.weekdaysLocalized().length,
- _column_width = Math.floor((this.rect.width-1)/_column_count),
- _row_height = Math.floor((this.rect.height-1-35)/6),
- _week_html_pre = ['<div class="calendar_weeks_week_row" style="width:'+(this.rect.width-3)+'px;height:'+_row_height+'px;top:','px">'],
+ _availWidth = this.rect.width-2,
+ _availHeight = this.rect.height-36,
+ _leftPlus = (_availWidth%8)-2,
+ _topPlus = _availHeight%6,
+ _column_width = Math.floor(_availWidth/8),
+ _row_height = Math.floor(_availHeight/6),
+ _week_html_pre = ['<div class="calendar_weeks_week_row" style="width:'+(_availWidth)+'px;height:'+_row_height+'px;top:','px">'],
_week_html_suf = '</div>',
_col_html_pre = ['<a href="javascript:void(HSystem.views['+this.viewId+'].setValue(','));" class="calendar_weeks_week_col','" style="width:'+_column_width+'px;height:'+_row_height+'px;line-height:'+_row_height+'px;left:','px">'],
_col_html_suf = '</a>',
_col_week_pre = '<div class="calendar_weeks_week_col_wk" style="width:'+_column_width+'px;height:'+_row_height+'px;line-height:'+_row_height+'px;left:0px">',
_col_week_suf = '</div>',
@@ -161,10 +247,11 @@
_row = 0,
_col,
_colMs,
_colSecs,
_colDate,
+ _monthYearHTML,
_extraCssClass;
for(; _row<6; _row++){
_week_html = [];
for(_col = 0; _col<8; _col++){
_colDate = new Date(_firstDate.getTime()+((_row*this.msWeek)+((_col-1)*this.msDay)));
@@ -188,25 +275,36 @@
_col_html_pre[0],
_colSecs,
_col_html_pre[1],
_extraCssClass,
_col_html_pre[2],
- (_col*_column_width),
+ (_col*_column_width+_leftPlus),
_col_html_pre[3],
this.mday(_colDate),
_col_html_suf
].join('');
}
_week_html.push(_col_html);
}
_month_html.push([
- _week_html_pre.join(_row*_row_height),
+ _week_html_pre.join(_row*_row_height+_topPlus),
_week_html.join(''),
_week_html_suf
].join('') );
}
- ELEM.setHTML(this.markupElemIds.value, _month_html.join(''));
- ELEM.setHTML(this.markupElemIds.state, this.monthName(_date)+' '+this.year(_date));
+ ELEM.setHTML( this.markupElemIds.value, _month_html.join('') );
+ _monthYearHTML = [
+ '<a href="javascript:void(HSystem.views[',
+ this.viewId,
+ '].monthMenu());">',
+ this.monthName(_date),
+ '</a> <a href="javascript:void(HSystem.views[',
+ this.viewId,
+ '].yearMenu());">',
+ this.year(_date),
+ '</a>'
+ ].join('');
+ ELEM.setHTML( this.markupElemIds.state, _monthYearHTML );
this.viewMonth = [_monthFirst.getUTCFullYear(),_monthFirst.getUTCMonth()];
}
});
HCalendar.implement(HDateTime);