Skip to content

Commit

Permalink
- Don't steal focus from editor when clicking toolbar buttons
Browse files Browse the repository at this point in the history
- Switch to safer path-parsing code (see adobe/brackets#4333)
  • Loading branch information
peterflynn committed Jul 25, 2013
1 parent dc773f4 commit a726da6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion XMLPathFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true */
/*global define, brackets, $, PathUtils, DOMParser */
/*global define, brackets, $, DOMParser */

define(function (require, exports, module) {
"use strict";
Expand Down
22 changes: 18 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,26 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true */
/*global define, brackets, $, PathUtils */
/*global define, brackets, $ */

define(function (require, exports, module) {
"use strict";

// Brackets modules
var DocumentManager = brackets.getModule("document/DocumentManager"),
EditorManager = brackets.getModule("editor/EditorManager"),
FileUtils = brackets.getModule("file/FileUtils"),
ExtensionUtils = brackets.getModule("utils/ExtensionUtils");

// Extension's own modules
var XMLPathFinder = require("XMLPathFinder");


// TODO:
// - source->image linkage -- blink element in SVG (if Live Highlight is toggled on)
// - blink element's fill red/normal/red/normal a few times when cursor enters its text bounds
// - (during NON-EDIT cursor movement only... how to detect??)

/**
* Preview panel that appears above the editor area. Lazily created, so may be null if never shown yet.
* @type {?jQuery}
Expand Down Expand Up @@ -169,7 +175,10 @@ define(function (require, exports, module) {
$svgParent.removeClass("checker");
$svgParent.css("background-color", $elt.css("background-color"));
}
});
})
.mousedown(function (event) {
event.preventDefault(); // don't steal focus
});

$(".svg-tb-button", $svgToolbar).click(function (event) {
var zoomFactor = $(event.currentTarget).attr("data-zoomFactor");
Expand All @@ -179,7 +188,10 @@ define(function (require, exports, module) {
currentState.zoomFactor *= zoomFactor;
}
updatePanel(EditorManager.getCurrentFullEditor());
});
})
.mousedown(function (event) {
event.preventDefault(); // don't steal focus
});
}

function createSVGPanel() {
Expand Down Expand Up @@ -232,7 +244,9 @@ define(function (require, exports, module) {
createSVGPanel();

// Inject panel into UI
// TODO: use PanelManager to create top panel, once possible
$("#editor-holder").before($svgPanel);

} else if ($svgPanel.is(":hidden")) {
$svgPanel.show();
}
Expand All @@ -255,7 +269,7 @@ define(function (require, exports, module) {

var newEditor = EditorManager.getCurrentFullEditor();
if (newEditor) {
var ext = PathUtils.filenameExtension(newEditor.document.file.fullPath);
var ext = FileUtils.getFilenameExtension(newEditor.document.file.fullPath);
if (ext.toLowerCase() === ".svg") {
showSVGPanel(newEditor);
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "SVG Preview",
"homepage": "https://github.com/peterflynn/svg-preview",
"author": "Peter Flynn",
"version": "1.1.0",
"version": "1.1.1",
"engines": { "brackets": ">=0.14" },
"description": "Live preview SVG files in an inline panel while you edit them."
}

0 comments on commit a726da6

Please sign in to comment.