Search code examples
jquery-uipopupnon-modal

How to implement a lightweight, non-modal, resizable and minimise-able popup


I want to have a pagein which I want to display a popup that is resizeable and minimise-able to a small button displayed in the topleft corner. When the button is clicked I want it to return to its previous size.

The content will just contain some text.

How can I do this? Should I use jqueryUi?


Solution

  • You can use the jqueryUI Dialog Widget to acommplish this.

    CSS

    .hidden {
        display: none;
    }
    

    HTML

    <p class="hidden" id="placeholder">Expand</p>
    <div id="dialog-message" title="Simple Dialog">
        <p> <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
    This is your basic dialog!</p>
    </div>
    

    JS

     $(function () {
         $("#dialog-message").dialog({
             modal: false,
             buttons: {
                 Ok: function () {
                     $(this).dialog("close");
                     $("#placeholder").removeClass('hidden');
                 },
                 autoOpen: true
             }
         });
         $("#placeholder")
             .button()
             .click(function (event) {
             $("#dialog-message").dialog("open");
             $("#placeholder").addClass('hidden');
         });
     });
    

    JSFiddle Of Solution

    Please check the documentation at JQuery UI Dialog