Lines Matching refs:buttons
1 YUI.add('widget-buttons-test', function (Y) {
41 '`buttons` should default to an empty Object': function () {
44 Assert.isObject(this.widget.get('buttons'), '`buttons` is not an Object.');
45 ObjectAssert.ownsNoKeys(this.widget.get('buttons'), '`buttons` was not an empty Object.');
48 '`buttons` should be accessible within a subclass initializer': function () {
54 var headerButtons = this.get('buttons.header');
64 buttons: [
75 '`buttons` should be parsed from a `srcNode`': function () {
79 '<span class="yui3-widget-buttons">' +
96 '`buttons` parsed from a `srcNode` should inherit any defaults': function () {
109 '<span class="yui3-widget-buttons">' +
136 '`buttons` parsed from a `srcNode` should be overridden by user-provided `buttons`': function () {
140 '<span class="yui3-widget-buttons">' +
153 buttons: [
160 Assert.areSame(1, this.widget.get('buttons.header').length, 'Header contained more than 1 button.');
169 '`destory()` should remove all buttons': function () {
173 buttons: [{label: 'foo'}]
179 Assert.isFalse(contentBox.all('.yui3-button').isEmpty(), 'Widget did not have buttons.');
182 Assert.isTrue(contentBox.all('.yui3-button').isEmpty(), 'Widget still had buttons.');
195 '`buttons` should be able to be specified as an Array of Objects': function () {
197 buttons: [
203 ArrayAssert.isNotEmpty(this.widget.get('buttons.header'), '`buttons.header` was empty.');
204 ArrayAssert.isNotEmpty(this.widget.get('buttons.footer'), '`buttons.footer` was empty.');
207 '`buttons` should be able to be specified as an Object of Arrays of Objects': function () {
209 buttons: {
215 ArrayAssert.isNotEmpty(this.widget.get('buttons.header'), '`buttons.header` was empty.');
216 ArrayAssert.isNotEmpty(this.widget.get('buttons.footer'), '`buttons.footer` was empty.');
219 '`buttons` specified as an Object of section-Arrays should override a button specific section': function () {
221 buttons: {
229 Assert.areSame(2, this.widget.get('buttons.header').length, '`buttons.header` did not have 2 buttons.');
230 Assert.isUndefined(this.widget.get('buttons.footer'), '`buttons.footer` was not `undefined`.');
233 '`buttons` specified without a section should default to the footer': function () {
235 buttons: [
241 Assert.areSame(2, this.widget.get('buttons.footer').length, '`buttons.footer` did not have 2 buttons.');
244 '`buttons` should be able to be specified as an Array of Y.Nodes': function () {
246 buttons: [
252 var buttons = this.widget.get('buttons.footer');
254 Assert.areSame(2, buttons.length, '`buttons.footer` did not have 2 buttons.');
255 Assert.areSame('foo', buttons[0].get('text'), 'First button did not have the test "foo".');
256 Assert.areSame('bar', buttons[1].get('text'), 'Second button did not have the test "bar".');
259 '`buttons` should be able to be specified as an Object of Arrays of Y.Nodes': function () {
261 buttons: {
267 ArrayAssert.isNotEmpty(this.widget.get('buttons.header'), '`buttons.header` was empty.');
268 ArrayAssert.isNotEmpty(this.widget.get('buttons.footer'), '`buttons.footer` was empty.');
271 '`buttons` should be able to be specified as a mixture of all possibile configurations': function () {
282 buttons: [
292 buttons = this.widget.get('buttons');
294 Assert.areSame(foo, buttons.header[0], '`foo` was not the first header button.');
295 Assert.areSame(bar, buttons.body[0], '`bar` was not the first body button.');
296 Assert.areSame(baz, buttons.footer[0], '`baz` was no the first footer button.');
299 '`buttons` should be settable to a new value': function () {
301 buttons: [{name: 'foo', label: 'Foo'}],
305 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Did not have 1 footer button.');
308 this.widget.set('buttons', [{name: 'foo', label: 'Bar'}]);
310 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Did not have 1 footer button.');
315 '`buttons` should be settable to the same value': function () {
317 buttons: [{name: 'foo', label: 'Foo'}],
321 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Did not have 1 footer button.');
324 this.widget.set('buttons', this.widget.get('buttons'));
326 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Did not have 1 footer button.');
352 buttons: {
358 ArrayAssert.isNotEmpty(this.widget.get('buttons.header'), 'Header buttons array was empty.');
361 ArrayAssert.isNotEmpty(this.widget.get('buttons.footer'), 'Footer buttons array was empty.');
365 'User-provided `buttons` should override defaults': function () {
380 widget1 = new PanelWidget({buttons: []}),
383 buttons: [
393 ObjectAssert.ownsNoKeys(widget1.get('buttons'), '`widget1` has buttons.');
394 Assert.areSame('Close', widget2.get('buttons.header')[0].get('text'), '`widget2` does not have a "close" button in header.');
405 buttons: [{name: 'foo'}]
411 'Last button in should win when multiple `buttons` have the same `name`': function () {
412 var buttons;
416 buttons: [
422 buttons = this.widget.get('contentBox').all('.yui3-button');
423 Assert.areSame(2, buttons.size(), 'Widget did not have 2 buttons.');
425 Assert.areSame(buttons.item(1), this.widget.getButton('foo'), 'First button is not `foo`.');
433 buttons: [{name: 'foo', action: 'doSomething'}]
447 buttons: [{name: 'foo', isDefault: true}]
453 'Last button in should win when multiple `buttons` are `isDefault`': function () {
455 buttons: [
461 Assert.areSame(2, this.widget.get('buttons.footer').length, 'Widget did not have 2 footer buttons.');
467 buttons: [
482 Assert.areSame(9, this.widget.get('buttons.footer').length, 'Widget did not have 9 footer buttons.');
490 buttons: [
559 buttons: [
595 Assert.isUndefined(this.widget.get('buttons.header'), 'Widget has button config in header.');
606 Assert.areSame(1, this.widget.get('buttons.header').length, 'Widget does not have 1 button config in header.');
623 Assert.areSame(1, this.widget.get('buttons').footer.length, 'Widget does not have 1 button config in header.');
635 buttons: {
640 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Footer did not have only 1 button.');
644 Assert.areSame(2, this.widget.get('buttons.footer').length, 'Footer did not have only 2 buttons.');
645 Assert.areSame('Bar', this.widget.get('buttons.footer')[1].get('text'), 'Last footer button was not "Bar".');
650 buttons: {
655 Assert.areSame(1, this.widget.get('buttons.header').length, 'Header did not have only 1 button.');
659 Assert.areSame(2, this.widget.get('buttons.header').length, 'Header did not have only 2 buttons.');
660 Assert.areSame('Bar', this.widget.get('buttons.header')[1].get('text'), 'Last header button was not "Bar".');
665 buttons: {
670 Assert.areSame(1, this.widget.get('buttons.header').length, 'Header did not have only 1 button.');
674 Assert.areSame(2, this.widget.get('buttons.header').length, 'Header did not have only 2 buttons.');
675 Assert.areSame('Bar', this.widget.get('buttons.header')[0].get('text'), 'Last header button was not "Bar".');
683 buttons: [
695 buttons: {
713 buttons: {
732 buttons: [{name: 'foo', label: 'Foo'}],
736 ArrayAssert.isNotEmpty(this.widget.get('buttons.footer'), 'Footer buttons was empty.');
741 Assert.isUndefined(this.widget.get('buttons.footer'), 'Footer buttons was not `undefined`.');
747 buttons: {
754 Assert.isUndefined(this.widget.get('buttons.header'), 'Header buttons were not empty.');
758 Assert.isUndefined(this.widget.get('buttons.header'), 'Header buttons were not empty.');
761 Assert.isUndefined(this.widget.get('buttons.footer'), 'Footer buttons were not empty.');
766 buttons: {
774 Assert.areSame(2, this.widget.get('buttons.footer').length, 'Footer did not have only 2 button.');
778 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Footer did not have only 1 buttons.');
779 Assert.areSame('Bar', this.widget.get('buttons.footer')[0].get('text'), 'The only footer button was not "Bar".');
784 buttons: {
792 Assert.areSame(2, this.widget.get('buttons.header').length, 'Header did not have only 2 button.');
796 Assert.areSame(1, this.widget.get('buttons.header').length, 'Header did not have only 1 buttons.');
797 Assert.areSame('Bar', this.widget.get('buttons.header')[0].get('text'), 'The only header button was not "Bar".');
816 '`buttons` should render their `value` as text': function () {
821 buttons: [
833 '`buttons` should render their `label` as text': function () {
838 buttons: [
850 '`buttons` should render in the correction section': function () {
855 buttons: [
874 '`buttons` should move to the correct position': function () {
878 '<span class="yui3-widget-buttons">' +
887 var headerButtons = Y.one('#test .yui3-widget-hd .yui3-widget-buttons'),
896 buttons: {
918 buttons: [
944 buttons: [{label: 'Foo'}]
966 '`buttonsChange` should fire when setting new `buttons`': function () {
968 buttons, button;
972 buttons: {
981 buttons = this.widget.get('buttons');
984 this.widget.set('buttons', [
993 Assert.areNotSame(buttons, this.widget.get('buttons'), '`buttons` was not re-created.');
996 Assert.areSame(1, this.widget.get('buttons.header').length, 'Widget header did not have a button.');
1005 buttons: {
1028 Assert.areSame(1, this.widget.get('buttons.header').length, 'Widget header did not have a button.');
1037 buttons: {
1056 Assert.isUndefined(this.widget.get('buttons.header'), 'Button was not removed from `buttons`.');
1063 buttons;
1067 buttons: [{label: 'Foo'}],
1083 buttons = this.widget.get('buttons');
1085 ArrayAssert.isNotEmpty(buttons.footer, 'Footer buttons was empty.');
1088 this.widget.set('buttons', []);
1090 ArrayAssert.isNotEmpty(this.widget.get('buttons.footer'), 'Footer buttons was empty.');
1091 Assert.areSame(buttons.footer[0], this.widget.get('buttons.footer')[0], '`buttons` changed.');
1101 buttons;
1105 buttons: [{label: 'Foo'}],
1121 buttons = this.widget.get('buttons');
1123 ArrayAssert.isNotEmpty(buttons.footer, 'Footer buttons was empty.');
1128 Assert.areSame(1, this.widget.get('buttons.footer').length, 'Footer buttons does not only have 1 button.');
1129 Assert.areSame(buttons.footer[0], this.widget.get('buttons.footer')[0], '`buttons` changed.');
1139 buttons;
1143 buttons: [
1162 buttons = this.widget.get('buttons');
1164 ArrayAssert.isNotEmpty(buttons.footer, 'Footer buttons was empty.');
1169 Assert.areSame(2, this.widget.get('buttons.footer').length, 'Footer buttons does not only have 2 buttons.');
1170 Assert.areSame(buttons.footer[0], this.widget.get('buttons.footer')[0], '`buttons` changed.');
1177 '`contentUpdate` should fire when the buttons change in the DOM': function () {
1182 buttons: [{label: 'Foo'}]
1192 this.widget.set('buttons', [{label: 'Bar'}]);
1204 buttons: [{label: 'Foo'}]
1215 Assert.areSame(2, this.widget.get('contentBox').all('.yui3-button').size(), 'The widget did not have 2 buttons.');
1224 buttons: [{label: 'Foo'}]
1235 Assert.areSame(0, this.widget.get('contentBox').all('.yui3-button').size(), 'The widget has buttons.');
1239 '`contentUpdate` should not fire when the buttons in the DOM do not actually change': function () {
1244 buttons: [{label: 'Foo'}]
1253 this.widget.set('buttons', this.widget.get('buttons'));
1263 requires: ['widget-buttons', 'test', 'node-event-simulate']