rsence 2.0.9.23 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL.rdoc +61 -49
- data/README.rdoc +20 -4
- data/VERSION +1 -1
- data/conf/default_conf.yaml +8 -0
- data/conf/rsence_command_strings.yaml +31 -20
- data/docs/ExampleGuiPlugin.rdoc +2 -2
- data/js/comm/comm.js +27 -5
- data/js/comm/transporter/transporter.js +1 -1
- data/js/comm/values/values.js +12 -5
- data/js/controls/button/button.js +12 -2
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +13 -1
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +13 -2
- data/js/controls/dialogs/sheet/sheet.js +35 -28
- data/js/controls/imageview/imageview.js +13 -13
- data/js/controls/progress/progressindicator/progressindicator.js +5 -5
- data/js/controls/sliders/slider/slider.js +4 -31
- data/js/controls/stepper/stepper.js +12 -19
- data/js/controls/textcontrol/textcontrol.js +0 -50
- data/js/controls/textcontrol/themes/default/textcontrol.html +1 -1
- data/js/controls/window/window.js +1 -1
- data/js/core/elem/elem.js +146 -160
- data/js/core/rsence_ns/rsence_ns.js +7 -0
- data/js/foundation/control/eventresponder/eventresponder.js +8 -7
- data/js/foundation/eventmanager/eventmanager.js +81 -48
- data/js/foundation/geom/rect/rect.js +1 -1
- data/js/foundation/json_renderer/json_renderer.js +4 -1
- data/js/foundation/system/system.js +37 -34
- data/js/foundation/view/morphanimation/morphanimation.js +53 -43
- data/js/foundation/view/view.js +119 -118
- data/js/lists/listitems/listitems.js +10 -10
- data/js/lists/propertylist/js.inc +0 -0
- data/js/lists/propertylist/propertylist.js +574 -0
- data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
- data/js/lists/propertylist/propertylisteditor/propertylisteditor.js +233 -0
- data/js/lists/radiobuttonlist/radiobuttonlist.js +15 -8
- data/js/menus/minimenu/js.inc +0 -0
- data/js/menus/minimenu/minimenu.js +139 -0
- data/js/menus/minimenu/minimenuitem/js.inc +0 -0
- data/js/menus/minimenu/minimenuitem/minimenuitem.js +33 -0
- data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem.css +45 -0
- data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem.html +4 -0
- data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem_checkmark.png +0 -0
- data/js/menus/minimenu/themes/default/minimenu.css +63 -0
- data/js/menus/minimenu/themes/default/minimenu.html +7 -0
- data/js/menus/minimenu/themes/default/minimenu.png +0 -0
- data/js/util/reloadapp/reloadapp.js +1 -1
- data/lib/conf/argv.rb +40 -11
- data/lib/daemon/daemon.rb +63 -22
- data/lib/plugins/gui_plugin.rb +28 -31
- data/lib/plugins/guiparser.rb +37 -7
- data/lib/plugins/plugin.rb +260 -28
- data/lib/plugins/plugin_base.rb +14 -0
- data/lib/plugins/plugin_plugins.rb +11 -1
- data/lib/plugins/pluginmanager.rb +127 -44
- data/lib/plugins/plugins.rb +10 -1
- data/lib/session/msg.rb +25 -1
- data/lib/session/sessionmanager.rb +11 -2
- data/lib/session/sessionstorage.rb +14 -14
- data/lib/transporter/transporter.rb +29 -13
- data/lib/values/hvalue.rb +30 -0
- data/plugins/client_pkg/info.yaml +2 -2
- data/plugins/{index_html → main}/img/loading.gif +0 -0
- data/plugins/{index_html → main}/img/riassence.gif +0 -0
- data/plugins/main/info.yaml +5 -4
- data/plugins/main/main.rb +180 -24
- data/plugins/{index_html → main}/tmpl/index.html +4 -2
- data/plugins/ticket/info.yaml +2 -2
- data/plugins/ticket/lib/upload.rb +57 -5
- data/plugins/ticket/ticket.rb +10 -4
- data/setup/welcome/info.yaml +2 -2
- data/setup/welcome/text/welcome.html +1 -1
- metadata +22 -11
- data/plugins/index_html/index_html.rb +0 -120
- 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
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
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 =
|
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
|
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
|
-
|
227
|
-
|
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
|
-
|
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
|
278
|
-
|
279
|
-
|
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 (
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
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
|
-
|
542
|
-
|
543
|
-
_size =
|
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
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
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
|
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
|
-
|
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 &&
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
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
|
-
/*
|
935
|
+
/* Using keyPress as an alias for the keyDown event */
|
901
936
|
keyPress: function(e) {
|
902
937
|
var _this = EVENT;
|
903
|
-
|
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 =
|
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.
|
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 =
|
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
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
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
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
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
|
-
|
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(
|
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
|
-
|
127
|
-
|
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
|
176
|
-
|
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
|
181
|
-
|
182
|
-
|
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
|
|