Updated GhostCluster web sample from upstream
[profile/ivi/sdk/web-sample-build.git] / samples / web / Sample / Tizen / Web App / Modello_SDL / project / app / view / sdl / AudioPassThruPopUp.js
1 /*
2  * Copyright (c) 2013, Ford Motor Company All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *  · Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  *  · Redistributions in binary form must reproduce the above copyright notice,
9  * this list of conditions and the following disclaimer in the documentation
10  * and/or other materials provided with the distribution.
11  *  · Neither the name of the Ford Motor Company nor the names of its
12  * contributors may be used to endorse or promote products derived from this
13  * software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 /**
28  * @name SDL.AudioPassThruPopUp
29  * @desc AudioPassThruPopUp module visual representation
30  * @category View
31  * @filesource app/view/sdl/AudioPassThruPopUp.js
32  * @version 1.0
33  */
34
35 SDL.AudioPassThruPopUp = Em.ContainerView.create( {
36
37     elementId: 'AudioPassThruPopUp',
38
39     classNames: 'AudioPassThruPopUp',
40
41     classNameBindings:
42         [
43             'activate:AudioPassThruActive'
44         ],
45
46     childViews:
47         [
48             'applicationName',
49             'image',
50             'message1',
51             'message2',
52             'message3',
53             'buttonRetry',
54             'buttonDone',
55             'buttonCancel'
56         ],
57
58     content1: 'Title',
59
60     content2: 'Text',
61
62     activateBinding: 'SDL.SDLModel.AudioPassThruState',
63
64     timer: null,
65
66     applicationName: SDL.Label.extend( {
67
68         elementId: 'AudioPassThruPopUpApplicationName',
69
70         classNames: 'applicationName',
71
72         contentBinding: 'parentView.appName'
73     } ),
74
75     /**
76      * Wagning image on Alert PopUp
77      */
78     image: Em.View.extend( {
79         elementId: 'audioPassThruImage',
80
81         classNames: 'audioPassThruImage'
82     } ),
83
84     message1: SDL.Label.extend( {
85
86         elementId: 'AudioPassThruPopUpMessage1',
87
88         classNames: 'message1',
89
90         contentBinding: 'parentView.content1'
91     } ),
92
93     message2: SDL.Label.extend( {
94
95         elementId: 'AudioPassThruPopUpMessage2',
96
97         classNames: 'message2',
98
99         contentBinding: 'parentView.content2'
100     } ),
101
102     message3: SDL.Label.extend( {
103
104         elementId: 'AudioPassThruPopUpMessage3',
105
106         classNames: 'message3',
107
108         contentBinding: 'parentView.content3'
109     } ),
110
111     buttonRetry: SDL.Button.create( {
112         elementId: 'AudioPassThruPopUpButtonRetry',
113         classNames: 'buttonRetry softButton',
114         text: 'Retry',
115         responseResult: 'RETRY',
116         actionUp: function() {
117             SDL.SDLController.callPerformAudioPassThruPopUpResponse( this );
118         }
119     } ),
120
121     buttonDone: SDL.Button.create( {
122         elementId: 'AudioPassThruPopUpButtonDone',
123         classNames: 'buttonDone softButton',
124         text: 'Done',
125         responseResult: 'SUCCESS',
126         actionUp: function() {
127             SDL.SDLController.callPerformAudioPassThruPopUpResponse( this );
128         }
129     } ),
130
131     buttonCancel: SDL.Button.create( {
132         elementId: 'AudioPassThruPopUpButtonCancel',
133         classNames: 'buttonCancel softButton',
134         text: 'Cancel',
135         responseResult: 'ABORTED',
136         actionUp: function() {
137             SDL.SDLController.callPerformAudioPassThruPopUpResponse( this );
138         }
139     } ),
140
141     /**
142      * Method clears PopUp's timer when activity flag become false, and show
143      * PopUp with data come from SDLCorel when activity flag become true
144      */
145     AudioPassThruActivity: function() {
146
147         if( this.activate ){
148
149             var self = this, data = SDL.SDLModel.AudioPassThruData;
150
151             SDL.SDLModel.onPrompt( data.initialPrompt.ttsChunks );
152
153             this.set( 'appName', SDL.SDLController.getApplicationModel( data.appId ).appName );
154
155             this.set( 'content1', data.audioPassThruDisplayText1 );
156             this.set( 'content2', data.audioPassThruDisplayText2 );
157
158             clearTimeout( this.timer );
159             this.timer = setTimeout( function() {
160                 SDL.SDLController.performAudioPassThruResponse( "SUCCESS" );
161             }, data.maxDuration );
162         }else{
163             if( this.timer ){
164                 clearTimeout( this.timer );
165             }
166         }
167     }.observes( 'activate' )
168 } );