videojs-language-switch
Advanced tools
Comparing version 1.1.0 to 1.2.0
/** | ||
* videojs-language-switch | ||
* @version 1.1.0 | ||
* @copyright 2017 Adam Oliver <mail@adamoliver.net> | ||
* @version 1.2.0 | ||
* @copyright 2018 Adam Oliver <mail@adamoliver.net> | ||
* @license MIT | ||
@@ -56,3 +56,3 @@ */ | ||
iconPlaceholder.classList.add(iconClass); | ||
iconPlaceholder.className += ' ' + iconClass; | ||
}; | ||
@@ -251,3 +251,3 @@ | ||
// Include the version number. | ||
languageSwitch.VERSION = '1.1.0'; | ||
languageSwitch.VERSION = '1.2.0'; | ||
@@ -254,0 +254,0 @@ exports.default = languageSwitch; |
@@ -1,1 +0,1 @@ | ||
!function e(t,n,o){function r(u,a){if(!n[u]){if(!t[u]){var l="function"==typeof require&&require;if(!a&&l)return l(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return r(n?n:e)},f,f.exports,e,t,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(e,t,n){(function(t){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var a="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,l=o(a),s=e(2),f=o(s),c=l.default.getComponent("MenuButton"),d=void 0,p=void 0,g=function(e){function t(n,o){r(this,t),d=o.languages,p=o.defaultLanguage;var u=i(this,e.call(this,n,o));return u.addClass("vjs-language-switch"),u.controlText(n.localize("Switch language")),u.options=o,u.addCustomIconClass(o),u}return u(t,e),t.prototype.addCustomIconClass=function(e){var t=this.el_.childNodes[0].children[0],n=e.buttonClass||"icon-globe";t.classList.add(n)},t.prototype.createItems=function(){var e=[],t=this.player_;return e=d.map(function(e){return new f.default(t,{sources:e.sources,label:e.name,defaultSelection:p===e.name})})},t}(c);n.default=g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){(function(e){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var u="undefined"!=typeof window?window.videojs:"undefined"!=typeof e?e.videojs:null,a=t(u),l=a.default.getComponent("MenuItem"),s=function(e){function t(n,i){o(this,t);var u=r(this,e.call(this,n,i));return u.addClass("vjs-language-switch__item"),u.selectable=!0,u.options=i,u.selected(i.defaultSelection),u}return i(t,e),t.prototype.handleClick=function(e){this.player_.trigger("changedlanguage",this.options),this.selected(this.player_.activeLanguage===this.options.label)},t}(l);l.registerComponent("LanguageMenuItem",s),n.default=s}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(t){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}n.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,u=o(i),a=e(1),l=o(a),s=function(e){var t=e.el().getElementsByClassName("vjs-language-switch__item");Array.from(t).forEach(function(e){e.classList.remove("vjs-selected")})},f=function(e,t,n){var o=e.currentTime();e.activeLanguage=t.label,s(e);var i=e.currentSources().filter(function(e){if(e.selected)return e.selected===!0});i.length&&!function(){var e=i[0].type,n=i[0].label,o=t.sources;t.sources.map(function(t,r){if(t.label===n&&t.type===e){var i=o.splice(r,1);o.unshift(i[0])}})}(),e.src(t.sources.map(function(e,t){var n={src:e.src,type:e.type,res:e.res,label:e.label};return i.length||0!==t?n:r(n,{selected:!0})})),e.on("loadedmetadata",function(){e.currentTime(o),e.play()})},c=function(e,t){e.on("changedlanguage",function(t,n){f(e,n)}),e.getChild("controlBar").addChild("LanguageMenuButton",t,t.positionIndex)},d=function(e){var t=this;this.ready(function(){c(t,e)})};u.default.registerComponent("LanguageMenuButton",l.default),u.default.registerPlugin("languageSwitch",d),d.VERSION="1.1.0",n.default=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[3]); | ||
!function e(t,n,o){function r(u,a){if(!n[u]){if(!t[u]){var l="function"==typeof require&&require;if(!a&&l)return l(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return r(n?n:e)},f,f.exports,e,t,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(e,t,n){(function(t){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var a="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,l=o(a),s=e(2),f=o(s),c=l.default.getComponent("MenuButton"),d=void 0,p=void 0,g=function(e){function t(n,o){r(this,t),d=o.languages,p=o.defaultLanguage;var u=i(this,e.call(this,n,o));return u.addClass("vjs-language-switch"),u.controlText(n.localize("Switch language")),u.options=o,u.addCustomIconClass(o),u}return u(t,e),t.prototype.addCustomIconClass=function(e){var t=this.el_.childNodes[0].children[0],n=e.buttonClass||"icon-globe";t.className+=" "+n},t.prototype.createItems=function(){var e=[],t=this.player_;return e=d.map(function(e){return new f.default(t,{sources:e.sources,label:e.name,defaultSelection:p===e.name})})},t}(c);n.default=g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){(function(e){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var u="undefined"!=typeof window?window.videojs:"undefined"!=typeof e?e.videojs:null,a=t(u),l=a.default.getComponent("MenuItem"),s=function(e){function t(n,i){o(this,t);var u=r(this,e.call(this,n,i));return u.addClass("vjs-language-switch__item"),u.selectable=!0,u.options=i,u.selected(i.defaultSelection),u}return i(t,e),t.prototype.handleClick=function(e){this.player_.trigger("changedlanguage",this.options),this.selected(this.player_.activeLanguage===this.options.label)},t}(l);l.registerComponent("LanguageMenuItem",s),n.default=s}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(t){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}n.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,u=o(i),a=e(1),l=o(a),s=function(e){var t=e.el().getElementsByClassName("vjs-language-switch__item");Array.from(t).forEach(function(e){e.classList.remove("vjs-selected")})},f=function(e,t,n){var o=e.currentTime();e.activeLanguage=t.label,s(e);var i=e.currentSources().filter(function(e){if(e.selected)return e.selected===!0});i.length&&!function(){var e=i[0].type,n=i[0].label,o=t.sources;t.sources.map(function(t,r){if(t.label===n&&t.type===e){var i=o.splice(r,1);o.unshift(i[0])}})}(),e.src(t.sources.map(function(e,t){var n={src:e.src,type:e.type,res:e.res,label:e.label};return i.length||0!==t?n:r(n,{selected:!0})})),e.on("loadedmetadata",function(){e.currentTime(o),e.play()})},c=function(e,t){e.on("changedlanguage",function(t,n){f(e,n)}),e.getChild("controlBar").addChild("LanguageMenuButton",t,t.positionIndex)},d=function(e){var t=this;this.ready(function(){c(t,e)})};u.default.registerComponent("LanguageMenuButton",l.default),u.default.registerPlugin("languageSwitch",d),d.VERSION="1.2.0",n.default=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[3]); |
@@ -48,3 +48,3 @@ 'use strict'; | ||
iconPlaceholder.classList.add(iconClass); | ||
iconPlaceholder.className += ' ' + iconClass; | ||
}; | ||
@@ -51,0 +51,0 @@ |
{ | ||
"name": "videojs-language-switch", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Control for switching between video language versions", | ||
@@ -5,0 +5,0 @@ "main": "es5/plugin.js", |
@@ -26,3 +26,3 @@ import videojs from 'video.js'; | ||
iconPlaceholder.classList.add(iconClass); | ||
iconPlaceholder.className += ' ' + iconClass; | ||
} | ||
@@ -29,0 +29,0 @@ |
@@ -71,3 +71,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
iconPlaceholder.classList.add(iconClass); | ||
iconPlaceholder.className += ' ' + iconClass; | ||
}; | ||
@@ -268,3 +268,3 @@ | ||
// Include the version number. | ||
languageSwitch.VERSION = '1.1.0'; | ||
languageSwitch.VERSION = '1.2.0'; | ||
@@ -447,2 +447,15 @@ exports.default = languageSwitch; | ||
_qunit2.default.test('add custom multiple icon classes', function (assert) { | ||
assert.expect(1); | ||
var testDataWithIcon = _extends(_testData2.default, { buttonClass: 'icon icon-test' }); | ||
this.player.languageSwitch(testDataWithIcon); | ||
// Tick the clock forward enough to trigger the player to be "ready". | ||
this.clock.tick(1); | ||
assert.ok(this.player.contentEl().getElementsByClassName('vjs-icon-placeholder icon icon-test'), 'the icon placeholder element has additional classes'); | ||
}); | ||
_qunit2.default.test('place the plug in button in correct index in the control bar', function (assert) { | ||
@@ -449,0 +462,0 @@ assert.expect(1); |
@@ -196,2 +196,21 @@ /* eslint no-console: 0 */ | ||
QUnit.test('add custom multiple icon classes', function(assert) { | ||
assert.expect(1); | ||
const testDataWithIcon = Object.assign( | ||
testData, | ||
{ buttonClass: 'icon icon-test' } | ||
); | ||
this.player.languageSwitch(testDataWithIcon); | ||
// Tick the clock forward enough to trigger the player to be "ready". | ||
this.clock.tick(1); | ||
assert.ok( | ||
this.player.contentEl().getElementsByClassName('vjs-icon-placeholder icon icon-test'), | ||
'the icon placeholder element has additional classes' | ||
); | ||
}); | ||
QUnit.test('place the plug in button in correct index in the control bar', | ||
@@ -198,0 +217,0 @@ function(assert) { |
Sorry, the diff of this file is not supported yet
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
78958
1443
13
3