Skip to content

Commit cb6c767

Browse files
committed
removed dependency on jquery-drag
1 parent 7115577 commit cb6c767

File tree

4 files changed

+36
-417
lines changed

4 files changed

+36
-417
lines changed

docs/javascript_bar.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ data from a data collector. Some common widgets are provided in
2020
the *widgets.js* file.
2121

2222
The `PhpDebugBar` namespace is used for all objects and the only
23-
dependencies are *jQuery*, *jquery-drag* and *FontAwesome* (css).
23+
dependencies are *jQuery* and *FontAwesome* (css). *FontAwesome* is
24+
optional but is used to add nice icons!
2425

2526
The main class is `PhpDebugBar.DebugBar`. It provides the infrastructure
2627
to manage tabs, indicators and datasets.

src/DebugBar/JavascriptRenderer.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class JavascriptRenderer
3131

3232
protected $cssVendors = array('vendor/font-awesome/css/font-awesome.css');
3333

34-
protected $jsVendors = array('vendor/jquery-1.8.3.min.js', 'vendor/jquery.event.drag-2.2.js');
34+
protected $jsVendors = array('vendor/jquery-1.8.3.min.js');
3535

3636
protected $includeVendors = true;
3737

@@ -116,11 +116,17 @@ public function getBaseUrl()
116116

117117
/**
118118
* Whether to include vendor assets
119+
*
120+
* You can only include js or css vendors using
121+
* setIncludeVendors('css') or setIncludeVendors('js')
119122
*
120123
* @param boolean $enabled
121124
*/
122125
public function setIncludeVendors($enabled = true)
123126
{
127+
if (is_string($enabled)) {
128+
$enabled = array($enabled);
129+
}
124130
$this->includeVendors = $enabled;
125131
return $this;
126132
}
@@ -132,7 +138,7 @@ public function setIncludeVendors($enabled = true)
132138
*/
133139
public function areVendorsIncluded()
134140
{
135-
return $this->includeVendors;
141+
return $this->includeVendors !== false;
136142
}
137143

138144
/**
@@ -260,9 +266,13 @@ protected function getAssetFiles($type = null)
260266
$cssFiles = $this->cssFiles;
261267
$jsFiles = $this->jsFiles;
262268

263-
if ($this->includeVendors) {
264-
$cssFiles = array_merge($this->cssVendors, $cssFiles);
265-
$jsFiles = array_merge($this->jsVendors, $jsFiles);
269+
if ($this->includeVendors !== false) {
270+
if ($this->includeVendors === true || in_array('css', $this->includeVendors)) {
271+
$cssFiles = array_merge($this->cssVendors, $cssFiles);
272+
}
273+
if ($this->includeVendors === true || in_array('js', $this->includeVendors)) {
274+
$jsFiles = array_merge($this->jsVendors, $jsFiles);
275+
}
266276
}
267277

268278
return $this->filterAssetArray(array($cssFiles, $jsFiles), $type);

src/DebugBar/Resources/debugbar.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,27 @@ if (typeof(localStorage) == 'undefined') {
305305
var self = this;
306306
this.$el.appendTo('body');
307307
this.$header = $('<div class="phpdebugbar-header" />').appendTo(this.$el);
308-
this.$body = $('<div class="phpdebugbar-body" />').appendTo(this.$el);
308+
var $body = this.$body = $('<div class="phpdebugbar-body" />').appendTo(this.$el);
309309
this.$resizehdle = $('<div class="phpdebugbar-resize-handle" />').appendTo(this.$body);
310310

311-
// allow resizing by dragging handle
312-
this.$body.drag('start', function(e, dd) {
313-
dd.height = $(this).height();
314-
}).drag(function(e, dd) {
315-
var h = Math.max(100, dd.height - dd.deltaY);
316-
$(this).css('height', h);
317-
localStorage.setItem('phpdebugbar-height', h);
318-
}, {handle: '.phpdebugbar-resize-handle'});
311+
// dragging of resize handle
312+
var dragging = false;
313+
this.$resizehdle.on('mousedown', function(e) {
314+
var orig_h = $body.height(), pos_y = e.pageY;
315+
dragging = true;
316+
317+
$body.parents().on('mousemove', function(e) {
318+
if (dragging) {
319+
var h = orig_h + (pos_y - e.pageY);
320+
$body.css('height', h);
321+
localStorage.setItem('phpdebugbar-height', h);
322+
}
323+
}).on('mouseup', function() {
324+
dragging = false;
325+
});
326+
327+
e.preventDefault();
328+
});
319329

320330
// minimize button
321331
this.$minimizebtn = $('<a class="phpdebugbar-minimize-btn" href="javascript:"><i class="icon-remove"></i></a>').appendTo(this.$header);

0 commit comments

Comments
 (0)