mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
parent
8336ba7b69
commit
f8c2bbb0c8
@ -7,6 +7,7 @@ define( [
|
|||||||
return $.extend( helper, {
|
return $.extend( helper, {
|
||||||
drag: function( element, handle, dx, dy ) {
|
drag: function( element, handle, dx, dy ) {
|
||||||
var d = element.dialog( "widget" );
|
var d = element.dialog( "widget" );
|
||||||
|
|
||||||
//this mouseover is to work around a limitation in resizable
|
//this mouseover is to work around a limitation in resizable
|
||||||
//TODO: fix resizable so handle doesn't require mouseover in order to be used
|
//TODO: fix resizable so handle doesn't require mouseover in order to be used
|
||||||
$( handle, d ).simulate( "mouseover" ).simulate( "drag", {
|
$( handle, d ).simulate( "mouseover" ).simulate( "drag", {
|
||||||
@ -30,6 +31,7 @@ return $.extend( helper, {
|
|||||||
actualDY = offsetAfter.top - offsetBefore.top;
|
actualDY = offsetAfter.top - offsetBefore.top;
|
||||||
ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg );
|
ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg );
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO switch back to checking the size of the .ui-dialog element (var d)
|
// TODO switch back to checking the size of the .ui-dialog element (var d)
|
||||||
// once we switch to using box-sizing: border-box (#9845) that should work fine
|
// once we switch to using box-sizing: border-box (#9845) that should work fine
|
||||||
// using the element's dimensions to avoid subpixel errors
|
// using the element's dimensions to avoid subpixel errors
|
||||||
|
@ -226,12 +226,14 @@ asyncTest( "#8958: dialog can be opened while opening", function() {
|
|||||||
$( "body" ).trigger( "focus" );
|
$( "body" ).trigger( "focus" );
|
||||||
|
|
||||||
$( "#favorite-animal" )
|
$( "#favorite-animal" )
|
||||||
|
|
||||||
// We focus the input to start the test. Once it receives focus, the
|
// We focus the input to start the test. Once it receives focus, the
|
||||||
// dialog will open. Opening the dialog, will cause an element inside
|
// dialog will open. Opening the dialog, will cause an element inside
|
||||||
// the dialog to gain focus, thus blurring the input.
|
// the dialog to gain focus, thus blurring the input.
|
||||||
.on( "focus", function() {
|
.on( "focus", function() {
|
||||||
element.dialog( "open" );
|
element.dialog( "open" );
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// When the input blurs, the dialog is in the process of opening. We
|
// When the input blurs, the dialog is in the process of opening. We
|
||||||
// try to open the dialog again, to make sure that dialogs properly
|
// try to open the dialog again, to make sure that dialogs properly
|
||||||
// handle a call to the open() method during the process of the dialog
|
// handle a call to the open() method during the process of the dialog
|
||||||
|
@ -444,6 +444,7 @@ test( "title", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var element = $( "<div></div>" ).dialog();
|
var element = $( "<div></div>" ).dialog();
|
||||||
|
|
||||||
// some browsers return a non-breaking space and some return " "
|
// some browsers return a non-breaking space and some return " "
|
||||||
// so we generate a non-breaking space for comparison
|
// so we generate a non-breaking space for comparison
|
||||||
equal( titleText(), $( "<span> </span>" ).html(), "[default]" );
|
equal( titleText(), $( "<span> </span>" ).html(), "[default]" );
|
||||||
@ -471,6 +472,7 @@ test( "title", function() {
|
|||||||
|
|
||||||
// Make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
|
// Make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
|
||||||
element = $( "<form><input name='title'></form>" ).dialog();
|
element = $( "<form><input name='title'></form>" ).dialog();
|
||||||
|
|
||||||
// some browsers return a non-breaking space and some return " "
|
// some browsers return a non-breaking space and some return " "
|
||||||
// so we get the text to normalize to the actual non-breaking space
|
// so we get the text to normalize to the actual non-breaking space
|
||||||
equal( titleText(), $( "<span> </span>" ).html(), "[default]" );
|
equal( titleText(), $( "<span> </span>" ).html(), "[default]" );
|
||||||
|
@ -68,6 +68,7 @@ $.widget( "ui.dialog", {
|
|||||||
at: "center",
|
at: "center",
|
||||||
of: window,
|
of: window,
|
||||||
collision: "fit",
|
collision: "fit",
|
||||||
|
|
||||||
// Ensure the titlebar is always visible
|
// Ensure the titlebar is always visible
|
||||||
using: function( pos ) {
|
using: function( pos ) {
|
||||||
var topOffset = $( this ).css( pos ).offset().top;
|
var topOffset = $( this ).css( pos ).offset().top;
|
||||||
@ -176,6 +177,7 @@ $.widget( "ui.dialog", {
|
|||||||
this.element
|
this.element
|
||||||
.removeUniqueId()
|
.removeUniqueId()
|
||||||
.css( this.originalCss )
|
.css( this.originalCss )
|
||||||
|
|
||||||
// Without detaching first, the following becomes really slow
|
// Without detaching first, the following becomes really slow
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
@ -186,6 +188,7 @@ $.widget( "ui.dialog", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
next = originalPosition.parent.children().eq( originalPosition.index );
|
next = originalPosition.parent.children().eq( originalPosition.index );
|
||||||
|
|
||||||
// Don't try to place the dialog next to itself (#8613)
|
// Don't try to place the dialog next to itself (#8613)
|
||||||
if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
|
if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
|
||||||
next.before( this.element );
|
next.before( this.element );
|
||||||
@ -290,6 +293,7 @@ $.widget( "ui.dialog", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_focusTabbable: function() {
|
_focusTabbable: function() {
|
||||||
|
|
||||||
// Set focus to the first match:
|
// Set focus to the first match:
|
||||||
// 1. An element that was focused previously
|
// 1. An element that was focused previously
|
||||||
// 2. First element inside the dialog matching [autofocus]
|
// 2. First element inside the dialog matching [autofocus]
|
||||||
@ -327,6 +331,7 @@ $.widget( "ui.dialog", {
|
|||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
checkFocus.call( this );
|
checkFocus.call( this );
|
||||||
|
|
||||||
// support: IE
|
// support: IE
|
||||||
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
|
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
|
||||||
// so we check again later
|
// so we check again later
|
||||||
@ -337,6 +342,7 @@ $.widget( "ui.dialog", {
|
|||||||
this.uiDialog = $( "<div>" )
|
this.uiDialog = $( "<div>" )
|
||||||
.hide()
|
.hide()
|
||||||
.attr( {
|
.attr( {
|
||||||
|
|
||||||
// Setting tabIndex makes the div focusable
|
// Setting tabIndex makes the div focusable
|
||||||
tabIndex: -1,
|
tabIndex: -1,
|
||||||
role: "dialog"
|
role: "dialog"
|
||||||
@ -398,10 +404,12 @@ $.widget( "ui.dialog", {
|
|||||||
"ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
|
"ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
|
||||||
this._on( this.uiDialogTitlebar, {
|
this._on( this.uiDialogTitlebar, {
|
||||||
mousedown: function( event ) {
|
mousedown: function( event ) {
|
||||||
|
|
||||||
// Don't prevent click on close button (#8838)
|
// Don't prevent click on close button (#8838)
|
||||||
// Focusing a dialog that is partially scrolled out of view
|
// Focusing a dialog that is partially scrolled out of view
|
||||||
// causes the browser to scroll it into view, preventing the click event
|
// causes the browser to scroll it into view, preventing the click event
|
||||||
if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
|
if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
|
||||||
|
|
||||||
// Dialog isn't getting focus when dragging (#8063)
|
// Dialog isn't getting focus when dragging (#8063)
|
||||||
this.uiDialog.trigger( "focus" );
|
this.uiDialog.trigger( "focus" );
|
||||||
}
|
}
|
||||||
@ -478,8 +486,10 @@ $.widget( "ui.dialog", {
|
|||||||
props = $.isFunction( props ) ?
|
props = $.isFunction( props ) ?
|
||||||
{ click: props, text: name } :
|
{ click: props, text: name } :
|
||||||
props;
|
props;
|
||||||
|
|
||||||
// Default to a non-submitting button
|
// Default to a non-submitting button
|
||||||
props = $.extend( { type: "button" }, props );
|
props = $.extend( { type: "button" }, props );
|
||||||
|
|
||||||
// Change the context for the click callback to be the main element
|
// Change the context for the click callback to be the main element
|
||||||
click = props.click;
|
click = props.click;
|
||||||
buttonOptions = {
|
buttonOptions = {
|
||||||
@ -545,6 +555,7 @@ $.widget( "ui.dialog", {
|
|||||||
var that = this,
|
var that = this,
|
||||||
options = this.options,
|
options = this.options,
|
||||||
handles = options.resizable,
|
handles = options.resizable,
|
||||||
|
|
||||||
// .ui-resizable has position: relative defined in the stylesheet
|
// .ui-resizable has position: relative defined in the stylesheet
|
||||||
// but dialogs have to use absolute or fixed positioning
|
// but dialogs have to use absolute or fixed positioning
|
||||||
position = this.uiDialog.css( "position" ),
|
position = this.uiDialog.css( "position" ),
|
||||||
@ -639,6 +650,7 @@ $.widget( "ui.dialog", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_position: function() {
|
_position: function() {
|
||||||
|
|
||||||
// Need to show the dialog to get the actual offset in the position plugin
|
// Need to show the dialog to get the actual offset in the position plugin
|
||||||
var isVisible = this.uiDialog.is( ":visible" );
|
var isVisible = this.uiDialog.is( ":visible" );
|
||||||
if ( !isVisible ) {
|
if ( !isVisible ) {
|
||||||
@ -695,6 +707,7 @@ $.widget( "ui.dialog", {
|
|||||||
|
|
||||||
if ( key === "closeText" ) {
|
if ( key === "closeText" ) {
|
||||||
this.uiDialogTitlebarClose.button( {
|
this.uiDialogTitlebarClose.button( {
|
||||||
|
|
||||||
// Ensure that we always pass a string
|
// Ensure that we always pass a string
|
||||||
label: "" + value
|
label: "" + value
|
||||||
} );
|
} );
|
||||||
@ -716,6 +729,7 @@ $.widget( "ui.dialog", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( key === "resizable" ) {
|
if ( key === "resizable" ) {
|
||||||
|
|
||||||
// currently resizable, becoming non-resizable
|
// currently resizable, becoming non-resizable
|
||||||
isResizable = uiDialog.is( ":data(ui-resizable)" );
|
isResizable = uiDialog.is( ":data(ui-resizable)" );
|
||||||
if ( isResizable && !value ) {
|
if ( isResizable && !value ) {
|
||||||
@ -739,6 +753,7 @@ $.widget( "ui.dialog", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_size: function() {
|
_size: function() {
|
||||||
|
|
||||||
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
|
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
|
||||||
// divs will both have width and height set, so we need to reset them
|
// divs will both have width and height set, so we need to reset them
|
||||||
var nonContentHeight, minContentHeight, maxContentHeight,
|
var nonContentHeight, minContentHeight, maxContentHeight,
|
||||||
|
Loading…
Reference in New Issue
Block a user