Skip to content
Snippets Groups Projects
jquery-ui.js 161 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jonas Leder's avatar
    Jonas Leder committed
    			if ( isResizable && typeof value === "string" ) {
    				uiDialog.resizable( "option", "handles", value );
    			}
    
    			// Currently non-resizable, becoming resizable
    			if ( !isResizable && value !== false ) {
    				this._makeResizable();
    			}
    		}
    
    		if ( key === "title" ) {
    			this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
    		}
    	},
    
    	_size: function() {
    
    		// 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
    		var nonContentHeight, minContentHeight, maxContentHeight,
    			options = this.options;
    
    		// Reset content sizing
    		this.element.show().css( {
    			width: "auto",
    			minHeight: 0,
    			maxHeight: "none",
    			height: 0
    		} );
    
    		if ( options.minWidth > options.width ) {
    			options.width = options.minWidth;
    		}
    
    		// Reset wrapper sizing
    		// determine the height of all the non-content elements
    		nonContentHeight = this.uiDialog.css( {
    			height: "auto",
    			width: options.width
    		} )
    			.outerHeight();
    		minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
    		maxContentHeight = typeof options.maxHeight === "number" ?
    			Math.max( 0, options.maxHeight - nonContentHeight ) :
    			"none";
    
    		if ( options.height === "auto" ) {
    			this.element.css( {
    				minHeight: minContentHeight,
    				maxHeight: maxContentHeight,
    				height: "auto"
    			} );
    		} else {
    			this.element.height( Math.max( 0, options.height - nonContentHeight ) );
    		}
    
    		if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
    			this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
    		}
    	},
    
    	_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;
    		}
    	},
    
    	_allowInteraction: function( event ) {
    		if ( $( event.target ).closest( ".ui-dialog" ).length ) {
    			return true;
    		}
    
    		// TODO: Remove hack when datepicker implements
    		// the .ui-front logic (#8989)
    		return !!$( event.target ).closest( ".ui-datepicker" ).length;
    	},
    
    	_createOverlay: function() {
    		if ( !this.options.modal ) {
    			return;
    		}
    
    		// We use a delay in case the overlay is created from an
    		// event that we're going to be cancelling (#2804)
    		var isOpening = true;
    		this._delay( function() {
    			isOpening = false;
    		} );
    
    		if ( !this.document.data( "ui-dialog-overlays" ) ) {
    
    			// Prevent use of anchors and inputs
    			// Using _on() for an event handler shared across many instances is
    			// safe because the dialogs stack and must be closed in reverse order
    			this._on( this.document, {
    				focusin: function( event ) {
    					if ( isOpening ) {
    						return;
    					}
    
    					if ( !this._allowInteraction( event ) ) {
    						event.preventDefault();
    						this._trackingInstances()[ 0 ]._focusTabbable();
    					}
    				}
    			} );
    		}
    
    		this.overlay = $( "<div>" )
    			.appendTo( this._appendTo() );
    
    		this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
    		this._on( this.overlay, {
    			mousedown: "_keepFocus"
    		} );
    		this.document.data( "ui-dialog-overlays",
    			( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
    	},
    
    	_destroyOverlay: function() {
    		if ( !this.options.modal ) {
    			return;
    		}
    
    		if ( this.overlay ) {
    			var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
    
    			if ( !overlays ) {
    				this._off( this.document, "focusin" );
    				this.document.removeData( "ui-dialog-overlays" );
    			} else {
    				this.document.data( "ui-dialog-overlays", overlays );
    			}
    
    			this.overlay.remove();
    			this.overlay = null;
    		}
    	}
    } );
    
    // DEPRECATED
    // TODO: switch return back to widget declaration at top of file when this is removed
    if ( $.uiBackCompat !== false ) {
    
    	// Backcompat for dialogClass option
    	$.widget( "ui.dialog", $.ui.dialog, {
    		options: {
    			dialogClass: ""
    		},
    		_createWrapper: function() {
    			this._super();
    			this.uiDialog.addClass( this.options.dialogClass );
    		},
    		_setOption: function( key, value ) {
    			if ( key === "dialogClass" ) {
    				this.uiDialog
    					.removeClass( this.options.dialogClass )
    					.addClass( value );
    			}
    			this._superApply( arguments );
    		}
    	} );
    }
    
    var widgetsDialog = $.ui.dialog;
    
    
    
    
    }));