Created
March 27, 2015 09:23
-
-
Save SebastienGautier/c8681ed31aa517dfff94 to your computer and use it in GitHub Desktop.
Save a jquery-ui dialog's size and position in cookies (requires jquery.cookie)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://jqueryui.com/dialog/ | |
//https://github.com/carhartl/jquery-cookie | |
$("#dialog").dialog({ | |
width: ($.cookie('dialog-width') || 500), | |
height: ($.cookie('dialog-height') || 300), | |
position: { | |
my: $.cookie('dialog-pos-my') || 'center', | |
at: $.cookie('dialog-pos-at') || 'center', | |
of: window | |
}, | |
dragStop: function(event, ui) { | |
$.cookie('dialog-pos-my', $(this).dialog('option', 'position').my); | |
$.cookie('dialog-pos-at', $(this).dialog('option', 'position').at); | |
}, | |
resizeStop: function(event, ui) { | |
$.cookie('dialog-width', $(this).width()); | |
$.cookie('dialog-height', $(this).height()); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment