Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html lang="en">
<head>
    <script src="http://code.jquery.com/jquery-1.11.2.js"></script>
    <script>
    var dialog = function( options, element ) {
        var that = this;
        this.element = $( element );
        this.options = options;
        this.uiDialog = $( "<div>" )
            .hide()
            .appendTo( "body" );
        this.element.appendTo( this.uiDialog );
        this.closeButton = $( "<a href='#'>a</a>" ).appendTo( this.element );
        this.uiDialog.fadeIn( this.options.show, function() {
            that.closeButton.focus();
            that.options.focus();
        } );
    };
    $.fn.dialog = function( options ) {
        if ( typeof options === "string" ) {
            this.each( function() {
                var instance = $.data( this, "ui-dialog" );
                instance[ options ]();
            } );
        } else {
            this.each( function() {
                $.data( this, "ui-dialog", new dialog( options, this ) );
            } );
        }
        return this;
    };
    $(function() {
        var element = $( "<div>" ).dialog({
            show: 1,
            focus: function() {
                element.remove();
                element = $( "<div>" ).dialog( {
                    show: 1000
                } );
                setTimeout( function() {
                    try {
                        if ( document.activeElement.nodeName.toLowerCase() !== "body" ) {
                            $( document.activeElement ).blur();
                        }
                    } catch ( error ) {
                        alert( error );
                    }
                }, 100 );
            }
        });
    });
    </script>
</head>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
scott_gonzalezpro
0viewers