Skip to content

Commit

Permalink
Widget: define a null default for the create callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Apr 25, 2011
1 parent c4c36e5 commit 325ee6e
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 121 deletions.
3 changes: 2 additions & 1 deletion tests/unit/accordion/accordion_defaults.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ commonWidgetTests( "accordion", {


// callbacks // callbacks
activate: null, activate: null,
beforeActivate: null beforeActivate: null,
create: null
} }
}); });
3 changes: 2 additions & 1 deletion tests/unit/accordion/accordion_defaults_deprecated.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ commonWidgetTests( "accordion", {
activate: null, activate: null,
beforeActivate: null, beforeActivate: null,
change: null, change: null,
changestart: null changestart: null,
create: null
} }
}); });
1 change: 1 addition & 0 deletions tests/unit/autocomplete/autocomplete_defaults.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ commonWidgetTests( "autocomplete", {
// callbacks // callbacks
change: null, change: null,
close: null, close: null,
create: null,
focus: null, focus: null,
open: null, open: null,
response: null, response: null,
Expand Down
25 changes: 12 additions & 13 deletions tests/unit/button/button_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,14 @@
/* commonWidgetTests( "button", {
* button_defaults.js defaults: {
*/ disabled: null,
icons: {
primary: null,
secondary: null
},
label: null,
text: true,


var button_defaults = { // callbacks
disabled: null, create: null
text: true,
label: null,
icons: {
primary: null,
secondary: null
} }
}; });

commonWidgetTests('button', { defaults: button_defaults });
67 changes: 33 additions & 34 deletions tests/unit/dialog/dialog_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,35 +1,34 @@
/* commonWidgetTests( "dialog", {
* dialog_defaults.js defaults: {
*/ autoOpen: true,
buttons: {},
closeOnEscape: true,
closeText: 'close',
disabled: false,
dialogClass: '',
draggable: true,
height: 'auto',
hide: null,
maxHeight: false,
maxWidth: false,
minHeight: 150,
minWidth: 150,
modal: false,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit',
using: $.ui.dialog.prototype.options.position.using
},
resizable: true,
show: null,
stack: true,
title: '',
width: 300,
zIndex: 1000,


var dialog_defaults = { // callbacks
autoOpen: true, create: null
buttons: {}, }
closeOnEscape: true, });
closeText: 'close',
disabled: false,
dialogClass: '',
draggable: true,
height: 'auto',
hide: null,
maxHeight: false,
maxWidth: false,
minHeight: 150,
minWidth: 150,
modal: false,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit',
using: $.ui.dialog.prototype.options.position.using
},
resizable: true,
show: null,
stack: true,
title: '',
width: 300,
zIndex: 1000
};

commonWidgetTests('dialog', { defaults: dialog_defaults });
4 changes: 2 additions & 2 deletions tests/unit/dialog/dialog_options.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ test("height", function() {
expect(3); expect(3);


el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(dlg().height(), dialog_defaults.minHeight, "default height"); equals(dlg().height(), 150, "default height");
el.remove(); el.remove();


el = $('<div></div>').dialog({ height: 237 }); el = $('<div></div>').dialog({ height: 237 });
Expand Down Expand Up @@ -431,7 +431,7 @@ test("width", function() {
expect(3); expect(3);


el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(dlg().width(), dialog_defaults.width, "default width"); equals(dlg().width(), 300, "default width");
el.remove(); el.remove();


el = $('<div></div>').dialog({width: 437 }); el = $('<div></div>').dialog({width: 437 });
Expand Down
21 changes: 10 additions & 11 deletions tests/unit/menu/menu_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,13 +1,12 @@
/* commonWidgetTests( "menu", {
* menu_defaults.js defaults: {
*/ disabled: false,
position: {
my: "left top",
at: "right top"
},


var menu_defaults = { // callbacks
disabled: false, create: null
position: {
my: "left top",
at: "right top"
} }
}; });

commonWidgetTests('menu', { defaults: menu_defaults });
19 changes: 9 additions & 10 deletions tests/unit/progressbar/progressbar_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,10 @@
/* commonWidgetTests( "progressbar", {
* progressbar_defaults.js defaults: {
*/ disabled: false,
value: 0,
max: 100,


var progressbar_defaults = { //callbacks
disabled: false, create: null
value: 0, }
max: 100 });
};

commonWidgetTests('progressbar', { defaults: progressbar_defaults });
37 changes: 18 additions & 19 deletions tests/unit/slider/slider_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,20 +1,19 @@
/* commonWidgetTests( "slider", {
* slider_defaults.js defaults: {
*/ animate: false,
cancel: function() {},
delay: 0,
disabled: false,
distance: 0,
max: 100,
min: 0,
orientation: 'horizontal',
range: false,
step: 1,
value: 0,
values: null,


var slider_defaults = { // callbacks
animate: false, create: null
cancel: function() {}, }
delay: 0, });
disabled: false,
distance: 0,
max: 100,
min: 0,
orientation: 'horizontal',
range: false,
step: 1,
value: 0,
values: null
};

commonWidgetTests('slider', { defaults: slider_defaults });
29 changes: 14 additions & 15 deletions tests/unit/spinner/spinner_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,16 +1,15 @@
/* commonWidgetTests( "spinner", {
* spinner_defaults.js defaults: {
*/ disabled: false,
incremental: true,
max: null,
min: null,
numberformat: null,
page: 10,
step: null,
value: null,


var spinner_defaults = { // callbacks
disabled: false, create: null
incremental: true, }
max: null, });
min: null,
numberformat: null,
page: 10,
step: null,
value: null
};

commonWidgetTests('spinner', { defaults: spinner_defaults });
1 change: 1 addition & 0 deletions tests/unit/tabs/tabs_defaults.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ commonWidgetTests( "tabs", {
activate: null, activate: null,
beforeActivate: null, beforeActivate: null,
beforeLoad: null, beforeLoad: null,
create: null,
load: null load: null
} }
}); });
1 change: 1 addition & 0 deletions tests/unit/tabs/tabs_defaults_deprecated.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ commonWidgetTests( "tabs", {
add: null, add: null,
beforeActivate: null, beforeActivate: null,
beforeLoad: null, beforeLoad: null,
create: null,
disable: null, disable: null,
enable: null, enable: null,
load: null, load: null,
Expand Down
27 changes: 13 additions & 14 deletions tests/unit/tooltip/tooltip_defaults.js
Original file line number Original file line Diff line number Diff line change
@@ -1,16 +1,15 @@
/* commonWidgetTests( "tooltip", {
* tooltip_defaults.js defaults: {
*/ disabled: false,
items: "[title]",
content: $.ui.tooltip.prototype.options.content,
position: {
my: "left center",
at: "right center",
offset: "15 0"
},


var tooltip_defaults = { // callbacks
disabled: false, create: null
items: "[title]",
content: $.ui.tooltip.prototype.options.content,
position: {
my: "left center",
at: "right center",
offset: "15 0"
} }
}; });

commonWidgetTests('tooltip', { defaults: tooltip_defaults });
3 changes: 3 additions & 0 deletions tests/unit/widget/widget_core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ test( "merge multiple option arguments", function() {
$.widget( "ui.testWidget", { $.widget( "ui.testWidget", {
_create: function() { _create: function() {
same( this.options, { same( this.options, {
create: null,
disabled: false, disabled: false,
option1: "value1", option1: "value1",
option2: "value2", option2: "value2",
Expand Down Expand Up @@ -249,6 +250,7 @@ test( "._getCreateOptions()", function() {
}, },
_create: function() { _create: function() {
same( this.options, { same( this.options, {
create: null,
disabled: false, disabled: false,
option1: "override1", option1: "override1",
option2: "value2", option2: "value2",
Expand Down Expand Up @@ -418,6 +420,7 @@ test( ".option() - getter", function() {


var options = div.testWidget( "option" ); var options = div.testWidget( "option" );
same( options, { same( options, {
create: null,
disabled: false, disabled: false,
foo: "bar", foo: "bar",
baz: 5, baz: 5,
Expand Down
5 changes: 4 additions & 1 deletion ui/jquery.ui.widget.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ $.Widget.prototype = {
widgetEventPrefix: "", widgetEventPrefix: "",
defaultElement: "<div>", defaultElement: "<div>",
options: { options: {
disabled: false disabled: false,

// callbacks
create: null
}, },
_createWidget: function( options, element ) { _createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ]; element = $( element || this.defaultElement || this )[ 0 ];
Expand Down

0 comments on commit 325ee6e

Please sign in to comment.