ui-dockable.dev.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Dockable.
  3. **/
  4. (function($){
  5. $.widget("db.dockable", $.ui.mouse, {
  6. options: {
  7. handle: false,
  8. axis: 'y',
  9. resize: function() {},
  10. resized: function() {}
  11. },
  12. _create: function() {
  13. if ( this.options.axis == 'x' ) {
  14. this.page = 'pageX';
  15. this.dimension = 'width';
  16. } else {
  17. this.page = 'pageY';
  18. this.dimension = 'height';
  19. }
  20. if ( ! this.options.handle )
  21. return;
  22. this.handle = $( this.options.handle );
  23. this._mouseInit();
  24. },
  25. _handoff: function() {
  26. return {
  27. element: this.element,
  28. handle: this.handle,
  29. axis: this.options.axis
  30. };
  31. },
  32. _mouseStart: function(event) {
  33. this._trigger( "start", event, this._handoff() );
  34. this.d0 = this.element[this.dimension]() + event[this.page];
  35. },
  36. _mouseDrag: function(event) {
  37. var resize = this._trigger( "resize", event, this._handoff() );
  38. // If the resize event returns false, we don't resize.
  39. if ( resize === false )
  40. return;
  41. this.element[this.dimension]( this.d0 - event[this.page] );
  42. this._trigger( "resized", event, this._handoff() );
  43. },
  44. _mouseCapture: function(event) {
  45. return !this.options.disabled && event.target == this.handle[0];
  46. },
  47. _mouseStop: function(event) {
  48. this._trigger( "stop", event, this._handoff() );
  49. }
  50. });
  51. })(jQuery);