diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-06-13 08:00:45 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-06-13 08:00:45 -0400 |
commit | 9608e981498846b3727cc4dad723a7fa7252fd86 (patch) | |
tree | 591ab885bf28ef77be87b2121fe9ecb461e7358f | |
parent | e8b623207abcae500ffb3860378543906cd4e2b2 (diff) | |
download | jquery-ui-9608e981498846b3727cc4dad723a7fa7252fd86.tar.gz jquery-ui-9608e981498846b3727cc4dad723a7fa7252fd86.zip |
Widget: Rename _bind() to _on(). Partial fix for #7795 - Widget: _on and _off.
-rw-r--r-- | demos/widget/default.html | 6 | ||||
-rw-r--r-- | tests/unit/widget/widget_core.js | 14 | ||||
-rw-r--r-- | ui/jquery.ui.accordion.js | 6 | ||||
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 6 | ||||
-rw-r--r-- | ui/jquery.ui.menu.js | 7 | ||||
-rw-r--r-- | ui/jquery.ui.slider.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.spinner.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.tabs.js | 8 | ||||
-rw-r--r-- | ui/jquery.ui.tooltip.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.widget.js | 10 |
10 files changed, 33 insertions, 34 deletions
diff --git a/demos/widget/default.html b/demos/widget/default.html index f39825034..8d08256ce 100644 --- a/demos/widget/default.html +++ b/demos/widget/default.html @@ -56,8 +56,8 @@ .button(); // bind click events on the changer button to the random method - this._bind( this.changer, { - // _bind won't call random when widget is disabled + this._on( this.changer, { + // _on won't call random when widget is disabled click: "random" }); this._refresh(); @@ -90,7 +90,7 @@ } }, - // events bound via _bind are removed automatically + // events bound via _on are removed automatically // revert other modifications here _destroy: function() { // remove generated elements diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index aa70e2425..3dfaf1918 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -610,13 +610,13 @@ test( ".widget() - overriden", function() { deepEqual( wrapper[0], $( "<div>" ).testWidget().testWidget( "widget" )[0] ); }); -test( "._bind() to element (default)", function() { +test( "._on() to element (default)", function() { expect( 12 ); var that, widget; $.widget( "ui.testWidget", { _create: function() { that = this; - this._bind({ + this._on({ keyup: this.keyup, keydown: "keydown" }); @@ -650,13 +650,13 @@ test( "._bind() to element (default)", function() { .trigger( "keydown" ); }); -test( "._bind() to descendent", function() { +test( "._on() to descendent", function() { expect( 12 ); var that, widget, descendant; $.widget( "ui.testWidget", { _create: function() { that = this; - this._bind( this.element.find( "strong" ), { + this._on( this.element.find( "strong" ), { keyup: this.keyup, keydown: "keydown" }); @@ -707,7 +707,7 @@ test( "._bind() to descendent", function() { .trigger( "keydown" ); }); -test( "_bind() with delegate", function() { +test( "_on() with delegate", function() { expect( 8 ); $.widget( "ui.testWidget", { _create: function() { @@ -727,7 +727,7 @@ test( "_bind() with delegate", function() { } }; }; - this._bind({ + this._on({ "click": "handler", "click a": "handler" }); @@ -740,7 +740,7 @@ test( "_bind() with delegate", function() { } }; }; - this._bind({ + this._on({ "change form fieldset > input": "handler" }); } diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 856b3ba4b..4cfc265a3 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -137,8 +137,8 @@ $.widget( "ui.accordion", { }); } - this._bind( this.headers, { keydown: "_keydown" }); - this._bind( this.headers.next(), { keydown: "_panelKeyDown" }); + this._on( this.headers, { keydown: "_keydown" }); + this._on( this.headers.next(), { keydown: "_panelKeyDown" }); this._setupEvents( options.event ); }, @@ -376,7 +376,7 @@ $.widget( "ui.accordion", { $.each( event.split(" "), function( index, eventName ) { events[ eventName ] = "_eventHandler"; }); - this._bind( this.headers, events ); + this._on( this.headers, events ); }, _eventHandler: function( event ) { diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 2fb7e395c..f73fff96d 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -63,7 +63,7 @@ $.widget( "ui.autocomplete", { .addClass( "ui-autocomplete-input" ) .attr( "autocomplete", "off" ); - this._bind({ + this._on({ keydown: function( event ) { if ( this.element.prop( "readOnly" ) ) { suppressKeyPress = true; @@ -190,7 +190,7 @@ $.widget( "ui.autocomplete", { .zIndex( this.element.zIndex() + 1 ) .hide() .data( "menu" ); - this._bind( this.menu.element, { + this._on( this.menu.element, { mousedown: function( event ) { // prevent moving focus out of the text field event.preventDefault(); @@ -297,7 +297,7 @@ $.widget( "ui.autocomplete", { // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 - this._bind( this.window, { + this._on( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 986cca168..eb0be494c 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -43,7 +43,7 @@ $.widget( "ui.menu", { tabIndex: 0 }) // need to catch all clicks on disabled menu - // not possible through _bind + // not possible through _on .bind( "click.menu", $.proxy(function( event ) { if ( this.options.disabled ) { event.preventDefault(); @@ -56,7 +56,7 @@ $.widget( "ui.menu", { .attr( "aria-disabled", "true" ); } - this._bind({ + this._on({ // Prevent focus from sticking to links inside menu after clicking // them (focus should always stay on UL during navigation). "mousedown .ui-menu-item > a": function( event ) { @@ -122,8 +122,7 @@ $.widget( "ui.menu", { this.refresh(); // TODO: We probably shouldn't bind to document for each menu. - // TODO: This isn't being cleaned up on destroy. - this._bind( this.document, { + this._on( this.document, { click: function( event ) { if ( !$( event.target ).closest( ".ui-menu" ).length ) { this.collapseAll( event ); diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index c302bfe8b..e44d20f7c 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -114,7 +114,7 @@ $.widget( "ui.slider", $.ui.mouse, { $( this ).data( "ui-slider-handle-index", i ); }); - this._bind( this.handles, { + this._on( this.handles, { keydown: function( event ) { var allowed, curVal, newVal, step, index = $( event.target ).data( "ui-slider-handle-index" ); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index b01feec9a..d6ebc6d87 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -54,13 +54,13 @@ $.widget( "ui.spinner", { this._value( this.element.val(), true ); this._draw(); - this._bind( this._events ); + this._on( this._events ); this._refresh(); // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 - this._bind( this.window, { + this._on( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index f3b27cf9d..5878a56a1 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -481,9 +481,9 @@ $.widget( "ui.tabs", { } this.anchors.add( this.tabs ).add( this.panels ).unbind( ".tabs" ); - this._bind( this.anchors, events ); - this._bind( this.tabs, { keydown: "_tabKeydown" } ); - this._bind( this.panels, { keydown: "_panelKeydown" } ); + this._on( this.anchors, events ); + this._on( this.tabs, { keydown: "_tabKeydown" } ); + this._on( this.panels, { keydown: "_panelKeydown" } ); this._focusable( this.tabs ); this._hoverable( this.tabs ); @@ -943,7 +943,7 @@ if ( $.uiBackCompat !== false ) { }, _create: function() { this._super(); - this._bind({ + this._on({ tabsbeforeload: function( event, ui ) { if ( !this.options.spinner ) { return; diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 752c95687..6a7aab706 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -61,7 +61,7 @@ $.widget( "ui.tooltip", { }, _create: function() { - this._bind({ + this._on({ mouseover: "open", focusin: "open" }); @@ -185,7 +185,7 @@ $.widget( "ui.tooltip", { this._trigger( "open", event, { tooltip: tooltip } ); - this._bind( target, { + this._on( target, { mouseleave: "close", focusout: "close", keyup: function( event ) { diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index e317d3841..410b7003a 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -224,7 +224,7 @@ $.Widget.prototype = { // TODO remove dual storage $.data( element, this.widgetName, this ); $.data( element, this.widgetFullName, this ); - this._bind({ remove: "destroy" }); + this._on({ remove: "destroy" }); this.document = $( element.style ? // element within the document element.ownerDocument : @@ -245,7 +245,7 @@ $.Widget.prototype = { destroy: function() { this._destroy(); // we can probably remove the unbind calls in 2.0 - // all event bindings should go through this._bind() + // all event bindings should go through this._on() this.element .unbind( "." + this.widgetName ) // 1.9 BC for #7810 @@ -342,7 +342,7 @@ $.Widget.prototype = { return this._setOption( "disabled", true ); }, - _bind: function( element, handlers ) { + _on: function( element, handlers ) { // no element argument, shuffle and use this.element if ( !handlers ) { handlers = element; @@ -395,7 +395,7 @@ $.Widget.prototype = { _hoverable: function( element ) { this.hoverable = this.hoverable.add( element ); - this._bind( element, { + this._on( element, { mouseenter: function( event ) { $( event.currentTarget ).addClass( "ui-state-hover" ); }, @@ -407,7 +407,7 @@ $.Widget.prototype = { _focusable: function( element ) { this.focusable = this.focusable.add( element ); - this._bind( element, { + this._on( element, { focusin: function( event ) { $( event.currentTarget ).addClass( "ui-state-focus" ); }, |