rsence 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.2
@@ -240,6 +240,7 @@ COMM.Transporter = HApplication.extend({
240
240
  // console.log('sync.');
241
241
  this.busy = true;
242
242
  if(window['sesWatcher'] && window.sesWatcher['sesTimeoutValue']){
243
+ // Sets the value of the session watcher to the current time. It could cause an unnecessary re-sync poll immediately after this sync otherwise.
243
244
  sesWatcher.sesTimeoutValue.set( new Date().getTime() );
244
245
  }
245
246
  var _this = this,
@@ -32,10 +32,13 @@ HImageView = HControl.extend({
32
32
  })),
33
33
 
34
34
  _makeScaleToFit: function(_parentId){
35
- this.elemId = ELEM.make(_parentId,'img');
36
- ELEM.setAttr(this.elemId,'src',this.getImgSrc());
37
- ELEM.setAttr(this.elemId,'alt',this.label);
38
- ELEM.setAttr(this.elemId,'title',this.label);
35
+ this.elemId = ELEM.make( _parentId, 'img', {
36
+ attrs: [
37
+ [ 'src', this.getImgSrc() ],
38
+ [ 'alt', this.label ],
39
+ [ 'title', this.label ]
40
+ ]
41
+ } );
39
42
  },
40
43
  _makeScaleToOriginal: function(_parentId){
41
44
  this.elemId = ELEM.make(_parentId,'div');
@@ -58,11 +61,17 @@ HImageView = HControl.extend({
58
61
  *
59
62
  **/
60
63
  refreshValue: function(){
64
+ var _src = this.getImgSrc();
61
65
  if(this.options.scaleToFit){
62
- ELEM.setAttr(this.elemId,'src',this.getImgSrc());
66
+ if(ELEM.getAttr(this.elemId,'src')!==_src){
67
+ ELEM.setAttr(this.elemId,'src',_src);
68
+ }
63
69
  }
64
70
  else{
65
- ELEM.setStyle(this.elemId,'background-image','url('+this.getImgSrc()+')');
71
+ var _url = 'url('+this.getImgSrc()+')';
72
+ if(ELEM.getStyle(this.elemId,'background-image') != _url){
73
+ ELEM.setStyle(this.elemId,'background-image',_url);
74
+ }
66
75
  }
67
76
  },
68
77
 
data/js/core/elem/elem.js CHANGED
@@ -774,7 +774,6 @@ ELEM = {
774
774
  _key = _currTodo.pop();
775
775
  _val = _attrCache[_key];
776
776
  _elem.setAttribute(_key, _val);
777
- //_elem[_key]=_val;
778
777
  }
779
778
  },
780
779
 
@@ -827,7 +826,7 @@ ELEM = {
827
826
  _attrTodo = _this._attrTodo[_id],
828
827
  _attrCache = _this._attrCache[_id],
829
828
  _differs = _value !== _this.getAttr(_id, _key);
830
- if (_differs) {
829
+ if (_differs || _bypass) {
831
830
  _attrCache[_key] = _value;
832
831
  if (_bypass) {
833
832
  _this._elements[_id].setAttribute(_key, _value);
@@ -1043,11 +1042,15 @@ ELEM = {
1043
1042
  * +_tagName+:: The tag name of the element.
1044
1043
  * (Optional, default: 'DIV')
1045
1044
  *
1045
+ * +_options+:: Options to set before appending child to parent.
1046
+ * Supported option attrs: [[key,value],[key,value]]
1047
+ * (Optional, rarely necessary except when creating IMG tags)
1048
+ *
1046
1049
  * = Returns
1047
1050
  * The new ELEM ID.
1048
1051
  *
1049
1052
  **/
1050
- make: function(_targetId, _tagName) {
1053
+ make: function(_targetId, _tagName, _options) {
1051
1054
  if (_targetId === undefined) {
1052
1055
  _targetId = 0;
1053
1056
  }
@@ -1084,9 +1087,22 @@ ELEM = {
1084
1087
  }
1085
1088
  }
1086
1089
  _elem = document.createElement(_tagName);
1087
- _this._elements[_targetId].appendChild(_elem);
1088
1090
  _id = _this._add(_elem);
1089
1091
  _this._initCache(_id);
1092
+ if(_options!==undefined){
1093
+ if(_options.attrs){
1094
+ var
1095
+ i = 0,
1096
+ _key, _value;
1097
+ for( ; i<_options.attrs.length; i++ ){
1098
+ _key = _options.attrs[i][0];
1099
+ _value = _options.attrs[i][1];
1100
+ _elem[_key] = _value;
1101
+ _this.setAttr( _id, _key, _value );
1102
+ }
1103
+ }
1104
+ }
1105
+ _this._elements[_targetId].appendChild(_elem);
1090
1106
  return _id;
1091
1107
  },
1092
1108
 
@@ -11,10 +11,36 @@
11
11
  ***/
12
12
  var//RSence.DateTime
13
13
  HTimeSheet = HControl.extend({
14
+
14
15
  componentName: 'timesheet',
16
+
17
+ /* Default amount of pixels per hour. Override with options when necessary. */
15
18
  pxPerHour: 24,
19
+
20
+ /* Default amount of pixels from left. Override with options when necessary. */
16
21
  itemOffsetLeft: 36,
22
+
23
+ /* Default amount of pixels from right. Override with options when necessary. */
17
24
  itemOffsetRight: 0,
25
+
26
+ controlDefaults: HControlDefaults.extend({
27
+ pxPerHour: null,
28
+ itemOffsetLeft: null,
29
+ itemOffsetRight: null,
30
+ newItemLabel: 'New Item',
31
+ constructor: function(_ctrl){
32
+ if(this.pxPerHour !== null){
33
+ _ctrl.pxPerHour = this.pxPerHour;
34
+ }
35
+ if(this.itemOffsetLeft !== null){
36
+ _ctrl.itemOffsetLeft = this.itemOffsetLeft;
37
+ }
38
+ if(this.itemOffsetRight !== null){
39
+ _ctrl.itemOffsetRight = this.itemOffsetRight;
40
+ }
41
+ }
42
+ }),
43
+
18
44
  /** = Description
19
45
  * Redraws the timesheet.
20
46
  *
@@ -82,16 +108,7 @@ HTimeSheet = HControl.extend({
82
108
  if(origY>maxY){
83
109
  origY = maxY;
84
110
  }
85
- var item = HTimeSheetItem.nu(
86
- this.createItemRect(origY,lineHeight),
87
- this, {
88
- label: 'New Item',
89
- events: {
90
- draggable: true
91
- }
92
- }
93
- );
94
- this.dragItem = item;
111
+ this.dragItem = this.createTimeSheetItem( { label: this.options.newItemLabel }, origY, lineHeight, 'create' );
95
112
  },
96
113
 
97
114
  /** = Description
@@ -144,6 +161,44 @@ HTimeSheet = HControl.extend({
144
161
  this.base();
145
162
  },
146
163
 
164
+ /** = Description
165
+ * Returns a new time sheet item control. By default returns an instance
166
+ * of HTimeSheetItem. Extend to use custom time sheet controls customized
167
+ * for application specific purposes.
168
+ *
169
+ * = Parameters
170
+ * *_value*:: A value object for the item.
171
+ * *_top*:: Top position, 0 by default.
172
+ * *_height*:: Height, same as half of +#pxPerHour+ by default.
173
+ * *_drogMode*:: Dragging mode. 'normal' or 'create'. Is 'normal' by default.
174
+ *
175
+ **/
176
+ createTimeSheetItem: function( _value, _top, _height, _dragMode ) {
177
+ if(_dragMode===undefined){
178
+ _dragMode = 'normal';
179
+ }
180
+ if(_top===undefined){
181
+ _top = 0;
182
+ }
183
+ if(_height===undefined){
184
+ _height = Math.round(this.pxPerHour/2);
185
+ }
186
+ var
187
+ _label = _value['label'],
188
+ _item = HTimeSheetItem.nu(
189
+ this.createItemRect( _top, _height ),
190
+ this, {
191
+ label: _label,
192
+ value: _value,
193
+ events: {
194
+ draggable: true
195
+ }
196
+ }
197
+ );
198
+ _item.dragMode = _dragMode;
199
+ return _item;
200
+ },
201
+
147
202
  /** = Description
148
203
  * Redraws and refreshes the values on timesheet.
149
204
  *
@@ -160,21 +215,10 @@ HTimeSheet = HControl.extend({
160
215
  this.listItemViews = [];
161
216
  }
162
217
  if(_data instanceof Array){
163
- var _value, _label, _item;
218
+ var _value, _item;
164
219
  for( i=0; i<_data.length; i++){
165
220
  _value = _data[i];
166
- _label = _value['label'];
167
- _item = HTimeSheetItem.nu(
168
- this.createItemRect( 0, 12 ),
169
- this, {
170
- label: _label,
171
- value: _value,
172
- events: {
173
- draggable: true
174
- }
175
- }
176
- );
177
- _item.dragMode = 'normal';
221
+ _item = this.createTimeSheetItem( _value );
178
222
  this.listItemViews.push( _item );
179
223
  }
180
224
  }
@@ -11,11 +11,25 @@
11
11
  ***/
12
12
  var//RSence.DateTime
13
13
  HTimeSheetItem = HControl.extend({
14
+
14
15
  componentName: 'timesheet_item',
16
+
17
+ /* Which mode the component is in. When created by dragging, acts in 'create' mode, otherwise is 'normal'. Can be overridden in options. */
15
18
  dragMode: 'create',
19
+
20
+ /* The previous coordinate. Used to detect double-drag as double-click. */
16
21
  prevXY: [0,0],
22
+
23
+ /* The time at the previous coordinate. Used to detect double-drag as double-click. */
17
24
  prevXYTime: 0,
18
25
 
26
+ controlDefaults: HControlDefaults.extend({
27
+ dragMode: 'create',
28
+ constructor: function(_ctrl){
29
+ _ctrl.dragMode = this.dragMode;
30
+ }
31
+ }),
32
+
19
33
  /** = Description
20
34
  * Dragging is used to change coordinates.
21
35
  *
@@ -31,7 +45,7 @@ HTimeSheetItem = HControl.extend({
31
45
  _xEquals = (Math.round(this.prevXY[0]/4) === Math.round(x/4)),
32
46
  _yEquals = (Math.round(this.prevXY[1]/4) === Math.round(y/4)),
33
47
  _noTimeout = ((_timeNow - this.prevXYTime) < 500);
34
- if( _xEquals && _yEquals && _noTimeout ) {
48
+ if( _xEquals && _yEquals && _noTimeout ) { // doubleClick
35
49
  if( this.parent['editor'] ){
36
50
  var _editor = this.parent.editor;
37
51
  _editor.setTimeSheetItem(this);
@@ -207,19 +221,18 @@ HTimeSheetItem = HControl.extend({
207
221
  _value;
208
222
  if(this.dragMode === 'create'){
209
223
  this.parent.listItemViews.push( this );
210
- _value = {
211
- 'timeBegin': this.rect.top/_pxPerHour,
212
- 'timeEnd': this.rect.bottom/_pxPerHour,
213
- 'label': this.label
214
- };
224
+ _value = {};
225
+ this._setValueTop( _value );
226
+ this._setValueBottom( _value );
227
+ this._setValueLabel( _value );
215
228
  if(this.parent['editor']){
216
229
  this.parent.editor.createItem( _value );
217
230
  }
218
231
  }
219
232
  else {
220
233
  _value = COMM.Values.clone( this.value );
221
- _value['timeBegin'] = this.rect.top/_pxPerHour;
222
- _value['timeEnd'] = this.rect.bottom/_pxPerHour;
234
+ this._setValueTop( _value );
235
+ this._setValueBottom( _value );
223
236
  if(this.parent['editor']){
224
237
  this.parent.editor.modifyItem( _value );
225
238
  }
@@ -229,17 +242,39 @@ HTimeSheetItem = HControl.extend({
229
242
  return true;
230
243
  },
231
244
 
245
+ _setValueTop: function( _value ) {
246
+ _value['timeBegin'] = this.rect.top/this.parent.pxPerHour;
247
+ },
248
+
249
+ _setValueBottom: function( _value ) {
250
+ _value['timeEnd'] = this.rect.bottom/this.parent.pxPerHour;
251
+ },
252
+
253
+ _setValueLabel: function( _value ) {
254
+ _value['label'] = this.label;
255
+ },
256
+
257
+ _getValueLabel: function( _value ){
258
+ return _value.label;
259
+ },
260
+
261
+ _getValueTop: function( _value ){
262
+ return _value.timeBegin * this.parent.pxPerHour;
263
+ },
264
+
265
+ _getValueBottom: function( _value ){
266
+ return _value.timeEnd * this.parent.pxPerHour;
267
+ },
268
+
232
269
  /** = Description
233
270
  * Refreshes the object's label and place on the HTimeSheet.
234
271
  *
235
272
  **/
236
273
  refreshValue: function(){
237
- var _value = this.value,
238
- _pxPerHour = this.parent.pxPerHour;
239
- if((_value instanceof Object) && !(_value instanceof Array)){
240
- this.setLabel( _value['label'] );
241
- this.rect.setTop( _value['timeBegin'] * _pxPerHour );
242
- this.rect.setBottom( _value['timeEnd'] * _pxPerHour );
274
+ if ( HVM.type(this.value) === 'h' ){
275
+ this.setLabel( this._getValueLabel( this.value ) );
276
+ this.rect.setTop( this._getValueTop( this.value ) );
277
+ this.rect.setBottom( this._getValueBottom( this.value ) );
243
278
  this.drawRect();
244
279
  }
245
280
  }
@@ -431,7 +431,13 @@ HDynControl = HControl.extend({
431
431
  **/
432
432
  startDrag: function(x,y,_isRightButton){
433
433
  var _parent = this.parent;
434
- if(_parent.elemId){
434
+ // parent outer position
435
+ // parent inner position, if it has subviews with different offset.
436
+ if ( _parent.markupElemIds && _parent.markupElemIds.subview ) {
437
+ x -= ELEM._getVisibleLeftPosition( _parent.markupElemIds.subview );
438
+ y -= ELEM._getVisibleTopPosition( _parent.markupElemIds.subview );
439
+ }
440
+ else if(_parent.elemId){
435
441
  x-=_parent.pageX();
436
442
  y-=_parent.pageY();
437
443
  }
@@ -459,7 +465,11 @@ HDynControl = HControl.extend({
459
465
  **/
460
466
  drag: function(x,y){
461
467
  var _parent = this.parent;
462
- if(_parent.elemId){
468
+ if ( _parent.markupElemIds && _parent.markupElemIds.subview ) {
469
+ x -= ELEM._getVisibleLeftPosition( _parent.markupElemIds.subview );
470
+ y -= ELEM._getVisibleTopPosition( _parent.markupElemIds.subview );
471
+ }
472
+ else if(_parent.elemId){
463
473
  x-=_parent.pageX();
464
474
  y-=_parent.pageY();
465
475
  }
@@ -485,7 +495,11 @@ HDynControl = HControl.extend({
485
495
  endDrag: function(x,y,_isRightButton){
486
496
  this.base();
487
497
  var _parent = this.parent;
488
- if(_parent.elemId){
498
+ if ( _parent.markupElemIds && _parent.markupElemIds.subview ) {
499
+ x -= ELEM._getVisibleLeftPosition( _parent.markupElemIds.subview );
500
+ y -= ELEM._getVisibleTopPosition( _parent.markupElemIds.subview );
501
+ }
502
+ else if(_parent.elemId){
489
503
  x-=_parent.pageX();
490
504
  y-=_parent.pageY();
491
505
  }
@@ -882,14 +882,15 @@ HView = HClass.extend({
882
882
  else {
883
883
  var
884
884
  _rect = this.parent.rect,
885
- _width = _rect.width,
886
- _height = _rect.height;
887
- if (this.parent.flexLeft && this.parent.flexRight){
888
- _width = parseInt( ELEM.getStyle(this.parent.elemId,'width',true), 10 );
889
- }
890
- if (this.parent.flexBottom && this.parent.flexTop){
891
- _height = parseInt( ELEM.getStyle(this.parent.elemId,'height',true), 10 );
892
- }
885
+ _width, // = _rect.width,
886
+ _height, // = _rect.height;
887
+ _parentElemId = ( this.parent.markupElemIds && this.parent.markupElemIds.subview ) ? this.parent.markupElemIds.subview : this.parent.elemId;
888
+ // if (this.parent.flexLeft && this.parent.flexRight){
889
+ _width = parseInt( ELEM.getStyle( _parentElemId, 'width', true ), 10 );
890
+ // }
891
+ // if (this.parent.flexBottom && this.parent.flexTop){
892
+ _height = parseInt( ELEM.getStyle( _parentElemId, 'height', true ), 10 );
893
+ // }
893
894
  return [ _width, _height ];
894
895
  }
895
896
  },
data/lib/values/hvalue.rb CHANGED
@@ -84,7 +84,10 @@ module RSence
84
84
  if RSence.args[:debug] and meta[:name] and not msg.valuemanager.id_exists?( msg, meta[:name] )
85
85
  @value_id = meta[:name]
86
86
  else
87
- @value_id = msg.valuemanager.randgen.gen
87
+ @value_id = '_'
88
+ while @value_id[0] == 95 # ascii for '_'
89
+ @value_id = msg.valuemanager.randgen.gen
90
+ end
88
91
  end
89
92
 
90
93
  @meta = meta
data/plugins/main/main.rb CHANGED
@@ -282,16 +282,15 @@ class MainPlugin < Plugin
282
282
  ## url_responder is bound in the client-space
283
283
  ## to tell the server its status by updating its value
284
284
  location_href_id = ses[:location_href].val_id.to_json
285
- msg.reply "COMM.Values.values[#{location_href_id}].bind(COMM.urlResponder);"
285
+ msg.reply "try{COMM.Values.values[#{location_href_id}].bind(COMM.urlResponder);}catch(e){console.log('urlResponder failed, reason:',e);}"
286
286
 
287
- ## This enables SesWatcher that changes :client_time every 60 seconds.
288
- ## It makes the client to poll the server on regular intervals, when polling mode
289
- ## is disabled.
287
+ ## This enables SesWatcher that changes :client_time every n seconds, which depends on the server_poll_interval configuration setting.
288
+ ## It makes the client to poll the server on regular intervals, when polling mode is disabled.
290
289
  # 5000ms = 5secs
291
290
 
292
291
  client_time_id = ses[:client_time].val_id.to_json
293
292
  poll_interval = ::RSence.config[:main_plugin][:server_poll_interval]
294
- msg.reply "sesWatcher = COMM.SessionWatcher.nu(#{poll_interval},#{client_time_id});"
293
+ msg.reply "try{window.sesWatcher=COMM.SessionWatcher.nu(#{poll_interval},#{client_time_id});}catch(e){console.log('sesWatcher failed, reason:',e);}"
295
294
 
296
295
  end
297
296
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsence
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 1
10
- version: 2.1.1
9
+ - 2
10
+ version: 2.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Riassence Inc.
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-07 00:00:00 +02:00
18
+ date: 2010-12-09 00:00:00 +02:00
19
19
  default_executable: rsence
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency