-
Notifications
You must be signed in to change notification settings - Fork 94
Removes variant format on mobile selection. #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
assets/js/translator.js
Outdated
| $('#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 */ |
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.
No magic number: 4 no-magic-numbers
assets/js/translator.js
Outdated
|
|
||
| $('#dstLangSelect').val(curDstLang); | ||
| var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]'); | ||
| if(currentDstLangSelect.text().charCodeAt(0) === 160) { |
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.
No magic number: 160 no-magic-numbers
assets/js/translator.js
Outdated
| $('#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 */ |
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.
No magic number: 4 no-magic-numbers
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.
This isn't robust. There's no reason a variant can't be en_GB.
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.
@sushain97 I do not understand exactly what you mean by your statement. I tried adding in comments to see if it might clarify anything.
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.
Also, why isn't /* sass-lint:disable-line no-magic-numbers */ working?
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.
@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?
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.
@sushain97 4 works because there are 4 : ' '.
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.
AH. My bad. Yeah, that should be commented.
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.
@sushain97 I did, see the new changes :D
assets/js/translator.js
Outdated
|
|
||
| $('#srcLangSelect').val(curSrcLang); | ||
| var currentSrcLangSelect = $('#srcLangSelect option[value="' + $('#srcLangSelect').val() + '"]'); | ||
| if(currentSrcLangSelect.text().charCodeAt(0) === 160) { |
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.
No magic number: 160 no-magic-numbers
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.
I'm not sure why the build is passing despite this error. It should be fixed.
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.
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)
assets/js/translator.js
Outdated
| $('#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 */ |
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.
No magic number: 4 no-magic-numbers
assets/js/translator.js
Outdated
|
|
||
| $('#dstLangSelect').val(curDstLang); | ||
| var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]'); | ||
| if(currentDstLangSelect.text().charCodeAt(0) === 160) { /* sass-lint:disable-line no-magic-numbers */ |
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.
No magic number: 160 no-magic-numbers
assets/js/translator.js
Outdated
| // 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 */ |
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.
No magic number: 4 no-magic-numbers
assets/js/translator.js
Outdated
| $('#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 */ |
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.
No magic number: 160 no-magic-numbers
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.
Wait, this is all silly. Go find the actual character for , make it a constant and use it everywhere instead.
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.
@sushain97 What do you mean by use it everywhere?
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.
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).
assets/js/translator.js
Outdated
| // 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 |
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.
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.
assets/js/translator.js
Outdated
| $('#dstLangSelect').val(curDstLang); | ||
| var currentDstLangSelect = $('#dstLangSelect option[value="' + $('#dstLangSelect').val() + '"]'); | ||
| if(currentDstLangSelect.text().startsWith(' ')) { | ||
| currentDstLangSelect.text(currentDstLangSelect.text().replace(/ /g,'')); |
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.
Irregular whitespace not allowed no-irregular-whitespace
A space is required after ',' comma-spacing
assets/js/translator.js
Outdated
| $('#srcLangSelect').val(curSrcLang); | ||
| var currentSrcLangSelect = $('#srcLangSelect option[value="' + $('#srcLangSelect').val() + '"]'); | ||
| if(currentSrcLangSelect.text().startsWith(' ')) { | ||
| currentSrcLangSelect.text(currentSrcLangSelect.text().replace(/ /g,'')); |
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.
Irregular whitespace not allowed no-irregular-whitespace
A space is required after ',' comma-spacing
6468425 to
37f640b
Compare
assets/js/translator.js
Outdated
| 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(' ')) { |
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.
There's no need to do this with one space here or below. Just use the four spaces.
37f640b to
9c4229e
Compare
sushain97
left a comment
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.
|
@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? |
|
Yeah, optgroup isn't a good solution and padding/margin certainly won't
work.
Why can't you hook onto the select open event and fix up any variants to
have the correct indent?
…On Jan 12, 2018 1:02 AM, "Jonathan Pan" ***@***.***> wrote:
@sushain97 <https://github.com/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.
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?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#263 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEBEfl4Zku_xTzG2UWEfIOcknziSinvnks5tJwOMgaJpZM4RY4Yf>
.
|
|
On second thought, I wonder if we should just eliminate this indentation
entirely.
Mobile Chrome on Android certainly doesn't show it. You could check other
devices and if it doesn't really show up anywhere, we need to find another
solution besides non-breaking spaces or if there isn't really a good one,
undo the non-breaking spaces and declare this a wontfix.
…On Jan 12, 2018 4:45 PM, "Sushain Cherivirala" ***@***.***> wrote:
Yeah, optgroup isn't a good solution and padding/margin certainly won't
work.
Why can't you hook onto the select open event and fix up any variants to
have the correct indent?
On Jan 12, 2018 1:02 AM, "Jonathan Pan" ***@***.***> wrote:
> @sushain97 <https://github.com/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.
>
> 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?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#263 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AEBEfl4Zku_xTzG2UWEfIOcknziSinvnks5tJwOMgaJpZM4RY4Yf>
> .
>
|
|
@sushain97 For iPhone, they all look like this for Firefox, Chrome, and Safari: I don't believe that there is any better way than using non-breaking spaces. Maybe we could try using dashes? |
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. |
In this case, let's get rid of the indentation on Mobile? |
9c4229e to
e4ba7f2
Compare


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