B2G/gecko/browser/components/tabview/items.js
// Enables or disables resizing of this item.
Enables or disables resizing of this item.
Enables or disables resizing of this item .
function Item_resizable(value) {
    try {
      var $container = iQ(this.container);
      iQ('.iq-resizable-handle', $container).remove();
      if (!value) {
        $container.removeClass('iq-resizable');
      } else {
        Utils.assert(this.resizeOptions, 'resizeOptions');
        $container.addClass('iq-resizable');
        var self = this;
        var startMouse;
        var startSize;
        var startAspect;
        var handleMouseMove = function(e) {
          resize.lastMoveTime = Date.now();
          var mouse = new Point(e.pageX, e.pageY);
          var box = self.getBounds();
          if (UI.rtl) {
            var minWidth = (self.resizeOptions.minWidth || 0);
            var oldWidth = box.width;
            if (minWidth != oldWidth || mouse.x < startMouse.x) {
              box.width = Math.max(minWidth, startSize.x - (mouse.x - startMouse.x));
              box.left -= box.width - oldWidth;
            }
          } else {
            box.width = Math.max(self.resizeOptions.minWidth || 0, startSize.x + (mouse.x - startMouse.x));
          }
          box.height = Math.max(self.resizeOptions.minHeight || 0, startSize.y + (mouse.y - startMouse.y));
          if (self.resizeOptions.aspectRatio) {
            if (startAspect < 1)
              box.height = box.width * startAspect;
            else
              box.width = box.height / startAspect;
          }
          self.setBounds(box, true);
          if (typeof self.resizeOptions.resize == "function")
            self.resizeOptions.resize.apply(self, [e]);
          e.preventDefault();
          e.stopPropagation();
        };
        var handleMouseUp = function(e) {
          iQ(gWindow)
            .unbind('mousemove', handleMouseMove)
            .unbind('mouseup', handleMouseUp);
          if (typeof self.resizeOptions.stop == "function")
            self.resizeOptions.stop.apply(self, [e]);
          e.preventDefault();
          e.stopPropagation();
        };
        iQ('<div>')
          .addClass('iq-resizable-handle iq-resizable-se')
          .appendTo($container)
          .mousedown(function(e) {
            if (!Utils.isLeftClick(e))
              return;
            startMouse = new Point(e.pageX, e.pageY);
            startSize = self.getBounds().size();
            startAspect = startSize.y / startSize.x;
            if (typeof self.resizeOptions.start == "function")
              self.resizeOptions.start.apply(self, [e]);
            iQ(gWindow)
              .mousemove(handleMouseMove)
              .mouseup(handleMouseUp);
            e.preventDefault();
            e.stopPropagation();
          });
        }
    } catch(e) {
      Utils.log(e);
    }
  }
function Item_resizable ( value ) { try { var $container = iQ ( this . container ) ; iQ ( '.iq-resizable-handle' , $container ) . remove ( ) ; if ( ! value ) { $container . removeClass ( 'iq-resizable' ) ; } else { Utils . assert ( this . resizeOptions , 'resizeOptions' ) ; $container . addClass ( 'iq-resizable' ) ; var self = this ; var startMouse ; var startSize ; var startAspect ; var handleMouseMove = function ( e ) { resize . lastMoveTime = Date . now ( ) ; var mouse = new Point ( e . pageX , e . pageY ) ; var box = self . getBounds ( ) ; if ( UI . rtl ) { var minWidth = ( self . resizeOptions . minWidth || 0 ) ; var oldWidth = box . width ; if ( minWidth != oldWidth || mouse . x < startMouse . x ) { box . width = Math . max ( minWidth , startSize . x - ( mouse . x - startMouse . x ) ) ; box . left -= box . width - oldWidth ; } } else { box . width = Math . max ( self . resizeOptions . minWidth || 0 , startSize . x + ( mouse . x - startMouse . x ) ) ; } box . height = Math . max ( self . resizeOptions . minHeight || 0 , startSize . y + ( mouse . y - startMouse . y ) ) ; if ( self . resizeOptions . aspectRatio ) { if ( startAspect < 1 ) box . height = box . width * startAspect ; else box . width = box . height / startAspect ; } self . setBounds ( box , true ) ; if ( typeof self . resizeOptions . resize == "function" ) self . resizeOptions . resize . apply ( self , [ e ] ) ; e . preventDefault ( ) ; e . stopPropagation ( ) ; } ; var handleMouseUp = function ( e ) { iQ ( gWindow ) . unbind ( 'mousemove' , handleMouseMove ) . unbind ( 'mouseup' , handleMouseUp ) ; if ( typeof self . resizeOptions . stop == "function" ) self . resizeOptions . stop . apply ( self , [ e ] ) ; e . preventDefault ( ) ; e . stopPropagation ( ) ; } ; iQ ( '<div>' ) . addClass ( 'iq-resizable-handle iq-resizable-se' ) . appendTo ( $container ) . mousedown ( function ( e ) { if ( ! Utils . isLeftClick ( e ) ) return ; startMouse = new Point ( e . pageX , e . pageY ) ; startSize = self . getBounds ( ) . size ( ) ; startAspect = startSize . y / startSize . x ; if ( typeof self . resizeOptions . start == "function" ) self . resizeOptions . start . apply ( self , [ e ] ) ; iQ ( gWindow ) . mousemove ( handleMouseMove ) . mouseup ( handleMouseUp ) ; e . preventDefault ( ) ; e . stopPropagation ( ) ; } ) ; } } catch ( e ) { Utils . log ( e ) ; } }
Enables or disables resizing of this item.
Enables or disables resizing of this item .
// ___ mousemove // global resize tracking // ___ mouseup // ___ handle + mousedown