|
13 | 13 | */
|
14 | 14 | (function( $, undefined ) {
|
15 | 15 |
|
16 |
| -var lastActive, |
| 16 | +var lastActive, startXPos, startYPos, clickDragged, |
17 | 17 | baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
|
18 | 18 | stateClasses = "ui-state-hover ui-state-active ",
|
19 | 19 | typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
|
@@ -111,21 +111,44 @@ $.widget( "ui.button", {
|
111 | 111 |
|
112 | 112 | if ( toggleButton ) {
|
113 | 113 | this.element.bind( "change.button", function() {
|
| 114 | + if ( clickDragged ) { |
| 115 | + return; |
| 116 | + } |
114 | 117 | self.refresh();
|
115 | 118 | });
|
| 119 | + // if mouse moves between mousedown and mouseup (drag) set clickDragged flag |
| 120 | + // prevents issue where button state changes but checkbox/radio checked state |
| 121 | + // does not in Firefox (see ticket #6970) |
| 122 | + this.buttonElement |
| 123 | + .bind( "mousedown.button", function( event ) { |
| 124 | + if ( options.disabled ) { |
| 125 | + return; |
| 126 | + } |
| 127 | + clickDragged = false; |
| 128 | + startXPos = event.pageX; |
| 129 | + startYPos = event.pageY; |
| 130 | + }) |
| 131 | + .bind( "mouseup.button", function( event ) { |
| 132 | + if ( options.disabled ) { |
| 133 | + return; |
| 134 | + } |
| 135 | + if ( startXPos !== event.pageX || startYPos !== event.pageY ) { |
| 136 | + clickDragged = true; |
| 137 | + } |
| 138 | + }); |
116 | 139 | }
|
117 | 140 |
|
118 | 141 | if ( this.type === "checkbox" ) {
|
119 | 142 | this.buttonElement.bind( "click.button", function() {
|
120 |
| - if ( options.disabled ) { |
| 143 | + if ( options.disabled || clickDragged ) { |
121 | 144 | return false;
|
122 | 145 | }
|
123 | 146 | $( this ).toggleClass( "ui-state-active" );
|
124 | 147 | self.buttonElement.attr( "aria-pressed", self.element[0].checked );
|
125 | 148 | });
|
126 | 149 | } else if ( this.type === "radio" ) {
|
127 | 150 | this.buttonElement.bind( "click.button", function() {
|
128 |
| - if ( options.disabled ) { |
| 151 | + if ( options.disabled || clickDragged ) { |
129 | 152 | return false;
|
130 | 153 | }
|
131 | 154 | $( this ).addClass( "ui-state-active" );
|
|
0 commit comments