|
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",
|
@@ -112,21 +112,44 @@ $.widget( "ui.button", {
|
112 | 112 |
|
113 | 113 | if ( toggleButton ) {
|
114 | 114 | this.element.bind( "change.button", function() {
|
| 115 | + if ( clickDragged ) { |
| 116 | + return; |
| 117 | + } |
115 | 118 | self.refresh();
|
116 | 119 | });
|
| 120 | + // if mouse moves between mousedown and mouseup (drag) set clickDragged flag |
| 121 | + // prevents issue where button state changes but checkbox/radio checked state |
| 122 | + // does not in Firefox (see ticket #6970) |
| 123 | + this.buttonElement |
| 124 | + .bind( "mousedown.button", function( event ) { |
| 125 | + if ( options.disabled ) { |
| 126 | + return; |
| 127 | + } |
| 128 | + clickDragged = false; |
| 129 | + startXPos = event.pageX; |
| 130 | + startYPos = event.pageY; |
| 131 | + }) |
| 132 | + .bind( "mouseup.button", function( event ) { |
| 133 | + if ( options.disabled ) { |
| 134 | + return; |
| 135 | + } |
| 136 | + if ( startXPos !== event.pageX || startYPos !== event.pageY ) { |
| 137 | + clickDragged = true; |
| 138 | + } |
| 139 | + }); |
117 | 140 | }
|
118 | 141 |
|
119 | 142 | if ( this.type === "checkbox" ) {
|
120 | 143 | this.buttonElement.bind( "click.button", function() {
|
121 |
| - if ( options.disabled ) { |
| 144 | + if ( options.disabled || clickDragged ) { |
122 | 145 | return false;
|
123 | 146 | }
|
124 | 147 | $( this ).toggleClass( "ui-state-active" );
|
125 | 148 | self.buttonElement.attr( "aria-pressed", self.element[0].checked );
|
126 | 149 | });
|
127 | 150 | } else if ( this.type === "radio" ) {
|
128 | 151 | this.buttonElement.bind( "click.button", function() {
|
129 |
| - if ( options.disabled ) { |
| 152 | + if ( options.disabled || clickDragged ) { |
130 | 153 | return false;
|
131 | 154 | }
|
132 | 155 | $( this ).addClass( "ui-state-active" );
|
|
0 commit comments