diff options
Diffstat (limited to 'SDL_Core/src/components/HMI/app/view/sdl/shared/sliderView.js')
-rw-r--r-- | SDL_Core/src/components/HMI/app/view/sdl/shared/sliderView.js | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/SDL_Core/src/components/HMI/app/view/sdl/shared/sliderView.js b/SDL_Core/src/components/HMI/app/view/sdl/shared/sliderView.js index 4e3b31798..aedb2cbc0 100644 --- a/SDL_Core/src/components/HMI/app/view/sdl/shared/sliderView.js +++ b/SDL_Core/src/components/HMI/app/view/sdl/shared/sliderView.js @@ -61,15 +61,59 @@ SDL.SliderView = SDL.SDLAbstractView.create( { */ sliderRequestId: null, + timer: null, + + timeout: null, + /** * Extend deactivate method send SUCCESS response on deactivate with current * slider value */ - deactivate: function() { + deactivate: function(ABORTED) { this._super(); - FFW.UI.sendSliderResult( "SUCCESS", this.get( 'sliderRequestId' ), this.get( 'adjustControl.sliderValue.value' ) ); + this.timeout = null; + clearTimeout(this.timer); + this.timer = null; + + if (ABORTED === true) { + FFW.UI.sendSliderResult( SDL.SDLModel.resultCode["SUCCESS"], this.get( 'sliderRequestId' ), this.get( 'adjustControl.sliderValue.value' ) ); + } else { + FFW.UI.sendSliderResult( SDL.SDLModel.resultCode["ABORTED"], this.get( 'sliderRequestId' ), this.get( 'adjustControl.sliderValue.value' ) ); + } + + SDL.SDLController.onSystemContextChange(); + }, + + activate: function(text, timeout) { + if( text ){ + this.set( 'caption', text ); + } + + this.set( 'active', true ); + + this.set('timeout', timeout); + + SDL.SDLController.onSystemContextChange(); + + this.timer = setTimeout(function () { + if (SDL.SliderView.active) { + SDL.SliderView.deactivate(true); + } + }, timeout); }, + dataChange: function(){ + if (this.timeout){ + var self = this; + + clearTimeout(this.timer); + SDL.SDLController.onResetTimeout(SDL.SDLAppController.model.appID, "UI.Slider"); + this.timer = setTimeout(function () { + self.deactivate(true); + }, this.timeout); + } + }.observes('this.adjustControl.sliderValue.value'), + adjustControl: Em.ContainerView.extend( { classNames: 'sliderControl', @@ -91,7 +135,9 @@ SDL.SliderView = SDL.SDLAbstractView.create( { icon: 'images/common/minus-ico.png', actionDown: function() { this._super(); - this.set( 'parentView.sliderValue.value', this._parentView.sliderValue.value - 1 ); + if (this._parentView.sliderValue.value > 1) { + this.set( 'parentView.sliderValue.value', this._parentView.sliderValue.value - 1 ); + } } } ), @@ -107,7 +153,9 @@ SDL.SliderView = SDL.SDLAbstractView.create( { icon: 'images/common/plus-ico.png', actionDown: function() { this._super(); - this.set( 'parentView.sliderValue.value', this._parentView.sliderValue.value + 1 ); + if (this._parentView.sliderValue.value < this._parentView.sliderValue.range) { + this.set( 'parentView.sliderValue.value', this._parentView.sliderValue.value + 1 ); + } } } ) } ), @@ -119,15 +167,26 @@ SDL.SliderView = SDL.SDLAbstractView.create( { this.set( 'sliderRequestId', message.id ); this.set( 'headerLabel.content', data.sliderHeader ); - this.set( 'footerLabel.content', data.sliderFooter[0] ); this.get( 'adjustControl.sliderValue' ).set( 'range', data.numTicks ); this.get( 'adjustControl.sliderValue' ).set( 'value', data.position ); - this.footerLabel.data = data.sliderFooter; - setTimeout( function() { SDL.SliderView.adjustControl.rerender(); }, 1 ); + + if (!data.sliderFooter) { + this.set('footerLabel.content', ''); + return; + } + + this.footerLabel.data = data.sliderFooter; + + if (data.sliderFooter.length != data.numTicks) { + this.set( 'footerLabel.content', data.sliderFooter[0] ); + } else { + // Magick number is array index correction + this.set( 'footerLabel.content', data.sliderFooter[data.position - 1] ); + } }, /** @@ -135,7 +194,7 @@ SDL.SliderView = SDL.SDLAbstractView.create( { * dynamic footer mode */ changeFooterText: function() { - if( this.footerLabel.data.length > 1 ){ + if( this.footerLabel.data && this.footerLabel.data.length > 1 ){ this.set( 'footerLabel.content', this.footerLabel.data[this.adjustControl.sliderValue.value - 1] ); } }.observes( 'adjustControl.sliderValue.value' ) |