diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 40 | ||||
-rw-r--r-- | ui/jquery.ui.datepicker.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.dialog.js | 59 | ||||
-rw-r--r-- | ui/jquery.ui.draggable.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.menu.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.slider.js | 151 |
6 files changed, 149 insertions, 107 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index af1acb02b..1b0f2138f 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -54,10 +54,21 @@ $.widget( "ui.autocomplete", { // so we use the suppressKeyPressRepeat flag to avoid handling keypress // events when we know the keydown event was used to modify the // search term. #7799 - var suppressKeyPress, suppressKeyPressRepeat, suppressInput; - - this.isMultiLine = this._isMultiLine(); - this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ]; + var suppressKeyPress, suppressKeyPressRepeat, suppressInput, + nodeName = this.element[0].nodeName.toLowerCase(), + isTextarea = nodeName === "textarea", + isInput = nodeName === "input"; + + this.isMultiLine = + // Textareas are always multi-line + isTextarea ? true : + // Inputs are always single-line, even if inside a contentEditable element + // IE also treats inputs as contentEditable + isInput ? false : + // All other element types are determined by whether or not they're contentEditable + this.element.prop( "isContentEditable" ); + + this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; this.isNewMenu = true; this.element @@ -181,7 +192,7 @@ $.widget( "ui.autocomplete", { this._initSource(); this.menu = $( "<ul>" ) - .addClass( "ui-autocomplete" ) + .addClass( "ui-autocomplete ui-front" ) .appendTo( this._appendTo() ) .menu({ // custom key handling for now @@ -189,7 +200,6 @@ $.widget( "ui.autocomplete", { // disable ARIA support, the live region takes care of that role: null }) - .zIndex( this.element.zIndex() + 1 ) .hide() .data( "ui-menu" ); @@ -341,20 +351,6 @@ $.widget( "ui.autocomplete", { return element; }, - _isMultiLine: function() { - // Textareas are always multi-line - if ( this.element.is( "textarea" ) ) { - return true; - } - // Inputs are always single-line, even if inside a contentEditable element - // IE also treats inputs as contentEditable - if ( this.element.is( "input" ) ) { - return false; - } - // All other element types are determined by whether or not they're contentEditable - return this.element.prop( "isContentEditable" ); - }, - _initSource: function() { var array, url, that = this; @@ -492,9 +488,7 @@ $.widget( "ui.autocomplete", { }, _suggest: function( items ) { - var ul = this.menu.element - .empty() - .zIndex( this.element.zIndex() + 1 ); + var ul = this.menu.element.empty(); this._renderMenu( ul, items ); this.menu.refresh(); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index e93f596fc..efee7a819 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1741,7 +1741,7 @@ $.extend(Datepicker.prototype, { (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) - ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2] + "'" : "") + // cell title + ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions (otherMonth && !showOtherMonths ? " " : // display for other months (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index ec4032ff3..85dbddda2 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -207,6 +207,7 @@ $.widget( "ui.dialog", { }, open: function() { + var that = this; if ( this._isOpen ) { if ( this._moveToTop() ) { this._focusTabbable(); @@ -214,19 +215,19 @@ $.widget( "ui.dialog", { return; } + this._isOpen = true; this.opener = $( this.document[0].activeElement ); this._size(); this._position(); this._createOverlay(); this._moveToTop( null, true ); - this._show( this.uiDialog, this.options.show ); - - this._focusTabbable(); + this._show( this.uiDialog, this.options.show, function() { + that._focusTabbable(); + that._trigger("focus"); + }); - this._isOpen = true; this._trigger("open"); - this._trigger("focus"); }, _focusTabbable: function() { @@ -395,7 +396,7 @@ $.widget( "ui.dialog", { this.uiDialogButtonPane.remove(); this.uiButtonSet.empty(); - if ( $.isEmptyObject( buttons ) ) { + if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) { this.uiDialog.removeClass("ui-dialog-buttons"); return; } @@ -443,6 +444,7 @@ $.widget( "ui.dialog", { containment: "document", start: function( event, ui ) { $( this ).addClass("ui-dialog-dragging"); + that._blockFrames(); that._trigger( "dragStart", event, filteredUi( ui ) ); }, drag: function( event, ui ) { @@ -454,6 +456,7 @@ $.widget( "ui.dialog", { ui.position.top - that.document.scrollTop() ]; $( this ).removeClass("ui-dialog-dragging"); + that._unblockFrames(); that._trigger( "dragStop", event, filteredUi( ui ) ); } }); @@ -490,6 +493,7 @@ $.widget( "ui.dialog", { handles: resizeHandles, start: function( event, ui ) { $( this ).addClass("ui-dialog-resizing"); + that._blockFrames(); that._trigger( "resizeStart", event, filteredUi( ui ) ); }, resize: function( event, ui ) { @@ -499,6 +503,7 @@ $.widget( "ui.dialog", { options.height = $( this ).height(); options.width = $( this ).width(); $( this ).removeClass("ui-dialog-resizing"); + that._unblockFrames(); that._trigger( "resizeStop", event, filteredUi( ui ) ); } }) @@ -665,6 +670,28 @@ $.widget( "ui.dialog", { } }, + _blockFrames: function() { + this.iframeBlocks = this.document.find( "iframe" ).map(function() { + var iframe = $( this ); + + return $( "<div>" ) + .css({ + position: "absolute", + width: iframe.outerWidth(), + height: iframe.outerHeight() + }) + .appendTo( iframe.parent() ) + .offset( iframe.offset() )[0]; + }); + }, + + _unblockFrames: function() { + if ( this.iframeBlocks ) { + this.iframeBlocks.remove(); + delete this.iframeBlocks; + } + }, + _createOverlay: function() { if ( !this.options.modal ) { return; @@ -677,16 +704,14 @@ $.widget( "ui.dialog", { this._delay(function() { // Handle .dialog().dialog("close") (#4065) if ( $.ui.dialog.overlayInstances ) { - this._on( this.document, { - focusin: function( event ) { - if ( !$( event.target ).closest(".ui-dialog").length && - // TODO: Remove hack when datepicker implements - // the .ui-front logic (#8989) - !$( event.target ).closest(".ui-datepicker").length ) { - event.preventDefault(); - $(".ui-dialog:visible:last .ui-dialog-content") - .data("ui-dialog")._focusTabbable(); - } + this.document.bind( "focusin.dialog", function( event ) { + if ( !$( event.target ).closest(".ui-dialog").length && + // TODO: Remove hack when datepicker implements + // the .ui-front logic (#8989) + !$( event.target ).closest(".ui-datepicker").length ) { + event.preventDefault(); + $(".ui-dialog:visible:last .ui-dialog-content") + .data("ui-dialog")._focusTabbable(); } }); } @@ -711,7 +736,7 @@ $.widget( "ui.dialog", { $.ui.dialog.overlayInstances--; if ( !$.ui.dialog.overlayInstances ) { - this._off( this.document, "focusin" ); + this.document.unbind( "focusin.dialog" ); } this.overlay.remove(); this.overlay = null; diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index cbf5e1747..9a31add7c 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -643,7 +643,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { this.instance.offset.click = inst.offset.click; if (this !== thisSortable && this.instance._intersectsWith(this.instance.containerCache) && - $.ui.contains(thisSortable.instance.element[0], this.instance.element[0]) + $.contains(thisSortable.instance.element[0], this.instance.element[0]) ) { innermostIntersecting = false; } diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 4ffe732d4..1c633786d 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -323,7 +323,7 @@ $.widget( "ui.menu", { menus.children( ":not(.ui-menu-item)" ).each(function() { var item = $( this ); // hyphen, em dash, en dash - if ( !/[^\-—–\s]/.test( item.text() ) ) { + if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) { item.addClass( "ui-widget-content ui-menu-divider" ); } }); diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 54024af49..b3e609aa2 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -42,12 +42,6 @@ $.widget( "ui.slider", $.ui.mouse, { }, _create: function() { - var i, handleCount, - o = this.options, - existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ), - handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>", - handles = []; - this._keySliding = false; this._mouseSliding = false; this._animateOff = true; @@ -62,29 +56,32 @@ $.widget( "ui.slider", $.ui.mouse, { " ui-widget-content" + " ui-corner-all"); - this.range = $([]); + this._refresh(); + this._setOption( "disabled", this.options.disabled ); - if ( o.range ) { - if ( o.range === true ) { - if ( !o.values ) { - o.values = [ this._valueMin(), this._valueMin() ]; - } else if ( o.values.length && o.values.length !== 2 ) { - o.values = [ o.values[0], o.values[0] ]; - } else if ( $.isArray( o.values ) ) { - o.values = o.values.slice(0); - } - } + this._animateOff = false; + }, - this.range = $( "<div></div>" ) - .appendTo( this.element ) - .addClass( "ui-slider-range" + - // note: this isn't the most fittingly semantic framework class for this element, - // but worked best visually with a variety of themes - " ui-widget-header ui-corner-all" + - ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) ); - } + _refresh: function() { + this._createRange(); + this._createHandles(); + this._setupEvents(); + this._refreshValue(); + }, + + _createHandles: function() { + var i, handleCount, + options = this.options, + existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ), + handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>", + handles = []; - handleCount = ( o.values && o.values.length ) || 1; + handleCount = ( options.values && options.values.length ) || 1; + + if ( existingHandles.length > handleCount ) { + existingHandles.slice( handleCount ).remove(); + existingHandles = existingHandles.slice( 0, handleCount ); + } for ( i = existingHandles.length; i < handleCount; i++ ) { handles.push( handle ); @@ -94,41 +91,56 @@ $.widget( "ui.slider", $.ui.mouse, { this.handle = this.handles.eq( 0 ); - this.handles.add( this.range ).filter( "a" ) - .click(function( event ) { - event.preventDefault(); - }) - .mouseenter(function() { - if ( !o.disabled ) { - $( this ).addClass( "ui-state-hover" ); - } - }) - .mouseleave(function() { - $( this ).removeClass( "ui-state-hover" ); - }) - .focus(function() { - if ( !o.disabled ) { - $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" ); - $( this ).addClass( "ui-state-focus" ); - } else { - $( this ).blur(); - } - }) - .blur(function() { - $( this ).removeClass( "ui-state-focus" ); - }); - this.handles.each(function( i ) { $( this ).data( "ui-slider-handle-index", i ); }); + }, - this._setOption( "disabled", o.disabled ); + _createRange: function() { + var options = this.options, + classes = ""; + + if ( options.range ) { + if ( options.range === true ) { + if ( !options.values ) { + options.values = [ this._valueMin(), this._valueMin() ]; + } else if ( options.values.length && options.values.length !== 2 ) { + options.values = [ options.values[0], options.values[0] ]; + } else if ( $.isArray( options.values ) ) { + options.values = options.values.slice(0); + } + } - this._on( this.handles, this._handleEvents ); + if ( !this.range || !this.range.length ) { + this.range = $( "<div></div>" ) + .appendTo( this.element ); - this._refreshValue(); + classes = "ui-slider-range" + + // note: this isn't the most fittingly semantic framework class for this element, + // but worked best visually with a variety of themes + " ui-widget-header ui-corner-all"; + } else { + this.range.removeClass( "ui-slider-range-min ui-slider-range-max" ) + // Handle range switching from true to min/max + .css({ + "left": "", + "bottom": "" + }); + } - this._animateOff = false; + this.range.addClass( classes + + ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) ); + } else { + this.range = $([]); + } + }, + + _setupEvents: function() { + var elements = this.handles.add( this.range ).filter( "a" ); + this._off( elements ); + this._on( elements, this._handleEvents ); + this._hoverable( elements ); + this._focusable( elements ); }, _destroy: function() { @@ -401,6 +413,16 @@ $.widget( "ui.slider", $.ui.mouse, { var i, valsLength = 0; + if ( key === "range" && this.options.range === true ) { + if ( value === "min" ) { + this.options.value = this._values( 0 ); + this.options.values = null; + } else if ( value === "max" ) { + this.options.value = this._values( this.options.values.length-1 ); + this.options.values = null; + } + } + if ( $.isArray( this.options.values ) ) { valsLength = this.options.values.length; } @@ -408,15 +430,6 @@ $.widget( "ui.slider", $.ui.mouse, { $.Widget.prototype._setOption.apply( this, arguments ); switch ( key ) { - case "disabled": - if ( value ) { - this.handles.filter( ".ui-state-focus" ).blur(); - this.handles.removeClass( "ui-state-hover" ); - this.handles.prop( "disabled", true ); - } else { - this.handles.prop( "disabled", false ); - } - break; case "orientation": this._detectOrientation(); this.element @@ -444,6 +457,11 @@ $.widget( "ui.slider", $.ui.mouse, { this._refreshValue(); this._animateOff = false; break; + case "range": + this._animateOff = true; + this._refresh(); + this._animateOff = false; + break; } }, @@ -469,7 +487,7 @@ $.widget( "ui.slider", $.ui.mouse, { val = this._trimAlignValue( val ); return val; - } else { + } else if ( this.options.values && this.options.values.length ) { // .slice() creates a copy of the array // this copy gets trimmed by min and max and then returned vals = this.options.values.slice(); @@ -478,6 +496,8 @@ $.widget( "ui.slider", $.ui.mouse, { } return vals; + } else { + return []; } }, @@ -632,6 +652,9 @@ $.widget( "ui.slider", $.ui.mouse, { this._slide( event, index, newVal ); }, + click: function( event ) { + event.preventDefault(); + }, keyup: function( event ) { var index = $( event.target ).data( "ui-slider-handle-index" ); |