Skip to content

Commit

Permalink
Nuked secondary selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
JPJPJPOPOP committed Jan 9, 2018
1 parent cec0819 commit b541da3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 63 deletions.
27 changes: 5 additions & 22 deletions assets/js/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* exported persistChoices, restoreChoices, cache, readCache */

/* global config, Store, getURLParam, iso639CodesInverse, pairs, refreshLangList populateSecondaryAnalyzerList,
populateSecondaryGeneratorList, populateSecondarySpellCheckerList, isSubset, handleNewCurrentLang */
populateSecondaryGeneratorList, isSubset, handleNewCurrentLang */
/* global srcLangs, dstLangs, recentSrcLangs, recentDstLangs, setCurDstLang, setCurSrcLang, setRecentDstLangs, setRecentSrcLangs, setLocale,
curSrcLang, curDstLang, locale */

Expand Down Expand Up @@ -77,7 +77,6 @@ function persistChoices(mode /*: string */, updatePermalink /*: ?boolean */) {
else if(mode === 'spellchecker') {
objects = {
'primarySpellCheckerChoice': $('#primarySpellCheckerMode').val(),
'secondarySpellCheckerChoice': $('#secondarySpellCheckerMode').val(),
'spellCheckerInput': $('#spellCheckerInput').text(),
'instantChecking': $('#instantChecking').val()
};
Expand Down Expand Up @@ -131,11 +130,6 @@ function persistChoices(mode /*: string */, updatePermalink /*: ?boolean */) {
urlParams.push('choice=' + encodeURIComponent($('#secondaryGeneratorMode').val()));
qVal = $('#morphGeneratorInput').val();
}
else if(hash === '#spellchecking' && $('#secondarySpellCheckerMode').val()) {
urlParams = [];
urlParams.push('choice=' + encodeURIComponent($('#secondarySpellCheckerMode').val()));
qVal = $('#spellCheckerInput').text();
}

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

Expand Down Expand Up @@ -282,15 +276,9 @@ function restoreChoices(mode /*: string */) {
}
else if(mode === 'spellchecker') {
if(store.able()) {
var primarySpellCheckerChoice = store.get('primarySpellCheckerChoice', ''),
secondarySpellCheckerChoice = store.get('secondarySpellCheckerChoice', '');
if(store.has('primarySpellCheckerChoice') && store.has('secondarySpellCheckerChoice')) {
var primarySpellCheckerChoice = store.get('primarySpellCheckerChoice', '');
if(store.has('primarySpellCheckerChoice')) {
$('#primarySpellCheckerMode option[value="' + primarySpellCheckerChoice + '"]').prop('selected', true);
populateSecondarySpellCheckerList();
$('#secondarySpellCheckerMode option[value="' + secondarySpellCheckerChoice + '"]').prop('selected', true);
}
else {
populateSecondarySpellCheckerList();
}
if(store.has('spellCheckerInput')) {
$('#spellCheckerInput').text(String(store.get('spellCheckerInput')));
Expand All @@ -299,12 +287,8 @@ function restoreChoices(mode /*: string */) {
}

if(getURLParam('choice')) {
choice = getURLParam('choice').split('-');
$('#primarySpellCheckerMode option[value="' + choice[0] + '"]').prop('selected', true);
populateSecondarySpellCheckerList();
if(choice.length === 2) {
$('#secondarySpellCheckerMode option[value="' + choice.join('-') + '"]').prop('selected', true);
}
choice = getURLParam('choice');
$('#primarySpellCheckerMode option[value="' + choice + '"]').prop('selected', true);
}
}
else if(mode === 'localization') {
Expand All @@ -330,6 +314,5 @@ function restoreChoices(mode /*: string */) {
/*:: import {iso639Codes, iso639CodesInverse, locale, setLocale} from "./localization.js" */
/*:: import {populateSecondaryGeneratorList} from "./generator.js" */
/*:: import {populateSecondaryAnalyzerList} from "./analyzer.js" */
/*:: import {populateSecondarySpellCheckerList} from "./spellchecker.js" */
/*:: import {getURLParam, isSubset} from "./util.js" */
/*:: import {Store} from "./store.js" */
38 changes: 2 additions & 36 deletions assets/js/spellchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var spellers = {}, spellerData = {};
var currentSpellCheckerRequest;

/* exported getSpellers, populateSecondarySpellCheckerList */
/* exported getSpellers */
/* global config, modeEnabled, persistChoices, readCache, ajaxSend, ajaxComplete, filterLangPairList, allowedLang, cache,
localizeInterface, getLangByCode, restoreChoices, callApy */
/* global ENTER_KEY_CODE */
Expand Down Expand Up @@ -69,15 +69,10 @@ if(modeEnabled('spellchecking')) {
});

$('#primarySpellCheckerMode').change(function () {
populateSecondarySpellCheckerList();
localizeInterface();
persistChoices('spellchecker');
});

$('#secondarySpellCheckerMode').change(function () {
persistChoices('spellchecker');
});

$('#spellCheckerInput').keydown(function (e /*: JQueryKeyEventObject */) {
if(e.keyCode === ENTER_KEY_CODE && !e.shiftKey) {
e.preventDefault();
Expand Down Expand Up @@ -169,35 +164,6 @@ function populatePrimarySpellCheckerList(data /*: {} */) {
restoreChoices('spellerchecker');
}

function populateSecondarySpellCheckerList() {
var group = spellers[$('#primarySpellCheckerMode').val()];
$('#secondarySpellCheckerMode').empty();

if(group) {
if(group.length <= 1) {
$('#secondarySpellCheckerMode').fadeOut('fast');
}
else {
$('#secondarySpellCheckerMode').fadeIn('fast');
}

group.sort(function (a, b) {
return a.length - b.length;
});

for(var i = 0; i < group.length; i++) {
var lang = group[i];
var langDisplay = lang.indexOf('-') !== -1
? getLangByCode(lang.split('-')[0]) + '-' + getLangByCode(lang.split('-')[1])
: getLangByCode(lang);
$('#secondarySpellCheckerMode').append($('<option></option').val(lang).text(langDisplay));
}
}
else {
$('#secondarySpellCheckerMode').fadeOut('fast');
}
}

function check() {
if(currentSpellCheckerRequest) {
currentSpellCheckerRequest.abort();
Expand Down Expand Up @@ -261,7 +227,7 @@ function spellCheckerNotAvailable(data) {
$('#spellCheckerInput').append($('<div></div>').text(data.explanation));
}

/*:: export {getSpellers, populateSecondarySpellCheckerList} */
/*:: export {getSpellers} */

/*:: import {modeEnabled, ajaxSend, ajaxComplete, allowedLang, filterLangPairList, callApy, ENTER_KEY_CODE} from "./util.js" */
/*:: import {persistChoices, restoreChoices} from "./persistence.js" */
Expand Down
5 changes: 0 additions & 5 deletions index.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,6 @@
<option></option>
</select>
</div>
<div class="col-sm-4">
<select class="form-control spellCheckerMode" id="secondarySpellCheckerMode" name="secondarySpellCheckerMode">
<option></option>
</select>
</div>
</div>
<div class="form-group">
<label for="spellCheckerInput" class="col-sm-2 control-label" data-text="Input_Text">Input Text</label>
Expand Down

0 comments on commit b541da3

Please sign in to comment.