{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/comments/149081487","pull_request_review_id":74419227,"id":149081487,"diff_hunk":"@@ -257,6 +247,118 @@ wikiaJWPlayerSettingsPlugin.prototype.updateCurrentQuality = function (data) {\n \t}\n };\n \n+wikiaJWPlayerSettingsPlugin.prototype.addCaptionListener = function () {\n+\tvar clickHandler = this.captionsClickHandler.bind(this);\n+\n+\tthis.player.on('captionsList', function (event) {\n+\t\t// tracks always include \"off\" item\n+\t\tif (event.tracks.length > 1) {\n+\t\t\tthis.currentlySelectedCaptions = this.getSuitableCaptionsIndex(\n+\t\t\t\tthis.captionLangMap[this.getUserLang()],\n+\t\t\t\tevent.tracks\n+\t\t\t);\n+\n+\t\t\tthis.getLabelElement(this.captionsToggle)\n+\t\t\t\t.addEventListener('click', clickHandler);\n+\n+\t\t\tthis.wikiaSettingsElement.classList.remove('are-captions-empty');\n+\t\t\tthis.player.setCurrentCaptions(this.currentlySelectedCaptions);\n+\t\t\tthis.show();\n+\t\t} else {\n+\t\t\tthis.getLabelElement(this.captionsToggle)\n+\t\t\t\t.removeEventListener('click', clickHandler);\n+\n+\t\t\tthis.wikiaSettingsElement.classList.add('are-captions-empty');\n+\t\t}\n+\t}.bind(this));\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.createCaptionsButton = function () {\n+\tthis.captionsToggle = createToggle({\n+\t\t\tid: this.player.getContainer().id + '-videoCaptionsToggle',\n+\t\t\tlabel: 'Captions',\n+\t\t\tchecked: this.config.showCaptionsToggle\n+\t\t});\n+\n+\tthis.captionsToggle.classList.add('wikia-jw-settings__captions-button');\n+\n+\treturn this.captionsToggle;\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.captionsClickHandler = function () {\n+\tif (this.areCaptionsOff(this.player.getCurrentCaptions())) {\n+\t\tthis.player.setCurrentCaptions(this.currentlySelectedCaptions)\n+\t} else {\n+\t\t// \"off\" caption track is always the first one\n+\t\tthis.player.setCurrentCaptions(0);\n+\t}\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.areCaptionsOff = function(captionIndex) {\n+\t// \"off\" always has first position in tracks array\n+\treturn captionIndex === 0;\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.getUserLang = function() {\n+\treturn window.navigator.language.slice(0, 2);\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.getSuitableCaptionsIndex = function(userLang, captionTracks) {\n+\t// use findIndex when ES6+ will be available\n+\treturn captionTracks\n+\t\t.map(function (track) {\n+\t\t\treturn track.label;\n+\t\t})\n+\t\t.indexOf(userLang);\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.captionLangMap = {\n+\ten: 'English',\n+\tpl: 'Polski',\n+\tfr: 'Français',\n+\tde: 'Deutsch',\n+\tit: 'Italiano',\n+\tja: '日本語',\n+\tpt: 'Português',\n+\tru: 'Русский язык',\n+\tes: 'Español',\n+\tzh: '中文'\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.getLabelElement = function (wrapper) {\n+\treturn wrapper.querySelector('label');\n+};\n+\n+wikiaJWPlayerSettingsPlugin.prototype.getSettingsButtonElement = function () {\n+\treturn this.player.getContainer().querySelector('[button=' + this.buttonID + ']');\n+};\n+\n wikiaJWPlayerSettingsPlugin.register = function () {\n \tjwplayer().registerPlugin('wikiaSettings', '8.0.0', wikiaJWPlayerSettingsPlugin);\n };\n+\n+function createToggle(params) {\n+\tvar toggleWrapper = document.createElement('li'),\n+\t\ttoggleInput = document.createElement('input'),\n+\t\ttoggleLabel = document.createElement('label');\n+\n+\ttoggleWrapper.className = 'wikia-jw-settings__toggle';\n+\n+\ttoggleInput.setAttribute('type', 'checkbox');\n+\ttoggleInput.setAttribute('id', params.id);\n+\ttoggleInput.classList.add('wds-toggle__input');","path":"src/settings.plugin.js","position":211,"original_position":211,"commit_id":"0d379a54e7ccc12a0c2d7e75e1ab13afb1c1f66c","original_commit_id":"0d379a54e7ccc12a0c2d7e75e1ab13afb1c1f66c","user":{"login":"xkxd","id":6940495,"avatar_url":"https://avatars1.githubusercontent.com/u/6940495?v=4","gravatar_id":"","url":"https://api.github.com/users/xkxd","html_url":"https://github.com/xkxd","followers_url":"https://api.github.com/users/xkxd/followers","following_url":"https://api.github.com/users/xkxd/following{/other_user}","gists_url":"https://api.github.com/users/xkxd/gists{/gist_id}","starred_url":"https://api.github.com/users/xkxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xkxd/subscriptions","organizations_url":"https://api.github.com/users/xkxd/orgs","repos_url":"https://api.github.com/users/xkxd/repos","events_url":"https://api.github.com/users/xkxd/events{/privacy}","received_events_url":"https://api.github.com/users/xkxd/received_events","type":"User","site_admin":false},"body":"i forgot about those little one, thx","created_at":"2017-11-06T13:45:06Z","updated_at":"2017-11-06T13:45:06Z","html_url":"https://github.com/Wikia/jwplayer-fandom/pull/14#discussion_r149081487","pull_request_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/comments/149081487"},"html":{"href":"https://github.com/Wikia/jwplayer-fandom/pull/14#discussion_r149081487"},"pull_request":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14"}},"in_reply_to_id":149080823},"pull_request":{"url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14","id":150574916,"html_url":"https://github.com/Wikia/jwplayer-fandom/pull/14","diff_url":"https://github.com/Wikia/jwplayer-fandom/pull/14.diff","patch_url":"https://github.com/Wikia/jwplayer-fandom/pull/14.patch","issue_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/14","number":14,"state":"open","locked":false,"title":"XW-4192 | add captions toggle","user":{"login":"xkxd","id":6940495,"avatar_url":"https://avatars1.githubusercontent.com/u/6940495?v=4","gravatar_id":"","url":"https://api.github.com/users/xkxd","html_url":"https://github.com/xkxd","followers_url":"https://api.github.com/users/xkxd/followers","following_url":"https://api.github.com/users/xkxd/following{/other_user}","gists_url":"https://api.github.com/users/xkxd/gists{/gist_id}","starred_url":"https://api.github.com/users/xkxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xkxd/subscriptions","organizations_url":"https://api.github.com/users/xkxd/orgs","repos_url":"https://api.github.com/users/xkxd/repos","events_url":"https://api.github.com/users/xkxd/events{/privacy}","received_events_url":"https://api.github.com/users/xkxd/received_events","type":"User","site_admin":false},"body":"https://wikia-inc.atlassian.net/browse/XW-4192\r\n\r\n@Wikia/x-wing ","created_at":"2017-11-03T16:38:52Z","updated_at":"2017-11-06T13:45:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79f112f32be0c2b8da30f8c272fc3af9ed5da73a","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14/commits","review_comments_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14/comments","review_comment_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/14/comments","statuses_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/statuses/0d379a54e7ccc12a0c2d7e75e1ab13afb1c1f66c","head":{"label":"Wikia:XW-4192","ref":"XW-4192","sha":"0d379a54e7ccc12a0c2d7e75e1ab13afb1c1f66c","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars3.githubusercontent.com/u/1171011?v=4","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":107678490,"name":"jwplayer-fandom","full_name":"Wikia/jwplayer-fandom","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars3.githubusercontent.com/u/1171011?v=4","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/jwplayer-fandom","description":"JWPlayer configuration","fork":false,"url":"https://api.github.com/repos/Wikia/jwplayer-fandom","forks_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/forks","keys_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/teams","hooks_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/hooks","issue_events_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/events","assignees_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/tags","blobs_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/languages","stargazers_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/stargazers","contributors_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/contributors","subscribers_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/subscribers","subscription_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/subscription","commits_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/merges","archive_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/downloads","issues_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/releases{/id}","deployments_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/deployments","created_at":"2017-10-20T13:00:27Z","updated_at":"2017-10-26T16:15:54Z","pushed_at":"2017-11-06T13:37:04Z","git_url":"git://github.com/Wikia/jwplayer-fandom.git","ssh_url":"git@github.com:Wikia/jwplayer-fandom.git","clone_url":"https://github.com/Wikia/jwplayer-fandom.git","svn_url":"https://github.com/Wikia/jwplayer-fandom","homepage":null,"size":250,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"Wikia:XW-4169","ref":"XW-4169","sha":"8635722e8dac78af2f3f2b27fb09d8bbb7a2739e","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars3.githubusercontent.com/u/1171011?v=4","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":107678490,"name":"jwplayer-fandom","full_name":"Wikia/jwplayer-fandom","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars3.githubusercontent.com/u/1171011?v=4","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/jwplayer-fandom","description":"JWPlayer configuration","fork":false,"url":"https://api.github.com/repos/Wikia/jwplayer-fandom","forks_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/forks","keys_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/teams","hooks_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/hooks","issue_events_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/events","assignees_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/tags","blobs_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/languages","stargazers_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/stargazers","contributors_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/contributors","subscribers_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/subscribers","subscription_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/subscription","commits_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/merges","archive_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/downloads","issues_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/releases{/id}","deployments_url":"https://api.github.com/repos/Wikia/jwplayer-fandom/deployments","created_at":"2017-10-20T13:00:27Z","updated_at":"2017-10-26T16:15:54Z","pushed_at":"2017-11-06T13:37:04Z","git_url":"git://github.com/Wikia/jwplayer-fandom.git","ssh_url":"git@github.com:Wikia/jwplayer-fandom.git","clone_url":"https://github.com/Wikia/jwplayer-fandom.git","svn_url":"https://github.com/Wikia/jwplayer-fandom","homepage":null,"size":250,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14"},"html":{"href":"https://github.com/Wikia/jwplayer-fandom/pull/14"},"issue":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/14"},"comments":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/jwplayer-fandom/statuses/0d379a54e7ccc12a0c2d7e75e1ab13afb1c1f66c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"xkxd"}}