2 * Copyright (c) 2013, Ford Motor Company All rights reserved.
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.
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.
31 * @filesource app/controlls/MenuList.js
35 SDL.MenuList = Em.ContainerView.extend( {
38 * Add new item to container
40 * @param buttons: SoftButton[]
42 addItems: function( buttons, appId ) {
47 for( var i = 0; i < buttons.length; i++ ){
48 this.get( 'content.childViews' ).pushObject( SDL.Button.create( SDL.PresetEventsCustom, {
49 text: buttons[i].text,
50 icon: buttons[i].image,
51 softButtonId: buttons[i].softButtonID,
52 systemAction: buttons[i].systemAction,
53 groupName: this.groupName,
61 * Delete existing Soft Buttons from container
63 deleteItems: function() {
65 this.get( 'content.childViews' ).removeObjects( this.get( 'content.childViews' ).filterProperty( 'softButtonId' ) );
78 // Position of current page
87 pageHeight: function() {
88 return this.itemsOnPage * this.ITEM_HEIGHT;
89 }.property( 'this.itemsOnPage' ),
91 elementHeight: function() {
92 return 'height:' + String( this.get( 'pageHeight' ) + this.ITEM_HEIGHT - 2 ) + 'px;';
93 }.property( 'this.pageHeight' ),
95 // Position of content block
96 contentPositon: function() {
97 return 'top:' + String( -( this.get( 'page' ) * this.get( 'pageHeight' ) ) ) + 'px; height:'
98 + String( this.get( 'pageHeight' ) - ( Boolean( this.get( 'onLastPage' ) && this.get( 'page' ) ) * this.ITEM_HEIGHT ) ) + 'px;';
99 }.property( 'onLastPage' ),
101 // Property for show or hide 'down' button
102 onLastPage: function() {
103 return( ( this.get( 'page' ) * this.itemsOnPage ) < ( this.get( 'content.childViews.length' ) - this.itemsOnPage ) );
104 }.property( 'page', 'content.childViews.length' ),
106 // Handeler to go previous page
108 if( this.get( 'page' ) ){
109 this.set( 'page', ( this.get( 'page' ) - 1 ) );
113 // Handeler to go next page
114 pageDown: function() {
115 if( this.get( 'onLastPage' ) ){
116 this.set( 'page', ( this.get( 'page' ) + 1 ) );
127 upButton: SDL.Button.extend( {
136 if( this.get( 'parentView.page' ) ){
141 }.property( 'parentView.page' ),
143 templateName: 'icon',
145 icon: 'images/media/ico_arrow_up.png',
152 downButton: SDL.Button.extend( {
161 if( this.get( 'parentView.onLastPage' ) ){
166 }.property( 'parentView.onLastPage' ),
168 templateName: 'icon',
170 icon: 'images/media/ico_arrow_down.png',
177 content: Em.ContainerView.extend( {
186 'parentView.contentPositon:style'