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

Commit

Permalink
Merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Narciso Jaramillo committed Dec 11, 2012
2 parents 3bd7dda + 7ba8722 commit 59993eb
Show file tree
Hide file tree
Showing 30 changed files with 904 additions and 522 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ src/extensions/disabled

#OSX .DS_Store files
.DS_Store

# unit test working directory
test/temp
File renamed without changes.
10 changes: 8 additions & 2 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
require.config({
paths: {
"text" : "thirdparty/text",
"i18n" : "thirdparty/i18n",
"defaults" : "../defaults"
"i18n" : "thirdparty/i18n"
},
// Use custom brackets property until CEF sets the correct navigator.language
// NOTE: When we change to navigator.language here, we also should change to
Expand Down Expand Up @@ -306,6 +305,13 @@ define(function (require, exports, module) {
}
});

// The .no-focus style is added to clickable elements that should
// not steal focus. Calling preventDefault() on mousedown prevents
// focus from going to the click target.
$("html").on("mousedown", ".no-focus", function (e) {
e.preventDefault();
});

// Localize MainViewHTML and inject into <BODY> tag
var templateVars = $.extend({
ABOUT_ICON : brackets.config.about_icon,
Expand Down
2 changes: 1 addition & 1 deletion src/command/KeyBindingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define(function (require, exports, module) {
KeyEvent = require("utils/KeyEvent"),
Strings = require("strings");

var KeyboardPrefs = JSON.parse(require("text!defaults/keyboard.json"));
var KeyboardPrefs = JSON.parse(require("text!base-config/keyboard.json"));

/**
* Maps normalized shortcut descriptor to key binding info.
Expand Down
94 changes: 41 additions & 53 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,42 @@ define(function (require, exports, module) {
}


/**
* Get the next or previous file in the working set, in MRU order (relative to currentDocument). May
* return currentDocument itself if working set is length 1.
* @param {Number} inc -1 for previous, +1 for next; no other values allowed
* @return {?FileEntry} null if working set empty
*/
function getNextPrevFile(inc) {
if (inc !== -1 && inc !== +1) {
throw new Error("Illegal argument: inc = " + inc);
}

if (_currentDocument) {
var mruI = findInWorkingSet(_currentDocument.file.fullPath, _workingSetMRUOrder);
if (mruI === -1) {
// If doc not in working set, return most recent working set item
if (_workingSetMRUOrder.length > 0) {
return _workingSetMRUOrder[0];
}
} else {
// If doc is in working set, return next/prev item with wrap-around
var newI = mruI + inc;
if (newI >= _workingSetMRUOrder.length) {
newI = 0;
} else if (newI < 0) {
newI = _workingSetMRUOrder.length - 1;
}

return _workingSetMRUOrder[newI];
}
}

// If no doc open or working set empty, there is no "next" file
return null;
}


/**
* Changes currentDocument to the given Document, firing currentDocumentChange, which in turn
* causes this Document's main editor UI to be shown in the editor pane, updates the selection
Expand Down Expand Up @@ -454,24 +490,11 @@ define(function (require, exports, module) {
// If this was the current document shown in the editor UI, we're going to switch to a
// different document (or none if working set has no other options)
if (_currentDocument && _currentDocument.file.fullPath === file.fullPath) {
var wsIndex = findInWorkingSet(file.fullPath);

// Decide which doc to show in editor after this one
var nextFile;
if (wsIndex === -1) {
// If doc wasn't in working set, use bottommost working set item
if (_workingSet.length > 0) {
nextFile = _workingSet[_workingSet.length - 1];
}
// else: leave nextDocument null; editor area will be blank
} else {
// If doc was in working set, use item next to it (below if possible)
if (wsIndex < _workingSet.length - 1) {
nextFile = _workingSet[wsIndex + 1];
} else if (wsIndex > 0) {
nextFile = _workingSet[wsIndex - 1];
}
// else: leave nextDocument null; editor area will be blank
// Get next most recent doc in the MRU order
var nextFile = getNextPrevFile(1);
if (nextFile && nextFile.fullPath === _currentDocument.file.fullPath) {
// getNextPrevFile() might return the file we're about to close if it's the only one open (due to wraparound)
nextFile = null;
}

// Switch editor to next document (or blank it out)
Expand Down Expand Up @@ -1010,41 +1033,6 @@ define(function (require, exports, module) {
}


/**
* Get the next or previous file in the working set, in MRU order (relative to currentDocument).
* @param {Number} inc -1 for previous, +1 for next; no other values allowed
* @return {?FileEntry} null if working set empty
*/
function getNextPrevFile(inc) {
if (inc !== -1 && inc !== +1) {
throw new Error("Illegal argument: inc = " + inc);
}

if (_currentDocument) {
var mruI = findInWorkingSet(_currentDocument.file.fullPath, _workingSetMRUOrder);
if (mruI === -1) {
// If doc not in working set, return most recent working set item
if (_workingSetMRUOrder.length > 0) {
return _workingSetMRUOrder[0];
}
} else {
// If doc is in working set, return next/prev item with wrap-around
var newI = mruI + inc;
if (newI >= _workingSetMRUOrder.length) {
newI = 0;
} else if (newI < 0) {
newI = _workingSetMRUOrder.length - 1;
}

return _workingSetMRUOrder[newI];
}
}

// If no doc open or working set empty, there is no "next" file
return null;
}


/**
* @private
* Preferences callback. Saves the document file paths for the working set.
Expand Down
20 changes: 11 additions & 9 deletions src/extensions/default/HTMLCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ define(function (require, exports, module) {
query.attrName = tagInfo.attr.name;
}

// TODO: get existing attributes for the current tag and add them to query.usedAttr
query.usedAttr = HTMLUtils.getTagAttributes(editor, cursor);
}

return query;
Expand Down Expand Up @@ -425,6 +425,7 @@ define(function (require, exports, module) {
attrName = query.attrName,
filter = query.queryStr,
unfiltered = [],
hints = [],
sortFunc = null;

this.closeOnSelect = true;
Expand All @@ -440,25 +441,26 @@ define(function (require, exports, module) {

if (attrInfo) {
if (attrInfo.type === "boolean") {
unfiltered = ["false", "true"];
hints = ["false", "true"];
} else if (attrInfo.type === "url") {
// Default behavior for url hints is do not close on select.
this.closeOnSelect = false;
unfiltered = this._getUrlList(query);
hints = this._getUrlList(query);
sortFunc = StringUtils.urlSort;
} else if (attrInfo.attribOption) {
unfiltered = attrInfo.attribOption;
hints = attrInfo.attribOption;
}
}
} else if (tags && tags[tagName] && tags[tagName].attributes) {
unfiltered = tags[tagName].attributes.concat(this.globalAttributes);

// TODO: exclude existing attributes from unfiltered array
hints = $.grep(unfiltered, function (attr, i) {
return $.inArray(attr, query.usedAttr) < 0;
});
}

if (unfiltered.length) {
if (hints.length) {
console.assert(!result.length);
result = $.map(unfiltered, function (item) {
result = $.map(hints, function (item) {
if (item.indexOf(filter) === 0) {
return item;
}
Expand Down
38 changes: 19 additions & 19 deletions src/extensions/default/InlineColorEditor/ColorEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ define(function (require, exports, module) {
this._originalColor = color;
this._redoColor = null;

this.$colorValue = this.$element.find(".color_value");
this.$colorValue = this.$element.find(".color-value");
this.$buttonList = this.$element.find("ul.button-bar");
this.$rgbaButton = this.$element.find(".rgba");
this.$hexButton = this.$element.find(".hex");
this.$hslButton = this.$element.find(".hsla");
this.$currentColor = this.$element.find(".current_color");
this.$originalColor = this.$element.find(".original_color");
this.$selection = this.$element.find(".color_selection_field");
this.$selectionBase = this.$element.find(".color_selection_field .selector_base");
this.$hueBase = this.$element.find(".hue_slider .selector_base");
this.$opacityGradient = this.$element.find(".opacity_gradient");
this.$hueSlider = this.$element.find(".hue_slider");
this.$hueSelector = this.$element.find(".hue_slider .selector_base");
this.$opacitySlider = this.$element.find(".opacity_slider");
this.$opacitySelector = this.$element.find(".opacity_slider .selector_base");
this.$currentColor = this.$element.find(".current-color");
this.$originalColor = this.$element.find(".original-color");
this.$selection = this.$element.find(".color-selection-field");
this.$selectionBase = this.$element.find(".color-selection-field .selector-base");
this.$hueBase = this.$element.find(".hue-slider .selector-base");
this.$opacityGradient = this.$element.find(".opacity-gradient");
this.$hueSlider = this.$element.find(".hue-slider");
this.$hueSelector = this.$element.find(".hue-slider .selector-base");
this.$opacitySlider = this.$element.find(".opacity-slider");
this.$opacitySelector = this.$element.find(".opacity-slider .selector-base");
this.$swatches = this.$element.find(".swatches");

// Create quick-access color swatches
Expand Down Expand Up @@ -339,7 +339,7 @@ define(function (require, exports, module) {
swatches.forEach(function (swatch) {
var stringFormat = (swatch.count > 1) ? Strings.COLOR_EDITOR_USED_COLOR_TIP_PLURAL : Strings.COLOR_EDITOR_USED_COLOR_TIP_SINGULAR,
usedColorTip = StringUtils.format(stringFormat, swatch.value, swatch.count);
_this.$swatches.append("<li tabindex='0'><div class='swatch_bg'><div class='swatch' style='background-color: " +
_this.$swatches.append("<li tabindex='0'><div class='swatch-bg'><div class='swatch' style='background-color: " +
swatch.value + ";' title='" + usedColorTip + "'></div></div> <span class='value'" + " title='" +
usedColorTip + "'>" + swatch.value + "</span></li>");
});
Expand Down Expand Up @@ -442,8 +442,8 @@ define(function (require, exports, module) {
hsv.s = xOffset / width;
hsv.v = 1 - yOffset / height;
this.setColorAsHsv(hsv, false);
if (!this.$selection.find(".selector_base").is(":focus")) {
this.$selection.find(".selector_base").focus();
if (!this.$selection.find(".selector-base").is(":focus")) {
this.$selection.find(".selector-base").focus();
}
};

Expand All @@ -455,8 +455,8 @@ define(function (require, exports, module) {
hsv = {};
hsv.h = (1 - offset / height) * 360;
this.setColorAsHsv(hsv, false);
if (!this.$hueSlider.find(".selector_base").is(":focus")) {
this.$hueSlider.find(".selector_base").focus();
if (!this.$hueSlider.find(".selector-base").is(":focus")) {
this.$hueSlider.find(".selector-base").focus();
}
};

Expand All @@ -468,8 +468,8 @@ define(function (require, exports, module) {
hsv = {};
hsv.a = 1 - offset / height;
this.setColorAsHsv(hsv, false);
if (!this.$opacitySlider.find(".selector_base").is(":focus")) {
this.$opacitySlider.find(".selector_base").focus();
if (!this.$opacitySlider.find(".selector-base").is(":focus")) {
this.$opacitySlider.find(".selector-base").focus();
}
};

Expand Down Expand Up @@ -673,7 +673,7 @@ define(function (require, exports, module) {
};

// Prevent clicks on some UI elements (color selection field, slider and large swatch) from taking focus
$(window.document).on("mousedown", ".color_selection_field, .slider, .large_swatch", function (e) {
$(window.document).on("mousedown", ".color-selection-field, .slider, .large-swatch", function (e) {
e.preventDefault();
});

Expand Down
28 changes: 14 additions & 14 deletions src/extensions/default/InlineColorEditor/ColorEditorTemplate.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@

<div tabindex="-1" class="color_editor">
<div tabindex="-1" class="color-editor">
<section>
<div class="sliders">
<div class="color_selection_field">
<div class="saturation_gradient gradient_overlay"></div>
<div class="luminosity_gradient gradient_overlay"></div>
<div tabindex="0" class="selector_base">
<div class="color-selection-field">
<div class="saturation-gradient gradient-overlay"></div>
<div class="luminosity-gradient gradient-overlay"></div>
<div tabindex="0" class="selector-base">
<div class="selector"></div>
</div>
</div>
<div class="hue_slider slider">
<div tabindex="0" class="selector_base">
<div class="hue-slider slider">
<div tabindex="0" class="selector-base">
<div class="selector"></div>
</div>
</div>
<div class="opacity_slider slider">
<div class="opacity_gradient gradient_overlay"></div>
<div tabindex="0" class="selector_base">
<div class="opacity-slider slider">
<div class="opacity-gradient gradient-overlay"></div>
<div tabindex="0" class="selector-base">
<div class="selector"></div>
</div>
</div>
</div>
<footer>
<input class="color_value" />
<input class="color-value" />
<ul class="button-bar">
<li class="selected" title="{{COLOR_EDITOR_RGBA_BUTTON_TIP}}"><a href="#" tabindex="0" class="rgba">RGBa</a></li>
<li title="{{COLOR_EDITOR_HEX_BUTTON_TIP}}"><a href="#" tabindex="0" class="hex">HEX</a></li>
Expand All @@ -32,9 +32,9 @@
</section>
<aside>
<header>
<div class="large_swatches">
<div class="current_color large_swatch" title="{{COLOR_EDITOR_CURRENT_COLOR_SWATCH_TIP}}"></div>
<div class="original_color large_swatch" title="{{COLOR_EDITOR_ORIGINAL_COLOR_SWATCH_TIP}}"></div>
<div class="large-swatches">
<div class="current-color large-swatch" title="{{COLOR_EDITOR_CURRENT_COLOR_SWATCH_TIP}}"></div>
<div class="original-color large-swatch" title="{{COLOR_EDITOR_ORIGINAL_COLOR_SWATCH_TIP}}"></div>
</div>
</header>
<ul class="swatches"></ul>
Expand Down
Loading

0 comments on commit 59993eb

Please sign in to comment.