Add Modello web sample applications; version up
[profile/ivi/sdk/web-sample-build.git] / samples / web / Sample / Tizen / Web App / Modello_SDL / project / app / view / sdl / shared / turnByTurnView.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.TurnByTurnView
29  * @desc TurnByTurnView module visual representation
30  * @category View
31  * @filesource app/view/sdl/shared/turnByTurnView.js
32  * @version 1.0
33  */
34
35 SDL.TurnByTurnView = SDL.SDLAbstractView.create( {
36
37     elementId: 'TurnByTurnView',
38
39     classNames: 'TurnByTurnView',
40
41     classNameBindings:
42         [
43             'active:active'
44         ],
45
46     active: false,
47
48     childViews:
49         [
50             'captionText',
51             'softButtons',
52             'totalDistanceLabel',
53             'etaLabel',
54             'turnList',
55             'homeScreen',
56             'navigationText2',
57             'turnIconImage'
58         ],
59
60     appId: -1,
61     navigationText2: null,
62     eta: null,
63     totalDistance: null,
64     turnIcon: null,
65     distanceToManeuver: null,
66     distanceToManeuverScale: null,
67     maneuverComplete: null,
68
69     activate: function( params ) {
70         if( params ){
71             this.softButtons.addItems( params.softButtons );
72             this.set( 'captionText.content', params.navigationText1 );
73             this.set( 'appId', params.appId );
74             this.set( 'navigationText2', params.navigationText2 );
75             this.set( 'eta', params.eta );
76             this.set( 'totalDistance', params.totalDistance );
77             this.set( 'turnIcon', params.turnIcon );
78             this.set( 'distanceToManeuver', params.distanceToManeuver );
79             this.set( 'distanceToManeuverScale', params.distanceToManeuverScale );
80             this.set( 'maneuverComplete', params.maneuverComplete );
81
82             this.set( 'active', true );
83         }
84     },
85
86     /**
87      * Deactivate View
88      */
89     deactivate: function() {
90         this.set( 'active', false );
91     },
92
93     totalDistanceLabel: SDL.Label.extend( {
94         classNames: 'totalDistanceLabel',
95         contentBinding: 'parentView.totalDistance'
96     } ),
97
98     etaLabel: SDL.Label.extend( {
99         classNames: 'etaLabel',
100         contentBinding: 'parentView.eta'
101     } ),
102
103     turnList: SDL.Button.create( {
104         elementId: 'turnList',
105         classNames: 'turnList btn',
106         text: 'Turn List',
107         action: function() {
108             SDL.SDLController.tbtTurnList( this._parentView.appId );
109         },
110         target: '',
111         onDown: false,
112         templateName: 'arrow'
113     } ),
114
115     turnIconImage: Em.View.create( {
116         classNames: 'turnIcon btn',
117         attributeBindings:
118             [
119                 'style'
120             ],
121         style: function() {
122             if( this._parentView.turnIcon ){
123                 return 'background-image: URL(' + this._parentView.turnIcon + ');';
124             }else{
125                 return '';
126             }
127         }.property( 'this.parentView.turnIcon' )
128     } ),
129
130     navigationText2: SDL.Label.extend( {
131         classNames: 'navigationText2',
132         contentBinding: 'parentView.navigationText2'
133     } ),
134
135     homeScreen: SDL.Button.create( {
136         elementId: 'homeScreen',
137         classNames: 'homeScreen btn',
138         text: 'Home Screen',
139         iconBinding: 'SDL.SDLAppController.model.appIcon',
140         target: 'this.parentView',
141         action: 'deactivate',
142         onDown: false
143     } ),
144
145     softButtons: SDL.MenuList.extend( {
146
147         itemsOnPage: 3,
148
149         groupName: "TurnByTurnView",
150
151         content: Em.ContainerView.extend( {
152
153             classNames:
154                 [
155                     'content'
156                 ]
157
158         } )
159     } )
160 } );