js/datetime/calendar/calendar.coffee in rsence-pre-2.2.0.38 vs js/datetime/calendar/calendar.coffee in rsence-pre-2.2.2.0

- old
+ new

@@ -9,19 +9,20 @@ #### = Description ## Use HCalendar to display a month calendar that displays days as columns ## and weeks as rows. Its value is a date/time number specified in seconds ## since or before epoch (1970-01-01 00:00:00 UTC). #### -HCalendar = HControl.extend( +HCalendar = HControl.extend componentName: 'calendar' + markupElemNames: [ 'control', 'state', 'label', 'value', 'prevMonth', 'nextMonth' ] ## Disable the mouseWheel event to prevent prev/next -month switching with ## the mouse wheel or equivalent content-scrolling user interface gesture defaultEvents: mouseWheel: true - click: true + # click: true ## Calls HCalendar#nextMonth or HCalendar#prevMonth based on delta change ## of the mouseWheel event mouseWheel: (_delta)-> if _delta < 0 @@ -31,10 +32,19 @@ ## Simple click-through for the themed hyperlinks click: -> false + drawSubviews: -> + _this = @ + Event.observe( @elemOfPart( 'prevMonth' ), 'click', -> + _this.prevMonth() + ) + Event.observe( @elemOfPart( 'nextMonth' ), 'click', -> + _this.nextMonth() + ) + ## Returns an array of week day names starting with the short name of the word "week". ## The default locale returns: ['Wk','Mon','Tue','Wed','Thu','Fri','Sat','Sun'] ## See HLocale for more details localizedDays: -> _str = HLocale.dateTime.strings @@ -242,10 +252,11 @@ _colWidth = Math.floor( _availWidth / 8 ) _rowHeight = Math.floor( _availHeight / 6 ) _parentElem = @markupElemIds.value ELEM.setStyle( _parentElem, 'visibility', 'hidden', true ) _elems = [] + _this = @ for _row in [0..5] _weekElem = ELEM.make( _parentElem ) _elems.push( _weekElem ) ELEM.addClassName( _weekElem, 'calendar_weeks_week_row' ) ELEM.setStyle( _weekElem, 'width', _availWidth+'px' ) @@ -274,34 +285,39 @@ ELEM.addClassName( _colElem, 'calendar_weeks_week_col_sel' ) else if _colDate < _monthFirst or _colDate > _monthLast ELEM.addClassName( _colElem, 'calendar_weeks_week_col_no' ) else ELEM.addClassName( _colElem, 'calendar_weeks_week_col_yes' ) - ELEM.setAttr( _colElem, 'href', "javascript:HSystem.views[#{@viewId}].setValue(#{_colSecs})" ) + ELEM.setAttr( _colElem, '_colSecs', _colSecs ) + Event.observe( ELEM.get( _colElem ), 'click', -> + _this.setValue( @_colSecs ) + ) + # ELEM.setAttr( _colElem, 'href', "javascript:HSystem.views[#{@viewId}].setValue(#{_colSecs})" ) _left = (_col*_colWidth+_leftPlus) ELEM.setStyle( _colElem, 'left', _left+'px' ) ELEM.setStyle( _colElem, 'width', (_colWidth-1)+'px' ) ELEM.setStyle( _colElem, 'height', (_rowHeight-1)+'px' ) ELEM.setStyle( _colElem, 'line-height', _rowHeight+'px' ) ELEM.setHTML( _colElem, @mday( _colDate ) ) ELEM.setStyle( _parentElem, 'visibility', 'inherit' ) _stateElem = @markupElemIds.state - @_monthMenu = ELEM.make( _stateElem, 'a' ) + @_monthMenu = ELEM.make( _stateElem, 'span' )#, 'a' ) _elems.push( @_monthMenu ) - ELEM.setAttr( @_monthMenu, 'href', "javascript:HSystem.views[#{@viewId}].monthMenu()" ) + # ELEM.setAttr( @_monthMenu, 'href', "javascript:HSystem.views[#{@viewId}].monthMenu()" ) + Event.observe( ELEM.get( @_monthMenu ), 'click', ( -> _this.monthMenu() ), false ) ELEM.setHTML( @_monthMenu, @monthName( _date ) ) _spacer = ELEM.make( _stateElem, 'span' ) _elems.push( _spacer ) ELEM.setHTML( _spacer, '&nbsp;' ) - @_yearMenu = ELEM.make( _stateElem, 'a' ) + @_yearMenu = ELEM.make( _stateElem, 'span' )#, 'a' ) _elems.push( @_yearMenu ) - ELEM.setAttr( @_yearMenu, 'href', "javascript:HSystem.views[#{@viewId}].yearMenu()" ) + Event.observe( ELEM.get( @_yearMenu ), 'click', ( -> _this.yearMenu() ), false ) + # ELEM.setAttr( @_yearMenu, 'href', "javascript:HSystem.views[#{@viewId}].yearMenu()" ) ELEM.setHTML( @_yearMenu, @year( _date ) ) @viewMonth = [ _monthFirst.getUTCFullYear(), _monthFirst.getUTCMonth() ] @_drawCalendarElems = _elems -) HCalendar.implement( HDateTime )