Permalink
Browse files

Merge branch 'refs/heads/master' into jason-sanjose/sprint9

Conflicts:
	src/project/ProjectManager.js
  • Loading branch information...
2 parents 2ec48eb + c9c4f9d commit bed2cb7610b73e69d95722badb406f07dc63a427 @jasonsanjose jasonsanjose committed May 18, 2012
@@ -38,6 +38,7 @@ define(function (require, exports, module) {
DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
FileUtils = require("file/FileUtils"),
+ StringUtils = require("utils/StringUtils"),
Async = require("utils/Async"),
Dialogs = require("widgets/Dialogs"),
Strings = require("strings"),
@@ -320,7 +321,7 @@ define(function (require, exports, module) {
Strings.ERROR_SAVING_FILE_TITLE,
Strings.format(
Strings.ERROR_SAVING_FILE,
- path,
+ StringUtils.htmlEscape(path),
FileUtils.getFileErrorString(code)
)
);
@@ -500,7 +501,7 @@ define(function (require, exports, module) {
Dialogs.showModalDialog(
Dialogs.DIALOG_ID_SAVE_CLOSE,
Strings.SAVE_CLOSE_TITLE,
- Strings.format(Strings.SAVE_CLOSE_MESSAGE, filename)
+ Strings.format(Strings.SAVE_CLOSE_MESSAGE, StringUtils.htmlEscape(filename))
).done(function (id) {
if (id === Dialogs.DIALOG_BTN_CANCEL) {
result.reject();
@@ -582,7 +583,9 @@ define(function (require, exports, module) {
message += "<ul>";
unsavedDocs.forEach(function (doc) {
- message += "<li><span class='dialog-filename'>" + ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath) + "</span></li>";
+ message += "<li><span class='dialog-filename'>"
+ + StringUtils.htmlEscape(ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath))
+ + "</span></li>";
});
message += "</ul>";
View
@@ -666,7 +666,7 @@ define(function (require, exports, module) {
/**
* Sets the cursor position within the editor. Removes any selection.
* @param {number} line The 0 based line number.
- * @param {number} ch The 0 based character position.
+ * @param {number=} ch The 0 based character position; treated as 0 if unspecified.
*/
Editor.prototype.setCursorPos = function (line, ch) {
this._codeMirror.setCursor(line, ch);
@@ -32,6 +32,8 @@ define(function (require, exports, module) {
// Load dependent modules
var DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
+ CommandManager = require("command/CommandManager"),
+ Commands = require("command/Commands"),
InlineWidget = require("editor/InlineWidget").InlineWidget;
/**
@@ -202,28 +204,41 @@ define(function (require, exports, module) {
self.close();
}
- // create the filename div
- var wrapperDiv = window.document.createElement("div");
- var $wrapperDiv = $(wrapperDiv);
+ // root container holding header & editor
+ var $wrapperDiv = $("<div/>");
+ var wrapperDiv = $wrapperDiv[0];
- // dirty indicator followed by filename
- var $filenameDiv = $(window.document.createElement("div")).addClass("filename");
+ // header containing filename, dirty indicator, line number
+ var $header = $("<div/>").addClass("inline-editor-header");
+ var $filenameInfo = $("<a/>").addClass("filename");
- // save file path data to dirty-indicator
- var $dirtyIndicatorDiv = $(window.document.createElement("div"))
+ // dirty indicator, with file path stored on it
+ var $dirtyIndicatorDiv = $("<div/>")
.addClass("dirty-indicator")
.width(0); // initialize indicator as hidden
$dirtyIndicatorDiv.data("fullPath", doc.file.fullPath);
- var $nameWithTooltip = $("<span></span>").text(doc.file.name).attr("title", doc.file.fullPath);
var $lineNumber = $("<span class='line-number'>" + (startLine + 1) + "</span>");
- $filenameDiv.append($dirtyIndicatorDiv)
- .append($nameWithTooltip)
- .append(" : ")
- .append($lineNumber);
- $wrapperDiv.append($filenameDiv);
+ // wrap filename & line number in clickable link with tooltip
+ $filenameInfo.append($dirtyIndicatorDiv)
+ .append(doc.file.name + " : ")
+ .append($lineNumber)
+ .attr("title", doc.file.fullPath);
+
+ // clicking filename jumps to full editor view
+ $filenameInfo.click(function () {
+ CommandManager.execute(Commands.FILE_OPEN, { fullPath: doc.file.fullPath })
+ .done(function () {
+ EditorManager.getCurrentFullEditor().setCursorPos(startLine);
+ });
+ });
+ $header.append($filenameInfo);
+ $wrapperDiv.append($header);
+
+
+ // Create actual Editor instance
var inlineInfo = EditorManager.createInlineEditorForDocument(doc, range, wrapperDiv, closeThisInline, additionalKeys);
this.editors.push(inlineInfo.editor);
container.appendChild(wrapperDiv);
@@ -311,10 +311,16 @@ define(function (require, exports, module) {
var childEditor = this.editors[0],
editorRoot = childEditor.getRootElement(),
editorPos = $(editorRoot).offset();
- if ($(editorRoot).find(event.target).length === 0) {
+
+ function containsClick($parent) {
+ return $parent.find(event.target) > 0 || $parent[0] === event.target;
+ }
+
+ // Ignore clicks in editor and clicks on filename link
+ if (!containsClick($(editorRoot)) && !containsClick($(".filename", this.$editorsDiv))) {
childEditor.focus();
// Only set the cursor if the click isn't in the range list.
- if (this.$relatedContainer.find(event.target).length === 0) {
+ if (!containsClick(this.$relatedContainer)) {
if (event.pageY < editorPos.top) {
childEditor.setCursorPos(0, 0);
} else if (event.pageY > editorPos.top + $(editorRoot).height()) {
View
@@ -177,7 +177,7 @@ define(function (require, exports, module) {
Strings.ERROR_OPENING_FILE_TITLE,
Strings.format(
Strings.ERROR_OPENING_FILE,
- path,
+ StringUtils.htmlEscape(path),
getFileErrorString(code)
)
);
@@ -48,6 +48,7 @@ define(function (require, exports, module) {
Async = require("utils/Async"),
Dialogs = require("widgets/Dialogs"),
Strings = require("strings"),
+ StringUtils = require("utils/StringUtils"),
FileUtils = require("file/FileUtils");
@@ -213,7 +214,7 @@ define(function (require, exports, module) {
Strings.ERROR_RELOADING_FILE_TITLE,
Strings.format(
Strings.ERROR_RELOADING_FILE,
- doc.file.fullPath,
+ StringUtils.htmlEscape(doc.file.fullPath),
FileUtils.getFileErrorString(error.code)
)
);
@@ -262,15 +263,15 @@ define(function (require, exports, module) {
dialogId = Dialogs.DIALOG_ID_EXT_CHANGED;
message = Strings.format(
Strings.EXT_MODIFIED_MESSAGE,
- ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
+ StringUtils.htmlEscape(ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath))
);
} else {
toClose = true;
dialogId = Dialogs.DIALOG_ID_EXT_DELETED;
message = Strings.format(
Strings.EXT_DELETED_MESSAGE,
- ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
+ StringUtils.htmlEscape(ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath))
);
}
@@ -50,6 +50,7 @@ define(function (require, exports, module) {
CommandManager = require("command/CommandManager"),
Commands = require("command/Commands"),
Dialogs = require("widgets/Dialogs"),
+ StringUtils = require("utils/StringUtils"),
Strings = require("strings"),
FileViewController = require("project/FileViewController"),
PerfUtils = require("utils/PerfUtils"),
@@ -523,7 +524,9 @@ define(function (require, exports, module) {
Dialogs.showModalDialog(
Dialogs.DIALOG_ID_ERROR,
Strings.ERROR_LOADING_PROJECT,
- Strings.format(Strings.READ_DIRECTORY_ENTRIES_ERROR, dirEntry.fullPath, error.code)
+ Strings.format(Strings.READ_DIRECTORY_ENTRIES_ERROR,
+ StringUtils.htmlEscape(dirEntry.fullPath),
+ error.code)
);
}
);
@@ -620,7 +623,7 @@ define(function (require, exports, module) {
Strings.ERROR_LOADING_PROJECT,
Strings.format(
Strings.REQUEST_NATIVE_FILE_SYSTEM_ERROR,
- rootPath,
+ StringUtils.htmlEscape(rootPath),
error.code,
function () {
result.reject();
@@ -793,13 +796,17 @@ define(function (require, exports, module) {
Dialogs.showModalDialog(
Dialogs.DIALOG_ID_ERROR,
Strings.INVALID_FILENAME_TITLE,
- Strings.format(Strings.FILE_ALREADY_EXISTS, data.rslt.name)
+ Strings.format(Strings.FILE_ALREADY_EXISTS,
+ StringUtils.htmlEscape(data.rslt.name))
);
} else {
var errString = error.code === FileError.NO_MODIFICATION_ALLOWED_ERR ?
Strings.NO_MODIFICATION_ALLOWED_ERR :
Strings.format(String.GENERIC_ERROR, error.code);
- var errMsg = Strings.format(Strings.ERROR_CREATING_FILE, data.rslt.name, errString);
+
+ var errMsg = Strings.format(Strings.ERROR_CREATING_FILE,
+ StringUtils.htmlEscape(data.rslt.name),
+ errString);
Dialogs.showModalDialog(
Dialogs.DIALOG_ID_ERROR,
@@ -827,29 +834,30 @@ define(function (require, exports, module) {
// Create the node and open the editor
_projectTree.jstree("create", node, position, {data: initialName}, null, skipRename);
- var $renameInput = _projectTree.find(".jstree-rename-input"),
- projectTreeScroller = _projectTree.get(0),
- renameInput = $renameInput.get(0),
- renameInputOffset = $renameInput.offset(),
- scrollTop = projectTreeScroller.scrollTop,
- scrollLeft = projectTreeScroller.scrollLeft;
-
- $renameInput.on("keydown", function (event) {
- // Listen for escape key on keydown, so we can remove the node in the create.jstree handler above
- if (event.keyCode === 27) {
- escapeKeyPressed = true;
- }
- });
-
- // make sure edit box is visible within the jstree, only scroll when necessary
- if ((renameInputOffset.top >= (scrollTop + _projectTree.height()))
- || (renameInputOffset.left < scrollLeft)
- || (renameInputOffset.left > scrollLeft + _projectTree.width())) {
- // below or horizontally outside viewport
- renameInput.scrollIntoView(false);
- } else if (renameInputOffset.top <= scrollTop) {
- // above viewport
- renameInput.scrollIntoView(true);
+ if (!skipRename) {
+ var $renameInput = _projectTree.find(".jstree-rename-input"),
+ projectTreeScroller = _projectTree.get(0),
+ renameInput = $renameInput.get(0),
+ renameInputOffset = $renameInput.offset(),
+ scrollTop = projectTreeScroller.scrollTop,
+ scrollLeft = projectTreeScroller.scrollLeft;
+
+ $renameInput.on("keydown", function (event) {
+ // Listen for escape key on keydown, so we can remove the node in the create.jstree handler above
+ if (event.keyCode === 27) {
+ escapeKeyPressed = true;
+ }
+ });
+
+ // make sure edit box is visible within the jstree, only scroll when necessary
+ if ((renameInputOffset.top >= (scrollTop + _projectTree.height()))
+ || (renameInputOffset.left < scrollLeft)
+ || (renameInputOffset.left > scrollLeft + _projectTree.width())) {
+ // below or horizontally outside viewport
+ renameInput.scrollIntoView(false);
+ } else if (renameInputOffset.top <= scrollTop) {
+ // above viewport
+ renameInput.scrollIntoView(true);
}
return result.promise();
View
@@ -402,21 +402,28 @@ ins.jstree-icon {
.inline-widget {
background-color: @inline-background-color-1;
- .filename {
- font-family: @fontstack-sans-serif;
- font-size: 1.1em;
- color: @inline-color-1;
+ .inline-editor-header {
padding: 10px 10px 0px 10px;
- .dirty-indicator {
- .bracket-sprite;
- display: inline-block;
- background-position: -32px 0;
- padding-top: 3px;
- }
-
- .line-number {
- color: @inline-color-2;
+ .filename {
+ font-family: @fontstack-sans-serif;
+ font-size: 1.1em;
+ color: @inline-color-1;
+
+ // Filename header is clickable (it's an <a> tag, so we get underscore on hover by
+ // default; but the hand cursor is shut off by Bootstrap's reset stylesheet)
+ cursor: pointer;
+
+ .dirty-indicator {
+ .bracket-sprite;
+ display: inline-block;
+ background-position: -32px 0;
+ padding-top: 3px;
+ }
+
+ .line-number {
+ color: @inline-color-2;
+ }
}
}
View
@@ -37,11 +37,5 @@ define(function (require, exports, module) {
.replace(/>/g, '&gt;');
}
- function regexEscape(str) {
- return (str+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
- }
-
exports.htmlEscape = htmlEscape;
- exports.regexEscape = regexEscape;
-
});

0 comments on commit bed2cb7

Please sign in to comment.