Ignore:
Timestamp:
Oct 28, 2011, 3:32:48 PM (12 years ago)
Author:
patdenice
Message:

merge r12525 from trunk to branch 2.3
feature:2487
Update jQuery to 1.6.4 and jQuery UI to 1.8.16

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/themes/default/js/ui/jquery.ui.button.js

    r9559 r12526  
    11/*
    2  * jQuery UI Button 1.8.10
     2 * jQuery UI Button 1.8.16
    33 *
    44 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
     
    1414(function( $, undefined ) {
    1515
    16 var lastActive,
     16var lastActive, startXPos, startYPos, clickDragged,
    1717        baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
    1818        stateClasses = "ui-state-hover ui-state-active ",
    1919        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",
    20         formResetHandler = function( event ) {
    21                 $( ":ui-button", event.target.form ).each(function() {
    22                         var inst = $( this ).data( "button" );
    23                         setTimeout(function() {
    24                                 inst.refresh();
    25                         }, 1 );
    26                 });
     20        formResetHandler = function() {
     21                var buttons = $( this ).find( ":ui-button" );
     22                setTimeout(function() {
     23                        buttons.button( "refresh" );
     24                }, 1 );
    2725        },
    2826        radioGroup = function( radio ) {
     
    5957
    6058                if ( typeof this.options.disabled !== "boolean" ) {
    61                         this.options.disabled = this.element.attr( "disabled" );
     59                        this.options.disabled = this.element.propAttr( "disabled" );
    6260                }
    6361
     
    9795                                $( this ).removeClass( hoverClass );
    9896                        })
     97                        .bind( "click.button", function( event ) {
     98                                if ( options.disabled ) {
     99                                        event.preventDefault();
     100                                        event.stopImmediatePropagation();
     101                                }
     102                        });
     103
     104                this.element
    99105                        .bind( "focus.button", function() {
    100106                                // no need to check disabled, focus won't be triggered anyway
    101                                 $( this ).addClass( focusClass );
     107                                self.buttonElement.addClass( focusClass );
    102108                        })
    103109                        .bind( "blur.button", function() {
    104                                 $( this ).removeClass( focusClass );
     110                                self.buttonElement.removeClass( focusClass );
    105111                        });
    106112
    107113                if ( toggleButton ) {
    108114                        this.element.bind( "change.button", function() {
     115                                if ( clickDragged ) {
     116                                        return;
     117                                }
    109118                                self.refresh();
     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                                        }
    110139                        });
    111140                }
     
    113142                if ( this.type === "checkbox" ) {
    114143                        this.buttonElement.bind( "click.button", function() {
    115                                 if ( options.disabled ) {
     144                                if ( options.disabled || clickDragged ) {
    116145                                        return false;
    117146                                }
     
    121150                } else if ( this.type === "radio" ) {
    122151                        this.buttonElement.bind( "click.button", function() {
    123                                 if ( options.disabled ) {
     152                                if ( options.disabled || clickDragged ) {
    124153                                        return false;
    125154                                }
    126155                                $( this ).addClass( "ui-state-active" );
    127                                 self.buttonElement.attr( "aria-pressed", true );
     156                                self.buttonElement.attr( "aria-pressed", "true" );
    128157
    129158                                var radio = self.element[ 0 ];
     
    134163                                        })
    135164                                        .removeClass( "ui-state-active" )
    136                                         .attr( "aria-pressed", false );
     165                                        .attr( "aria-pressed", "false" );
    137166                        });
    138167                } else {
     
    180209                // be overridden by individual plugins
    181210                this._setOption( "disabled", options.disabled );
     211                this._resetButton();
    182212        },
    183213
    184214        _determineButtonType: function() {
    185                
     215
    186216                if ( this.element.is(":checkbox") ) {
    187217                        this.type = "checkbox";
     218                } else if ( this.element.is(":radio") ) {
     219                        this.type = "radio";
     220                } else if ( this.element.is("input") ) {
     221                        this.type = "input";
    188222                } else {
    189                         if ( this.element.is(":radio") ) {
    190                                 this.type = "radio";
    191                         } else {
    192                                 if ( this.element.is("input") ) {
    193                                         this.type = "input";
    194                                 } else {
    195                                         this.type = "button";
    196                                 }
    197                         }
    198                 }
    199                
     223                        this.type = "button";
     224                }
     225
    200226                if ( this.type === "checkbox" || this.type === "radio" ) {
    201227                        // we don't search against the document in case the element
    202228                        // is disconnected from the DOM
    203                         this.buttonElement = this.element.parents().last()
    204                                 .find( "label[for=" + this.element.attr("id") + "]" );
     229                        var ancestor = this.element.parents().filter(":last"),
     230                                labelSelector = "label[for='" + this.element.attr("id") + "']";
     231                        this.buttonElement = ancestor.find( labelSelector );
     232                        if ( !this.buttonElement.length ) {
     233                                ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
     234                                this.buttonElement = ancestor.filter( labelSelector );
     235                                if ( !this.buttonElement.length ) {
     236                                        this.buttonElement = ancestor.find( labelSelector );
     237                                }
     238                        }
    205239                        this.element.addClass( "ui-helper-hidden-accessible" );
    206240
     
    239273                if ( key === "disabled" ) {
    240274                        if ( value ) {
    241                                 this.element.attr( "disabled", true );
     275                                this.element.propAttr( "disabled", true );
    242276                        } else {
    243                                 this.element.removeAttr( "disabled" );
    244                         }
     277                                this.element.propAttr( "disabled", false );
     278                        }
     279                        return;
    245280                }
    246281                this._resetButton();
     
    257292                                        $( this ).button( "widget" )
    258293                                                .addClass( "ui-state-active" )
    259                                                 .attr( "aria-pressed", true );
     294                                                .attr( "aria-pressed", "true" );
    260295                                } else {
    261296                                        $( this ).button( "widget" )
    262297                                                .removeClass( "ui-state-active" )
    263                                                 .attr( "aria-pressed", false );
     298                                                .attr( "aria-pressed", "false" );
    264299                                }
    265300                        });
     
    268303                                this.buttonElement
    269304                                        .addClass( "ui-state-active" )
    270                                         .attr( "aria-pressed", true );
     305                                        .attr( "aria-pressed", "true" );
    271306                        } else {
    272307                                this.buttonElement
    273308                                        .removeClass( "ui-state-active" )
    274                                         .attr( "aria-pressed", false );
     309                                        .attr( "aria-pressed", "false" );
    275310                        }
    276311                }
     
    295330
    296331                if ( icons.primary || icons.secondary ) {
    297                         buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
     332                        if ( this.options.text ) {
     333                                buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
     334                        }
    298335
    299336                        if ( icons.primary ) {
     
    307344                        if ( !this.options.text ) {
    308345                                buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
    309                                 buttonElement.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
    310346
    311347                                if ( !this.hasTitle ) {
     
    342378       
    343379        refresh: function() {
     380                var ltr = this.element.css( "direction" ) === "ltr";
     381               
    344382                this.buttons = this.element.find( this.options.items )
    345383                        .filter( ":ui-button" )
     
    354392                                .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
    355393                                .filter( ":first" )
    356                                         .addClass( "ui-corner-left" )
     394                                        .addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
    357395                                .end()
    358396                                .filter( ":last" )
    359                                         .addClass( "ui-corner-right" )
     397                                        .addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
    360398                                .end()
    361399                        .end();
Note: See TracChangeset for help on using the changeset viewer.