Changeset 20824 for trunk/themes/default/js/ui/jquery.ui.autocomplete.js
- Timestamp:
- Feb 18, 2013, 10:18:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/themes/default/js/ui/jquery.ui.autocomplete.js
r18630 r20824 1 1 /*! 2 * jQuery UI Autocomplete 1. 9.02 * jQuery UI Autocomplete 1.10.1 3 3 * http://jqueryui.com 4 4 * 5 * Copyright 201 2jQuery Foundation and other contributors5 * Copyright 2013 jQuery Foundation and other contributors 6 6 * Released under the MIT license. 7 7 * http://jquery.org/license … … 21 21 22 22 $.widget( "ui.autocomplete", { 23 version: "1. 9.0",23 version: "1.10.1", 24 24 defaultElement: "<input>", 25 25 options: { 26 appendTo: "body",26 appendTo: null, 27 27 autoFocus: false, 28 28 delay: 300, … … 55 55 // events when we know the keydown event was used to modify the 56 56 // search term. #7799 57 var suppressKeyPress, suppressKeyPressRepeat, suppressInput; 58 59 this.isMultiLine = this._isMultiLine(); 60 this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ]; 57 var suppressKeyPress, suppressKeyPressRepeat, suppressInput, 58 nodeName = this.element[0].nodeName.toLowerCase(), 59 isTextarea = nodeName === "textarea", 60 isInput = nodeName === "input"; 61 62 this.isMultiLine = 63 // Textareas are always multi-line 64 isTextarea ? true : 65 // Inputs are always single-line, even if inside a contentEditable element 66 // IE also treats inputs as contentEditable 67 isInput ? false : 68 // All other element types are determined by whether or not they're contentEditable 69 this.element.prop( "isContentEditable" ); 70 71 this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; 61 72 this.isNewMenu = true; 62 73 … … 65 76 .attr( "autocomplete", "off" ); 66 77 67 this._on( {78 this._on( this.element, { 68 79 keydown: function( event ) { 80 /*jshint maxcomplexity:15*/ 69 81 if ( this.element.prop( "readOnly" ) ) { 70 82 suppressKeyPress = true; … … 181 193 this._initSource(); 182 194 this.menu = $( "<ul>" ) 183 .addClass( "ui-autocomplete " )184 .appendTo( this. document.find( this.options.appendTo || "body" )[ 0 ])195 .addClass( "ui-autocomplete ui-front" ) 196 .appendTo( this._appendTo() ) 185 197 .menu({ 186 198 // custom key handling for now … … 189 201 role: null 190 202 }) 191 .zIndex( this.element.zIndex() + 1 )192 203 .hide() 193 .data( "menu" ); 204 .data( "ui-menu" ); 205 194 206 this._on( this.menu.element, { 195 207 mousedown: function( event ) { … … 237 249 } 238 250 239 // back compat for _renderItem using item.autocomplete, via #7810 240 // TODO remove the fallback, see #8156 241 var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ); 251 var item = ui.item.data( "ui-autocomplete-item" ); 242 252 if ( false !== this._trigger( "focus", event, { item: item } ) ) { 243 253 // use value to match what will end up in the input, if it was a key event … … 255 265 }, 256 266 menuselect: function( event, ui ) { 257 // back compat for _renderItem using item.autocomplete, via #7810 258 // TODO remove the fallback, see #8156 259 var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ), 267 var item = ui.item.data( "ui-autocomplete-item" ), 260 268 previous = this.previous; 261 269 … … 292 300 .insertAfter( this.element ); 293 301 294 if ( $.fn.bgiframe ) {295 this.menu.element.bgiframe();296 }297 298 302 // turning off autocomplete prevents the browser from remembering the 299 303 // value when navigating through history, so we re-enable autocomplete … … 321 325 } 322 326 if ( key === "appendTo" ) { 323 this.menu.element.appendTo( this. document.find( value || "body" )[0]);327 this.menu.element.appendTo( this._appendTo() ); 324 328 } 325 329 if ( key === "disabled" && value && this.xhr ) { … … 328 332 }, 329 333 330 _isMultiLine: function() { 331 // Textareas are always multi-line 332 if ( this.element.is( "textarea" ) ) { 333 return true; 334 } 335 // Inputs are always single-line, even if inside a contentEditable element 336 // IE also treats inputs as contentEditable 337 if ( this.element.is( "input" ) ) { 338 return false; 339 } 340 // All other element types are determined by whether or not they're contentEditable 341 return this.element.prop( "isContentEditable" ); 334 _appendTo: function() { 335 var element = this.options.appendTo; 336 337 if ( element ) { 338 element = element.jquery || element.nodeType ? 339 $( element ) : 340 this.document.find( element ).eq( 0 ); 341 } 342 343 if ( !element ) { 344 element = this.element.closest( ".ui-front" ); 345 } 346 347 if ( !element.length ) { 348 element = this.document[0].body; 349 } 350 351 return element; 342 352 }, 343 353 … … 360 370 data: request, 361 371 dataType: "json", 362 success: function( data , status) {372 success: function( data ) { 363 373 response( data ); 364 374 }, … … 479 489 480 490 _suggest: function( items ) { 481 var ul = this.menu.element 482 .empty() 483 .zIndex( this.element.zIndex() + 1 ); 491 var ul = this.menu.element.empty(); 484 492 this._renderMenu( ul, items ); 485 493 this.menu.refresh(); … … 542 550 }, 543 551 544 _value: function( value) {552 _value: function() { 545 553 return this.valueMethod.apply( this.element, arguments ); 546 554 }, … … 598 606 }); 599 607 600 601 608 }( jQuery ));
Note: See TracChangeset
for help on using the changeset viewer.