This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Combine jdiel's "language switching" pull request with tvoliter's templatization of index.html using mustache #1358
Merged
Merged
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
da48df8
localize
tvoliter 5f2c46f
- delete strings.json and move content to strings.js. Now there is on…
tvoliter e319956
Remove decomp of index.html into separate template files. Integrate l…
tvoliter c3a9992
adding localization notes in comments
tvoliter c387fc0
add mustache submodule
tvoliter a388de1
code review fixes
tvoliter ee3a6de
code review fix
tvoliter b4338bd
working on load order
tvoliter 6ecb6d9
brackest sends "htmlContentLoadComplete" event to indicate when modul…
tvoliter 545c15b
updating comment
tvoliter c155b92
Updating config of SpecRunner.js to match Bracket.js
tvoliter a5440c2
localize quick open and find in files input dialogs
redmunds 6593119
- removed htmlContentLoad.js module. Functionality moved to brackets.js
tvoliter 71c97d6
- removed htmlContentLoad.js module. Functionality moved to brackets.js
tvoliter ea0ba01
Merge remote-tracking branch 'origin/tvoliter/localizationSupport' in…
tvoliter bf7c36b
Merge remote-tracking branch 'origin/master' into tvoliter/localizati…
tvoliter 1e2c63d
Merge remote-tracking branch 'origin/master' into tvoliter/localizati…
tvoliter cb74555
merged index.html
tvoliter baa2c8f
use double quotes
tvoliter ada344b
remove unused $ in define
tvoliter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,9 @@ define(function (require, exports, module) { | |
Editor = require("editor/Editor").Editor, | ||
Strings = require("strings"), | ||
PerfUtils = require("utils/PerfUtils"), | ||
NativeApp = require("utils/NativeApp"); | ||
NativeApp = require("utils/NativeApp"), | ||
NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem, | ||
FileUtils = require("file/FileUtils"); | ||
|
||
function handleShowDeveloperTools(commandData) { | ||
brackets.app.showDeveloperTools(); | ||
|
@@ -130,6 +132,93 @@ define(function (require, exports, module) { | |
function _handleNewBracketsWindow() { | ||
window.open(window.location.href); | ||
} | ||
|
||
function _handleSwitchLanguage() { | ||
var stringsPath = FileUtils.getNativeBracketsDirectoryPath() + "/nls"; | ||
NativeFileSystem.requestNativeFileSystem(stringsPath, function (dirEntry) { | ||
dirEntry.createReader().readEntries(function (entries) { | ||
|
||
var $activeLanguage; | ||
var $submit; | ||
function setLanguage(event) { | ||
if ($activeLanguage) { | ||
$activeLanguage.css("font-weight", "normal"); | ||
} | ||
$activeLanguage = $(event.currentTarget); | ||
$activeLanguage.css("font-weight", "bold"); | ||
$submit.attr("disabled", false); | ||
} | ||
|
||
var $modal = $("<div class='modal hide' />"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll file a general issue to move blocks such as this one into a template. |
||
|
||
var $header = $("<div class='modal-header' />") | ||
.append("<a href='#' class='close'>×</a>") | ||
.append("<h1 class='dialog-title'>" + Strings.LANGUAGE_TITLE + "</h1>") | ||
.appendTo($modal); | ||
|
||
var $body = $("<div class='modal-body' style='max-height: 500px; overflow: auto;' />") | ||
.appendTo($modal); | ||
|
||
var $p = $("<p class='dialog-message'>") | ||
.text(Strings.LANGUAGE_MESSAGE) | ||
.appendTo($body); | ||
|
||
var $ul = $("<ul>") | ||
.on("click", "li", setLanguage) | ||
.appendTo($p); | ||
|
||
// add english | ||
var $li = $("<li>") | ||
.text("en-EN") | ||
.data("locale", "en-EN") | ||
.appendTo($ul); | ||
|
||
// inspect all children of dirEntry | ||
entries.forEach(function (entry) { | ||
if (entry.isDirectory && entry.name.match(/^[a-z]{2}-[A-Z]{2}$/)) { | ||
var language = entry.name; | ||
var $li = $("<li>") | ||
.text(entry.name) | ||
.data("locale", language) | ||
.appendTo($ul); | ||
} | ||
}); | ||
|
||
var $footer = $("<div class='modal-footer' />") | ||
.appendTo($modal); | ||
|
||
var $cancel = $("<button class='dialog-button btn left'>") | ||
.on("click", function () { | ||
$modal.modal('hide'); | ||
}) | ||
.text(Strings.LANGUAGE_CANCEL) | ||
.appendTo($footer); | ||
|
||
$submit = $("<button class='dialog-button btn primary'>") | ||
.text(Strings.LANGUAGE_SUBMIT) | ||
.on("click", function () { | ||
if (!$activeLanguage) { | ||
return; | ||
} | ||
var locale = $activeLanguage.data("locale"); | ||
window.localStorage.setItem("locale", locale); | ||
CommandManager.execute(Commands.DEBUG_REFRESH_WINDOW); | ||
}) | ||
.attr("disabled", "disabled") | ||
.appendTo($footer); | ||
|
||
$modal | ||
.appendTo(window.document.body) | ||
.modal({ | ||
backdrop: "static", | ||
show: true | ||
}) | ||
.on("hidden", function () { | ||
$(this).remove(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
/* Register all the command handlers */ | ||
|
||
|
@@ -139,6 +228,7 @@ define(function (require, exports, module) { | |
CommandManager.register(Strings.CMD_NEW_BRACKETS_WINDOW, Commands.DEBUG_NEW_BRACKETS_WINDOW, _handleNewBracketsWindow); | ||
CommandManager.register(Strings.CMD_RUN_UNIT_TESTS, Commands.DEBUG_RUN_UNIT_TESTS, _handleRunUnitTests); | ||
CommandManager.register(Strings.CMD_SHOW_PERF_DATA, Commands.DEBUG_SHOW_PERF_DATA, _handleShowPerfData); | ||
CommandManager.register(Strings.CMD_SWITCH_LANGUAGE, Commands.DEBUG_SWITCH_LANGUAGE, _handleSwitchLanguage); | ||
|
||
CommandManager.register(Strings.CMD_USE_TAB_CHARS, Commands.TOGGLE_USE_TAB_CHARS, _handleUseTabChars) | ||
.setChecked(Editor.getUseTabChar()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global require, define, brackets: true, $, Mustache */ | ||
|
||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
// Load dependent non-module scripts | ||
var Strings = require("strings"), | ||
rootView = require("text!htmlContent/main-view.html"); | ||
|
||
$('body').html(Mustache.render(rootView, Strings)); | ||
|
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have seen this sooner, but do we need a completely separate module anymore? htmlContentLoad.js won't be reused anywhere else. It seems like we could inline the
Mustache.render()
call inside_onReady()
in brackets.js.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can make this change, then
$(brackets).trigger("htmlContentLoadComplete");
would immediately followMustache.render()
. I think that would be a cleaner approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I removed that module and moved the functionality to brackets.js
Now SidebarView.js and ProjectManager.js listen for the htmlContentLoadComplete event since they both init jquery vars on load.
From: Jason San Jose [mailto:notifications@github.com]
Sent: Tuesday, August 14, 2012 10:33 AM
To: adobe/brackets
Cc: Ty Voliter
Subject: Re: [brackets] Combine jdiel's "language switching" pull request with tvoliter's templatization of index.html using mustache (#1358)
In src/brackets.js:
Should have seen this sooner, but do we need a completely separate module anymore? htmlContentLoad.js won't be reused anywhere else. It seems like we could inline the Mustache.render() call inside _onReady() in brackets.js.
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/1358/files#r1374771.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
From: Jason San Jose [mailto:notifications@github.com]
Sent: Tuesday, August 14, 2012 10:34 AM
To: adobe/brackets
Cc: Ty Voliter
Subject: Re: [brackets] Combine jdiel's "language switching" pull request with tvoliter's templatization of index.html using mustache (#1358)
In src/brackets.js:
If we can make this change, then $(brackets).trigger("htmlContentLoadComplete"); would immediately follow Mustache.render(). I think that would be a cleaner approach.
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/1358/files#r1374784.