});
test("destroy", function() {
+ var expected = $('#list1').accordion(),
+ actual = expected.accordion('destroy');
+ equals(actual, expected, 'destroy is chainable');
ok(false, 'missing test - untested code is broken code');
});
test("enable", function() {
+ var expected = $('#list1').accordion(),
+ actual = expected.accordion('enable');
+ equals(actual, expected, 'enable is chainable');
ok(false, 'missing test - untested code is broken code');
});
test("disable", function() {
+ var expected = $('#list1').accordion(),
+ actual = expected.accordion('disable');
+ equals(actual, expected, 'disable is chainable');
ok(false, 'missing test - untested code is broken code');
});
+test("activate", function() {
+ var expected = $('#list1').accordion(),
+ actual = expected.accordion('activate', 2);
+ equals(actual, expected, 'activate is chainable');
+});
+
test("activate, numeric", function() {
var ac = $('#list1').accordion({ active: 1 });
state(ac, 0, 1, 0);
state(ac, 0, 1, 0);
});
+test("resize", function() {
+ var expected = $('#list1').accordion(),
+ actual = expected.accordion('resize');
+ equals(actual, expected, 'resize is chainable');
+ ok(false, 'missing test - untested code is broken code');
+});
+
})(jQuery);
});
test("destroy", function() {
- expect(6);
+ expect(7);
$("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on element');
$('<div></div>').dialog().dialog("destroy").data("foo.dialog", "bar").remove();
ok(true, 'arbitrary option setter after destroy');
+
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('destroy');
+ equals(actual, expected, 'destroy is chainable');
+});
+
+test("enable", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('enable');
+ equals(actual, expected, 'enable is chainable');
+ ok(false, 'missing test - untested code is broken code');
+});
+
+test("disable", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('disable');
+ equals(actual, expected, 'disable is chainable');
+ ok(false, 'missing test - untested code is broken code');
+});
+
+test("close", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('close');
+ equals(actual, expected, 'close is chainable');
+ ok(false, 'missing test - untested code is broken code');
});
test("isOpen", function() {
el.remove();
});
+test("moveToTop", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('moveToTop');
+ equals(actual, expected, 'moveToTop is chainable');
+ ok(false, 'missing test - untested code is broken code');
+});
+
+test("open", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('open');
+ equals(actual, expected, 'open is chainable');
+ ok(false, 'missing test - untested code is broken code');
+});
+
})(jQuery);
});
test("destroy", function() {
- expect(6);
+ expect(7);
$("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
ok(true, '.draggable("destroy") called on element');
$("<div></div>").draggable().draggable("destroy").data("foo.draggable", "bar");
ok(true, 'arbitrary option setter after destroy');
+
+ var expected = $('<div></div>').draggable(),
+ actual = expected.draggable('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
- expect(6);
+ expect(7);
el = $("#draggable2").draggable({ disabled: true });
shouldnotmove('.draggable({ disabled: true })');
el.draggable("enable");
el.data("disabled.draggable", false);
equals(el.data("disabled.draggable"), false, "disabled.draggable setter");
shouldmove('.data("disabled.draggable", false)');
+
+ var expected = $('<div></div>').draggable(),
+ actual = expected.draggable('enable');
+ equals(actual, expected, 'enable is chainable');
});
test("disable", function() {
- expect(6);
+ expect(7);
el = $("#draggable2").draggable({ disabled: false });
shouldmove('.draggable({ disabled: false })');
el.draggable("disable");
el.data("disabled.draggable", true);
equals(el.data("disabled.draggable"), true, "disabled.draggable setter");
shouldnotmove('.data("disabled.draggable", true)');
+
+ var expected = $('<div></div>').draggable(),
+ actual = expected.draggable('disable');
+ equals(actual, expected, 'disable is chainable');
});
})(jQuery);
});
test("destroy", function() {
- expect(6);
+ expect(7);
$("<div></div>").appendTo('body').droppable().droppable("destroy").remove();
ok(true, '.droppable("destroy") called on element');
$("<div></div>").droppable().droppable("destroy").data("foo.droppable", "bar");
ok(true, 'arbitrary option setter after destroy');
+
+ var expected = $('<div></div>').droppable(),
+ actual = expected.droppable('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
- expect(6);
+ expect(7);
el = $("#droppable1").droppable({ disabled: true });
shouldNotBeDroppable();
el.droppable("enable");
el.data("disabled.droppable", false);
equals(el.data("disabled.droppable"), false, "disabled.droppable setter");
shouldBeDroppable();
+
+ var expected = $('<div></div>').droppable(),
+ actual = expected.droppable('enable');
+ equals(actual, expected, 'enable is chainable');
});
test("disable", function() {
- expect(6);
+ expect(7);
el = $("#droppable1").droppable({ disabled: false });
shouldBeDroppable();
el.droppable("disable");
el.data("disabled.droppable", true);
equals(el.data("disabled.droppable"), true, "disabled.droppable setter");
shouldNotBeDroppable();
+
+ var expected = $('<div></div>').droppable(),
+ actual = expected.droppable('disable');
+ equals(actual, expected, 'disable is chainable');
});
})(jQuery);
});
test("destroy", function() {
- expect(1);
+ expect(2);
$("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove();
ok(true, '.progressbar("destroy") called on element');
+ var expected = $('<div></div>').progressbar(),
+ actual = expected.progressbar('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
})(jQuery);
});
test("destroy", function() {
- expect(6);
+ expect(7);
$("<div></div>").appendTo('body').resizable().resizable("destroy").remove();
ok(true, '.resizable("destroy") called on element');
$('<div></div>').resizable().resizable("destroy").data("foo.resizable", "bar").remove();
ok(true, 'arbitrary option setter after destroy');
+
+ var expected = $('<div></div>').resizable(),
+ actual = expected.resizable('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
+ var expected = $('<div></div>').resizable(),
+ actual = expected.resizable('enable');
+ equals(actual, expected, 'enable is chainable');
ok(false, "missing test - untested code is broken code.");
});
test("disable", function() {
+ var expected = $('<div></div>').resizable(),
+ actual = expected.resizable('disable');
+ equals(actual, expected, 'disable is chainable');
ok(false, "missing test - untested code is broken code.");
});
});
test("destroy", function() {
- expect(6);
+ expect(7);
$("<div></div>").appendTo('body').selectable().selectable("destroy").remove();
ok(true, '.selectable("destroy") called on element');
$("<div></div>").selectable().selectable("destroy").data("foo.selectable", "bar").remove();
ok(true, 'arbitrary option setter after destroy');
+
+ var expected = $('<div></div>').selectable(),
+ actual = expected.selectable('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
- expect(2);
+ expect(3);
var fired = false;
el = $("#selectable1");
el.simulate("drag", 20, 20);
equals(fired, true, "start fired");
el.selectable("destroy");
+
+ var expected = $('<div></div>').selectable(),
+ actual = expected.selectable('enable');
+ equals(actual, expected, 'enable is chainable');
});
test("disable", function() {
- expect(2);
+ expect(3);
var fired = false;
el = $("#selectable1");
el.simulate("drag", 20, 20);
equals(fired, false, "start fired");
el.selectable("destroy");
+
+ var expected = $('<div></div>').selectable(),
+ actual = expected.selectable('disable');
+ equals(actual, expected, 'disable is chainable');
});
})(jQuery);
});
test("destroy", function() {
- expect(8);
+ expect(9);
$("<div></div>").appendTo('body').slider().slider("destroy").remove();
ok(true, '.slider("destroy") called on element');
$('<div></div>').slider().slider("destroy").slider("options", "foo", "bar").remove();
ok(true, 'arbitrary option setter (.slider option method) after destroy');
+
+ var expected = $('<div></div>').slider(),
+ actual = expected.slider('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
+ var expected = $('<div></div>').slider(),
+ actual = expected.slider('enable');
+ equals(actual, expected, 'enable is chainable');
ok(false, "missing test - untested code is broken code.");
});
test("disable", function() {
+ var expected = $('<div></div>').slider(),
+ actual = expected.slider('disable');
+ equals(actual, expected, 'disable is chainable');
ok(false, "missing test - untested code is broken code.");
});
});
test("destroy", function() {
- expect(6);
+ expect(7);
$("<div></div>").appendTo('body').sortable().sortable("destroy").remove();
ok(true, '.sortable("destroy") called on element');
$("<div></div>").sortable().sortable("destroy").data("foo.sortable", "bar");
ok(true, 'arbitrary option setter after destroy');
+
+ var expected = $('<div></div>').sortable(),
+ actual = expected.sortable('destroy');
+ equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
- expect(4);
+ expect(5);
el = $("#sortable").sortable({ disabled: true });
sort($("li", el)[0], 0, 40, 0, '.sortable({ disabled: true })');
equals(el.data("disabled.sortable"), false, "disabled.sortable setter");
sort($("li", el)[0], 0, 40, 2, '.data("disabled.sortable", false)');
+
+ var expected = $('<div></div>').sortable(),
+ actual = expected.sortable('enable');
+ equals(actual, expected, 'enable is chainable');
});
test("disable", function() {
- expect(5);
+ expect(6);
el = $("#sortable").sortable({ disabled: false });
sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })');
el.data("disabled.sortable", true);
equals(el.data("disabled.sortable"), true, "disabled.sortable setter");
sort($("li", el)[0], 0, 40, 0, '.data("disabled.sortable", true)');
+
+ var expected = $('<div></div>').sortable(),
+ actual = expected.sortable('disable');
+ equals(actual, expected, 'disable is chainable');
});
})(jQuery);
if (o.autoHeight || o.fillHeight) {
contents.css("height", "");
}
+
+ return this;
},
_setData: function(key, value) {
}).height(maxHeight);
}
+ return this;
},
activate: function(index) {
// call clickHandler with custom event
var active = this._findActive(index)[0];
this._clickHandler({ target: active }, active);
+
+ return this;
},
_findActive: function(selector) {
// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
-function getter(namespace, plugin, method, args) {
- function getMethods(type) {
- var methods = $[namespace][plugin][type] || [];
- return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
- }
-
- var methods = getMethods('getter');
- if (args.length == 1 && typeof args[0] == 'string') {
- methods = methods.concat(getMethods('getterSetter'));
- }
- return ($.inArray(method, methods) != -1);
-}
-
$.widget = function(name, prototype) {
var namespace = name.split(".")[0],
fullName;
// create plugin method
$.fn[name] = function(options) {
var isMethodCall = (typeof options == 'string'),
- args = Array.prototype.slice.call(arguments, 1);
+ args = Array.prototype.slice.call(arguments, 1),
+ returnValue = this;
// prevent calls to internal methods
if (isMethodCall && options.substring(0, 1) == '_') {
- return this;
- }
-
- // handle getter methods
- if (isMethodCall && getter(namespace, name, options, args)) {
- var instance = $.data(this[0], name);
- return (instance ? instance[options].apply(instance, args)
- : undefined);
+ return returnValue;
}
- // handle initialization and non-getter methods
- return this.each(function() {
- var instance = $.data(this, name);
-
- // constructor
- (!instance && !isMethodCall &&
- $.data(this, name, new $[namespace][name](this, options))._init());
+ (isMethodCall
+ ? this.each(function() {
+ var instance = $.data(this, name),
+ methodValue = (instance && $.isFunction(instance[options])
+ ? instance[options].apply(instance, args)
+ : instance);
+ if (methodValue !== instance) {
+ returnValue = methodValue;
+ return false;
+ }
+ })
+ : this.each(function() {
+ ($.data(this, name) ||
+ $.data(this, name, new $[namespace][name](this, options))._init());
+ }));
- // method call
- (instance && isMethodCall && $.isFunction(instance[options]) &&
- instance[options].apply(instance, args));
- });
+ return returnValue;
};
// create widget constructor
// add widget prototype
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
-
- // TODO: merge getter and getterSetter properties from widget prototype
- // and plugin prototype
- $[namespace][name].getterSetter = 'option';
};
$.widget.prototype = {
this.element.removeData(this.widgetName)
.removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
.removeAttr('aria-disabled');
+
+ return this;
},
option: function(key, value) {
$.each(options, function(key, value) {
self._setData(key, value);
});
+
+ return self;
},
_getData: function(key) {
return this.options[key];
enable: function() {
this._setData('disabled', false);
+ return this;
},
disable: function() {
this._setData('disabled', true);
+ return this;
},
_trigger: function(type, event, data) {
(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
(options.autoOpen && this.open());
-
},
destroy: function() {
this.uiDialog.remove();
(this.originalTitle && this.element.attr('title', this.originalTitle));
+
+ return this;
},
close: function(event) {
$.ui.dialog.overlay.resize();
self._isOpen = false;
-
+
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
if (self.options.modal) {
var maxZ = 0;
});
$.ui.dialog.maxZ = maxZ;
}
+
+ return self;
},
isOpen: function() {
// the force parameter allows us to move modal dialogs to their correct
// position on open
moveToTop: function(force, event) {
-
if ((this.options.modal && !force)
|| (!this.options.stack && !this.options.modal)) {
return this._trigger('focus', event);
this.uiDialog.css('z-index', ++$.ui.dialog.maxZ);
this.element.attr(saveScroll);
this._trigger('focus', event);
+
+ return this;
},
open: function() {
this._trigger('open');
this._isOpen = true;
+
+ return this;
},
_createButtons: function(buttons) {
zIndex: 1000
},
- getter: 'isOpen',
-
uuid: 0,
maxZ: 0,
+ " ui-draggable-dragging"
+ " ui-draggable-disabled");
this._mouseDestroy();
+
+ return this;
},
_mouseCapture: function(event) {
.removeClass("ui-droppable ui-droppable-disabled")
.removeData("droppable")
.unbind(".droppable");
+
+ return this;
},
_setData: function(key, value) {
$.widget.prototype.destroy.apply(this, arguments);
+ return this;
},
value: function(newValue) {
this.originalElement.css('resize', this.originalResizeStyle);
_destroy(this.originalElement);
+ return this;
},
_mouseCapture: function(event) {
.removeData("selectable")
.unbind(".selectable");
this._mouseDestroy();
+
+ return this;
},
_mouseStart: function(event) {
this._mouseDestroy();
+ return this;
},
_mouseCapture: function(event) {
}));
$.extend($.ui.slider, {
- getter: "value values",
version: "@VERSION",
eventPrefix: "slide",
defaults: {
for ( var i = this.items.length - 1; i >= 0; i-- )
this.items[i].item.removeData("sortable-item");
+
+ return this;
},
_mouseCapture: function(event, overrideHandle) {
$(this.domPosition.parent).prepend(this.currentItem);
}
- return true;
+ return this;
},
refresh: function(event) {
this._refreshItems(event);
this.refreshPositions();
+ return this;
},
_connectWith: function() {
};
}
+ return this;
},
_createPlaceholder: function(that) {
}));
$.extend($.ui.sortable, {
- getter: "serialize toArray",
version: "@VERSION",
eventPrefix: "sort",
defaults: {
if (o.cookie) {
this._cookie(null, o.cookie);
}
+
+ return this;
},
add: function(url, label, index) {
// callback
this._trigger('add', null, this._ui(this.anchors[index], this.panels[index]));
+ return this;
},
remove: function(index) {
// callback
this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0]));
+ return this;
},
enable: function(index) {
// callback
this._trigger('enable', null, this._ui(this.anchors[index], this.panels[index]));
+ return this;
},
disable: function(index) {
// callback
this._trigger('disable', null, this._ui(this.anchors[index], this.panels[index]));
}
+
+ return this;
},
select: function(index) {
}
this.anchors.eq(index).trigger(this.options.event + '.tabs');
+ return this;
},
load: function(index) {
self.element.dequeue("tabs");
}
}));
+
+ return this;
},
abort: function() {
// take care of tab labels
this._cleanup();
-
+ return this;
},
url: function(index, url) {
this.anchors.eq(index).removeData('cache.tabs').data('load.tabs', url);
+ return this;
},
length: function() {
$.extend($.ui.tabs, {
version: '@VERSION',
- getter: 'length',
defaults: {
ajaxOptions: null,
cache: false,
delete this._rotate;
delete this._unrotate;
}
+
+ return this;
}
});