Sencha Touch imitates TabPanel navigation bar Tabbar instance Code _javascript tips

Source: Internet
Author: User

Based on the Sencha Touch 2.2 write

Code:

Copy Code code 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
},
The button that was selected
Selectbutton:null
},
Initialize:function () {
var me = this;
Me.callparent ();
Listener button Click event
Me.on ({
Delegate: ' > button ',
Scope:me,
Tap: ' Onbuttontap '
});
},
Update is 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 Add Item, call the Add method automatically
*/
Onitemadd:function (item, index) {
if (!this.getselectbutton () && item.getinitialconfig (' selected ')) {
This.setselectbutton (item);
}
This.callparent (arguments);
}
});

CSS Required:

Copy Code code 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 code as follows:

Ext.define (' App.view.MyBar ', {
Alternateclassname: ' Mybar ',
Extend: ' UX. Tabbar ',
Xtype: ' Mybar ',
Config: {
Items: [
{
Xtype: ' button ',
Text: ' Survey ',
Only the first setting has a valid property
Selected:true
},
{
Xtype: ' button ',
Text: ' My points '
},
{
Xtype: ' button ',
Text: ' Lottery Hall '
},
{
Xtype: ' button ',
Text: ' Lucky number '
},
{
Xtype: ' button ',
Text: ' More '
}]
}
});

Effect Chart:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.