Bug 919706 - Localize search UI. r=robcee

This commit is contained in:
Anton Kovalyov
2013-10-23 14:57:13 -07:00
parent ac8c7cc5f2
commit d178d67a5b
3 changed files with 14 additions and 5 deletions

View File

@@ -18,8 +18,9 @@ To confirm the functionality run mochitests for the following components:
The sourceeditor component contains imported CodeMirror tests [3]. Some
tests were commented out because we don't use that functionality within
Firefox (for example Ruby editing mode). Other than that, we don't have
any Mozilla-specific patches applied to CodeMirror itself.
Firefox (for example Ruby editing mode). The search addon (search.js)
was slightly modified to make search UI localizable. Other than that,
we don't have any Mozilla-specific patches applied to CodeMirror itself.
# Addons

View File

@@ -45,12 +45,16 @@
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
return isRE ? new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i") : query;
}
var queryDialog =
'Search: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
var queryDialog;
function doSearch(cm, rev) {
if (!queryDialog) {
queryDialog = cm.l10n('findCmd.promptMessage') +
' <input type="text" style="width: 10em"/>';
}
var state = getSearchState(cm);
if (state.query) return findNext(cm, rev);
dialog(cm, queryDialog, "Search for:", function(query) {
dialog(cm, queryDialog, cm.l10n('findCmd.promptMessage'), function(query) {
cm.operation(function() {
if (!query || state.query) return;
state.query = parseQuery(query);

View File

@@ -207,6 +207,10 @@ Editor.prototype = {
cm.on("gutterClick", (cm, line) => this.emit("gutterClick", line));
cm.on("cursorActivity", (cm) => this.emit("cursorActivity"));
win.CodeMirror.defineExtension("l10n", (name) => {
return L10N.GetStringFromName(name);
});
doc.defaultView.controllers.insertControllerAt(0, controller(this, doc.defaultView));
this.container = env;