Skip to content

Instantly share code, notes, and snippets.

@SebastienGautier
Created March 27, 2015 09:23
Show Gist options
  • Save SebastienGautier/c8681ed31aa517dfff94 to your computer and use it in GitHub Desktop.
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)
//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