4c21804509c1adc40a00f32c175068bf209168df
[profile/ivi/sdk/web-sample-build.git] / samples / web / Sample / Tizen / Web App / Modello_SDL / project / app / view / info / nonMediaView.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.InfoNonMedia
29  * @desc NonMedia application visual representation
30  * @category View
31  * @filesource app/view/info/nonMedia.js
32  * @version 1.0
33  */
34
35 SDL.InfoNonMedia = Em.ContainerView.create( {
36
37     elementId: 'info_nonMedia',
38
39     controller: SDL.SDLAppController,
40
41     childViews:
42         [
43             'content'
44         ],
45
46     classNameBindings:
47         [
48             'SDL.States.info.nonMedia.active:active_state:inactive_state'
49         ],
50
51     content: Em.ContainerView.extend( {
52         classNames:
53             [
54                 'inner_content'
55             ],
56
57         childViews:
58             [
59                 'deviceName',
60                 'image',
61                 'fields',
62                 'innerMenu',
63                 'presets'
64             ],
65
66         /**
67          * Deactivate View
68          */
69         deactivate: function() {
70             SDL.States.goToStates( 'info.apps' );
71         },
72
73         deviceName: SDL.Label.extend( {
74
75             classNames:
76                 [
77                     'app_title'
78                 ],
79
80             contentBinding: 'SDL.SDLAppController.model.deviceName'
81         } ),
82
83         image: Em.View.extend( {
84
85             classNames:
86                 [
87                     'app_image'
88                 ],
89
90             template: Ember.Handlebars.compile( '<img width="150px" {{bindAttr src="SDL.SDLAppController.model.appInfo.mainImage"}}>' )
91         } ),
92
93         fields: Em.ContainerView.extend( {
94
95             classNames:
96                 [
97                     'app_fields'
98                 ],
99
100             childViews:
101                 [
102                     'field1',
103                     'field2',
104                     'field3',
105                     'field4'
106                 ],
107
108             field1: SDL.Label.extend( {
109                 contentBinding: 'controller.model.appInfo.field1'
110             } ),
111
112             field2: SDL.Label.extend( {
113                 contentBinding: 'controller.model.appInfo.field2'
114             } ),
115
116             field3: SDL.Label.extend( {
117                 contentBinding: 'controller.model.appInfo.field3'
118             } ),
119
120             field4: SDL.Label.extend( {
121                 contentBinding: 'controller.model.appInfo.field4'
122             } )
123
124         } ),
125
126         innerMenu: SDL.MenuList.extend( {
127
128             refreshItems: function() {
129                 if( SDL.SDLAppController.model.appId == SDL.NonMediaController.currentAppId ){
130                     this.addItems( SDL.SDLAppController.model.softButtons, SDL.SDLAppController.model.appId );
131                 }
132             }.observes( 'SDL.SDLAppController.model.softButtons.@each' ),
133
134             groupName: "NonMediaView",
135
136             content: Em.ContainerView.extend( {
137
138                 classNames:
139                     [
140                         'content'
141                     ],
142
143                 attributeBindings:
144                     [
145                         'parentView.contentPositon:style'
146                     ],
147
148                 childViews:
149                     [
150                         'optionsButton'
151                     ],
152
153                 optionsButton: SDL.Button.extend( {
154                     text: 'Options',
155
156                     templateName: 'arrow',
157
158                     action: 'openCommandsList',
159                     target: 'SDL.SDLAppController'
160                 } )
161             } )
162         } ),
163
164         presets: Em.ContainerView.extend( {
165             classNames:
166                 [
167                     'presets'
168                 ],
169
170             classNameBindings:
171                 [
172                     'hidden'
173                 ],
174
175             hidden: function() {
176
177                 if( SDL.SDLAppController.model ){
178                     return !Boolean( SDL.SDLAppController.model.get( 'appInfo.customPresets' ).length );
179                 }
180
181             }.property( 'SDL.SDLAppController.model.appInfo.customPresets.@each' ),
182
183             childViews:
184                 [
185                     'perset1',
186                     'perset2',
187                     'perset3',
188                     'perset4',
189                     'perset5',
190                     'perset6'
191                 ],
192
193             perset1: SDL.SDLPresetButton.extend( {
194                 textBinding: 'SDL.SDLAppController.model.appInfo.customPresets.0',
195                 presetName: 'PRESET_1'
196             } ),
197             perset2: SDL.SDLPresetButton.extend( {
198                 textBinding: 'SDL.SDLAppController.model.appInfo.customPresets.1',
199                 presetName: 'PRESET_2'
200             } ),
201             perset3: SDL.SDLPresetButton.extend( {
202                 textBinding: 'SDL.SDLAppController.model.appInfo.customPresets.2',
203                 presetName: 'PRESET_3'
204             } ),
205             perset4: SDL.SDLPresetButton.extend( {
206                 textBinding: 'SDL.SDLAppController.model.appInfo.customPresets.3',
207                 presetName: 'PRESET_4'
208             } ),
209             perset5: SDL.SDLPresetButton.extend( {
210                 textBinding: 'SDL.SDLAppController.model.appInfo.customPresets.4',
211                 presetName: 'PRESET_5'
212             } ),
213             perset6: SDL.SDLPresetButton.extend( {
214                 textBinding: 'SDL.SDLAppController.model.appInfo.customPresets.5',
215                 presetName: 'PRESET_6'
216             } )
217         } )
218     } )
219 } );