|
| 1 | +import Button from '../../../src/button/Base.mjs'; |
| 2 | +import CheckBox from '../../../src/form/field/CheckBox.mjs'; |
| 3 | +import ComboBox from '../../../src/form/field/ComboBox.mjs'; |
| 4 | +import ConfigurationViewport from '../../ConfigurationViewport.mjs'; |
| 5 | +import Container from '../../../src/container/Base.mjs'; |
| 6 | +import NumberField from '../../../src/form/field/Number.mjs'; |
| 7 | +import Radio from '../../../src/form/field/Radio.mjs'; |
| 8 | +import TextField from '../../../src/form/field/Text.mjs'; |
| 9 | +import Toolbar from '../../../src/toolbar/Base.mjs'; |
| 10 | + |
| 11 | +/** |
| 12 | + * @class Neo.examples.layout.card.MainContainer |
| 13 | + * @extends Neo.examples.ConfigurationViewport |
| 14 | + */ |
| 15 | +class MainContainer extends ConfigurationViewport { |
| 16 | + static config = { |
| 17 | + className : 'Neo.examples.layout.card.MainContainer', |
| 18 | + configItemLabelWidth: 160, |
| 19 | + configItemWidth : 280, |
| 20 | + layout : {ntype: 'hbox', align: 'stretch'} |
| 21 | + } |
| 22 | + |
| 23 | + createConfigurationComponents() { |
| 24 | + let me = this, |
| 25 | + {layout} = me.exampleComponent; |
| 26 | + |
| 27 | + return [{ |
| 28 | + module : Radio, |
| 29 | + checked : layout.slideDirection === 'bottom-left', |
| 30 | + hideValueLabel: false, |
| 31 | + labelText : 'slideDirection', |
| 32 | + listeners : {change: me.onRadioLayoutChange.bind(me, 'slideDirection', 'horizontal')}, |
| 33 | + name : 'slideDirection', |
| 34 | + valueLabelText: 'horizontal' |
| 35 | + }, { |
| 36 | + module : Radio, |
| 37 | + checked : layout.slideDirection === 'vertical', |
| 38 | + hideValueLabel: false, |
| 39 | + labelText : '', |
| 40 | + listeners : {change: me.onRadioLayoutChange.bind(me, 'slideDirection', 'vertical')}, |
| 41 | + name : 'slideDirection', |
| 42 | + valueLabelText: 'vertical' |
| 43 | + }, { |
| 44 | + module : Radio, |
| 45 | + checked : layout.slideDirection === null, |
| 46 | + hideValueLabel: false, |
| 47 | + labelText : '', |
| 48 | + listeners : {change: me.onRadioLayoutChange.bind(me, 'slideDirection', null)}, |
| 49 | + name : 'slideDirection', |
| 50 | + valueLabelText: 'null' |
| 51 | + }, { |
| 52 | + module : NumberField, |
| 53 | + clearable : true, |
| 54 | + labelText : 'height', |
| 55 | + listeners : {change: me.onConfigChange.bind(me, 'height')}, |
| 56 | + maxValue : 300, |
| 57 | + minValue : 30, |
| 58 | + stepSize : 5, |
| 59 | + style : {marginTop: '10px'}, |
| 60 | + value : me.exampleComponent.height |
| 61 | + }, { |
| 62 | + module : NumberField, |
| 63 | + clearable : true, |
| 64 | + labelText : 'width', |
| 65 | + listeners : {change: me.onConfigChange.bind(me, 'width')}, |
| 66 | + maxValue : 300, |
| 67 | + minValue : 100, |
| 68 | + stepSize : 5, |
| 69 | + style : {marginTop: '10px'}, |
| 70 | + value : me.exampleComponent.width |
| 71 | + }]; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @returns {Neo.component.Base} |
| 76 | + */ |
| 77 | + createExampleComponent() { |
| 78 | + return Neo.create({ |
| 79 | + module : Container, |
| 80 | + height : 300, |
| 81 | + width : 400, |
| 82 | + |
| 83 | + items: [{ |
| 84 | + module: Container, |
| 85 | + layout: {ntype: 'card', slideDirection: 'horizontal'}, |
| 86 | + items : [{ |
| 87 | + style: {backgroundColor: 'red'} |
| 88 | + }, { |
| 89 | + style: {backgroundColor: 'blue'} |
| 90 | + }] |
| 91 | + }, { |
| 92 | + module: Toolbar, |
| 93 | + flex : 'none', |
| 94 | + items : [{ |
| 95 | + handler: 'onNextButtonClick', |
| 96 | + text : 'Prev' |
| 97 | + }, '->', { |
| 98 | + handler: 'onPrevButtonClick', |
| 99 | + text : 'Next' |
| 100 | + }] |
| 101 | + }] |
| 102 | + }) |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * @param {Object} data |
| 107 | + */ |
| 108 | + onNextButtonClick(data) { |
| 109 | + this.exampleComponent.layout.activeIndex++; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * @param {String} config |
| 114 | + * @param {String} value |
| 115 | + * @param {Object} opts |
| 116 | + */ |
| 117 | + onRadioLayoutChange(config, value, opts) { |
| 118 | + if (opts.value === true) { // we only want to listen to check events, not uncheck |
| 119 | + this.exampleComponent.layout[config] = value; |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * @param {Object} data |
| 125 | + */ |
| 126 | + onPrevButtonClick(data) { |
| 127 | + this.exampleComponent.layout.activeIndex--; |
| 128 | + } |
| 129 | +} |
| 130 | + |
| 131 | +Neo.setupClass(MainContainer); |
| 132 | + |
| 133 | +export default MainContainer; |
0 commit comments