Skip to content

Conversation

@JPJPJPOPOP
Copy link
Contributor

@JPJPJPOPOP JPJPJPOPOP commented Jan 10, 2018

Removes variant formatting for mobile because it doesn't show up anyways.

$('#dstLangSelect').val(curDstLang);
var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]');
if(currentDstLangSelect.text().charCodeAt(0) === 160) {
currentDstLangSelect.text(currentDstLangSelect.text().substring(4)); /* sass-lint:disable-line no-magic-numbers */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 4 no-magic-numbers


$('#dstLangSelect').val(curDstLang);
var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]');
if(currentDstLangSelect.text().charCodeAt(0) === 160) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 160 no-magic-numbers

$('#srcLangSelect').val(curSrcLang);
var currentSrcLangSelect = $('#srcLangSelect option[value="' + $('#srcLangSelect').val() + '"]');
if(currentSrcLangSelect.text().charCodeAt(0) === 160) {
currentSrcLangSelect.text(currentSrcLangSelect.text().substring(4)); /* sass-lint:disable-line no-magic-numbers */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 4 no-magic-numbers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't robust. There's no reason a variant can't be en_GB.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sushain97 I do not understand exactly what you mean by your statement. I tried adding in comments to see if it might clarify anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why isn't /* sass-lint:disable-line no-magic-numbers */ working?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sushain97 I do not understand exactly what you mean by your statement. I tried adding in comments to see if it might clarify anything.

Why does 4 work?

Also, why isn't /* sass-lint:disable-line no-magic-numbers */ working?

Why would it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sushain97 4 works because there are 4  : '    '.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH. My bad. Yeah, that should be commented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sushain97 I did, see the new changes :D


$('#srcLangSelect').val(curSrcLang);
var currentSrcLangSelect = $('#srcLangSelect option[value="' + $('#srcLangSelect').val() + '"]');
if(currentSrcLangSelect.text().charCodeAt(0) === 160) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 160 no-magic-numbers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why the build is passing despite this error. It should be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says that it is a warning not an error:

/home/circleci/project/assets/js/translator.js
  639:54  warning  No magic number: 160  no-magic-numbers
  641:73  warning  No magic number: 4    no-magic-numbers
  646:54  warning  No magic number: 160  no-magic-numbers
  647:73  warning  No magic number: 4    no-magic-numbers

✖ 4 problems (0 errors, 4 warnings)

$('#dstLangSelect').val(curDstLang);
var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]');
if(currentDstLangSelect.text().charCodeAt(0) === 160) { /* sass-lint:disable-line no-magic-numbers */
currentDstLangSelect.text(currentDstLangSelect.text().substring(4)); /* sass-lint:disable-line no-magic-numbers */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 4 no-magic-numbers


$('#dstLangSelect').val(curDstLang);
var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]');
if(currentDstLangSelect.text().charCodeAt(0) === 160) { /* sass-lint:disable-line no-magic-numbers */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 160 no-magic-numbers

// Check if language begins with  
if(currentSrcLangSelect.text().charCodeAt(0) === 160) { /* sass-lint:disable-line no-magic-numbers */
// If it does, temporarily remove the four spaces
currentSrcLangSelect.text(currentSrcLangSelect.text().substring(4)); /* sass-lint:disable-line no-magic-numbers */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 4 no-magic-numbers

$('#srcLangSelect').val(curSrcLang);
var currentSrcLangSelect = $('#srcLangSelect option[value="' + $('#srcLangSelect').val() + '"]');
// Check if language begins with  
if(currentSrcLangSelect.text().charCodeAt(0) === 160) { /* sass-lint:disable-line no-magic-numbers */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic number: 160 no-magic-numbers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, this is all silly. Go find the actual character for  , make it a constant and use it everywhere instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sushain97 What do you mean by use it everywhere?

Copy link
Member

@sushain97 sushain97 Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use 160 or  . Use the character itself instead after you put it into a constant (or if it shows up fine, just use it directly).

// Check if language begins with  
if(currentSrcLangSelect.text().charAt(0) === ' ') {
// If it does, temporarily remove the four spaces
currentSrcLangSelect.text(currentSrcLangSelect.text().substring(4)); // eslint-disable-line no-magic-numbers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just replace the non-breaking spaces now. Also, safe to remove the comments; the code's intention is now clear :) Also, .startsWith( is nicer than the charAt.

$('#dstLangSelect').val(curDstLang);
var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]');
if(currentDstLangSelect.text().startsWith(' ')) {
currentDstLangSelect.text(currentDstLangSelect.text().replace(/ /g,''));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irregular whitespace not allowed no-irregular-whitespace
A space is required after ',' comma-spacing

$('#srcLangSelect').val(curSrcLang);
var currentSrcLangSelect = $('#srcLangSelect option[value="' + $('#srcLangSelect').val() + '"]');
if(currentSrcLangSelect.text().startsWith(' ')) {
currentSrcLangSelect.text(currentSrcLangSelect.text().replace(/ /g,''));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irregular whitespace not allowed no-irregular-whitespace
A space is required after ',' comma-spacing

if(currentSrcLangSelect.text().charAt(0) === ' ') {
// If it does, temporarily remove the four spaces
currentSrcLangSelect.text(currentSrcLangSelect.text().substring(4)); // eslint-disable-line no-magic-numbers
if(currentSrcLangSelect.text().startsWith(' ')) {
Copy link
Member

@sushain97 sushain97 Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to do this with one space here or below. Just use the four spaces.

Copy link
Member

@sushain97 sushain97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is good until they become normal after you re-click on the select after focusing somewhere else:

image

@JPJPJPOPOP
Copy link
Contributor Author

JPJPJPOPOP commented Jan 12, 2018

@sushain97 The variants only lose their indentations temporarily when they are selected. Selecting a different language will cause the indentation to reappear. Given my code, one way to fix this is to detect if the select dropdown is open and add in the indentations. I tried implementing this, but this ended up in some funky functionality. First, the code for detecting if the select dropdown is open is not clean and might have some cases that it fails. Also, adding the indentation apparently causes the dropdown to close.

Another way I tried was with optgroup. The only problem is that when I try adding in a blank label, it creates an empty space. Otherwise it works fine.

CSS properties like padding and margins don't work well with options.

I'm kinda stuck. Do you have any suggestions?

@sushain97
Copy link
Member

sushain97 commented Jan 12, 2018 via email

@sushain97
Copy link
Member

sushain97 commented Jan 12, 2018 via email

@JPJPJPOPOP
Copy link
Contributor Author

JPJPJPOPOP commented Jan 13, 2018

@sushain97 For iPhone, they all look like this for Firefox, Chrome, and Safari:
img_0775
All centered with no indentation.

I don't believe that there is any better way than using non-breaking spaces. Maybe we could try using dashes?
With optgroup, we could do something like this:
screen shot 2018-01-12 at 6 18 52 pm

@JPJPJPOPOP
Copy link
Contributor Author

@sushain97

Why can't you hook onto the select open event and fix up any variants to
have the correct indent?

Well first, I couldn't find any select open event. All of ones I found had to detect for multiple cases, i.e. mouse clicks, keypresses, and they had edge cases possibly.
Also, adding back the indent, which I was trying to do with .text(), actually causes the select drop-down to close automatically.

@sushain97
Copy link
Member

@sushain97 For iPhone, they all look like this for Firefox, Chrome, and Safari:

In this case, let's get rid of the indentation on Mobile?

@JPJPJPOPOP JPJPJPOPOP changed the title Fixes variant format on mobile selection. Removes variant format on mobile selection. Jan 13, 2018
@sushain97 sushain97 merged commit 0781dd3 into apertium:master Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants