Home > Web Front-end > JS Tutorial > sencha touch imitates tabpanel navigation bar TabBar example code_javascript skills

sencha touch imitates tabpanel navigation bar TabBar example code_javascript skills

WBOY
Release: 2016-05-16 17:19:04
Original
885 people have browsed it

Written based on sencha touch 2.2

Code:

Copy code The code is as follows:

/*
*Imitate tabpanel navigation bar
*/
Ext.define('ux.TabBar', {
alternateClassName: 'tabBar',
extend: 'Ext.Toolbar',
xtype: 'tabBar',
config : {
docked: 'bottom',
cls: 'navToolbar',
layout: {
align: 'stretch'
},
defaults: {
flex: 1
                                                                                                                                                                                          );
//Listen for button click events
me.on({
delegate: '> button',
scope: me,
tap: 'onButtonTap'
}) ;
},
//Update the selected button
updateSelectButton: function (newItem, oldItem) {
console.log(oldItem);
if (oldItem) {
oldItem. removeCls('x-tabBar-pressing');
}
if (newItem) {
} newItem.addCls('x-tabBar-pressing');
}
},
//When the button is clicked
onButtonTap: function (button) {
this.setSelectButton(button);
},
/**
* @private
* Execute the added item and automatically execute it after calling the add method
*/
onItemAdd: function (item, index) {
                                                                                                                                );
}
});



Required css:





Copy code

The code is as follows:

.navToolbar { padding:0;}.navToolbar .x-button { border:0; margin:0; border-right:1px solid #585B5B;
border-radius:0;
padding:0;
}
.navToolbar .x-button .x-button-label {
font-weight:normal;
color:White;
font-size:0.6em;
}
.navToolbar .x-tabBar-pressing {
background-image:none;
background-color:#0f517e;
background-image:-webkit-gradient(linear,50 % 0%,50% 100%,color-stop(0%,#0a3351),color-stop(10%,#0c4267),color-stop(65%,#0f517e),color-stop(100%,# 0f5280));
background-image:-webkit-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
background-image:-moz-linear-gradient (top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
background-image:-o-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,# 0f5280);
background-image:linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
}



Use:





Copy code

The code is as follows:


Ext.define('app.view.MyBar', {
alternateClassName: 'myBar',
extend: 'ux.TabBar',
xtype: 'myBar',
config: {
items: [
selected : true
                                                                      xtype: 'button',
text: 'Lottery Hall'
},
{
xtype: 'button',
text: 'Lucky Number'
},
{
xtype: 'button ',
text: 'More'
}]
}
});



Rendering:



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template