Ext.require([
'Ext.window.Window',
'Ext.panel.Panel',
'Ext.toolbar.*',
'Ext.tree.Panel',
'Ext.container.Viewport',
'Ext.container.ButtonGroup',
'Ext.form.*',
'Ext.tab.*',
'Ext.slider.*',
'Ext.layout.*',
'Ext.button.*',
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.perf.Monitor'
]);
function hasOption (name) {
return window.location.search.indexOf(name) >= 0;
}
var useDeferRender = true;
if (hasOption('diag')) {
Ext.require([
'Ext.diag.layout.ContextItem',
'Ext.diag.layout.Context'
]);
}
function getBasicPanel () {
return applySizing('basicPanel', {
xtype: 'panel',
title: 'Basic Panel',
animCollapse: true,
bodyPadding: 5,
html: 'Some content'
});
}
function getCollapsedPanel () {
return applySizing('collapsedPanel', {
xtype: 'panel',
title: 'Collapsed Panel',
animCollapse: true,
bodyPadding: 5,
html: 'Some content',
collapsible: true,
collapsed: true
});
}
function getMaskedPanel () {
return Ext.widget(applySizing('maskedPanel', {
xtype: 'panel',
title: 'Masked Panel',
bodyPadding: 5,
html: 'Some content',
animCollapse: true,
collapsible: true
}));
}
function getFramedPanel () {
return applySizing('framedPanel', {
xtype: 'panel',
title: 'Framed Panel',
animCollapse: true,
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
items: [{
text: 'test'
}]
}, {
dock: 'right',
xtype: 'toolbar',
items: [{
text: 'test B'
}]
}, {
dock: 'left',
xtype: 'toolbar',
items: [{
text: 'test A'
}]
}],
html : 'Some content',
frame: true
});
}
function getCollapsedFramedPanel () {
return applySizing('collapsedFramedPanel', {
xtype: 'panel',
title: 'Collapsed Framed Panel',
animCollapse: true,
bodyPadding: 5,
bodyBorder: true,
html: 'Some content',
frame: true,
collapsible: true,
collapsed: true
});
}
function getPanelWithToolbars () {
/**
* Toolbar with a menu
*/
return applySizing('panelWithToolbars', {
xtype: 'panel',
id: 'panelWithToolbars',
title: 'Basic Panel With Toolbars',
collapsible: true,
tbar: {
id: 'panelWithToolbars_tbar',
items: [{
xtype: 'buttongroup',
title: 'Button Group',
id: 'panelWithToolbars_btngroup',
columns: 2,
defaults: {
scale: 'small'
},
items: [
{
xtype:'splitbutton',
text: 'Menu Button',
iconCls: 'add16',
menu: [{text: 'Menu Button 1'}]
},
{
xtype:'splitbutton',
text: 'Cut',
icon: '../shared/icons/fam/cross.gif',
id: 'panelWithToolbars_splitbtn',
menu: [{text: 'Cut Menu Item'}]
}
]
}]
},
bbar: {
id: 'panelWithToolbars_bbar',
items: [
'Toolbar',
' ',
'-',
{text: 'Button'},
{
text: 'Menu Button',
id : 'menu-btn',
menu: [
{text: 'Menu item'},
{text: 'Check 1', checked: true},
{text: 'Check 2', checked: false},
'-',
{text: 'Option 1', checked: true, group: 'opts'},
{text: 'Option 2', checked: false, group: 'opts'},
'-',
{
text: 'Sub-items',
menu: Ext.widget('menu', {
items: [
{text: 'Item 1'},
{text: 'Item 2'}
]
})
}
]
},
{
xtype: 'splitbutton',
text : 'Split Button',
menu : Ext.widget('menu', {
items: [
{text: 'Item 1'},
{text: 'Item 2'}
]
})
},
{
xtype : 'button',
enableToggle: true,
pressed : true,
text : 'Toggle Button'
}
]
},
lbar: {
id: 'panelWithToolbars_lbar',
items: [
{ text: 'Left' }
]
},
rbar: {
id: 'panelWithToolbars_rbar',
items: [
{ text: 'Right' }
]
}
});
}
function getFormWidgets () {
return applySizing('formWidgets', {
xtype: 'form',
id : 'form-widgets',
title: 'Form Widgets',
frame: true,
collapsible: true,
tools: [
{type:'toggle'},
{type:'close'},
{type:'minimize'},
{type:'maximize'},
{type:'restore'},
{type:'gear'},
{type:'pin'},
{type:'unpin'},
{type:'right'},
{type:'left'},
{type:'down'},
{type:'refresh'},
{type:'minus'},
{type:'plus'},
{type:'help'},
{type:'search'},
{type:'save'},
{type:'print'}
],
bodyPadding: '10 20',
defaults: {
anchor : '98%',
msgTarget : 'side',
allowBlank: false
},
items: [
{
xtype: 'label',
text : 'Plain Label'
},
{
fieldLabel: 'TextField',
xtype : 'textfield',
name : 'someField',
emptyText : 'Enter a value'
},
{
fieldLabel: 'ComboBox',
xtype: 'combo',
store: ['Foo', 'Bar']
},
{
fieldLabel: 'DateField',
xtype : 'datefield',
name : 'date'
},
{
fieldLabel: 'TimeField',
name: 'time',
xtype: 'timefield'
},
{
fieldLabel: 'NumberField',
xtype : 'numberfield',
name : 'number',
emptyText : '(This field is optional)',
allowBlank: true
},
{
fieldLabel: 'TextArea',
xtype : 'textareafield',
name : 'message',
cls : 'x-form-valid',
value : 'This field is hard-coded to have the "valid" style (it will require some code changes to add/remove this style dynamically)'
},
{
fieldLabel: 'Checkboxes',
xtype: 'checkboxgroup',
columns: [100,100],
items: [
{boxLabel: 'Foo', checked: true,id:'fooChk',inputId:'fooChkInput'},
{boxLabel: 'Bar'}
]
},
{
fieldLabel: 'Radios',
xtype: 'radiogroup',
columns: [100,100],
items: [{boxLabel: 'Foo', checked: true, name: 'radios'},{boxLabel: 'Bar', name: 'radios'}]
},
{
hideLabel : true,
id : 'htmleditor',
xtype : 'htmleditor',
name : 'html',
enableColors: false,
value : 'Mouse over toolbar for tooltips.
The HTMLEditor IFrame requires a refresh between a stylesheet switch to get accurate colors.',
height : 110
},
{
xtype : 'fieldset',
title : 'Plain Fieldset',
items: [
{
hideLabel: true,
xtype: 'radiogroup',
items: [
{boxLabel: 'Radio A', checked: true, name: 'radiogrp2'},
{boxLabel: 'Radio B', name: 'radiogrp2'}
]
}
]
},
{
xtype : 'fieldset',
title : 'Collapsible Fieldset',
collapsible: true,
items: [
{ xtype: 'checkbox', boxLabel: 'Checkbox 1' },
{ xtype: 'checkbox', boxLabel: 'Checkbox 2' }
]
},
{
xtype : 'fieldset',
title : 'Checkbox Fieldset',
checkboxToggle: true,
items: [
{ xtype: 'radio', boxLabel: 'Radio 1', name: 'radiongrp1' },
{ xtype: 'radio', boxLabel: 'Radio 2', name: 'radiongrp1' }
]
}
],
buttons: [
{
text :'Toggle Enabled',
handler: function() {
this.up('form').items.each(function(item) {
item.setDisabled(!item.disabled);
});
}
},
{
text : 'Reset Form',
handler: function() {
Ext.getCmp('form-widgets').getForm().reset();
}
},
{
text : 'Validate',
handler: function() {
Ext.getCmp('form-widgets').getForm().isValid();
}
}
]
});
}
function getBorderLayout() {
return applySizing('borderLayout', {
xtype: 'panel',
title : 'BorderLayout Panel',
layout: {
type: 'border',
padding: Ext.themeName === 'neptune' ? 8 : 5 // match padding to theme splitter size
},
collapsible: true,
defaults: {
collapsible: true,
split : true
},
items: [
{
title : 'North',
region : 'north',
html : 'North',
ctitle : 'North',
//margins: '5 5 0 5', // TRBL
height : 70
},
{
title : 'South',
region : 'south',
html : 'South',
collapseMode: 'mini',
//margins : '0 5 5 5', // TRBL
height : 70
},
{
title : 'West',
region : 'west',
html : 'West',
collapseMode: 'mini',
//margins : '0 0 0 5', // TRBL
width : 100
},
{
title : 'East',
region : 'east',
html : 'East',
//margins: '0 5 0 0', // TRBL
width : 100
},
{
title : 'Center',
region : 'center',
collapsible: false,
html : 'Center'
}
]
});
}
function getStore () {
// Reverse order data should get sorted by the MemoryProxy
var myData = [
['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am'],
['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'],
['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
['3m Co',71.72,0.02,0.03,'9/1 12:00am']
];
return Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'company'},
{name: 'price', type: 'float', convert: null},
{name: 'change', type: 'float', convert: null},
{name: 'pctChange', type: 'float', convert: null},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
],
sorters: {
property : 'company',
direction: 'ASC'
},
data: myData,
pageSize: 8
});
}
function getGrid () {
var store = getStore(),
pagingBar = Ext.widget('pagingtoolbar', {
store : store,
displayInfo: true,
displayMsg : 'Displaying topics {0} - {1} of {2}'
});
return applySizing('grid', {
xtype: 'gridpanel',
title: 'GridPanel',
collapsible: true,
deferRowRender: useDeferRender,
store: store,
columns: [
{header: "Company", flex: 1, sortable: true, dataIndex: 'company'},
{header: "Price", width: 75, sortable: true, dataIndex: 'price'},
{header: "Change", width: 80, sortable: true, dataIndex: 'change'},
{header: "% Change", width: 95, sortable: true, dataIndex: 'pctChange'},
{header: "Last Updated", width: 110, sortable: true, xtype: 'datecolumn', dataIndex: 'lastChange'}
],
loadMask: true,
viewConfig: {
stripeRows: true
},
bbar: pagingBar,
tbar: [
{text: 'Toolbar'},
'->',
{
xtype: 'triggerfield',
trigger1Cls: Ext.baseCSSPrefix + 'form-clear-trigger',
trigger2Cls: Ext.baseCSSPrefix + 'form-search-trigger'
}
]
});
}
function getAccordion () {
var tree = Ext.create('Ext.tree.Panel', {
title: 'TreePanel',
deferRowRender: useDeferRender,
root: {
text: 'Root Node',
expanded: true,
children: [{
text: 'Item 1',
leaf: true
}, {
text: 'Item 2',
leaf: true
}, {
text: 'Folder',
children: [{
text: 'Item 3',
leaf: true
}]
}]
}
});
return applySizing('accordion', {
title : 'Accordion and TreePanel',
collapsible: true,
layout: 'accordion',
items: [
tree, {
title: 'Item 2',
html: 'Some content'
}, {
title: 'Item 3',
html : 'Some content'
}
]
});
}
function getTabs (config) {
return Ext.apply({
xtype: 'tabpanel',
activeTab: 0,
defaults: {
bodyPadding: 10
},
items: [
{
title: 'Tab 1',
html : 'Free-standing tab panel'
},
{
title : 'Tab 2',
closable: true
},
{
title : 'Tab 3',
closable: true
}
]
}, config);
}
function getScrollingTabs () {
return applySizing('scrollingTabs', getTabs({
enableTabScroll: true,
items: [
{
title: 'Tab 1',
html : 'Tab panel 1 content'
},
{
title: 'Tab 2',
html : 'Tab panel 2 content',
closable: true
},
{
title: 'Tab 3',
html : 'Tab panel 3 content',
closable: true
},
{
title: 'Tab 4',
html : 'Tab panel 4 content',
closable: true
},
{
title: 'Tab 5',
html : 'Tab panel 5 content',
closable: true
},
{
title: 'Tab 6',
html : 'Tab panel 6 content',
closable: true
}
]
}));
}
function getPlainTabs () {
return applySizing('plainTabs', getTabs({
plain: true
}));
}
function getDatePicker () {
return applySizing('datePicker', {
xtype: 'panel',
border: false,
items: {
xtype: 'datepicker'
}
});
}
function getProgressBar () {
var progressbar = Ext.widget('progressbar', {
value: 0.5
});
if (!hasOption('nopbar')) {
setTimeout(function() {
progressbar.wait({
//animate: true,
text: 'Progress text...'
});
}, 7000);
}
return applySizing('progressBar', {
xtype: 'panel',
title: 'ProgressBar / Slider',
bodyPadding: 5,
layout: 'anchor',
items: [
progressbar,
{
xtype : 'slider',
hideLabel: true,
value : 50,
margin : '5 0 0 0',
anchor : '100%'
},
{
xtype : 'slider',
vertical: true,
value : 50,
height : 100,
margin : '5 0 0 0'
}
]
});
}
function getFramedGrid () {
return applySizing('framedGrid', {
xtype: 'grid',
title: 'Framed Grid',
collapsible: true,
store: getStore(),
multiSelect: true,
emptyText: 'No images to display',
deferRowRender: useDeferRender,
frame: true,
enableColumnMove: false,
columns: [
{header: "Company", flex: 1, sortable: true, dataIndex: 'company'},
{header: "Price", width: 75, sortable: true, dataIndex: 'price'},
{header: "Change", width: 75, sortable: true, dataIndex: 'change'}
]
});
}
function getBasicWindow () {
return Ext.widget('window', applySizing('basicWindow', {
id: 'basicWindow',
hidden: false,
title: 'Window',
bodyPadding: 5,
html : 'Click Submit for Confirmation Msg.',
collapsible: true,
floating : false,
closable : false,
draggable : false,
resizable: { handles: 's' },
animCollapse: true,
tbar: [
{text: 'Toolbar'}
],
buttons: [
{
text : 'Submit',
id : 'message_box',
handler: function() {
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?');
}
}
]
}));
}
function getResizer() {
return Ext.widget(applySizing('resizer', {
xtype: 'component',
style: 'background:transparent;overflow:hidden;',
html: '