r3560 committed - Widget factory:...
Revision: 3560
Author: scott.gonzalez
Date: Wed Dec 30 10:04:17 2009
Log: Widget factory:
- Added widget() method to get the outermost element.
- Applying disabled classes to this.widget() instead of this.element.
- Returning full options hash when calling the options method with no
arguments.
Fixes #4913 - Add a widget method.
Fixes #5020 - method to get all options.
Fixes #5028 - Widget: disabled classes should be added to main element.
http://code.google.com/p/jquery-ui/source/detail?r=3560
Modified:
/branches/dev/ui/jquery.ui.widget.js
=======================================
--- /branches/dev/ui/jquery.ui.widget.js Mon Dec 28 07:51:04 2009
+++ /branches/dev/ui/jquery.ui.widget.js Wed Dec 30 10:04:17 2009
@@ -46,6 +46,11 @@
// we need to make the options hash a property directly on the new
instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
+// $.each(basePrototype, function(key, val) {
+// if ($.isPlainObject(val)) {
+// basePrototype[key] = $.extend({}, val);
+// }
+// });
basePrototype.options = $.extend({}, basePrototype.options);
$[namespace][name].prototype = $.extend(true, basePrototype, {
namespace: namespace,
@@ -126,17 +131,28 @@
destroy: function() {
this.element
.unbind('.' + this.widgetName)
- .removeData(this.widgetName)
+ .removeData(this.widgetName);
+ this.widget()
+ .unbind('.' + this.widgetName)
.removeAttr('aria-disabled')
.removeClass(
this.widgetBaseClass + '-disabled ' +
this.namespace + '-state-disabled');
},
+ widget: function() {
+ return this.element;
+ },
+
option: function(key, value) {
var options = key,
self = this;
+ if (arguments.length === 0) {
+ // don't return a reference to the internal hash
+ return $.extend({}, self.options);
+ }
+
if (typeof key == "string") {
if (value === undefined) {
return this.options[key];
@@ -155,7 +171,7 @@
this.options[key] = value;
if (key == 'disabled') {
- this.element
+ this.widget()
[value ? 'addClass' : 'removeClass'](
this.widgetBaseClass + '-disabled' + ' ' +
this.namespace + '-state-disabled')
--