rsence-pre 2.2.0.29 → 2.2.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/js/core/elem/elem.coffee +22 -0
- data/js/datetime/calendar/calendar.coffee +307 -0
- data/lib/rsence/pluginmanager.rb +9 -2
- data/lib/rsence/transporter.rb +1 -0
- data/plugins/client_pkg/lib/client_pkg_build.rb +2 -0
- metadata +6 -6
- data/js/datetime/calendar/calendar.js +0 -310
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.0.
|
1
|
+
2.2.0.30.pre
|
data/js/core/elem/elem.coffee
CHANGED
@@ -187,6 +187,20 @@ ELEM = HClass.extend({
|
|
187
187
|
_elem = @_elements[_id]
|
188
188
|
[ _elem.offsetWidth, _elem.offsetHeight ]
|
189
189
|
|
190
|
+
###
|
191
|
+
Returns the position of the element as a [ x, y ] tuple
|
192
|
+
###
|
193
|
+
getPosition: (_id)->
|
194
|
+
_elem = @_elements[_id]
|
195
|
+
[ _elem.offsetLeft, _elem.offsetTop ]
|
196
|
+
|
197
|
+
###
|
198
|
+
Returns the scroll position of the element as a [ x, y ] tuple
|
199
|
+
###
|
200
|
+
getScrollPosition: (_id)->
|
201
|
+
_elem = @_elements[_id]
|
202
|
+
[ _elem.scrollLeft, _elem.scrollTop ]
|
203
|
+
|
190
204
|
###
|
191
205
|
Returns the scroll size of the element as a [ width, height ] tuple
|
192
206
|
###
|
@@ -266,6 +280,14 @@ ELEM = HClass.extend({
|
|
266
280
|
@setStyle( _id, 'height', h+'px' )
|
267
281
|
null
|
268
282
|
|
283
|
+
###
|
284
|
+
Gets box coordinates [ x, y, width, height )
|
285
|
+
###
|
286
|
+
getBoxCoords: (_id)->
|
287
|
+
[ x, y ] = @getPosition( _id )
|
288
|
+
[ w, h ] = @getSize( _id )
|
289
|
+
[ x, y, w, h ]
|
290
|
+
|
269
291
|
###
|
270
292
|
Computes extra size (padding and border size) of element
|
271
293
|
###
|
@@ -0,0 +1,307 @@
|
|
1
|
+
## RSence
|
2
|
+
# Copyright 2009-2011 Riassence Inc.
|
3
|
+
# http://riassence.com/
|
4
|
+
#
|
5
|
+
# You should have received a copy of the GNU General Public License along
|
6
|
+
# with this software package. If not, contact licensing@riassence.com
|
7
|
+
##
|
8
|
+
|
9
|
+
#### = Description
|
10
|
+
## Use HCalendar to display a month calendar that displays days as columns
|
11
|
+
## and weeks as rows. Its value is a date/time number specified in seconds
|
12
|
+
## since or before epoch (1970-01-01 00:00:00 UTC).
|
13
|
+
####
|
14
|
+
HCalendar = HControl.extend(
|
15
|
+
|
16
|
+
componentName: 'calendar'
|
17
|
+
|
18
|
+
## Disable the mouseWheel event to prevent prev/next -month switching with
|
19
|
+
## the mouse wheel or equivalent content-scrolling user interface gesture
|
20
|
+
defaultEvents:
|
21
|
+
mouseWheel: true
|
22
|
+
click: true
|
23
|
+
|
24
|
+
## Calls HCalendar#nextMonth or HCalendar#prevMonth based on delta change
|
25
|
+
## of the mouseWheel event
|
26
|
+
mouseWheel: (_delta)->
|
27
|
+
if _delta < 0
|
28
|
+
@nextMonth()
|
29
|
+
else
|
30
|
+
@prevMonth()
|
31
|
+
|
32
|
+
## Simple click-through for the themed hyperlinks
|
33
|
+
click: ->
|
34
|
+
false
|
35
|
+
|
36
|
+
## Returns an array of week day names starting with the short name of the word "week".
|
37
|
+
## The default locale returns: ['Wk','Mon','Tue','Wed','Thu','Fri','Sat','Sun']
|
38
|
+
## See HLocale for more details
|
39
|
+
localizedDays: ->
|
40
|
+
_str = HLocale.dateTime.strings
|
41
|
+
_arr = HVM.clone( _str.weekDaysShort )
|
42
|
+
_arr.push( _arr.shift() )
|
43
|
+
_arr.unshift( _str.weekShort )
|
44
|
+
_arr
|
45
|
+
|
46
|
+
_destroyWeekDayElems: ->
|
47
|
+
if @_weekDayElems?
|
48
|
+
for _elemId in @_weekDayElems
|
49
|
+
ELEM.del( _elemId )
|
50
|
+
@_weekDayElems = null
|
51
|
+
|
52
|
+
## Refreshes the week days header
|
53
|
+
refreshWeekDays: ->
|
54
|
+
@_destroyWeekDayElems()
|
55
|
+
_dayNames = @localizedDays()
|
56
|
+
_availWidth = @rect.width-2
|
57
|
+
_dayWidth = Math.floor( _availWidth/8 )
|
58
|
+
_leftOffset = ( _availWidth % 8 ) - 1
|
59
|
+
_parentElem = @markupElemIds.label
|
60
|
+
_dayElems = []
|
61
|
+
for _dayName, i in _dayNames
|
62
|
+
_dayElem = ELEM.make( _parentElem )
|
63
|
+
ELEM.setHTML( _dayElem, _dayName )
|
64
|
+
ELEM.setStyle( _dayElem, 'width', _dayWidth+'px' )
|
65
|
+
_left = i * _dayWidth + _leftOffset
|
66
|
+
ELEM.setStyle( _dayElem, 'left', _left+'px' )
|
67
|
+
@_weekDayElems = _dayElems
|
68
|
+
|
69
|
+
## Calls #refreshWeekDays when theme is applied
|
70
|
+
refreshLabel: ->
|
71
|
+
@refreshWeekDays() if @markupElemIds? and not @_weekDayElems?
|
72
|
+
|
73
|
+
## Calculates the first and last week of the month of the _date
|
74
|
+
##
|
75
|
+
## Params:
|
76
|
+
## - _date: A Date instance to check date range from
|
77
|
+
##
|
78
|
+
## Returns:
|
79
|
+
## [Object]: {
|
80
|
+
## week: {
|
81
|
+
## firstDate: [Date]
|
82
|
+
## lastDate: [Date]
|
83
|
+
## firstNum: [Number]
|
84
|
+
## lastNum: [Number]
|
85
|
+
## count: [Number]
|
86
|
+
## }
|
87
|
+
## month: {
|
88
|
+
## firstDate: [Date]
|
89
|
+
## lastDate: [Date]
|
90
|
+
## }
|
91
|
+
## }
|
92
|
+
calendarDateRange: (_date)->
|
93
|
+
_monthFirst = @firstDateOfMonth( _date )
|
94
|
+
_monthLast = @lastDateOfMonth( _date )
|
95
|
+
_weekFirst = @firstDateOfWeek( _monthFirst )
|
96
|
+
_weekLast = @lastDateOfWeek( _monthLast )
|
97
|
+
_firstWeekNum = @week( _weekFirst )
|
98
|
+
_lastWeekNum = @week( _weekLast )
|
99
|
+
_weeks = _firstWeekNum - _lastWeekNum
|
100
|
+
if _weeks == 5
|
101
|
+
if _weekFirst.getDate() == 1
|
102
|
+
_weekFirst = new Date( _weekFirst.getTime() - @msWeek )
|
103
|
+
else
|
104
|
+
_weekLast = new Date( _weekLast.getTime() + @msWeek )
|
105
|
+
else if _weeks == 4
|
106
|
+
_weekFirst = new Date( _weekFirst.getTime() - @msWeek )
|
107
|
+
return {
|
108
|
+
week: {
|
109
|
+
firstDate: _weekFirst
|
110
|
+
lastDate: _weekLast
|
111
|
+
firstNum: _firstWeekNum
|
112
|
+
lastNum: _lastWeekNum
|
113
|
+
count: _weeks
|
114
|
+
}
|
115
|
+
month: {
|
116
|
+
firstDate: _monthFirst
|
117
|
+
lastDate: _monthLast
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
## Calls #drawCalendar when the value is changed
|
122
|
+
refreshValue: ->
|
123
|
+
@drawCalendar( @date() )
|
124
|
+
|
125
|
+
## Draws the next month
|
126
|
+
nextMonth: ->
|
127
|
+
_dateNext = new Date( @viewMonth[0], @viewMonth[1]+1, 1 )
|
128
|
+
_dateMs = _dateNext.getTime() - @tzMs(_dateNext)
|
129
|
+
@drawCalendar( new Date(_dateMs) )
|
130
|
+
|
131
|
+
## Drows the prev month
|
132
|
+
prevMonth: ->
|
133
|
+
_datePrev = new Date( @viewMonth[0], @viewMonth[1]-1, 1 )
|
134
|
+
_dateMs = _datePrev.getTime() - @tzMs(_datePrev)
|
135
|
+
@drawCalendar( new Date(_dateMs) )
|
136
|
+
|
137
|
+
## Stores the currently viewed year and month
|
138
|
+
viewMonth: [ 1970, 0 ]
|
139
|
+
|
140
|
+
## Shows a pulldown menu for month selection
|
141
|
+
monthMenu: ->
|
142
|
+
return unless HMiniMenu?
|
143
|
+
_calendar = this
|
144
|
+
_monthValues = []
|
145
|
+
for _monthName, i in HLocale.dateTime.strings.monthsLong
|
146
|
+
_monthValues.push( [ i, _monthName ] )
|
147
|
+
_rect = ELEM.getBoxCoords( @_monthMenu )
|
148
|
+
_rect[0] += 20
|
149
|
+
_rect[2] = 80 if _rect[2] < 80
|
150
|
+
HMiniMenu.extend(
|
151
|
+
_killAfterRefresh: false
|
152
|
+
menuHide: ->
|
153
|
+
@base()
|
154
|
+
_menu = @
|
155
|
+
_menu._killAfterRefresh = true
|
156
|
+
COMM.Queue.push( ->
|
157
|
+
if _menu._killAfterRefresh
|
158
|
+
_menu.refreshValue()
|
159
|
+
)
|
160
|
+
return true;
|
161
|
+
refreshValue: ->
|
162
|
+
@base()
|
163
|
+
if @_killAfterRefresh
|
164
|
+
@_killAfterRefresh = false
|
165
|
+
_calendar.setValue( _calendar.setMonth( @value ) )
|
166
|
+
if _calendar.month() != @value
|
167
|
+
_calendar.setValue( _calendar.setMday( 30 ) )
|
168
|
+
_calendar.setValue( _calendar.setMonth( this.value ) )
|
169
|
+
if _calendar.month() != @value
|
170
|
+
_calendar.setValue( _calendar.setMday( 29 ) )
|
171
|
+
_calendar.setValue( _calendar.setMonth( @value ) )
|
172
|
+
if _calendar.month() != this.value
|
173
|
+
_calendar.setValue( _calendar.setMday( 28 ) )
|
174
|
+
_calendar.setValue( _calendar.setMonth( @value ) )
|
175
|
+
_menu = this
|
176
|
+
COMM.Queue.push( ->
|
177
|
+
_menu.die()
|
178
|
+
)
|
179
|
+
).new( _rect, @,
|
180
|
+
value: @month()
|
181
|
+
initialVisibility: true
|
182
|
+
).setListItems( _monthValues )
|
183
|
+
|
184
|
+
## Shows a text field for year selection
|
185
|
+
yearMenu: ->
|
186
|
+
_calendar = @
|
187
|
+
_rect = ELEM.getBoxCoords( @_yearMenu )
|
188
|
+
_rect[0] += 20
|
189
|
+
_rect[2] = 40 if _rect[2] < 40
|
190
|
+
_rect[3] = 20
|
191
|
+
HNumericTextControl.extend(
|
192
|
+
refreshValue: ->
|
193
|
+
@base()
|
194
|
+
_calendar.setValue( _calendar.setYear( @value ) )
|
195
|
+
textBlur: ->
|
196
|
+
@base()
|
197
|
+
_year = this
|
198
|
+
COMM.Queue.push( ->
|
199
|
+
_year.die() if _year.markupElemIds?
|
200
|
+
)
|
201
|
+
textEnter: ->
|
202
|
+
@base()
|
203
|
+
_returnKeyPressed = EVENT.status[ EVENT.keysDown ].indexOf( 13 ) != -1
|
204
|
+
_noKeysPressed = EVENT.status[ EVENT.keysDown ].length == 0
|
205
|
+
if _returnKeyPressed or _noKeysPressed
|
206
|
+
ELEM.get( @markupElemIds.value ).blur()
|
207
|
+
).new( _rect, @,
|
208
|
+
value: @year()
|
209
|
+
minValue: -38399
|
210
|
+
maxValue: 38400
|
211
|
+
focusOnCreate: true
|
212
|
+
refreshOnInput: false
|
213
|
+
)
|
214
|
+
|
215
|
+
_destroyCalendarElems: ->
|
216
|
+
if @_drawCalendarElems?
|
217
|
+
for _elemId in @_drawCalendarElems
|
218
|
+
ELEM.del( _elemId )
|
219
|
+
@_drawCalendarElems = null
|
220
|
+
|
221
|
+
die: ->
|
222
|
+
@_destroyWeekDayElems()
|
223
|
+
@_destroyCalendarElems()
|
224
|
+
@base()
|
225
|
+
|
226
|
+
## Draws the calendar with the date open given as input.
|
227
|
+
##
|
228
|
+
## Params:
|
229
|
+
## - _date: The date on which calendar UI is opened at.
|
230
|
+
drawCalendar: (_date)->
|
231
|
+
@_destroyCalendarElems()
|
232
|
+
_date = @date() unless ( _date instanceof Date )
|
233
|
+
_calendarDateRange = @calendarDateRange( _date )
|
234
|
+
_monthFirst = _calendarDateRange.month.firstDate
|
235
|
+
_monthLast = _calendarDateRange.month.lastDate
|
236
|
+
_firstDate = _calendarDateRange.week.firstDate
|
237
|
+
_lastDate = _calendarDateRange.week.lastDate
|
238
|
+
_availWidth = @rect.width - 2
|
239
|
+
_availHeight = @rect.height - 36
|
240
|
+
_leftPlus = ( _availWidth % 8 ) - 2
|
241
|
+
_topPlus = ( _availHeight % 6 )
|
242
|
+
_colWidth = Math.floor( _availWidth / 8 )
|
243
|
+
_rowHeight = Math.floor( _availHeight / 6 )
|
244
|
+
_parentElem = @markupElemIds.value
|
245
|
+
ELEM.setStyle( _parentElem, 'visibility', 'hidden', true )
|
246
|
+
_elems = []
|
247
|
+
for _row in [0..5]
|
248
|
+
_weekElem = ELEM.make( _parentElem )
|
249
|
+
_elems.push( _weekElem )
|
250
|
+
ELEM.addClassName( _weekElem, 'calendar_weeks_week_row' )
|
251
|
+
ELEM.setStyle( _weekElem, 'width', _availWidth+'px' )
|
252
|
+
ELEM.setStyle( _weekElem, 'height', _availHeight+'px' )
|
253
|
+
_top = (_row*_rowHeight)+_topPlus
|
254
|
+
ELEM.setStyle( _weekElem, 'top', _top+'px' )
|
255
|
+
for _col in [0..7]
|
256
|
+
if _col == 0
|
257
|
+
_colDate = new Date( _firstDate.getTime() + (_row*@msWeek) + (_col*@msDay) )
|
258
|
+
_colMs = _colDate.getTime()
|
259
|
+
_colElem = ELEM.make( _weekElem )
|
260
|
+
_elems.push( _colElem )
|
261
|
+
ELEM.addClassName( _colElem, 'calendar_weeks_week_col_wk' )
|
262
|
+
ELEM.setStyle( _colElem, 'left', '0px' )
|
263
|
+
ELEM.setStyle( _colElem, 'width', _colWidth+'px' )
|
264
|
+
ELEM.setStyle( _colElem, 'height', _rowHeight+'px' )
|
265
|
+
ELEM.setStyle( _colElem, 'line-height', _rowHeight+'px' )
|
266
|
+
ELEM.setHTML( _colElem, @week( _colDate ) )
|
267
|
+
else
|
268
|
+
_colDate = new Date( _firstDate.getTime() + (_row*@msWeek) + ((_col-1)*@msDay) )
|
269
|
+
_colMs = _colDate.getTime()
|
270
|
+
_colSecs = Math.round( _colMs/1000 )
|
271
|
+
_colElem = ELEM.make( _weekElem, 'a' )
|
272
|
+
_elems.push( _colElem )
|
273
|
+
if @value >= _colSecs and @value < _colSecs+86400
|
274
|
+
ELEM.addClassName( _colElem, 'calendar_weeks_week_col_sel' )
|
275
|
+
else if _colDate < _monthFirst or _colDate > _monthLast
|
276
|
+
ELEM.addClassName( _colElem, 'calendar_weeks_week_col_no' )
|
277
|
+
else
|
278
|
+
ELEM.addClassName( _colElem, 'calendar_weeks_week_col_yes' )
|
279
|
+
ELEM.setAttr( _colElem, 'href', "javascript:HSystem.views[#{@viewId}].setValue(#{_colMs})" )
|
280
|
+
_left = (_col*_colWidth+_leftPlus)
|
281
|
+
ELEM.setStyle( _colElem, 'left', _left+'px' )
|
282
|
+
ELEM.setStyle( _colElem, 'width', (_colWidth-1)+'px' )
|
283
|
+
ELEM.setStyle( _colElem, 'height', (_rowHeight-1)+'px' )
|
284
|
+
ELEM.setStyle( _colElem, 'line-height', _rowHeight+'px' )
|
285
|
+
ELEM.setHTML( _colElem, @mday( _colDate ) )
|
286
|
+
ELEM.setStyle( _parentElem, 'visibility', 'inherit' )
|
287
|
+
_stateElem = @markupElemIds.state
|
288
|
+
|
289
|
+
@_monthMenu = ELEM.make( _stateElem, 'a' )
|
290
|
+
_elems.push( @_monthMenu )
|
291
|
+
ELEM.setAttr( @_monthMenu, 'href', "javascript:HSystem.views[#{@viewId}].monthMenu()" )
|
292
|
+
ELEM.setHTML( @_monthMenu, @monthName( _date ) )
|
293
|
+
|
294
|
+
_spacer = ELEM.make( _stateElem, 'span' )
|
295
|
+
_elems.push( _spacer )
|
296
|
+
ELEM.setHTML( _spacer, ' ' )
|
297
|
+
|
298
|
+
@_yearMenu = ELEM.make( _stateElem, 'a' )
|
299
|
+
_elems.push( @_yearMenu )
|
300
|
+
ELEM.setAttr( @_yearMenu, 'href', "javascript:HSystem.views[#{@viewId}].yearMenu()" )
|
301
|
+
ELEM.setHTML( @_yearMenu, @year( _date ) )
|
302
|
+
|
303
|
+
@viewMonth = [ _monthFirst.getUTCFullYear(), _monthFirst.getUTCMonth() ]
|
304
|
+
@_drawCalendarElems = _elems
|
305
|
+
)
|
306
|
+
|
307
|
+
HCalendar.implement( HDateTime )
|
data/lib/rsence/pluginmanager.rb
CHANGED
@@ -642,12 +642,19 @@ module RSence
|
|
642
642
|
end
|
643
643
|
|
644
644
|
attr_reader :transporter
|
645
|
-
attr_reader :sessions
|
646
645
|
attr_reader :autoreload
|
647
646
|
attr_reader :name_prefix
|
648
647
|
attr_reader :plugin_paths
|
649
648
|
attr_reader :parent_manager
|
650
649
|
|
650
|
+
def sessions
|
651
|
+
warn "no sessions" unless @sessions
|
652
|
+
@sessions
|
653
|
+
end
|
654
|
+
def sessions=(ses_manager)
|
655
|
+
@sessions = ses_manager
|
656
|
+
end
|
657
|
+
|
651
658
|
@@pluginmanager_id = 0
|
652
659
|
# Initialize with a list of directories as plugin_paths.
|
653
660
|
# It's an array containing all plugin directories to scan.
|
@@ -671,7 +678,7 @@ module RSence
|
|
671
678
|
|
672
679
|
if options[:transporter]
|
673
680
|
@transporter = options[:transporter]
|
674
|
-
|
681
|
+
#@sessions = options[:transporter].sessions
|
675
682
|
end
|
676
683
|
|
677
684
|
@autoreload = options[:autoreload]
|
data/lib/rsence/transporter.rb
CHANGED
@@ -53,6 +53,7 @@ module RSence
|
|
53
53
|
@valuemanager = ValueManager.new
|
54
54
|
RSence.value_manager = @valuemanager
|
55
55
|
@sessions = SessionManager.new( self )
|
56
|
+
@plugins.sessions = @sessions
|
56
57
|
RSence.session_manager = @sessions
|
57
58
|
if RSence.config[:session_conf][:reset_sessions]
|
58
59
|
puts "Resetting all sessions..."
|
@@ -276,6 +276,8 @@ class ClientPkgBuild
|
|
276
276
|
rescue CoffeeScript::CompilationError
|
277
277
|
warn "Invalid CoffeeScript supplied:\n----\n#{src}----\n"
|
278
278
|
js = "function(){console.log('ERROR; invalid CoffeeScript supplied: #{src.to_json}');}"
|
279
|
+
rescue
|
280
|
+
js = "function(){console.log('ERROR; CoffeeScript compilation failed: #{src.to_json}');}"
|
279
281
|
end
|
280
282
|
js = squeeze( js )
|
281
283
|
return js[1..-3] if js.start_with?('(') and js.end_with?(');')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsence-pre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.0.
|
4
|
+
version: 2.2.0.30
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,19 +10,19 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsence-deps
|
17
|
-
requirement: &
|
17
|
+
requirement: &70312415196520 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - =
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '966'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70312415196520
|
26
26
|
description: ! 'RSence is a different and unique development model and software frameworks
|
27
27
|
designed first-hand for real-time web applications. RSence consists of separate,
|
28
28
|
but tigtly integrated data- and user interface frameworks.
|
@@ -271,7 +271,7 @@ files:
|
|
271
271
|
- js/core/iefix/iefix.js
|
272
272
|
- js/core/rsence_ns/rsence_ns.coffee
|
273
273
|
- js/core/rsence_ns/rsence_ns.js
|
274
|
-
- js/datetime/calendar/calendar.
|
274
|
+
- js/datetime/calendar/calendar.coffee
|
275
275
|
- js/datetime/calendar/themes/default/calendar.css
|
276
276
|
- js/datetime/calendar/themes/default/calendar.html
|
277
277
|
- js/datetime/calendar/themes/default/calendar_arrows-ie6.gif
|
@@ -1,310 +0,0 @@
|
|
1
|
-
/* RSence
|
2
|
-
* Copyright 2009 Riassence Inc.
|
3
|
-
* http://riassence.com/
|
4
|
-
*
|
5
|
-
* You should have received a copy of the GNU General Public License along
|
6
|
-
* with this software package. If not, contact licensing@riassence.com
|
7
|
-
*/
|
8
|
-
|
9
|
-
/*** = Description
|
10
|
-
** Use HCalendar to display a month calendar that displays days as columns
|
11
|
-
** and weeks as rows. Its value is a date/time number specified in seconds
|
12
|
-
** since or before epoch (1970-01-01 00:00:00 UTC).
|
13
|
-
***/
|
14
|
-
var//RSence.DateTime
|
15
|
-
HCalendar = HControl.extend({
|
16
|
-
componentName: 'calendar',
|
17
|
-
weekdaysLocalized: function(){
|
18
|
-
var
|
19
|
-
_localeStrings = HLocale.dateTime.strings,
|
20
|
-
_outputArray = COMM.Values.clone( _localeStrings.weekDaysShort );
|
21
|
-
_outputArray.push( _outputArray.shift() );
|
22
|
-
_outputArray.unshift( _localeStrings.weekShort );
|
23
|
-
return _outputArray;
|
24
|
-
},//['Wk','Mon','Tue','Wed','Thu','Fri','Sat','Sun'],
|
25
|
-
defaultEvents: {
|
26
|
-
mouseWheel: true,
|
27
|
-
click: true
|
28
|
-
},
|
29
|
-
/** = Description
|
30
|
-
* Calls HCalendar#nextMonth or HCalendar#prevMonth based on delta
|
31
|
-
* of mouseWheel.
|
32
|
-
*
|
33
|
-
**/
|
34
|
-
mouseWheel: function(_delta){
|
35
|
-
if ( _delta < 0 ) {
|
36
|
-
this.nextMonth();
|
37
|
-
}
|
38
|
-
else {
|
39
|
-
this.prevMonth();
|
40
|
-
}
|
41
|
-
},
|
42
|
-
|
43
|
-
/** = Description
|
44
|
-
* Simple clickthrough
|
45
|
-
**/
|
46
|
-
click: function(){
|
47
|
-
return false;
|
48
|
-
},
|
49
|
-
|
50
|
-
/** = Description
|
51
|
-
* Refreshes weekdays.
|
52
|
-
*
|
53
|
-
**/
|
54
|
-
refreshLabel: function(){
|
55
|
-
if(!this['markupElemIds']){
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
var _weekdays_localized = this.weekdaysLocalized(),
|
59
|
-
_availWidth = this.rect.width-2,
|
60
|
-
_weekdays_width = Math.floor(_availWidth/8),
|
61
|
-
_leftPlus = (_availWidth % 8)-1,
|
62
|
-
_weekdays_html = [],
|
63
|
-
i = 0,
|
64
|
-
_weekdays_html_pre = ['<div style="width:'+_weekdays_width+'px;left:','px">'],
|
65
|
-
_weekdays_html_suf = '</div>';
|
66
|
-
for(;i<_weekdays_localized.length;i++){
|
67
|
-
_weekdays_html.push([
|
68
|
-
_weekdays_html_pre.join(i*_weekdays_width+_leftPlus),
|
69
|
-
_weekdays_localized[i],
|
70
|
-
_weekdays_html_suf
|
71
|
-
].join('') );
|
72
|
-
}
|
73
|
-
ELEM.setHTML(this.markupElemIds.label, _weekdays_html.join(''));
|
74
|
-
},
|
75
|
-
|
76
|
-
/** = Description
|
77
|
-
* Checks the date range for the month which the date given as input belongs.
|
78
|
-
*
|
79
|
-
* = Parameters
|
80
|
-
* +_date+:: A Date instance to check date range from
|
81
|
-
*
|
82
|
-
* = Returns
|
83
|
-
* Array of [0] first week's date and [1] last week's date.
|
84
|
-
*
|
85
|
-
**/
|
86
|
-
calendarDateRange: function(_date){
|
87
|
-
var _date_begin = this.firstDateOfMonth(_date),
|
88
|
-
_date_end = this.lastDateOfMonth(_date),
|
89
|
-
_firstWeeksDate = this.firstDateOfWeek(_date_begin),
|
90
|
-
_lastWeeksDate = this.lastDateOfWeek(_date_end),
|
91
|
-
_week_begin = this.week(_firstWeeksDate),
|
92
|
-
_week_end = this.week(_lastWeeksDate),
|
93
|
-
_weeks = _week_end-_week_begin;
|
94
|
-
if((_weeks===5) && (_firstWeeksDate.getDate() !== 1)){
|
95
|
-
_lastWeeksDate = new Date( _lastWeeksDate.getTime() + this.msWeek );
|
96
|
-
}
|
97
|
-
else if((_weeks===5) && (_firstWeeksDate.getDate() === 1)){
|
98
|
-
_firstWeeksDate = new Date( _firstWeeksDate.getTime() - this.msWeek );
|
99
|
-
}
|
100
|
-
else if(_weeks===4){
|
101
|
-
_firstWeeksDate = new Date( _firstWeeksDate.getTime() - this.msWeek );
|
102
|
-
_lastWeeksDate = new Date( _lastWeeksDate.getTime() + this.msWeek );
|
103
|
-
}
|
104
|
-
return [
|
105
|
-
_firstWeeksDate,
|
106
|
-
_lastWeeksDate
|
107
|
-
];
|
108
|
-
},
|
109
|
-
|
110
|
-
/** = Description
|
111
|
-
* Refreshes the calendar.
|
112
|
-
*
|
113
|
-
**/
|
114
|
-
refreshValue: function(){
|
115
|
-
var _date = this.date();
|
116
|
-
this.drawCalendar(_date);
|
117
|
-
},
|
118
|
-
|
119
|
-
/** = Description
|
120
|
-
* Draws the next month on calendar.
|
121
|
-
*
|
122
|
-
**/
|
123
|
-
nextMonth: function(){
|
124
|
-
var _date = new Date( this.viewMonth[0], this.viewMonth[1]+1, 1 );
|
125
|
-
this.drawCalendar( new Date(_date.getTime() - this.tzMs(_date)) );
|
126
|
-
},
|
127
|
-
|
128
|
-
/** = Description
|
129
|
-
* Draws the previous month on calendar.
|
130
|
-
*
|
131
|
-
**/
|
132
|
-
prevMonth: function(){
|
133
|
-
var _date = new Date( this.viewMonth[0], this.viewMonth[1]-1, 1 );
|
134
|
-
this.drawCalendar( new Date(_date.getTime() - this.tzMs(_date)) );
|
135
|
-
},
|
136
|
-
viewMonth: [1970,0],
|
137
|
-
|
138
|
-
monthMenu: function(){
|
139
|
-
if(!HPopupMenu){
|
140
|
-
console.log('HPopupMenu not included; cannot continue');
|
141
|
-
return;
|
142
|
-
}
|
143
|
-
var
|
144
|
-
_calendar = this,
|
145
|
-
_menu = HMiniMenu.extend({
|
146
|
-
refreshValue: function(){
|
147
|
-
this.base();
|
148
|
-
if( this._killAfterRefresh ){
|
149
|
-
this._killAfterRefresh = false;
|
150
|
-
var _menu = this;
|
151
|
-
_calendar.setValue( _calendar.setMonth( this.value ) );
|
152
|
-
if( _calendar.month() !== this.value ){
|
153
|
-
_calendar.setValue( _calendar.setMday( 30 ) );
|
154
|
-
_calendar.setValue( _calendar.setMonth( this.value ) );
|
155
|
-
}
|
156
|
-
if( _calendar.month() !== this.value ){
|
157
|
-
_calendar.setValue( _calendar.setMday( 29 ) );
|
158
|
-
_calendar.setValue( _calendar.setMonth( this.value ) );
|
159
|
-
}
|
160
|
-
if( _calendar.month() !== this.value ){
|
161
|
-
_calendar.setValue( _calendar.setMday( 28 ) );
|
162
|
-
_calendar.setValue( _calendar.setMonth( this.value ) );
|
163
|
-
}
|
164
|
-
COMM.Queue.push( function(){_menu.die();} );
|
165
|
-
}
|
166
|
-
},
|
167
|
-
_killAfterRefresh: false,
|
168
|
-
menuHide: function(){
|
169
|
-
this.base();
|
170
|
-
var _menu = this;
|
171
|
-
_menu._killAfterRefresh = true;
|
172
|
-
COMM.Queue.push( function(){_menu._killAfterRefresh && _menu.refreshValue();} );
|
173
|
-
return true;
|
174
|
-
}
|
175
|
-
}).nu( [24, 0, Math.round(this.rect.width*0.66)-24, 20 ], this, {
|
176
|
-
value: this.month(),
|
177
|
-
initialVisibility: true
|
178
|
-
} ),
|
179
|
-
_monthValues = [],
|
180
|
-
i = 0,
|
181
|
-
_monthNames = HLocale.dateTime.strings.monthsLong;
|
182
|
-
for(;i<_monthNames.length;i++){
|
183
|
-
_monthValues.push( [ i, _monthNames[i] ] );
|
184
|
-
}
|
185
|
-
_menu.setListItems( _monthValues );
|
186
|
-
},
|
187
|
-
|
188
|
-
yearMenu: function(){
|
189
|
-
var
|
190
|
-
_calendar = this,
|
191
|
-
_year = HNumericTextControl.extend({
|
192
|
-
refreshValue: function(){
|
193
|
-
this.base();
|
194
|
-
_calendar.setValue( _calendar.setYear( this.value ) );
|
195
|
-
},
|
196
|
-
textBlur: function(){
|
197
|
-
this.base();
|
198
|
-
COMM.Queue.push( function(){_year.die();} );
|
199
|
-
},
|
200
|
-
textEnter: function(){
|
201
|
-
this.base();
|
202
|
-
if( ( EVENT.status[ EVENT.keysDown ].indexOf( 13 ) !== -1 ) || ( EVENT.status[ EVENT.keysDown ].length === 0 ) ){
|
203
|
-
ELEM.get( this.markupElemIds.value ).blur();
|
204
|
-
}
|
205
|
-
}
|
206
|
-
}).nu(
|
207
|
-
HRect.nu(this.rect.width/2,0,this.rect.width-32,20),
|
208
|
-
this, {
|
209
|
-
value: this.year(),
|
210
|
-
minValue: -38399,
|
211
|
-
maxValue: 38400,
|
212
|
-
focusOnCreate: true,
|
213
|
-
refreshOnInput: false
|
214
|
-
}
|
215
|
-
);
|
216
|
-
},
|
217
|
-
|
218
|
-
/** = Description
|
219
|
-
* Draws the calendar with the date open given as input.
|
220
|
-
*
|
221
|
-
* = Parameters
|
222
|
-
* +_date+:: The date on which calendar UI is opened at.
|
223
|
-
*
|
224
|
-
**/
|
225
|
-
drawCalendar: function(_date){
|
226
|
-
_date = (_date instanceof Date)?_date:this.date();
|
227
|
-
var _calendarDateRange = this.calendarDateRange(_date),
|
228
|
-
_monthFirst = this.firstDateOfMonth(_date),
|
229
|
-
_monthLast = this.lastDateOfMonth(_date),
|
230
|
-
_firstDate = _calendarDateRange[0],
|
231
|
-
_lastDate = _calendarDateRange[1],
|
232
|
-
_availWidth = this.rect.width-2,
|
233
|
-
_availHeight = this.rect.height-36,
|
234
|
-
_leftPlus = (_availWidth%8)-2,
|
235
|
-
_topPlus = _availHeight%6,
|
236
|
-
_column_width = Math.floor(_availWidth/8),
|
237
|
-
_row_height = Math.floor(_availHeight/6),
|
238
|
-
_week_html_pre = ['<div class="calendar_weeks_week_row" style="width:'+(_availWidth)+'px;height:'+_row_height+'px;top:','px">'],
|
239
|
-
_week_html_suf = '</div>',
|
240
|
-
_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">'],
|
241
|
-
_col_html_suf = '</a>',
|
242
|
-
_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">',
|
243
|
-
_col_week_suf = '</div>',
|
244
|
-
_month_html = [],
|
245
|
-
_week_html,
|
246
|
-
_col_html,
|
247
|
-
_row = 0,
|
248
|
-
_col,
|
249
|
-
_colMs,
|
250
|
-
_colSecs,
|
251
|
-
_colDate,
|
252
|
-
_monthYearHTML,
|
253
|
-
_extraCssClass;
|
254
|
-
for(; _row<6; _row++){
|
255
|
-
_week_html = [];
|
256
|
-
for(_col = 0; _col<8; _col++){
|
257
|
-
_colDate = new Date(_firstDate.getTime()+((_row*this.msWeek)+((_col-1)*this.msDay)));
|
258
|
-
_colMs = _colDate.getTime();
|
259
|
-
if(_col===0){
|
260
|
-
_col_html = [
|
261
|
-
_col_week_pre,
|
262
|
-
this.week(_colDate),
|
263
|
-
_col_week_suf
|
264
|
-
].join('');
|
265
|
-
}
|
266
|
-
else {
|
267
|
-
_colSecs = Math.round(_colMs/1000);
|
268
|
-
if((this.value >= _colSecs) && (this.value < (_colSecs+86400))){
|
269
|
-
_extraCssClass = '_'+'sel';
|
270
|
-
}
|
271
|
-
else{
|
272
|
-
_extraCssClass = (_colDate<_monthFirst || _colDate > _monthLast)?'_'+'no':'_'+'yes';
|
273
|
-
}
|
274
|
-
_col_html = [
|
275
|
-
_col_html_pre[0],
|
276
|
-
_colSecs,
|
277
|
-
_col_html_pre[1],
|
278
|
-
_extraCssClass,
|
279
|
-
_col_html_pre[2],
|
280
|
-
(_col*_column_width+_leftPlus),
|
281
|
-
_col_html_pre[3],
|
282
|
-
this.mday(_colDate),
|
283
|
-
_col_html_suf
|
284
|
-
].join('');
|
285
|
-
}
|
286
|
-
_week_html.push(_col_html);
|
287
|
-
}
|
288
|
-
_month_html.push([
|
289
|
-
_week_html_pre.join(_row*_row_height+_topPlus),
|
290
|
-
_week_html.join(''),
|
291
|
-
_week_html_suf
|
292
|
-
].join('') );
|
293
|
-
}
|
294
|
-
ELEM.setHTML( this.markupElemIds.value, _month_html.join('') );
|
295
|
-
_monthYearHTML = [
|
296
|
-
'<a href="javascript:void(HSystem.views[',
|
297
|
-
this.viewId,
|
298
|
-
'].monthMenu());">',
|
299
|
-
this.monthName(_date),
|
300
|
-
'</a> <a href="javascript:void(HSystem.views[',
|
301
|
-
this.viewId,
|
302
|
-
'].yearMenu());">',
|
303
|
-
this.year(_date),
|
304
|
-
'</a>'
|
305
|
-
].join('');
|
306
|
-
ELEM.setHTML( this.markupElemIds.state, _monthYearHTML );
|
307
|
-
this.viewMonth = [_monthFirst.getUTCFullYear(),_monthFirst.getUTCMonth()];
|
308
|
-
}
|
309
|
-
});
|
310
|
-
HCalendar.implement(HDateTime);
|