@@ -442,6 +442,9 @@ if (typeof(PhpDebugBar) == 'undefined') {
442442                this . respCSSSize  =  0 ; 
443443                this . $header . removeClass ( cssClass ) ; 
444444            } 
445+ 
446+             // Reset height to ensure bar is still visible 
447+             this . setHeight ( this . $body . height ( ) ) ; 
445448        } , 
446449
447450        /** 
@@ -452,6 +455,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
452455        render : function ( )  { 
453456            var  self  =  this ; 
454457            this . $el . appendTo ( 'body' ) ; 
458+             this . $dragCapture  =  $ ( '<div />' ) . addClass ( csscls ( 'drag-capture' ) ) . appendTo ( this . $el ) ; 
455459            this . $resizehdle  =  $ ( '<div />' ) . addClass ( csscls ( 'resize-handle' ) ) . appendTo ( this . $el ) ; 
456460            this . $header  =  $ ( '<div />' ) . addClass ( csscls ( 'header' ) ) . appendTo ( this . $el ) ; 
457461            this . $headerLeft  =  $ ( '<div />' ) . addClass ( csscls ( 'header-left' ) ) . appendTo ( this . $header ) ; 
@@ -460,29 +464,21 @@ if (typeof(PhpDebugBar) == 'undefined') {
460464            this . recomputeBottomOffset ( ) ; 
461465
462466            // dragging of resize handle 
463-             var  dragging  =  false ; 
464-             var  min_h  =  40 ; 
465-             var  max_h  =  $ ( window ) . height ( )  -  this . $header . height ( )  -  10 ; 
467+             var  pos_y ,  orig_h ; 
466468            this . $resizehdle . on ( 'mousedown' ,  function ( e )  { 
467-                 var  orig_h  =  $body . height ( ) ,  pos_y  =  e . pageY ; 
468-                 dragging  =  true ; 
469- 
470-                 $body . parents ( ) . on ( 'mousemove' ,  function ( e )  { 
471-                     if  ( dragging )  { 
472-                         var  h  =  orig_h  +  ( pos_y  -  e . pageY ) ; 
473-                         // Respect the min/max values 
474-                         h  =  Math . min ( h ,  max_h ) ; 
475-                         h  =  Math . max ( h ,  min_h ) ; 
476-                         $body . css ( 'height' ,  h ) ; 
477-                         localStorage . setItem ( 'phpdebugbar-height' ,  h ) ; 
478-                         self . recomputeBottomOffset ( ) ; 
479-                     } 
480-                 } ) . on ( 'mouseup' ,  function ( )  { 
481-                     dragging  =  false ; 
482-                 } ) ; 
483- 
469+                 orig_h  =  $body . height ( ) ,  pos_y  =  e . pageY ; 
470+                 $body . parents ( ) . on ( 'mousemove' ,  mousemove ) . on ( 'mouseup' ,  mouseup ) ; 
471+                 self . $dragCapture . show ( ) ; 
484472                e . preventDefault ( ) ; 
485473            } ) ; 
474+             var  mousemove  =  function ( e )  { 
475+                 var  h  =  orig_h  +  ( pos_y  -  e . pageY ) ; 
476+                 self . setHeight ( h ) ; 
477+             } ; 
478+             var  mouseup  =  function ( )  { 
479+                 $body . parents ( ) . off ( 'mousemove' ,  mousemove ) . off ( 'mouseup' ,  mouseup ) ; 
480+                 self . $dragCapture . hide ( ) ; 
481+             } ; 
486482
487483            // minimize button 
488484            this . $closebtn  =  $ ( '<a href="javascript:" />' ) . addClass ( csscls ( 'close-btn' ) ) . appendTo ( this . $headerRight ) ; 
@@ -513,6 +509,24 @@ if (typeof(PhpDebugBar) == 'undefined') {
513509            } ) ; 
514510        } , 
515511
512+         /** 
513+          * Sets the height of the debugbar body section 
514+          * Forces the height to lie within a reasonable range 
515+          * Stores the height in local storage so it can be restored 
516+          * Resets the document body bottom offset 
517+          * 
518+          * @this  {DebugBar} 
519+          */ 
520+         setHeight : function ( height )  { 
521+           var  min_h  =  40 ; 
522+           var  max_h  =  $ ( window ) . innerHeight ( )  -  this . $header . height ( )  -  10 ; 
523+           height  =  Math . min ( height ,  max_h ) ; 
524+           height  =  Math . max ( height ,  min_h ) ; 
525+           this . $body . css ( 'height' ,  height ) ; 
526+           localStorage . setItem ( 'phpdebugbar-height' ,  height ) ; 
527+           this . recomputeBottomOffset ( ) ; 
528+         } , 
529+ 
516530        /** 
517531         * Restores the state of the DebugBar using localStorage 
518532         * This is not called by default in the constructor and 
@@ -523,11 +537,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
523537        restoreState : function ( )  { 
524538            // bar height 
525539            var  height  =  localStorage . getItem ( 'phpdebugbar-height' ) ; 
526-             if  ( height )  { 
527-                 this . $body . css ( 'height' ,  height ) ; 
528-             }  else  { 
529-                 localStorage . setItem ( 'phpdebugbar-height' ,  this . $body . height ( ) ) ; 
530-             } 
540+             this . setHeight ( height  ||  this . $body . height ( ) ) ; 
531541
532542            // bar visibility 
533543            var  open  =  localStorage . getItem ( 'phpdebugbar-open' ) ; 
0 commit comments