Hi Scott, Thanks for the speedy reply. All I can say is that I did need to account for the window scroll position when resizing but didn't need (or want) to when dragging. That's why I didn't have the same parameters into the storeLocation function.
RE: this syntax '.bind(event1 event2, functionToCall)' that's neat. I didn't know you could do that (even though not too helpful in this context). BTW, you still didn't tell me EXACTLY how to extend the 'dialogopen' event or function (which is it anyway? how can I figure that out?) (syntax and example would HELP!). Marv On Jul 12, 9:00 am, Scott González <[email protected]> wrote: > Hey Marv, > > This is looking better. I would pull all of the storing functionality > into storeLocation though: > > this.uiDialog > .bind('dragstop resizestart', storeLocation) > .bind('resizestop', ...); > function storeLocation(event, ui) { > if (self.options.sticky) { > self.location = ui.position; > } > > } > > Does ui.position contain different information for draggable and > resizable? I see you're removing the scroll offset when handling > resizing, but not dragging. I would think they should be consistent, > seems like a bug if they're not. > > On Jul 11, 11:26 pm, Marv <[email protected]> wrote: > > > > > Thanks again Scott for your constructive comments! I understand that > > v1.8 should obsolete my need for this widget extension, but I created > > it for two reasons: > > > 1) to learn how toproperlycreate such an extension since I have > > never created a plugin or widget extension before > > > 2) I need this functionality right now > > > Here's my code with your suggestions implemented. I just couldn't get > > the syntax correct for your "You could also just bind to the > > dialogopen > > event in _init. " suggestion. As it turned out having the > > functionality I wanted in the open in the _init instead made more > > sense -- but that's a bit of a cop out since I haven't learned how to > >extendthedialog'sopen event yet!!! > > > // This code block extends the uiDialog widget by adding a new boolean > > option 'sticky' which, > > // by default, is set to false. When set to true on adialoginstance, > > it will keep thedialog's > > // position 'anchored' regardless of window scrolling. > > > /****************** Start of uiDialog widget extension > > ****************/ > > > (function($) { > > var _init = $.ui.dialog.prototype._init; > > $.ui.dialog.prototype._init = function() { > > var self = this; > > _init.apply(this, arguments); > > if (self.options.sticky) { > > self.uiDialog.css('position', 'fixed'); > > }; > > this.uiDialog > > .bind('dragstop', function(event, ui) { > > if (self.options.sticky) > > storeLocation(ui.position.left, > > ui.position.top); > > }) > > .bind('resizestart', function(event, ui) { > > if (self.options.sticky) > > storeLocation(ui.position.left - $ > > (window).scrollLeft(), > > ui.position.top - $(window).scrollTop > > ()); > > }) > > .bind('resizestop', function(event, ui) { > > if (self.options.sticky) { > > self.uiDialog.css({ > > 'position': 'fixed', > > 'left': self.location.left, > > 'top': self.location.top > > }); > > }; > > }); > > function storeLocation(_left, _top) { > > self.location = { left: _left, top: _top }; > > }; > > }; > > $.ui.dialog.defaults.sticky = false;})(jQuery); > > > /***************** End of uiDialog widget extension > > *********************/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~---
