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

Commit

Permalink
Code cleanup, raising events when panel is shown/hidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Oct 15, 2015
1 parent a1a6573 commit 51c0232
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/extensions/default/NoDistractions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ define(function (require, exports, module) {
_updateCheckedState();
});

WorkspaceManager.on("workspaceUpdateLayout", _updateLayout);
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_PANEL_SHOWN, _updateLayout);

/**
* Register the Commands , add the Menu Items and key bindings
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ define(function (require, exports, module) {
// Load dependent modules
var AppInit = require("utils/AppInit"),
EventDispatcher = require("utils/EventDispatcher"),
viewUtils = require("utils/ViewUtils"),
ViewUtils = require("utils/ViewUtils"),
PreferencesManager = require("preferences/PreferencesManager");

var $mainView;
Expand Down Expand Up @@ -536,7 +536,7 @@ define(function (require, exports, module) {

// The main toolbar is only collapsible.
if ($("#main-toolbar").hasClass("collapsible") && PreferencesManager.get(PREFS_PURE_CODE)) {
viewUtils.hideMainToolBar();
ViewUtils.hideMainToolBar();
}
});

Expand Down
26 changes: 18 additions & 8 deletions src/view/WorkspaceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ define(function (require, exports, module) {
EventDispatcher = require("utils/EventDispatcher"),
Resizer = require("utils/Resizer");

//constants
var EVENT_WORKSPACE_UPDATE_LAYOUT = "workspaceUpdateLayout",
EVENT_WORKSPACE_PANEL_SHOWN = "workspacePanelShown",
EVENT_WORKSPACE_PANEL_HIDDEN = "workspacePanelHidden";

/**
* The ".content" vertical stack (editor + all header/footer panels)
Expand Down Expand Up @@ -114,7 +118,7 @@ define(function (require, exports, module) {
$editorHolder.height(editorAreaHeight); // affects size of "not-editor" placeholder as well

// Resize editor to fill the space
exports.trigger("workspaceUpdateLayout", editorAreaHeight, refreshHint);
exports.trigger(EVENT_WORKSPACE_UPDATE_LAYOUT, editorAreaHeight, refreshHint);
}


Expand Down Expand Up @@ -189,13 +193,15 @@ define(function (require, exports, module) {
*/
Panel.prototype.show = function () {
Resizer.show(this.$panel[0]);
exports.trigger(EVENT_WORKSPACE_PANEL_SHOWN, this.panelID);
};

/**
* Hides the panel
*/
Panel.prototype.hide = function () {
Resizer.hide(this.$panel[0]);
exports.trigger(EVENT_WORKSPACE_PANEL_HIDDEN, this.panelID);
};

/**
Expand All @@ -204,9 +210,9 @@ define(function (require, exports, module) {
*/
Panel.prototype.setVisible = function (visible) {
if (visible) {
Resizer.show(this.$panel[0]);
this.show();
} else {
Resizer.hide(this.$panel[0]);
this.hide();
}
};

Expand All @@ -227,6 +233,7 @@ define(function (require, exports, module) {
updateResizeLimits(); // initialize panel's max size

panelIDMap[id] = new Panel($panel, minSize);
panelIDMap[id].panelID = id;

return panelIDMap[id];
}
Expand Down Expand Up @@ -290,9 +297,12 @@ define(function (require, exports, module) {
EventDispatcher.makeEventDispatcher(exports);

// Define public API
exports.createBottomPanel = createBottomPanel;
exports.recomputeLayout = recomputeLayout;
exports.getAllPanelIDs = getAllPanelIDs;
exports.getPanelForID = getPanelForID;
exports._setMockDOM = _setMockDOM;
exports.createBottomPanel = createBottomPanel;
exports.recomputeLayout = recomputeLayout;
exports.getAllPanelIDs = getAllPanelIDs;
exports.getPanelForID = getPanelForID;
exports._setMockDOM = _setMockDOM;
exports.EVENT_WORKSPACE_UPDATE_LAYOUT = EVENT_WORKSPACE_UPDATE_LAYOUT;
exports.EVENT_WORKSPACE_PANEL_SHOWN = EVENT_WORKSPACE_PANEL_SHOWN;
exports.EVENT_WORKSPACE_PANEL_HIDDEN = EVENT_WORKSPACE_PANEL_HIDDEN;
});

0 comments on commit 51c0232

Please sign in to comment.