rsence 2.0.9.23 → 2.1.0

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.
Files changed (74) hide show
  1. data/INSTALL.rdoc +61 -49
  2. data/README.rdoc +20 -4
  3. data/VERSION +1 -1
  4. data/conf/default_conf.yaml +8 -0
  5. data/conf/rsence_command_strings.yaml +31 -20
  6. data/docs/ExampleGuiPlugin.rdoc +2 -2
  7. data/js/comm/comm.js +27 -5
  8. data/js/comm/transporter/transporter.js +1 -1
  9. data/js/comm/values/values.js +12 -5
  10. data/js/controls/button/button.js +12 -2
  11. data/js/controls/dialogs/alert_sheet/alert_sheet.js +13 -1
  12. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +13 -2
  13. data/js/controls/dialogs/sheet/sheet.js +35 -28
  14. data/js/controls/imageview/imageview.js +13 -13
  15. data/js/controls/progress/progressindicator/progressindicator.js +5 -5
  16. data/js/controls/sliders/slider/slider.js +4 -31
  17. data/js/controls/stepper/stepper.js +12 -19
  18. data/js/controls/textcontrol/textcontrol.js +0 -50
  19. data/js/controls/textcontrol/themes/default/textcontrol.html +1 -1
  20. data/js/controls/window/window.js +1 -1
  21. data/js/core/elem/elem.js +146 -160
  22. data/js/core/rsence_ns/rsence_ns.js +7 -0
  23. data/js/foundation/control/eventresponder/eventresponder.js +8 -7
  24. data/js/foundation/eventmanager/eventmanager.js +81 -48
  25. data/js/foundation/geom/rect/rect.js +1 -1
  26. data/js/foundation/json_renderer/json_renderer.js +4 -1
  27. data/js/foundation/system/system.js +37 -34
  28. data/js/foundation/view/morphanimation/morphanimation.js +53 -43
  29. data/js/foundation/view/view.js +119 -118
  30. data/js/lists/listitems/listitems.js +10 -10
  31. data/js/lists/propertylist/js.inc +0 -0
  32. data/js/lists/propertylist/propertylist.js +574 -0
  33. data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
  34. data/js/lists/propertylist/propertylisteditor/propertylisteditor.js +233 -0
  35. data/js/lists/radiobuttonlist/radiobuttonlist.js +15 -8
  36. data/js/menus/minimenu/js.inc +0 -0
  37. data/js/menus/minimenu/minimenu.js +139 -0
  38. data/js/menus/minimenu/minimenuitem/js.inc +0 -0
  39. data/js/menus/minimenu/minimenuitem/minimenuitem.js +33 -0
  40. data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem.css +45 -0
  41. data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem.html +4 -0
  42. data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem_checkmark.png +0 -0
  43. data/js/menus/minimenu/themes/default/minimenu.css +63 -0
  44. data/js/menus/minimenu/themes/default/minimenu.html +7 -0
  45. data/js/menus/minimenu/themes/default/minimenu.png +0 -0
  46. data/js/util/reloadapp/reloadapp.js +1 -1
  47. data/lib/conf/argv.rb +40 -11
  48. data/lib/daemon/daemon.rb +63 -22
  49. data/lib/plugins/gui_plugin.rb +28 -31
  50. data/lib/plugins/guiparser.rb +37 -7
  51. data/lib/plugins/plugin.rb +260 -28
  52. data/lib/plugins/plugin_base.rb +14 -0
  53. data/lib/plugins/plugin_plugins.rb +11 -1
  54. data/lib/plugins/pluginmanager.rb +127 -44
  55. data/lib/plugins/plugins.rb +10 -1
  56. data/lib/session/msg.rb +25 -1
  57. data/lib/session/sessionmanager.rb +11 -2
  58. data/lib/session/sessionstorage.rb +14 -14
  59. data/lib/transporter/transporter.rb +29 -13
  60. data/lib/values/hvalue.rb +30 -0
  61. data/plugins/client_pkg/info.yaml +2 -2
  62. data/plugins/{index_html → main}/img/loading.gif +0 -0
  63. data/plugins/{index_html → main}/img/riassence.gif +0 -0
  64. data/plugins/main/info.yaml +5 -4
  65. data/plugins/main/main.rb +180 -24
  66. data/plugins/{index_html → main}/tmpl/index.html +4 -2
  67. data/plugins/ticket/info.yaml +2 -2
  68. data/plugins/ticket/lib/upload.rb +57 -5
  69. data/plugins/ticket/ticket.rb +10 -4
  70. data/setup/welcome/info.yaml +2 -2
  71. data/setup/welcome/text/welcome.html +1 -1
  72. metadata +22 -11
  73. data/plugins/index_html/index_html.rb +0 -120
  74. data/plugins/index_html/info.yaml +0 -18
@@ -12,10 +12,17 @@
12
12
  // ..into this namespace.
13
13
  // Additional logic for handling the namespaces will however be required.
14
14
  var RSence = {
15
+
16
+ // Configuration method for the html document of the server
15
17
  serverConf: function(_clientPrefix,_helloUrl){
16
18
  COMM.ClientPrefix=_clientPrefix;
17
19
  COMM.Transporter.HelloUrl=_helloUrl;
18
20
  HThemeManager.themePath=_clientPrefix+'/themes';
21
+ },
22
+
23
+ // Structure reserved for JSONRenderer instances remotely populated by the server
24
+ guiTrees: {
25
+
19
26
  }
20
27
  };
21
28
 
@@ -174,13 +174,14 @@ HEventResponder = HClass.extend({
174
174
  **/
175
175
  setEnabled: function(_flag) {
176
176
 
177
- var _this = this,
178
- _elemId = this.elemId,
179
- _sysViews = HSystem.views,
180
- i = 0,
181
- _views = _this.views,
182
- _view,
183
- _viewsLen = _views.length;
177
+ var
178
+ _this = this,
179
+ _elemId = this.elemId,
180
+ _sysViews = HSystem.views,
181
+ i = 0,
182
+ _views = _this.views,
183
+ _view,
184
+ _viewsLen = _views.length;
184
185
 
185
186
  // Enable/disable the children first.
186
187
  for (; i < _viewsLen; i++) {
@@ -131,7 +131,7 @@ EVENT = {
131
131
  var _this = EVENT;
132
132
  _this.hovered = [];
133
133
  // items currently under the mouse cursor
134
- _this.hoverInterval = 50;
134
+ _this.hoverInterval = 200;
135
135
  // 50 means send hover events at most with 50ms intervals
136
136
  _this.hoverTimer = new Date().getTime();
137
137
  // Time since last hover event triggered
@@ -210,21 +210,23 @@ EVENT = {
210
210
  /** Registers the _ctrl object by event listener flags in _focusOptions.
211
211
  **/
212
212
  reg: function(_ctrl, _focusOptions) {
213
- var _elemId,
214
- _elem,
215
- _this = EVENT,
216
- _propIn;
213
+ var
217
214
  // Binds the class to the element (so it can be called on the event)
218
- _elemId = _ctrl.elemId;
219
- _elem = ELEM.get(_elemId);
215
+ _elemId = _ctrl.elemId,
216
+ _elem = ELEM.get(_elemId),
217
+ _this = EVENT,
218
+ _propIn,
219
+ _init = ( _this.listeners[_elemId] === undefined || _this.listeners[_elemId] === false );
220
220
  if (BROWSER_TYPE.ie) {
221
221
  _elem.setAttribute('ctrl', _ctrl);
222
222
  }
223
223
  else {
224
224
  _elem.ctrl = _ctrl;
225
225
  }
226
- _this.listeners[_elemId] = true;
227
- _this.focused[_elemId] = false;
226
+ if(_init){
227
+ _this.listeners[_elemId] = true;
228
+ _this.focused[_elemId] = false;
229
+ }
228
230
  for (_propIn in _this._defaultFocusOptions) {
229
231
  if (_focusOptions[_propIn] === undefined) {
230
232
  _focusOptions[_propIn] = _defaultFocusOptions[_propIn];
@@ -264,7 +266,9 @@ EVENT = {
264
266
  _this.resizeListeners.splice(_resizeIndex,1);
265
267
  }
266
268
  }
267
- Event.observe(_elem, 'mouseover', _this._mouseOver);
269
+ if(_init){
270
+ Event.observe(_elem, 'mouseover', _this._mouseOver);
271
+ }
268
272
  if(_ctrl.drawn){
269
273
  _this._updateHoverItems();
270
274
  (_this.hovered.length !== 0) && (_this.hovered.indexOf(_ctrl.elemId) === _this.hovered.length-1) && _this.focus(_ctrl);
@@ -274,9 +278,10 @@ EVENT = {
274
278
  /** Unregisters the _ctrl object event listeners
275
279
  **/
276
280
  unreg: function(_ctrl) {
277
- var _this = EVENT,
278
- _elemId,
279
- _elem;
281
+ var
282
+ _this = EVENT,
283
+ _elemId,
284
+ _elem;
280
285
  if (_ctrl === this.activeControl) {
281
286
  _this.changeActiveControl(null);
282
287
  }
@@ -479,12 +484,14 @@ EVENT = {
479
484
  _hoverIndex = _this.hovered[j];
480
485
  if (_hoverIndex !== _elemId && _this.focusOptions[_hoverIndex].ctrl) {
481
486
  _dropCtrl = _this.focusOptions[_hoverIndex].ctrl;
482
- if (!_this.topmostDroppable ||
483
- // First time
484
- _dropCtrl.zIndex() > _this.topmostDroppable.zIndex() ||
485
- // Z beaten
486
- _dropCtrl.supr === _this.topmostDroppable) {
487
+ if (
488
+ // First time
489
+ !_this.topmostDroppable ||
490
+ // Z beaten
491
+ _dropCtrl.zIndex() > _this.topmostDroppable.zIndex() ||
487
492
  // subview
493
+ _dropCtrl.parent === _this.topmostDroppable
494
+ ) {
488
495
  if (_this.focusOptions[_dropCtrl.elemId].droppable) {
489
496
  _this.topmostDroppable = _dropCtrl;
490
497
  // Finally, the item must accept drop events.
@@ -526,6 +533,7 @@ EVENT = {
526
533
  i = 0,
527
534
  _ctrl,
528
535
  _elem,
536
+ _rect,
529
537
  _pos,
530
538
  _size,
531
539
  _coords,
@@ -536,24 +544,24 @@ EVENT = {
536
544
  }
537
545
  _ctrl = _this.focusOptions[i].ctrl;
538
546
  if(_ctrl.drawn){
547
+ if(ELEM.getStyle(i,'visibility',true) === 'hidden'){
548
+ continue;
549
+ }
539
550
  _elem = ELEM.get(i);
540
551
  if (!_this._coordCacheFlag || !_this._coordCache[i]) {
541
- _pos = ELEM.getVisiblePosition(_ctrl.elemId);
542
- // [x,y]
543
- _size = ELEM.getVisibleSize(_ctrl.elemId);
544
- // [w,h]
552
+ _rect = _ctrl.rect;
553
+ _pos = [_ctrl.pageX(),_ctrl.pageY()];
554
+ _size = [_rect.width,_rect.height];
545
555
  _this._coordCache[i] = [_pos[0], _pos[1], _size[0], _size[1]];
546
556
  }
547
557
  _coords = _this._coordCache[i];
548
558
 
549
559
  // Is the mouse pointer inside the element's rectangle?
550
560
  if (x >= _coords[0] && x <= _coords[0] + _coords[2] && y >= _coords[1] && y <= _coords[1] + _coords[3]) {
551
- // console.log('coords:',_coords);
552
561
  _hovered.push(i);
553
562
  }
554
563
  }
555
564
  }
556
- // console.log('update hover:',_hovered);
557
565
  _this.hovered = _hovered;
558
566
  },
559
567
 
@@ -713,28 +721,40 @@ EVENT = {
713
721
  }
714
722
  return true;
715
723
  },
716
-
724
+
725
+ focusTrace: false,
726
+ prevActiveCtrl: null,
727
+
717
728
  /** Changes active ctrl.
718
729
  * The previous active ctrl gets the _lostActiveStatus pseudo-event,
719
730
  * The new active ctrl gets the _gainedActiveStatus pseudo-event
720
731
  **/
721
732
  changeActiveControl: function(_ctrl) {
722
- //console.log('EVENT.changeActiveControl: ',_ctrl);
723
- var _this = EVENT,
724
- // Store the currently active control so we can inform it, if it no longer is the active control.
725
- _prevActiveCtrl = _this.activeControl;
733
+ var
734
+ _this = EVENT,
735
+ // Store the currently active control so we can inform it,
736
+ // if it's no longer the active control.
737
+ _prevActiveCtrl = _this.activeControl;
726
738
  // Did the active control change?
727
- if (_ctrl !== _prevActiveCtrl) {
728
- if (_prevActiveCtrl) {
739
+ if (_ctrl && (_ctrl !== _prevActiveCtrl) && (_ctrl._gainedActiveStatus || _prevActiveCtrl._lostActiveStatus)) {
740
+ if (_prevActiveCtrl && _prevActiveCtrl._lostActiveStatus) {
729
741
  // Previously active control just lost the active status.
730
742
  _prevActiveCtrl.active = false;
731
743
  _prevActiveCtrl._lostActiveStatus(_ctrl);
744
+ if(_this.focusTrace){
745
+ _prevActiveCtrl.setStyle('border','2px solid green');
746
+ _this.prevActiveCtrl && _this.prevActiveCtrl.setStyle('border','2px solid blue');
747
+ }
748
+ _this.prevActiveCtrl = _prevActiveCtrl;
732
749
  }
733
- if (_ctrl) {
750
+ if (_ctrl && _ctrl._gainedActiveStatus) {
734
751
  // A new control gained the active status.
735
752
  _ctrl.active = true;
736
753
  _this.activeControl = _ctrl;
737
754
  _ctrl._gainedActiveStatus(_prevActiveCtrl);
755
+ if(_this.focusTrace){
756
+ _ctrl.setStyle('border','2px solid red');
757
+ }
738
758
  }
739
759
  else {
740
760
  _this.activeControl = null;
@@ -767,7 +787,7 @@ EVENT = {
767
787
  for (; i !== _this.dragItems.length; i++) {
768
788
  _elemId = _this.dragItems[i];
769
789
  _ctrl = _this.focusOptions[_elemId].ctrl;
770
- _ctrl.endDrag(x, y,_isLeftButton);
790
+ _ctrl.endDrag(x, y, _isLeftButton);
771
791
  _didEndDrag = true;
772
792
  // If the mouse slipped off the dragged item before the mouse button was released, blur the item manually
773
793
  if (_this.enableDroppableChecks) {
@@ -790,10 +810,11 @@ EVENT = {
790
810
  document.onselectstart = _this._storedOnSelectStart;
791
811
  }
792
812
  // Check for mouseUp listeners.
793
- for (i = 0; i !== _this.focused.length; i++) {
813
+ for (i = 0; i < _this.focused.length; i++) {
794
814
  if (_this.focused[i] === true) {
815
+ _ctrl = _this.focusOptions[i].ctrl;
795
816
  if (_this.focusOptions[i].mouseUp === true) {
796
- _this.focusOptions[i].ctrl.mouseUp(x, y, _isLeftButton);
817
+ _ctrl.mouseUp(x, y, _isLeftButton);
797
818
  }
798
819
  }
799
820
  }
@@ -841,22 +862,28 @@ EVENT = {
841
862
  **/
842
863
  keyDown: function(e) {
843
864
  var _this = EVENT,
844
- _theKeyCode = e.keyCode;
865
+ _theKeyCode = e.keyCode,
866
+ _keyDownStateForActiveControl = _this.activeControl?(_this.focusOptions[_this.activeControl.elemId]?_this.focusOptions[_this.activeControl.elemId].keyDown:false):false,
867
+ _repeat = (_keyDownStateForActiveControl === 'repeat'),
868
+ _stopEvent = false;
845
869
  _this._modifiers(e);
846
870
  if(!_this.status[_this.cmdKeyDown] && _this._detectCmdKey(e.keyCode)){
847
871
  _this.status[_this.cmdKeyDown] = true;
848
872
  }
849
- if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
850
- Event.stop(e);
851
- // Workaround for msie rapid fire keydown
852
- if (_this._lastKeyDown !== _theKeyCode) {
853
- _this.activeControl.keyDown(_theKeyCode);
873
+ if (_this.activeControl && _keyDownStateForActiveControl) {
874
+ if ((_this._lastKeyDown !== _theKeyCode) || _repeat) {
875
+ if(_this.activeControl.keyDown(_theKeyCode)){
876
+ _stopEvent = true;
877
+ }
854
878
  }
855
879
  }
856
880
  // Insert key to the realtime array, remove in keyUp
857
881
  if (_this.status[_this.keysDown].indexOf(_theKeyCode) === -1) {
858
882
  _this.status[_this.keysDown].push(_theKeyCode);
859
883
  }
884
+ if (!_this.status[_this.cmdKeyDown] && _stopEvent){
885
+ Event.stop(e);
886
+ }
860
887
  _this._lastKeyDown = _theKeyCode;
861
888
  },
862
889
 
@@ -873,20 +900,28 @@ EVENT = {
873
900
  _theKeyCode = e.keyCode,
874
901
  _keyCodeIndex,
875
902
  i = 0,
903
+ _stopEvent = false,
876
904
  _ctrlId,
877
905
  _ctrl;
878
906
  _this._modifiers(e);
879
907
  _this._lastKeyDown = null;
880
- if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyUp === true) {
881
- _this.activeControl.keyUp(_theKeyCode);
908
+ if (_this.activeControl && _this.activeControl.elemId && _this.focusOptions[_this.activeControl.elemId].keyUp === true) {
909
+ if(_this.activeControl.keyUp(_theKeyCode)){
910
+ _stopEvent = true;
911
+ }
882
912
  }
883
913
  for (; i < _this.textEnterCtrls.length; i++) {
884
914
  _ctrlId = _this.textEnterCtrls[i];
885
915
  _ctrl = HSystem.views[_ctrlId];
886
916
  if (_ctrl.textEnter) {
887
- _ctrl.textEnter();
917
+ if(_ctrl.textEnter()){
918
+ _stopEvent = true;
919
+ }
888
920
  }
889
921
  }
922
+ if (!_this.status[_this.cmdKeyDown] && _stopEvent){
923
+ Event.stop(e);
924
+ }
890
925
  if(_this.status[_this.cmdKeyDown] && _this._detectCmdKey(e.keyCode)){
891
926
  _this.status[_this.cmdKeyDown] = false;
892
927
  }
@@ -897,12 +932,10 @@ EVENT = {
897
932
  }
898
933
  },
899
934
 
900
- /* Prevents the onKeyPress event (key being hold down; we don't need that event) */
935
+ /* Using keyPress as an alias for the keyDown event */
901
936
  keyPress: function(e) {
902
937
  var _this = EVENT;
903
- if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
904
- Event.stop(e);
905
- }
938
+ _this.keyDown(e);
906
939
  },
907
940
 
908
941
 
@@ -134,7 +134,7 @@ HRect = HClass.extend({
134
134
  }
135
135
  _parentHeight = _parentSize[1];
136
136
  if(_view.flexBottom){
137
- _this.bottom = _parentWidth - _view.flexBottomOffset - _this.top;
137
+ _this.bottom = _parentHeight - _view.flexBottomOffset - _this.top;
138
138
  }
139
139
  if(!_view.flexTop){
140
140
  _this.top = _this.bottom - _this.height;
@@ -24,7 +24,7 @@
24
24
  //var//RSence.Foundation
25
25
  COMM.JSONRenderer = HClass.extend({
26
26
 
27
- version: 0.6,
27
+ version: 0.7,
28
28
 
29
29
  /** = Description
30
30
  * Renders JSON structured data, see some of the demos for usage examples.
@@ -48,6 +48,9 @@ COMM.JSONRenderer = HClass.extend({
48
48
  this.scopeDepth = 0;
49
49
  this.view = this.renderNode( this.data, this.parent );
50
50
  },
51
+ die: function(){
52
+ this.view.die();
53
+ },
51
54
  defineInScope: function( _definition ){
52
55
  var _isArr = (_definition instanceof Array),
53
56
  _isObj = (_definition instanceof Object);
@@ -97,7 +97,7 @@ HSystem = {
97
97
  i = 0;
98
98
  for( ; i < this.views.length; i++ ){
99
99
  _view = this.views[i];
100
- if(_view.flexRight || _view.flexBottom){
100
+ if(_view && (_view.flexRight || _view.flexBottom)){
101
101
  _view.rect._updateFlexibleDimensions();
102
102
  }
103
103
  }
@@ -292,6 +292,9 @@ HSystem = {
292
292
  if(this._updateZIndexOfChildrenBuffer.indexOf(_viewId)===-1){
293
293
  this._updateZIndexOfChildrenBuffer.push(_viewId);
294
294
  }
295
+ if((_viewId !== undefined && _viewId !== null) && (this.views[_viewId].app === this.views[_viewId].parent)){
296
+ (this._updateZIndexOfChildrenBuffer.indexOf(null)===-1) && this._updateZIndexOfChildrenBuffer.push(null);
297
+ }
295
298
  },
296
299
 
297
300
  /** Flushes the z-indexes. This is a fairly expensive operation,
@@ -305,7 +308,7 @@ HSystem = {
305
308
  _this = HSystem,
306
309
 
307
310
  // reference to the buffer
308
- _buffer = this._updateZIndexOfChildrenBuffer,
311
+ _buffer = _this._updateZIndexOfChildrenBuffer,
309
312
 
310
313
  // the length of the buffer
311
314
  _bufLen = _buffer.length;
@@ -315,40 +318,40 @@ HSystem = {
315
318
 
316
319
 
317
320
  // get and remove view the view id from the z-index flush status buffer:
318
- var _viewId = _buffer.shift(),
319
-
320
- // reference to the view's z-index array or the system root-level views if _viewId is 0
321
- _views = ((_viewId === null)?(_this.viewsZOrder):(_this.views[ _viewId ].viewsZOrder)),
322
-
323
- // the length of the view's z-index array
324
- _viewLen = _views.length,
325
-
326
- // reference to the setStyle method of the element manager
327
- _setStyl = ELEM.setStyle,
328
-
329
- // reference to HSystem.views (collection of all views, by index)
330
- _sysViews = _this.views,
331
-
332
-
321
+ var
322
+ _viewId = _buffer.shift(),
323
+
324
+ // reference to the view's z-index array or the system root-level views if _viewId is null
325
+ _views = ((_viewId === null)?(_this.viewsZOrder):(_this.views[ _viewId ].viewsZOrder)),
326
+
327
+ // the length of the view's z-index array
328
+ _viewLen = _views.length,
329
+
330
+ // reference to the setStyle method of the element manager
331
+ _setStyl = ELEM.setStyle,
332
+
333
+ // reference to HSystem.views (collection of all views, by index)
334
+ _sysViews = _this.views,
335
+
333
336
  // assign variables for use inside the inner loop:
334
337
 
335
- // the viewId of the view to be updated
336
- _subViewId,
337
-
338
- // the view itself with the viewId above
339
- _view,
340
-
341
- // the elemId property, used as a [] -lookup in the loop
342
- _elemIdStr = 'elemId',
343
-
344
- // the css property name
345
- _zIdxStr = 'z-index',
346
-
347
- // the loop index
348
- i=0,
349
-
350
- // the element id of the view
351
- _elemId;
338
+ // the viewId of the view to be updated
339
+ _subViewId,
340
+
341
+ // the view itself with the viewId above
342
+ _view,
343
+
344
+ // the elemId property, used as a [] -lookup in the loop
345
+ _elemIdStr = 'elemId',
346
+
347
+ // the css property name
348
+ _zIdxStr = 'z-index',
349
+
350
+ // the loop index
351
+ i=0,
352
+
353
+ // the element id of the view
354
+ _elemId;
352
355
 
353
356
  // end of var declarations
354
357
 
@@ -63,7 +63,7 @@ HMorphAnimation = HClass.extend({
63
63
  this._animateTo(_obj, _duration);
64
64
  }
65
65
  else {
66
- throw "Wrong argument type.";
66
+ this._animateTo(_obj, _duration);
67
67
  }
68
68
  return this;
69
69
  },
@@ -77,7 +77,7 @@ HMorphAnimation = HClass.extend({
77
77
  * is still in action.
78
78
  *
79
79
  */
80
- stopAnimation: function() {
80
+ stopAnimation: function(_target) {
81
81
  if (this._animateInterval) {
82
82
  // Stop the animation interval only if it has been set.
83
83
  window.clearInterval(this._animateInterval);
@@ -102,10 +102,45 @@ HMorphAnimation = HClass.extend({
102
102
  return this;
103
103
  },
104
104
 
105
+ _animFunction: function(_that,_target,_startTime,_duration){
106
+ return function(){
107
+ if(!_that){
108
+ return;
109
+ }
110
+ var _rect = _target;
111
+ _that._animateStep({
112
+ startTime: _startTime,
113
+ duration: _duration,
114
+ // Linear transition effect.
115
+ transition: function(t, b, c, d) { return c * t / d + b; },
116
+ props: [{
117
+ prop: 'left',
118
+ from: _that.rect.left,
119
+ to: _rect.left,
120
+ unit: 'px'
121
+ },{
122
+ prop: 'top',
123
+ from: _that.rect.top,
124
+ to: _rect.top,
125
+ unit: 'px'
126
+ },{
127
+ prop: 'width',
128
+ from: _that.rect.width,
129
+ to: _rect.width,
130
+ unit: 'px'
131
+ },{
132
+ prop: 'height',
133
+ from: _that.rect.height,
134
+ to: _rect.height,
135
+ unit: 'px'
136
+ }]
137
+ });
138
+ };
139
+ },
105
140
 
106
141
  // --Private method.++
107
142
  // --Starts the animation with the target _rect.++
108
- _animateTo: function(_rect, _duration, _fps) {
143
+ _animateTo: function(_target, _duration, _fps) {
109
144
 
110
145
  if (null === _duration || undefined === _duration) {
111
146
  _duration = 500; // default duration is half second
@@ -120,41 +155,9 @@ HMorphAnimation = HClass.extend({
120
155
  this.onAnimationStart();
121
156
 
122
157
  var _startTime = new Date().getTime();
123
-
124
- var _that = this;
125
158
  this._animateInterval = window.setInterval(
126
- function() {
127
- if(!_that){
128
- return;
129
- }
130
- _that._animateStep({
131
- startTime: _startTime,
132
- duration: _duration,
133
- // Linear transition effect.
134
- transition: function(t, b, c, d) { return c * t / d + b; },
135
- props: [{
136
- prop: 'left',
137
- from: _that.rect.left,
138
- to: _rect.left,
139
- unit: 'px'
140
- },{
141
- prop: 'top',
142
- from: _that.rect.top,
143
- to: _rect.top,
144
- unit: 'px'
145
- },{
146
- prop: 'width',
147
- from: _that.rect.width,
148
- to: _rect.width,
149
- unit: 'px'
150
- },{
151
- prop: 'height',
152
- from: _that.rect.height,
153
- to: _rect.height,
154
- unit: 'px'
155
- }]
156
- });
157
- }, Math.round(1000 / _fps)
159
+ this._animFunction(this, _target, _startTime, _duration),
160
+ Math.round(1000 / _fps)
158
161
  );
159
162
  }
160
163
  return this;
@@ -165,21 +168,28 @@ HMorphAnimation = HClass.extend({
165
168
  // --Moves the view for one step. This gets called repeatedly when the animation++
166
169
  // --is happening.++
167
170
  _animateStep: function(_obj) {
168
-
169
171
  var _time = new Date().getTime(), i;
170
172
  if (_time < _obj.startTime + _obj.duration) {
171
173
  var _cTime = _time - _obj.startTime;
172
174
 
173
175
  // Handle all the defined properties.
174
176
  for (i = 0; i < _obj.props.length; i++) {
175
- var _from = _obj.props[i].from;
176
- var _to = _obj.props[i].to;
177
+ var
178
+ _from = _obj.props[i].from,
179
+ _to = _obj.props[i].to;
177
180
 
178
181
  if (_from !== _to) {
179
182
  // The value of the property at this time.
180
- var _propNow = _obj.transition(_cTime, _from, (_to - _from),
181
- _obj.duration);
182
- ELEM.setStyle(this.elemId,_obj.props[i].prop, _propNow + _obj.props[i].unit);
183
+ var
184
+ _key = _obj.props[i].prop,
185
+ _propNow = _obj.transition(
186
+ _cTime, _from, (_to - _from), _obj.duration
187
+ ),
188
+ _unit = _obj.props[i].unit;
189
+ if(_unit){
190
+ _propNow += _unit;
191
+ }
192
+ ELEM.setStyle(this.elemId,_key, _propNow);
183
193
  }
184
194
  }
185
195