rsence-pre 2.1.8.1 → 2.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/INSTALL.rdoc +3 -3
  2. data/README.rdoc +4 -4
  3. data/VERSION +1 -1
  4. data/conf/default_conf.yaml +4 -1
  5. data/js/comm/sessionwatcher/sessionwatcher.js +3 -2
  6. data/js/controls/textcontrol/textcontrol.js +45 -19
  7. data/js/core/elem/elem.js +6 -0
  8. data/js/datetime/timesheet/old_timesheet.js +292 -0
  9. data/js/datetime/timesheet/themes/default/old_timesheet.css +30 -0
  10. data/js/datetime/timesheet/themes/default/old_timesheet.html +2 -0
  11. data/js/datetime/timesheet/themes/default/timesheet.css +50 -22
  12. data/js/datetime/timesheet/themes/default/timesheet.html +4 -2
  13. data/js/datetime/timesheet/timesheet.js +448 -159
  14. data/js/datetime/timesheet_item/old_timesheet_item.js +308 -0
  15. data/js/datetime/timesheet_item/themes/default/old_timesheet_item.css +42 -0
  16. data/js/datetime/timesheet_item/themes/default/old_timesheet_item.html +8 -0
  17. data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -11
  18. data/js/datetime/timesheet_item/themes/default/timesheet_item.html +4 -2
  19. data/js/datetime/timesheet_item/themes/default/timesheet_item_icons.png +0 -0
  20. data/js/datetime/timesheet_item/timesheet_item.js +156 -259
  21. data/js/datetime/timesheet_item_edit/old_timesheet_item_edit.js +274 -0
  22. data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +0 -274
  23. data/js/foundation/control/valueaction/js.inc +0 -0
  24. data/js/foundation/control/valueaction/valueaction.js +72 -0
  25. data/js/foundation/locale_settings/js.inc +0 -0
  26. data/js/foundation/locale_settings/locale_settings.js +122 -0
  27. data/js/foundation/system/system.js +3 -2
  28. data/js/foundation/view/view.js +27 -0
  29. data/js/lists/checkboxlist/checkboxlist.js +9 -0
  30. data/js/lists/listitems/listitems.js +16 -0
  31. data/js/lists/radiobuttonlist/radiobuttonlist.js +17 -1
  32. data/js/menus/minimenu/minimenu.js +9 -5
  33. data/lib/conf/argv.rb +1 -0
  34. metadata +21 -9
@@ -13,296 +13,193 @@ var//RSence.DateTime
13
13
  HTimeSheetItem = HControl.extend({
14
14
 
15
15
  componentName: 'timesheet_item',
16
+ markupElemNames: ['bg', 'label', 'state', 'icons', 'value', 'subview'],
16
17
 
17
- /* Which mode the component is in. When created by dragging, acts in 'create' mode, otherwise is 'normal'. Can be overridden in options. */
18
- dragMode: 'create',
19
-
20
- /* The previous coordinate. Used to detect double-drag as double-click */
21
- prevXY: [0,0],
22
-
23
- /* The time at the previous coordinate. Used to detect double-drag as double-click. */
24
- prevXYTime: 0,
25
-
26
- defaultEvents: {
27
- draggable: true,
28
- click: true,
29
- doubleClick: true
30
- },
31
-
32
- controlDefaults: HControlDefaults.extend({
33
- dragMode: 'create',
34
- constructor: function(_ctrl){
35
- _ctrl.dragMode = this.dragMode;
36
- }
37
- }),
38
-
39
- /** = Description
40
- * Dragging is used to change coordinates.
41
- *
42
- * = Parameters
43
- * +x+:: X coordinate at the start of drag.
44
- * +y+:: Y coordinate at the start of drag.
45
- *
46
- **/
47
- startDrag: function(x,y){
48
- this.origY = y-this.parent.pageY();
49
- if(this.dragMode === 'normal'){
50
- var _timeNow = new Date().getTime(),
51
- _xEquals = (Math.round(this.prevXY[0]/4) === Math.round(x/4)),
52
- _yEquals = (Math.round(this.prevXY[1]/4) === Math.round(y/4)),
53
- _noTimeout = ((_timeNow - this.prevXYTime) < 500);
54
- if( _xEquals && _yEquals && _noTimeout ) { // doubleClick
55
- return true;
56
- }
57
- else {
58
- var _diffTop = this.rect.top - this.origY,
59
- _diffBottom = this.rect.bottom - this.origY;
60
- if(0 >= _diffTop && _diffTop >= -3){
61
- this.dragMode = 'resize-top';
62
- }
63
- else if(0 <= _diffBottom && _diffBottom <= 4){
64
- this.dragMode = 'resize-bottom';
65
- }
66
- else {
67
- this.dragMode = 'move';
68
- this.moveDiff = this.origY - this.rect.top;
69
- }
70
- this.bringToFront();
71
- }
72
- }
73
- this.prevXY = [x,y];
74
- this.prevXYTime = _timeNow;
75
- return true;
76
- },
77
-
78
- doubleClick: function(x,y){
79
- if( this.parent['editor'] ){
80
- var _editor = this.parent.editor;
81
- _editor.setTimeSheetItem(this);
82
- _editor.bringToFront();
83
- _editor.show();
84
- return true;
85
- }
86
- return false;
87
- },
88
-
89
- /** = Description
90
- * Label setter function.
91
- *
92
- * = Parameters
93
- * +_label+:: New label
94
- *
95
- **/
96
- setTimeSheetItemLabel: function(_label){
97
- this.label = _label;
98
- this.refreshLabel();
18
+ drawIcon: function( _iconOrder, _iconId ){
19
+ var
20
+ _iconElemId = ELEM.make( this.markupElemIds.icons, 'div' );
21
+ ELEM.addClassName( _iconElemId, 'timesheet_item_icon' );
22
+ ELEM.setStyle( _iconElemId, 'right', ((_iconOrder*16)+_iconOrder)+'px' );
23
+ ELEM.setStyle( _iconElemId, 'background-position', '0px '+(_iconId*-16)+'px' );
24
+ return _iconElemId;
99
25
  },
100
26
 
101
- /** = Description
102
- * Function used to calculate the right size for a new
103
- * item created by dragging.
104
- *
105
- * = Parameters
106
- * +_y+:: Y coordinate at the start of drag.
107
- *
108
- **/
109
- dragCreate: function(_y){
110
- var _negative = (_y < this.origY),
111
- _lineHeight = Math.floor(this.parent.pxPerHour/2),
112
- _top, _bottom, _diff;
113
- if(_negative){
114
- var _floorY = Math.floor(_y/_lineHeight)*_lineHeight,
115
- _ceilYo = Math.ceil(this.origY/_lineHeight)*_lineHeight;
116
- if(_floorY<0){_floorY=0;}
117
- _diff = _floorY-_ceilYo;
118
- if( _diff <= 0-_lineHeight ){
119
- _top = _floorY;
120
- _bottom = _ceilYo;
121
- }
122
- else if( _diff === 0 ){
123
- _top = _floorY-_lineHeight;
124
- _bottom = _ceilYo;
27
+ clearAllIcons: function(){
28
+ if(this.icons instanceof Array){
29
+ for( var i=0; i < this.icons.length; i++ ){
30
+ ELEM.del( this.icons[i] );
125
31
  }
126
32
  }
127
- else {
128
- var _ceilY = Math.ceil(_y/_lineHeight)*_lineHeight,
129
- _floorYo = Math.floor(this.origY/_lineHeight)*_lineHeight;
130
- if(_ceilY>(_lineHeight*48)){_ceilY=_lineHeight*48;}
131
- _diff = _ceilY-_floorYo;
132
- if( _diff >= _lineHeight ){
133
- _top = _floorYo;
134
- _bottom = _ceilY;
135
- }
136
- else if( _diff === 0 ){
137
- _top = _floorYo;
138
- _bottom = _ceilY+_lineHeight;
139
- }
140
- }
141
- this.rect.setTop(_top);
142
- this.rect.setBottom(_bottom);
33
+ this.icons = [];
143
34
  },
144
35
 
145
- /** = Description
146
- * Resize top by dragging auxiliary function.
147
- *
148
- * = Parameters
149
- * +_y+:: Y coordinate at the start of drag.
150
- **/
151
- dragResizeTop: function(_y){
152
- var _lineHeight = Math.floor(this.parent.pxPerHour/2),
153
- _top = Math.floor( _y/_lineHeight )*_lineHeight;
154
- if(_top < 0){ _top = 0; }
155
- if(_top+_lineHeight > this.rect.bottom){
156
- _top = this.rect.bottom - _lineHeight;
157
- }
158
- this.rect.setTop( _top );
36
+ die: function(){
37
+ this.clearAllIcons();
38
+ this.icons = null;
39
+ this.base();
159
40
  },
160
41
 
161
- /** = Description
162
- * Resize function for resizing the bottom of item.
163
- *
164
- * = Parameters
165
- * +_y+:: Y coordinate at the start of drag.
166
- *
167
- **/
168
- dragResizeBottom: function(_y){
169
- var _lineHeight = Math.floor(this.parent.pxPerHour/2),
170
- _bottom = Math.floor( _y/_lineHeight )*_lineHeight;
171
- if(_bottom > _lineHeight*48){ _bottom = _lineHeight*48; }
172
- if(_bottom-_lineHeight < this.rect.top){
173
- _bottom = this.rect.top + _lineHeight;
174
- }
175
- this.rect.setBottom( _bottom );
176
- },
177
-
178
- /** = Description
179
- * Move function for item by dragging and dropping.
180
- *
181
- * = Parameters
182
- * +_y+:: Y coordinate at the start of drag.
183
- *
184
- **/
185
- dragMove: function(_y){
186
- var _lineHeight = Math.floor(this.parent.pxPerHour/2),
187
- _top = Math.floor( (0-this.moveDiff+_y)/_lineHeight )*_lineHeight;
188
- if(_top<0){_top = 0;}
189
- if(_top+this.rect.height>_lineHeight*48){
190
- _top = _lineHeight*48 - this.rect.height;
191
- }
192
- this.rect.offsetTo( this.rect.left, _top );
42
+ refreshState: function( _start, _duration ){
43
+ var
44
+ _startTime = _start || this.value.start,
45
+ _endTime = _startTime + ( _duration || this.value.duration ),
46
+ _locale = HLocale.dateTime,
47
+ _stateText = _locale.formatTime( _startTime ) + _locale.strings.rangeDelimitter + _locale.formatTime( _endTime );
48
+ ELEM.setHTML( this.markupElemIds.state, _stateText );
193
49
  },
194
50
 
195
- /** = Description
196
- * Drag function for item. Decides whether the user wants to create a new
197
- * item, resize top, resize bottom or move an existing item.
198
- *
199
- * = Parameters
200
- * +x+:: X coordinate at the start of drag.
201
- * +y+:: Y coordinate at the start of drag.
202
- *
203
- **/
204
- drag: function(x,y){
205
- var _pageY = this.parent.pageY(),
206
- _y = y - _pageY;
207
- if(this.dragMode === 'create'){
208
- this.dragCreate(_y);
209
- }
210
- else if(this.dragMode === 'resize-top'){
211
- this.dragResizeTop(_y);
51
+ refreshValue: function(){
52
+ if ( !(this.value instanceof Object) ){
53
+ return;
212
54
  }
213
- else if(this.dragMode === 'resize-bottom'){
214
- this.dragResizeBottom(_y);
55
+ this.drawRect();
56
+ if ( this.value.color ) {
57
+ this.setStyleOfPart( 'bg', 'background-color', this.value.color );
215
58
  }
216
- else if(this.dragMode === 'move'){
217
- this.dragMove(_y);
59
+ else {
60
+ this.setStyleOfPart( 'bg', 'background-color', '#999' );
218
61
  }
219
- this.drawRect();
220
- return true;
221
- },
222
-
223
- /** = Description
224
- * Modifies the existing item's coordinates or creates a new one.
225
- *
226
- * = Parameters
227
- * +x+:: X coordinate at the end of drag.
228
- * +y+:: Y coordinate at the end of drag.
229
- *
230
- **/
231
- endDrag: function(x,y){
232
- var
233
- _pxPerHour = Math.floor(this.parent.pxPerHour),
234
- _value,
235
- _yEquals = (Math.round(this.prevXY[1]/4) === Math.round(y/4));
236
- if(_yEquals){ // nothing moved, just return.
237
- return true;
62
+ if ( this.value.label ) {
63
+ this.setLabel( this.value.label );
238
64
  }
239
- if(this.dragMode === 'create'){
240
- this.parent.listItemViews.push( this );
241
- _value = {};
242
- this._setValueTop( _value );
243
- this._setValueBottom( _value );
244
- this._setValueLabel( _value );
245
- if(this.parent['editor']){
246
- this.parent.editor.createItem( _value );
247
- }
65
+ if ( this.value.locked ) {
66
+ ELEM.addClassName( this.elemId, 'locked' );
248
67
  }
249
68
  else {
250
- _value = COMM.Values.clone( this.value );
251
- this._setValueTop( _value );
252
- this._setValueBottom( _value );
253
- if(this.parent['editor']){
254
- this.parent.editor.modifyItem( _value );
69
+ ELEM.removeClassName( this.elemId, 'locked' );
70
+ }
71
+ this.refreshState();
72
+ this.clearAllIcons();
73
+ if( this.value.icons instanceof Array ){
74
+ for( var i = 0; i < this.value.icons.length; i++ ){
75
+ this.icons.push( this.drawIcon( i, this.value.icons[i] ) );
255
76
  }
256
77
  }
257
- this.setValue( _value );
258
- this.dragMode = 'normal';
259
- return true;
260
- },
261
-
262
- _setValueTop: function( _value ) {
263
- _value['timeBegin'] = this.rect.top/this.parent.pxPerHour;
264
- },
265
-
266
- _setValueBottom: function( _value ) {
267
- _value['timeEnd'] = this.rect.bottom/this.parent.pxPerHour;
268
78
  },
269
79
 
270
- _setValueLabel: function( _value ) {
271
- _value['label'] = this.label;
80
+ click: function(){
81
+ this.bringToFront();
272
82
  },
273
83
 
274
- _getValueLabel: function( _value ){
275
- return _value.label;
84
+ doubleClick: function( x, y ){
85
+ this.bringToFront();
86
+ var _time = this.parent.pxToTime( y-this.parent.pageY() );
87
+ this.parent.activateEditor( this );
88
+ // if( this.parent.activateEditor( this ) ){
89
+ // // console.log('editor start');
90
+ // }
276
91
  },
277
92
 
278
- _getValueTop: function( _value ){
279
- return (_value.timeBegin * this.parent.pxPerHour)+1;
93
+ dragMode: 0, // none
94
+ startDrag: function( x, y ){
95
+ this.bringToFront();
96
+ if( !this.value.locked ){
97
+ var
98
+ _topY = y-this.pageY(),
99
+ _bottomY = this.rect.height - _topY,
100
+ _resizeTop = ( _topY >= 0 && _topY <= 6 ),
101
+ _resizeBottom = ( _bottomY >= 0 && _bottomY <= 6 ),
102
+ _move = ( _topY > 6 && _bottomY > 6 );
103
+ if( _resizeTop ){
104
+ this.dragMode = 2; // resize-top
105
+ }
106
+ else if ( _resizeBottom ){
107
+ this.dragMode = 3; // resize-bottom
108
+ }
109
+ else if ( _move ){
110
+ this.dragMode = 1; // move
111
+ }
112
+ else {
113
+ this.dragMode = 0; // none
114
+ }
115
+ if( this.dragMode === 0 ){
116
+ this.originY = false;
117
+ }
118
+ else {
119
+ var
120
+ _originY = y-this.parent.pageY(),
121
+ _parentY = this.parent.pageY(),
122
+ _originTimeStart = this.value.start,
123
+ _originTimeEnd = _originTimeStart + this.value.duration;
124
+ this.originY = _originY;
125
+ this.originTopPx = this.rect.top;
126
+ this.originBottomPx = this.rect.bottom;
127
+ this.originTimeStart = _originTimeStart;
128
+ this.originTimeEnd = _originTimeEnd;
129
+ this.originDuration = _originTimeEnd - _originTimeStart;
130
+ this.dragTimeStart = _originTimeStart;
131
+ this.dragDuration = this.originDuration;
132
+ }
133
+ }
280
134
  },
281
135
 
282
- _getValueBottom: function( _value ){
283
- return (_value.timeEnd * this.parent.pxPerHour)-2;
136
+ drag: function( x, y ){
137
+ if( !this.value.locked && this.dragMode !== 0 ){
138
+ y -= this.parent.pageY();
139
+ var
140
+ _movePx = y - this.originY,
141
+ _topPx = this.parent.snapPx( this.originTopPx + _movePx ),
142
+ _parentY = this.parent.pageY(),
143
+ _bottomPx, _minBottomPx, _maxBottomPx, _maxTopPx, _timeStart, _timeEnd, _duration;
144
+ if( this.dragMode === 1 ){ // move
145
+ _maxTopPx = this.parent.timeToPx( this.parent.options.timeEnd ) - this.rect.height;
146
+ if( _topPx > _maxTopPx ){
147
+ _topPx = _maxTopPx;
148
+ }
149
+ _timeStart = this.parent.pxToTime(_topPx);
150
+ _duration = this.originDuration;
151
+ this.rect.offsetTo( this.rect.left, _topPx );
152
+ this.drawRect();
153
+ this.dragTimeStart = _timeStart;
154
+ this.dragDuration = _duration;
155
+ }
156
+ else if( this.dragMode === 2 ){ // resize-top
157
+ _maxTopPx = this.parent.timeToPx( this.originTimeEnd - this.parent.minDuration );
158
+ if( _topPx > _maxTopPx ){
159
+ _topPx = _maxTopPx;
160
+ }
161
+ _timeStart = this.parent.pxToTime(_topPx);
162
+ _timeEnd = this.originTimeEnd;
163
+ if( (this.rect.bottom - _topPx) < this.parent.options.itemMinHeight ){
164
+ _topPx = this.rect.bottom - this.parent.options.itemMinHeight;
165
+ }
166
+ this.rect.setTop( _topPx );
167
+ this.drawRect();
168
+ this.dragTimeStart = _timeStart;
169
+ this.dragDuration = _timeEnd - _timeStart;
170
+ }
171
+ else if( this.dragMode === 3 ){ // resize-top
172
+ _minBottomPx = this.parent.timeToPx( this.originTimeStart + this.parent.minDuration );
173
+ _bottomPx = this.parent.snapPx( this.originBottomPx + _movePx );
174
+ if( _bottomPx < _minBottomPx ){
175
+ _bottomPx = _minBottomPx;
176
+ }
177
+ _timeStart = this.originTimeStart;
178
+ _timeEnd = this.parent.pxToTime(_bottomPx);
179
+ if( _bottomPx - this.rect.top < this.parent.options.itemMinHeight ){
180
+ _bottomPx = this.rect.top + this.parent.options.itemMinHeight;
181
+ }
182
+ this.rect.setBottom( _bottomPx );
183
+ this.drawRect();
184
+ this.dragTimeStart = _timeStart;
185
+ this.dragDuration = _timeEnd - _timeStart;
186
+ }
187
+ this.refreshState( this.dragTimeStart, this.dragDuration );
188
+ }
284
189
  },
285
190
 
286
- /** = Description
287
- * Refreshes the object's label and place on the HTimeSheet.
288
- *
289
- **/
290
- refreshValue: function(){
291
- if ( HVM.type(this.value) === 'h' ){
191
+ endDrag: function( x, y ){
192
+ if( !this.value.locked && this.dragMode !== 0 ){
292
193
  var
293
- _label = this._getValueLabel( this.value ),
294
- _top = this._getValueTop( this.value ),
295
- _bottom = this._getValueBottom( this.value ),
296
- _minHeight = this.parent.options.itemMinHeight;
297
- this.setLabel( _label );
298
- if( (_bottom - _top) < _minHeight ){
299
- _bottom = _top + _minHeight;
194
+ _startChanged = ( this.dragTimeStart !== this.originTimeStart ) && ( this.dragTimeStart !== this.value.start ),
195
+ _durationChanged = ( this.dragDuration !== this.originDuration ) && ( this.dragDuration !== this.value.duration );
196
+ if( _startChanged || _durationChanged ){
197
+ if( this.parent['editor'] ){
198
+ var _modValue = { id: this.value.id, start: this.dragTimeStart, duration: this.dragDuration, label: this.value.label };
199
+ this.parent.editor.modifyItem( _modValue );
200
+ }
300
201
  }
301
- this.rect.setTop( _top );
302
- this.rect.setBottom( _bottom );
303
- this.drawRect();
304
202
  }
305
203
  }
204
+
306
205
  });
307
-
308
-