Skip to content
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

Fix clean js from styles 1 #1111

Merged
merged 6 commits into from
Nov 10, 2016
Merged

Conversation

idainatovych
Copy link
Contributor

@idainatovych idainatovych commented Nov 4, 2016

Do not change element styles directly, use css classes instead. It helps to:

  • keep JS code clean;
  • override styles;
  • avoid long css selectors;
  • increase performance of the application.

@idainatovych idainatovych force-pushed the FIX-clean-js-from-styles-1 branch from 64bf25b to 1b1b947 Compare November 10, 2016 11:32

console.log('recording is visible', isVisible);

if (isVisible) {
Copy link
Member

Choose a reason for hiding this comment

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

The variable above should probably be renamed because if (isVisible) showElement(); doesn't make sense. The console log above also prints the wrong message. The recording is not visible at this point, it will be made visible after we call showElement. Let's call the variable isShow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to shouldShow

}

document.querySelector('#recordingSpinner').classList
.toggle('show-inline', recordingState === Status.RETRYING);
Copy link
Member

Choose a reason for hiding this comment

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

As far as I see this line doesn't refactor existing code. Is it a fix for a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably these lines were added after rebase (because refactored version is above)

} else {
$("#subject").css({display: "none"});
toggleFunction = UIUtil.hideElement.bind(UIUtil);
Copy link
Member

Choose a reason for hiding this comment

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

This can be shortened by let toggleFunction = (subject) ? xxxx : yyyy; syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* @param tag
* @returns {*}
*/
getElementDefaultDisplay(tag) {
Copy link
Member

Choose a reason for hiding this comment

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

If this is a private method only let's rename it to _getElement......

Copy link
Contributor Author

@idainatovych idainatovych Nov 11, 2016

Choose a reason for hiding this comment

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

I thought we can expose this method to the interface of UIUtils (it can be useful to define if element is block or inline) but we don't use it in the code outside the module. So, let's keep it private for now.

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