Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/adobe/brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetx committed Oct 21, 2012
2 parents 1b9444d + b0c6525 commit 1d93c6e
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 60 deletions.
1 change: 0 additions & 1 deletion src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ define(function (require, exports, module) {
exports.EDIT_LINE_COMMENT = "edit.lineComment";
exports.EDIT_LINE_UP = "edit.lineUp";
exports.EDIT_LINE_DOWN = "edit.lineDown";
exports.TOGGLE_USE_TAB_CHARS = "debug.useTabChars";

// VIEW
exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar";
Expand Down
2 changes: 0 additions & 2 deletions src/command/Menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,6 @@ define(function (require, exports, module) {
platform: "mac"}]);
menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_LINE_COMMENT, "Ctrl-/");
menu.addMenuDivider();
menu.addMenuItem(Commands.TOGGLE_USE_TAB_CHARS);

/*
* View menu
Expand Down
11 changes: 0 additions & 11 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,6 @@ define(function (require, exports, module) {

editor._codeMirror.execCommand("indentLess");
}

/**
* Toggles tabs/spaces preferences
*/
function toggleUseTabChars() {
var useTabs = !Editor.getUseTabChar();
Editor.setUseTabChar(useTabs);
CommandManager.get(Commands.TOGGLE_USE_TAB_CHARS).setChecked(useTabs);
}

// Register commands
CommandManager.register(Strings.CMD_INDENT, Commands.EDIT_INDENT, indentText);
Expand All @@ -305,6 +296,4 @@ define(function (require, exports, module) {
CommandManager.register(Strings.CMD_DELETE_LINES, Commands.EDIT_DELETE_LINES, deleteCurrentLines);
CommandManager.register(Strings.CMD_LINE_UP, Commands.EDIT_LINE_UP, moveLineUp);
CommandManager.register(Strings.CMD_LINE_DOWN, Commands.EDIT_LINE_DOWN, moveLineDown);
CommandManager.register(Strings.CMD_USE_TAB_CHARS, Commands.TOGGLE_USE_TAB_CHARS, toggleUseTabChars)
.setChecked(Editor.getUseTabChar());
});
6 changes: 6 additions & 0 deletions src/editor/EditorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ define(function (require, exports, module) {
require("thirdparty/CodeMirror2/mode/mysql/mysql");
require("thirdparty/CodeMirror2/mode/diff/diff");
require("thirdparty/CodeMirror2/mode/markdown/markdown");
require("thirdparty/CodeMirror2/mode/yaml/yaml");

/**
* @private
Expand Down Expand Up @@ -147,7 +148,12 @@ define(function (require, exports, module) {
return "diff";

case "md":
case "markdown":
return "markdown";

case "yaml":
case "yml":
return "yaml";

default:
console.log("Called EditorUtils.js _getModeFromFileExtensions with an unhandled file extension: " + ext);
Expand Down
21 changes: 2 additions & 19 deletions src/language/JSLintUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,10 @@ define(function (require, exports, module) {
Strings = require("strings"),
StringUtils = require("utils/StringUtils"),
AppInit = require("utils/AppInit"),
Resizer = require("utils/Resizer"),
StatusBar = require("widgets/StatusBar");

var PREFERENCES_CLIENT_ID = module.id,
defaultPrefs = { height: 200, enabled: true };

/** @type {Number} Height of the JSLint panel header in pixels. Hardcoded to avoid race
condition when measuring it on htmlReady*/
var HEADER_HEIGHT = 27;
defaultPrefs = { enabled: true };

/**
* @private
Expand Down Expand Up @@ -229,20 +224,8 @@ define(function (require, exports, module) {

// Initialize items dependent on HTML DOM
AppInit.htmlReady(function () {
var height = Math.max(_prefs.getValue("height"), 100),
$jslintResults = $("#jslint-results"),
var $jslintResults = $("#jslint-results"),
$jslintContent = $("#jslint-results .table-container");

$jslintResults.height(height);
$jslintContent.height(height - HEADER_HEIGHT);

if (_enabled) {
EditorManager.resizeEditor();
}

$jslintResults.on("panelResizeEnd", function (event, height) {
_prefs.setValue("height", height);
});

StatusBar.addIndicator(module.id, $("#gold-star"), false);
});
Expand Down
1 change: 0 additions & 1 deletion src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ define({
"CMD_SHOW_PERF_DATA" : "Show Performance Data",
"CMD_NEW_BRACKETS_WINDOW" : "New {APP_NAME} Window",
"CMD_SHOW_EXTENSIONS_FOLDER" : "Show Extensions Folder",
"CMD_USE_TAB_CHARS" : "Use Tab Characters",
"CMD_SWITCH_LANGUAGE" : "Switch Language",
"CMD_CHECK_FOR_UPDATE" : "Check for Updates",

Expand Down
19 changes: 1 addition & 18 deletions src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,15 @@ define(function (require, exports, module) {
DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
FileIndexManager = require("project/FileIndexManager"),
PreferencesManager = require("preferences/PreferencesManager"),
KeyEvent = require("utils/KeyEvent"),
AppInit = require("utils/AppInit"),
Resizer = require("utils/Resizer"),
StatusBar = require("widgets/StatusBar");

var searchResults = [];

var FIND_IN_FILES_MAX = 100,
maxHitsFoundInFile = false;

var PREFERENCES_CLIENT_ID = module.id,
defaultPrefs = { height: 200 };

/** @type {Number} Height of the FIF panel header in pixels. Hardcoded to avoid race
condition when measuring it on htmlReady*/
var HEADER_HEIGHT = 27;

// This dialog class was mostly copied from QuickOpen. We should have a common dialog
// class that everyone can use.

Expand Down Expand Up @@ -370,16 +361,8 @@ define(function (require, exports, module) {
// Initialize items dependent on HTML DOM
AppInit.htmlReady(function () {
var $searchResults = $("#search-results"),
$searchContent = $("#search-results .table-container"),
prefs = PreferencesManager.getPreferenceStorage(module.id, defaultPrefs),
height = prefs.getValue("height");
$searchContent = $("#search-results .table-container");

$searchResults.height(height);
$searchContent.height(height - HEADER_HEIGHT);

$searchResults.on("panelResizeEnd", function (event, height) {
prefs.setValue("height", height);
});
});

function _fileNameChangeHandler(event, oldName, newName) {
Expand Down
65 changes: 57 additions & 8 deletions src/utils/Resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,24 @@ define(function (require, exports, module) {
var POSITION_BOTTOM = "bottom";
var POSITION_LEFT = "left";
var POSITION_RIGHT = "right";
// Minimum size (height or width) for autodiscovered resizable panels
var DEFAULT_MIN_SIZE = 100;

// Load dependent modules
var AppInit = require("utils/AppInit"),
PreferencesManager = require("preferences/PreferencesManager"),
EditorManager = require("editor/EditorManager");

var PREFERENCES_CLIENT_ID = module.id,
defaultPrefs = { };

/**
* @private
* @type {PreferenceStorage}
*/
var _prefs = null;

var $mainView;

/**
Expand Down Expand Up @@ -132,19 +142,23 @@ define(function (require, exports, module) {
$element = $(element),
$resizableElement = $($element.find(".resizable-content:first")[0]),
$body = $(window.document.body),
elementID = $element.attr("id"),
elementPrefs = _prefs.getValue(elementID) || {},
animationRequest = null,
directionProperty = direction === DIRECTION_HORIZONTAL ? "clientX" : "clientY",
elementSizeFunction = direction === DIRECTION_HORIZONTAL ? $element.width : $element.height,
resizerCSSPosition = direction === DIRECTION_HORIZONTAL ? "left" : "top",
contentSizeFunction = null;
contentSizeFunction = direction === DIRECTION_HORIZONTAL ? $resizableElement.width : $resizableElement.height;
minSize = minSize || 0;
collapsable = collapsable || false;

$element.prepend($resizer);

$element.data("show", function () {

$element.show();
elementPrefs.visible = true;

if (collapsable) {
$element.prepend($resizer);
Expand All @@ -153,19 +167,22 @@ define(function (require, exports, module) {

EditorManager.resizeEditor();
$element.trigger("panelExpanded");
_prefs.setValue(elementID, elementPrefs);
});

$element.data("hide", function () {
var elementOffset = $element.offset(),
elementSize = elementSizeFunction.apply($element);

$element.hide();
elementPrefs.visible = false;
if (collapsable) {
$resizer.insertBefore($element).css(resizerCSSPosition, elementOffset[resizerCSSPosition] + elementSize);
}

EditorManager.resizeEditor();
$element.trigger("panelCollapsed");
_prefs.setValue(elementID, elementPrefs);
});

$resizer.on("mousedown", function (e) {
Expand All @@ -189,8 +206,6 @@ define(function (require, exports, module) {
baseSize += $(child).outerHeight();
}
});

contentSizeFunction = direction === DIRECTION_HORIZONTAL ? $resizableElement.width : $resizableElement.height;
}

animationRequest = window.webkitRequestAnimationFrame(function doRedraw() {
Expand Down Expand Up @@ -244,9 +259,18 @@ define(function (require, exports, module) {
}

function endResize(e) {
var elementSize = elementSizeFunction.apply($element);

elementPrefs.size = elementSize;

if (contentSizeFunction) {
elementPrefs.contentSize = contentSizeFunction.apply($resizableElement);
}

if (isMouseDown) {
isMouseDown = false;
$element.trigger("panelResizeEnd", [elementSizeFunction.apply($element)]);
$element.trigger("panelResizeEnd", [elementSize]);
_prefs.setValue(elementID, elementPrefs);

// We wait 100ms to remove the resizer container to capture a mousedown
// on the container that would account for double click
Expand All @@ -263,16 +287,41 @@ define(function (require, exports, module) {

e.preventDefault();
});

// Panel preferences initialization
if (elementPrefs) {

if (elementPrefs.size !== undefined) {
elementSizeFunction.apply($element, [Math.max(elementPrefs.size, minSize)]);
}

if (elementPrefs.contentSize !== undefined) {
contentSizeFunction.apply($resizableElement, [Math.max(elementPrefs.contentSize, minSize)]);
}

//if (elementPrefs.visible !== undefined) {
// hide($element);
//}
}
}

// Init PreferenceStorage
_prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID, defaultPrefs);

// Scan DOM for horz-resizable and vert-resizable classes and make them resizable
AppInit.htmlReady(function () {
var minSize = DEFAULT_MIN_SIZE;

$mainView = $(".main-view");

$(".vert-resizable").each(function (index, element) {

if ($(element).data().minsize !== undefined) {
minSize = $(element).data().minsize;
}

if ($(element).hasClass("top-resizer")) {
makeResizable(element, DIRECTION_VERTICAL, POSITION_TOP, DEFAULT_MIN_SIZE, $(element).hasClass("collapsable"));
makeResizable(element, DIRECTION_VERTICAL, POSITION_TOP, minSize, $(element).hasClass("collapsable"));
}

//if ($(element).hasClass("bottom-resizer")) {
Expand Down

0 comments on commit 1d93c6e

Please sign in to comment.