Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

kelly/header #105

Merged
merged 11 commits into from
Dec 28, 2016
Merged

kelly/header #105

merged 11 commits into from
Dec 28, 2016

Conversation

kelly-binary
Copy link

update language dropdown and header.

@ashkanx
Copy link
Contributor

ashkanx commented Dec 27, 2016

@kellybinary please fix the conflicts

@@ -1,9 +1,9 @@
<span class="language-select">
<!-- <span class="language-select">
Copy link

@aminmarashi aminmarashi Dec 27, 2016

Choose a reason for hiding this comment

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

@kellybinary Never keep the previous code in comments, git will take care of backing up codes.

</div>
</a>
</div>
<head>
Copy link

@aminmarashi aminmarashi Dec 27, 2016

Choose a reason for hiding this comment

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

@kellybinary
👍 for fixing the indentation.
It's always a good idea to pull the most recent changes from upstream before you make a PR. Because sometimes changes from other collaborators will cause merge conflicts.
If you don't have the upstream origin add it like this:

git remote add upstream https://github.com/binary-com/binary-bot.git

Then you will be able to perform git pull

git pull upstream master

Sometimes there'll be merge conflicts, you need to look thoroughly into the code to find out what has changed and keep the desired changes.
Test again to see if everything is as expected and then add the changes and commit them to complete the merge process.

<th><span data-i18n-text="Buy Price"></span></th>
<th><span data-i18n-text="Final Price"></span></th>
<th><span data-i18n-text="Profit/Loss"></span></th>
<th data-i18n-text="No. of runs"></th>
Copy link

@aminmarashi aminmarashi Dec 27, 2016

Choose a reason for hiding this comment

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

@kellybinary 👍 for fixing the other parts of the code, better to make a separate commit for this fix.

Copy link
Author

@kelly-binary kelly-binary Dec 27, 2016

Choose a reason for hiding this comment

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

@aminmarashi i didn't add this tho. it was already there, probably fetched from the beta branch

Choose a reason for hiding this comment

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

@kellybinary So better to revert. Let's keep the change set as concise as possible.

en,
ach,
}
zh_tw: zhTw,

Choose a reason for hiding this comment

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

@kellybinary We use 2 spaces for each tab, not 4.

Copy link
Author

@kelly-binary kelly-binary Dec 27, 2016

Choose a reason for hiding this comment

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

@aminmarashi noted. i will fix it.

@@ -0,0 +1,14 @@
import $ from 'jquery'

export default class LanguageDropdown {

Choose a reason for hiding this comment

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

🥇 for using ES6.
This function can be moved inside the translator constructor and be used instead of the event listener like this:

$('ul#select_language li')
  .click(function onClick() {
     const lang = $(this).attr('class')
     document.location.search = `l=${lang}`
  })
....

Choose a reason for hiding this comment

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

In es6 encapsulation is the default behavior, therefore you don't need to define classes to ensure encapsulation. You could simply write:

export () => {
  $('ul#select_language li')
    .click(function onClick() {
...
}

Copy link
Author

@kelly-binary kelly-binary Dec 27, 2016

Choose a reason for hiding this comment

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

😄 you're right, needed to wrap it in another click event as such:

.click(function onClick() {
        $('ul#select_language li')
          .click(function onClick() {
            const lang = $(this).attr('class')
            document.location.search = `l=${lang}`
          })
      })

})
const lang = this.getLanguage()
$('#language').val(lang)
$('.language').text(languageDisplayName[lang]);
$(document.getElementsByClassName(lang)[0]).hide();

Choose a reason for hiding this comment

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

shorter version thanks to es6:

$(`.${lang}`)
  .hide()

Copy link
Author

Choose a reason for hiding this comment

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

lovely shorter version!

document.location.search = `l=${value}`
})
$.each(languageDisplayName, (key, value) => { // populate language dropdown
$('#select_language').append(`<li class=${key}>${value}</li>`);

Choose a reason for hiding this comment

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

👍

$('.language').on('change_language', (event, value) => {
document.location.search = `l=${value}`
})
$.each(languageDisplayName, (key, value) => { // populate language dropdown

Choose a reason for hiding this comment

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

Better not to use jquery each sth js is able to do:

for (const key of Object.keys(languageDisplayName)) {
  const value = languageDisplayName[key]
...

Copy link
Author

@kelly-binary kelly-binary Dec 27, 2016

Choose a reason for hiding this comment

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

noted 👍

@aminmarashi
Copy link

@ashkanx Should we do the same for the ugly tour dropdown?
screen shot 2016-12-27 at 11 17 49 am

@ashkanx
Copy link
Contributor

ashkanx commented Dec 27, 2016

Yes. I think it's better to make it look like the other one.

$('#language').change(e => {
document.location.search = `l=${e.target.value}`
})
$('.language')
Copy link
Author

Choose a reason for hiding this comment

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

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 81.272% when pulling 6090d6f on kellybinary:master into 291f5db on binary-com:master.

<th><span data-i18n-text="Buy Price"></span></th>
<th><span data-i18n-text="Final Price"></span></th>
<th><span data-i18n-text="Profit/Loss"></span></th>
<th data-i18n-text="No. of runs"></th>
Copy link
Author

Choose a reason for hiding this comment

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

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 81.272% when pulling 26d7baa on kellybinary:master into 291f5db on binary-com:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 81.272% when pulling d445940 on kellybinary:master into 291f5db on binary-com:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 81.272% when pulling b1d2423 on kellybinary:master into 291f5db on binary-com:master.

Copy link

@aminmarashi aminmarashi left a comment

Choose a reason for hiding this comment

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

All done, good job!

}
};

const languageDisplayName = {

Choose a reason for hiding this comment

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

@kellybinary Is there any reason to do this in js? Why not simply define these in html?

Choose a reason for hiding this comment

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

Great! we no longer need this.

<th><span data-i18n-text="Buy Price"></span></th>
<th><span data-i18n-text="Final Price"></span></th>
<th><span data-i18n-text="Profit/Loss"></span></th>
<th data-i18n-text="No. of runs"></th>

Choose a reason for hiding this comment

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

@kellybinary So better to revert. Let's keep the change set as concise as possible.

@@ -1,3 +1,5 @@
**/mock/*.js
**/translations/*.js
**/calls.js
src/common/language_dropdown.js
src/common/translator.js

Choose a reason for hiding this comment

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

@kellybinary Not a good idea to ignore one of the main modules

Choose a reason for hiding this comment

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

@kellybinary Bump ^

$('#language').change(e => {
document.location.search = `l=${e.target.value}`
})
$('.language')

Choose a reason for hiding this comment

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

@kellybinary How about this:

    const lang = this.getLanguage()
    $('#select_language li:not(:first)')
      .click((e) => {
        const newLang = $(e.target).attr('class')
        document.location.search = `l=${newLang}`
      })
    $('.language')
      .text($(`.${lang}`)
      .hide().text())

@@ -30,14 +30,38 @@ const supportedLanguages = {
fr,
en,
ach,
}
};

Choose a reason for hiding this comment

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

We don't use semicolons in Binary Bot js files. So let's keep them out of this! 😄

@@ -41,7 +41,7 @@
</div>
{{> loading }}
<div id="topbar">
<div class="right-header">
<div class="wrapper">

Choose a reason for hiding this comment

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

Let's prefer right-header over wrapper. I will make the changes first thing tomorrow.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 81.272% when pulling 7a30497 on kellybinary:master into 291f5db on binary-com:master.

@aminmarashi aminmarashi merged commit 00d09c3 into binary-com:master Dec 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants