Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 9de1238

Browse files
committed
Merge pull request #1661 from jbalsas/jslint-panel-resize
Fix for issue #1122
2 parents 1e0bbe7 + ab2645a commit 9de1238

File tree

7 files changed

+282
-16
lines changed

7 files changed

+282
-16
lines changed

src/brackets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ define(function (require, exports, module) {
9191
UrlParams = require("utils/UrlParams").UrlParams,
9292
NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem,
9393
PreferencesManager = require("preferences/PreferencesManager"),
94+
Resizer = require("utils/Resizer"),
9495
StatusBar = require("widgets/Statusbar");
9596

9697
// Local variables

src/htmlContent/main-view.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,20 @@
9090
</div>
9191
</div>
9292

93-
<div id="jslint-results" class="bottom-panel">
93+
<div id="jslint-results" class="bottom-panel vert-resizable top-resizer">
9494
<div class="toolbar simple-toolbar-layout">
9595
<div class="title">{{JSLINT_ERRORS}}</div>
9696
</div>
97-
<div class="table-container"></div>
97+
<div class="table-container resizable-content"></div>
9898
</div>
99-
<div id="search-results" class="bottom-panel">
99+
100+
<div id="search-results" class="bottom-panel vert-resizable top-resizer">
100101
<div class="toolbar simple-toolbar-layout">
101102
<div class="title">{{SEARCH_RESULTS}}</div>
102103
<div class="title" id="search-result-summary"></div>
103104
<a href="#" class="close">&times;</a>
104105
</div>
105-
<div class="table-container"></div>
106+
<div class="table-container resizable-content"></div>
106107
</div>
107108

108109
<div id="status-bar" class="statusbar">

src/language/JSLintUtils.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
26-
/*global define, $, brackets, JSLINT, PathUtils */
26+
/*global define, $, JSLINT, PathUtils */
2727

2828
/**
2929
* Allows JSLint to run on the current document and report results in a UI panel.
@@ -47,7 +47,15 @@ define(function (require, exports, module) {
4747
Strings = require("strings"),
4848
StringUtils = require("utils/StringUtils"),
4949
AppInit = require("utils/AppInit"),
50+
Resizer = require("utils/Resizer"),
5051
StatusBar = require("widgets/StatusBar");
52+
53+
var PREFERENCES_CLIENT_ID = module.id,
54+
defaultPrefs = { height: 200, enabled: true };
55+
56+
/** @type {Number} Height of the JSLint panel header in pixels. Hardcoded to avoid race
57+
condition when measuring it on htmlReady*/
58+
var HEADER_HEIGHT = 27;
5159

5260
/**
5361
* @private
@@ -212,20 +220,33 @@ define(function (require, exports, module) {
212220
setEnabled(!getEnabled());
213221
}
214222

215-
216223
// Register command handlers
217224
CommandManager.register(Strings.CMD_JSLINT, Commands.TOGGLE_JSLINT, _handleToggleJSLint);
218225

219226
// Init PreferenceStorage
220-
_prefs = PreferencesManager.getPreferenceStorage(module.id, { enabled: !!brackets.config.enable_jslint });
227+
_prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID, defaultPrefs);
221228
_setEnabled(_prefs.getValue("enabled"));
222229

223-
// Init StatusBar indicator
230+
// Initialize items dependent on HTML DOM
224231
AppInit.htmlReady(function () {
232+
var height = Math.max(_prefs.getValue("height"), 100),
233+
$jslintResults = $("#jslint-results"),
234+
$jslintContent = $("#jslint-results .table-container");
235+
236+
$jslintResults.height(height);
237+
$jslintContent.height(height - HEADER_HEIGHT);
238+
239+
if (_enabled) {
240+
EditorManager.resizeEditor();
241+
}
242+
243+
$jslintResults.on("panelResizeEnd", function (event, height) {
244+
_prefs.setValue("height", height);
245+
});
246+
225247
StatusBar.addIndicator(module.id, $("#gold-star"), false);
226248
});
227-
228-
249+
229250
// Define public API
230251
exports.run = run;
231252
exports.getEnabled = getEnabled;

src/search/FindInFiles.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ define(function (require, exports, module) {
5050
DocumentManager = require("document/DocumentManager"),
5151
EditorManager = require("editor/EditorManager"),
5252
FileIndexManager = require("project/FileIndexManager"),
53+
PreferencesManager = require("preferences/PreferencesManager"),
5354
KeyEvent = require("utils/KeyEvent"),
55+
AppInit = require("utils/AppInit"),
56+
Resizer = require("utils/Resizer"),
5457
StatusBar = require("widgets/StatusBar");
5558

5659
var searchResults = [];
5760

5861
var FIND_IN_FILES_MAX = 100;
59-
62+
63+
var PREFERENCES_CLIENT_ID = module.id,
64+
defaultPrefs = { height: 200 };
65+
66+
/** @type {Number} Height of the FIF panel header in pixels. Hardcoded to avoid race
67+
condition when measuring it on htmlReady*/
68+
var HEADER_HEIGHT = 27;
69+
6070
// This dialog class was mostly copied from QuickOpen. We should have a common dialog
6171
// class that everyone can use.
6272

@@ -340,6 +350,21 @@ define(function (require, exports, module) {
340350
}
341351
});
342352
}
353+
354+
// Initialize items dependent on HTML DOM
355+
AppInit.htmlReady(function () {
356+
var $searchResults = $("#search-results"),
357+
$searchContent = $("#search-results .table-container"),
358+
prefs = PreferencesManager.getPreferenceStorage(module.id, defaultPrefs),
359+
height = prefs.getValue("height");
360+
361+
$searchResults.height(height);
362+
$searchContent.height(height - HEADER_HEIGHT);
363+
364+
$searchResults.on("panelResizeEnd", function (event, height) {
365+
prefs.setValue("height", height);
366+
});
367+
});
343368

344369
function _fileNameChangeHandler(event, oldName, newName) {
345370
if ($("#search-results").is(":visible")) {
@@ -353,4 +378,4 @@ define(function (require, exports, module) {
353378

354379
$(DocumentManager).on("fileNameChange", _fileNameChangeHandler);
355380
CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.EDIT_FIND_IN_FILES, doFindInFiles);
356-
});
381+
});

src/styles/brackets.less

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ html, body {
6262
body {
6363
.vbox;
6464

65-
/* This appears to be necessary in Firefox when body is set to display: box. */
66-
width: 100%;
6765
&.resizing a, &.resizing #projects a, &.resizing .main-view, &.resizing .CodeMirror-lines {
6866
cursor: col-resize;
6967
}
68+
69+
&.vert-resizing a, &.vert-resizing #projects a, &.vert-resizing .main-view, &.vert-resizing .CodeMirror-lines {
70+
cursor: row-resize;
71+
}
7072
}
7173

7274

@@ -180,14 +182,32 @@ a, img {
180182
background: @background-color-2 url('images/no_content_bg.svg') no-repeat center 45%;
181183
}
182184
}
183-
185+
186+
.vert-resizer {
187+
position: absolute;
188+
height: 6px;
189+
width: 100%;
190+
z-index: @z-index-brackets-panel-resizer;
191+
opacity: 0;
192+
cursor: row-resize;
193+
}
194+
195+
.horz-resizer {
196+
position: absolute;
197+
height: 100%;
198+
width: 6px;
199+
z-index: @z-index-brackets-panel-resizer;
200+
opacity: 0;
201+
cursor: col-resize;
202+
}
203+
184204
.bottom-panel {
185205
display: none;
186206
height: 200px;
187207
border-top-style: solid;
188208
border-width: 1px;
189209
border-color: lighten(@bc-grey, @bc-color-step-size*4);
190-
210+
191211
.toolbar {
192212
height: auto;
193213
padding-top: @base-padding / 2;

src/styles/brackets_variables.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@
5050

5151
@z-index-brackets-sidebar-resizer: @z-index-brackets-ui + 2;
5252
@z-index-brackets-resizer-div: @z-index-brackets-sidebar-resizer + 1;
53+
@z-index-brackets-panel-resizer: @z-index-brackets-ui + 2;
5354

5455
@z-index-brackets-context-menu-base: 1000;

0 commit comments

Comments
 (0)