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

Refactor TextTrackSettings (Phase 2) #3660

Closed
wants to merge 25 commits into from

Conversation

misteroneill
Copy link
Member

We can review and merge this into the already-approved branch from #3570, then open a new PR for the combination of the two.

Specific Changes proposed

This refactors the TextTrackSettings HTML blob into createEl calls. Also, we extend the createEl function to take a conventional content argument at the end, allowing nested calls to createEl to build up a DOM structure.

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

brandonocasey and others added 9 commits September 29, 2016 11:58
This plugin makes browserify output numbers instead of the bundle paths to save some bytes in the output.
…d time range

The control text element was being counted as the first buffered region but it didn't have the correct styling to be shown.
Instead, we keep the buffered region elements in a separate element rather than relying on el.children to be correct.
…ideojs#3629)

babel-preset-es2015-loose is deprecated as it's now available as an option to the es2015 preset.
* Disable HLS hack on Firefox for Android

* Fix canPlayType patching tests

* Add test to ensure that canPlayType is not patched in Firefox for Android

* Fix assertion message in Firefox for Android test
Some of the code in the html5 tech is a bit redundant and can be written another way to reduce the file size. Also, we made sure that all functions can still be documented properly.
iOS still doesn't have native fullscreen API access. The video element uses the old webkit fullscreen events `webkitbeginfullscreen` and `webkitendfullscreen`. This makes it so both of those trigger `fullscreenchange` on the player always as opposed to only when `requestFullscreen` was called on the player.
* removing duplicate constructor docs
fixing doc block (should not have ended in ?)

* adding back event doc comments
id: 'captions-foreground-color-%s',
label: 'Color',
options: [
['#FFF', 'White'],
Copy link
Contributor

Choose a reason for hiding this comment

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

We should define the colors at the top once as a const, since we are using them in two places

id: 'captions-window-opacity-%s',
label: 'Transparency',
options: [
['0', 'Transparent'],
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe define this as a const as well since it is used in two places

fontPercent: {
selector: '.vjs-font-percent > select',
id: 'captions-font-size-%s',
label: 'Font Size',
options: [
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use an object for options in all of these?

Copy link
Member

Choose a reason for hiding this comment

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

Easier to loop through? plus it matches other usecases above

Copy link
Member Author

@misteroneill misteroneill Sep 30, 2016

Choose a reason for hiding this comment

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

Also, ordering could be/is important.

'select',
{id},
undefined,
config.options.map(o => {
Copy link
Contributor

Choose a reason for hiding this comment

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

if options becomes an object this will have to change

{className: 'vjs-tracksettings-colors'},
undefined,
[
createEl(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe create all of these elements outside of the main createEl call so that this code is more understandable (as they will all have to have names, and you can add comments)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this one could be simpler.

{className: 'vjs-tracksettings-font'},
undefined,
[
createEl(
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment with this one as the createElColors_ although it isn't nearly as bad.

'div',
{className: 'vjs-tracksettings'},
undefined,
[this.createElColors_(), this.createElFont_(), this.createElControls_()]);
Copy link
Contributor

Choose a reason for hiding this comment

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

should this ); go on the next line?

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like the function argument format we've decided on was:

foo(
  'a',
  'b',
  'c');

undefined,
[this.createElColors_(), this.createElFont_(), this.createElControls_()]);

const heading = createEl(
Copy link
Contributor

@brandonocasey brandonocasey Sep 30, 2016

Choose a reason for hiding this comment

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

might just be opinion here but I would like it if these blocks looked something like this:

const heading = createEl('div', {
  ...
  }, {
  ...
});

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, personally, but this is another case of trying to be consistent is some way w/ function arguments.

* @method setDefaults
*/
setDefaults() {
Obj.each(selectConfigs, config => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we typically wrap this in another set of parens in video.js. Obj.each((selectConfigs, config) =>

Copy link
Member Author

Choose a reason for hiding this comment

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

We're iterating over selectConfigs, though. If anything, it'd be Obj.each(selectConfigs, (config) =>.

Copy link
Member Author

Choose a reason for hiding this comment

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

But it's apparent that this could be confusing, I'll add parens around config. 👍

*/
createElControls_() {
return createEl(
'div',
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment with this one as the createElColors_ although it isn't nearly as bad.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

Assuming the DOM output is the same, don't have any additional comments beyond what @brandonocasey already mentioned.

fontPercent: {
selector: '.vjs-font-percent > select',
id: 'captions-font-size-%s',
label: 'Font Size',
options: [
Copy link
Member

Choose a reason for hiding this comment

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

Easier to loop through? plus it matches other usecases above

@@ -108,128 +200,6 @@ function setSelectedOption(el, value, parser) {
}
}

function captionOptionsMenuTemplate(uniqueId, dialogLabelId, dialogDescriptionId) {
const template = `
Copy link
Member

Choose a reason for hiding this comment

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

hurray

* @return {Element}
* @function createEl
*/
export function createEl(tagName = 'div', properties = {}, attributes = {}) {
export function createEl(tagName = 'div', properties = {}, attributes = {}, content) {
Copy link
Member

Choose a reason for hiding this comment

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

This change would make it a minor, which is fine.

Copy link
Member

Choose a reason for hiding this comment

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

But it does seem like a nice thing to have.

@misteroneill
Copy link
Member Author

To be clear about the timeline/plan here, once this is approved, I'll close an re-open a new PR with both this one and #3570 together.

Copy link
Contributor

@brandonocasey brandonocasey left a comment

Choose a reason for hiding this comment

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

LGTM

['#FF0', 'Yellow'],
['#F0F', 'Magenta'],
['#0FF', 'Cyan']
COLOR_BLACK,
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@gkatsev
Copy link
Member

gkatsev commented Oct 3, 2016

@OwenEdwards would you be able to take a look?

@@ -301,7 +301,7 @@ class TextTrackSettings extends Component {

return createEl('fieldset', {
className: 'vjs-fg-color vjs-tracksetting'
}, undefined, [legend, select, opacity]);
}, undefined, [legend].concat(select, opacity));
Copy link
Member

Choose a reason for hiding this comment

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

why is the other way broken?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the select is an array.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see 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.

8 participants