Skip to content

Commit 9e67f03

Browse files
committed
Deconflicted #176
1 parent 7be069a commit 9e67f03

File tree

6 files changed

+378
-5
lines changed

6 files changed

+378
-5
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ JSFILES= \
4646
assets/js/translator.js \
4747
assets/js/analyzer.js \
4848
assets/js/generator.js \
49-
assets/js/sandbox.js
49+
assets/js/sandbox.js \
50+
assets/js/spellchecker.js
5051

5152
build/js/config.js: $(CONFIG) tools/read-conf.py build/js/.d
5253
./tools/read-conf.py -c $< js > $@

assets/css/translation.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,36 @@ html[dir='rtl'] #srcLanguages {
7777
clear: both;
7878
}
7979

80+
/* Spell Checker */
81+
82+
#spellcheckerInput {
83+
display: block;
84+
height: 131px;
85+
overflow: auto;
86+
resize: both;
87+
}
88+
89+
.spellcheckVisible .spellError {
90+
border-bottom: 1px solid #f00;
91+
}
92+
93+
.popover-content { /* sass-lint:disable-line class-name-format */
94+
max-height: 190px;
95+
overflow: auto;
96+
padding: 0;
97+
width: 110%;
98+
}
99+
100+
.list-group { /* sass-lint:disable-line class-name-format */
101+
margin-bottom: 0;
102+
}
103+
104+
.list-group-item { /* sass-lint:disable-line class-name-format */
105+
border: 0;
106+
cursor: pointer;
107+
padding: 4px 10px;
108+
}
109+
80110
#translatedWebpage {
81111
border: 1px solid #ccc;
82112
border-radius: 4px;

assets/js/localization.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ var localizedLanguageCodes /*: {[string]: string} */ = {}, localizedLanguageName
1313

1414
/* global config, getPairs, getGenerators, getAnalyzers, persistChoices, getURLParam, cache, ajaxSend, ajaxComplete, sendEvent,
1515
srcLangs, dstLangs, generators, analyzers, readCache, modeEnabled, populateTranslationList, populateGeneratorList,
16-
populateAnalyzerList, analyzerData, generatorData, curSrcLang, curDstLang, restoreChoices, refreshLangList, onlyUnique */
16+
populateAnalyzerList, analyzerData, generatorData, curSrcLang, curDstLang, restoreChoices, refreshLangList, onlyUnique
17+
getSpellers */
1718

1819
var dynamicLocalizations /*: {[lang: string]: {[string]: string}} */ = {
1920
'fallback': {
@@ -52,7 +53,12 @@ $(document).ready(function () {
5253
iso639CodesInverse[language] = code;
5354
});
5455

55-
var possibleItems = {'translation': getPairs, 'generation': getGenerators, 'analyzation': getAnalyzers};
56+
var possibleItems = {
57+
'translation': getPairs,
58+
'generation': getGenerators,
59+
'analyzation': getAnalyzers,
60+
'spellchecker': getSpellers
61+
};
5662
var deferredItems = [getLocale(), getLocales()];
5763
if(config.ENABLED_MODES) {
5864
$.each(config.ENABLED_MODES, function () {
@@ -427,3 +433,4 @@ function setLocale(newLocale /*: string */) {
427433
/*:: import {generatorData, generators, getGenerators, populateGeneratorList} from "./generator.js" */
428434
/*:: import {analyzerData, analyzers, getAnalyzers, populateAnalyzerList} from "./analyzer.js" */
429435
/*:: import {cache, persistChoices, readCache, restoreChoices} from "./persistence.js" */
436+
/*:: import {getSpellers} from "./spellchecker.js" */

assets/js/persistence.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* exported persistChoices, restoreChoices, cache, readCache */
44

55
/* global config, Store, getURLParam, iso639CodesInverse, pairs, refreshLangList populateSecondaryAnalyzerList,
6-
populateSecondaryGeneratorList, isSubset, handleNewCurrentLang */
6+
populateSecondaryGeneratorList, populateSecondarySpellcheckerList, isSubset, handleNewCurrentLang */
77
/* global srcLangs, dstLangs, recentSrcLangs, recentDstLangs, setCurDstLang, setCurSrcLang, setRecentDstLangs, setRecentSrcLangs, setLocale,
88
curSrcLang, curDstLang, locale */
99

@@ -73,6 +73,14 @@ function persistChoices(mode /*: string */, updatePermalink /*: ?boolean */) {
7373
'generatorInput': $('#morphGeneratorInput').val()
7474
};
7575
}
76+
else if(mode === 'spellchecker') {
77+
objects = {
78+
'primarySpellcheckerChoice': $('#primarySpellcheckerMode').val(),
79+
'secondarySpellcheckerChoice': $('#secondarySpellcheckerMode').val(),
80+
'spellcheckerInput': $('#spellcheckerInput').text(),
81+
'instantChecking': $('#instantChecking').val()
82+
};
83+
}
7684
else if(mode === 'localization') {
7785
objects = {
7886
'locale': $('.localeSelect').val()
@@ -122,6 +130,11 @@ function persistChoices(mode /*: string */, updatePermalink /*: ?boolean */) {
122130
urlParams.push('choice=' + encodeURIComponent($('#secondaryGeneratorMode').val()));
123131
qVal = $('#morphGeneratorInput').val();
124132
}
133+
else if(hash === '#spellchecker' && $('#secondarySpellcheckerMode').val()) {
134+
urlParams = [];
135+
urlParams.push('choice=' + encodeURIComponent($('#secondarySpellcheckerMode').val()));
136+
qVal = $('#spellcheckerInput').text();
137+
}
125138

126139
var qName /*: string */ = HASH_URL_MAP[hash];
127140

@@ -266,6 +279,33 @@ function restoreChoices(mode /*: string */) {
266279
$('#morphGeneratorInput').val(decodeURIComponent(getURLParam('qG')));
267280
}
268281
}
282+
else if(mode === 'spellchecker') {
283+
if(store.able()) {
284+
var primarySpellcheckerChoice = store.get('primarySpellcheckerChoice', ''),
285+
secondarySpellcheckerChoice = store.get('secondarySpellcheckerChoice', '');
286+
if(store.has('primarySpellcheckerChoice') && store.has('secondarySpellcheckerChoice')) {
287+
$('#primarySpellcheckerMode option[value="' + primarySpellcheckerChoice + '"]').prop('selected', true);
288+
populateSecondarySpellcheckerList();
289+
$('#secondarySpellcheckerMode option[value="' + secondarySpellcheckerChoice + '"]').prop('selected', true);
290+
}
291+
else {
292+
populateSecondarySpellcheckerList();
293+
}
294+
if(store.has('spellcheckerInput')) {
295+
$('#spellcheckerInput').text(store.get('spellcheckerInput'));
296+
$('#instantChecking').prop('checked', store.get('instantChecking', true));
297+
}
298+
}
299+
300+
if(getURLParam('choice')) {
301+
choice = getURLParam('choice').split('-');
302+
$('#primarySpellcheckerMode option[value="' + choice[0] + '"]').prop('selected', true);
303+
populateSecondarySpellcheckerList();
304+
if(choice.length === 2) {
305+
$('#secondarySpellcheckerMode option[value="' + choice.join('-') + '"]').prop('selected', true);
306+
}
307+
}
308+
}
269309
else if(mode === 'localization') {
270310
if(store.able()) {
271311
setLocale(store.get('locale', ''));
@@ -289,5 +329,6 @@ function restoreChoices(mode /*: string */) {
289329
/*:: import {iso639Codes, iso639CodesInverse, locale, setLocale} from "./localization.js" */
290330
/*:: import {populateSecondaryGeneratorList} from "./generator.js" */
291331
/*:: import {populateSecondaryAnalyzerList} from "./analyzer.js" */
332+
/*:: import {populateSecondarySpellcheckerList} from "./spellchecker.js" */
292333
/*:: import {getURLParam, isSubset} from "./util.js" */
293334
/*:: import {Store} from "./store.js" */

0 commit comments

Comments
 (0)