diff --git a/dist/level-selector.min.js b/dist/level-selector.min.js index 0f1f8f1..4f29d6a 100644 --- a/dist/level-selector.min.js +++ b/dist/level-selector.min.js @@ -4,7 +4,7 @@ function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=l(1),e.exports=t["default"]},/*!*********************!*\ !*** ./src/main.js ***! \*********************/ -function(e,t,l){"use strict";function n(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("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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var l=0;l0;t&&this.fillLevels(e.levels)}},{key:"reload",value:function(){this.unBindEvents(),this.bindEvents()}},{key:"shouldRender",value:function(){if(!this.core.getCurrentContainer())return!1;var e=this.core.getCurrentPlayback();if(!e)return!1;var t=void 0!==e.currentLevel,l=!!(this.levels&&this.levels.length>0);return t&&l}},{key:"render",value:function(){if(this.shouldRender()){var e=a.Styler.getStyleFor(f["default"],{baseUrl:this.core.options.baseUrl});this.$el.html(this.template({levels:this.levels,title:this.getTitle()})),this.$el.append(e),this.core.mediaControl.$(".media-control-right-panel").append(this.el),this.updateText(this.selectedLevelId)}return this}},{key:"fillLevels",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?h:arguments[1];this.selectedLevelId=t,this.levels=e,this.configureLevelsLabels(),this.render()}},{key:"configureLevelsLabels",value:function(){if(void 0!==this.core.options.levelSelectorConfig)for(var e in this.core.options.levelSelectorConfig.labels||{}){e=parseInt(e,10);var t=!!this.findLevelBy(e);t&&this.changeLevelLabelBy(e,this.core.options.levelSelectorConfig.labels[e])}}},{key:"findLevelBy",value:function(e){var t;return this.levels.forEach(function(l){l.id===e&&(t=l)}),t}},{key:"changeLevelLabelBy",value:function(e,t){var l=this;this.levels.forEach(function(n,o){n.id===e&&(l.levels[o].label=t)})}},{key:"onLevelSelect",value:function(e){return this.selectedLevelId=parseInt(e.target.dataset.levelSelectorSelect,10),this.core.getCurrentPlayback().currentLevel=this.selectedLevelId,this.toggleContextMenu(),this.updateText(this.selectedLevelId),e.stopPropagation(),!1}},{key:"onShowLevelSelectMenu",value:function(e){this.toggleContextMenu()}},{key:"toggleContextMenu",value:function(){this.$(".level_selector ul").toggle()}},{key:"buttonElement",value:function(){return this.$(".level_selector button")}},{key:"getTitle",value:function(){return(this.core.options.levelSelectorConfig||{}).title}},{key:"startLevelSwitch",value:function(){this.buttonElement().addClass("changing")}},{key:"stopLevelSwitch",value:function(){this.buttonElement().removeClass("changing"),this.updateText(this.selectedLevelId)}},{key:"updateText",value:function(e){if(e===h){var t=this.core.getCurrentPlayback().currentLevel;this.buttonElement().text(t===h?"AUTO":"AUTO ("+this.findLevelBy(t).label+")")}else this.buttonElement().text(this.findLevelBy(e).label)}},{key:"name",get:function(){return"level_selector"}},{key:"template",get:function(){return(0,a.template)(u["default"])}},{key:"attributes",get:function(){return{"class":this.name,"data-level-selector":""}}},{key:"events",get:function(){return{"click [data-level-selector-select]":"onLevelSelect","click [data-level-selector-button]":"onShowLevelSelectMenu"}}}],[{key:"version",get:function(){return VERSION}}]),t}(a.UICorePlugin);t["default"]=d,e.exports=t["default"]},/*!*************************!*\ +function(e,t,l){"use strict";function n(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("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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var l=0;l0;t&&this.fillLevels(e.levels)}},{key:"reload",value:function(){this.unBindEvents(),this.bindEvents(),this.bindPlaybackEvents()}},{key:"shouldRender",value:function(){if(!this.core.getCurrentContainer())return!1;var e=this.core.getCurrentPlayback();if(!e)return!1;var t=void 0!==e.currentLevel,l=!!(this.levels&&this.levels.length>0);return t&&l}},{key:"render",value:function(){if(this.shouldRender()){var e=a.Styler.getStyleFor(h["default"],{baseUrl:this.core.options.baseUrl});this.$el.html(this.template({levels:this.levels,title:this.getTitle()})),this.$el.append(e),this.core.mediaControl.$(".media-control-right-panel").append(this.el),this.updateText(this.selectedLevelId),this.highlightCurrentLevel()}return this}},{key:"fillLevels",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?f:arguments[1];void 0===this.selectedLevelId&&(this.selectedLevelId=t),this.levels=e,this.configureLevelsLabels(),this.render()}},{key:"configureLevelsLabels",value:function(){if(void 0!==this.core.options.levelSelectorConfig)for(var e in this.core.options.levelSelectorConfig.labels||{}){e=parseInt(e,10);var t=!!this.findLevelBy(e);t&&this.changeLevelLabelBy(e,this.core.options.levelSelectorConfig.labels[e])}}},{key:"findLevelBy",value:function(e){var t;return this.levels.forEach(function(l){l.id===e&&(t=l)}),t}},{key:"changeLevelLabelBy",value:function(e,t){var l=this;this.levels.forEach(function(n,o){n.id===e&&(l.levels[o].label=t)})}},{key:"onLevelSelect",value:function(e){return this.selectedLevelId=parseInt(e.target.dataset.levelSelectorSelect,10),this.core.getCurrentPlayback().currentLevel=this.selectedLevelId,this.toggleContextMenu(),this.updateText(this.selectedLevelId),e.stopPropagation(),!1}},{key:"onShowLevelSelectMenu",value:function(e){this.toggleContextMenu()}},{key:"toggleContextMenu",value:function(){this.$(".level_selector ul").toggle()}},{key:"buttonElement",value:function(){return this.$(".level_selector button")}},{key:"levelElement",value:function(e){return this.$(".level_selector ul a"+(isNaN(e)?"":'[data-level-selector-select="'+e+'"]')).parent()}},{key:"getTitle",value:function(){return(this.core.options.levelSelectorConfig||{}).title}},{key:"startLevelSwitch",value:function(){this.buttonElement().addClass("changing")}},{key:"stopLevelSwitch",value:function(){this.buttonElement().removeClass("changing"),this.updateText(this.selectedLevelId)}},{key:"updateText",value:function(e){e===f?this.buttonElement().text(this.currentLevel?"AUTO ("+this.currentLevel.label+")":"AUTO"):this.buttonElement().text(this.findLevelBy(e).label)}},{key:"updateCurrentLevel",value:function(e){var t=this.findLevelBy(e.level);this.currentLevel=t?t:null,this.highlightCurrentLevel()}},{key:"highlightCurrentLevel",value:function(){this.levelElement().removeClass("current"),this.currentLevel&&this.levelElement(this.currentLevel.id).addClass("current")}},{key:"name",get:function(){return"level_selector"}},{key:"template",get:function(){return(0,a.template)(u["default"])}},{key:"attributes",get:function(){return{"class":this.name,"data-level-selector":""}}},{key:"events",get:function(){return{"click [data-level-selector-select]":"onLevelSelect","click [data-level-selector-button]":"onShowLevelSelectMenu"}}}],[{key:"version",get:function(){return VERSION}}]),t}(a.UICorePlugin);t["default"]=d,e.exports=t["default"]},/*!*************************!*\ !*** external "Clappr" ***! \*************************/ function(t,l){t.exports=e},/*!****************************************!*\ @@ -13,7 +13,7 @@ function(t,l){t.exports=e},/*!****************************************!*\ function(e,t){e.exports='\n\n'},/*!*******************************!*\ !*** ./src/public/style.scss ***! \*******************************/ -function(e,t,l){t=e.exports=l(5)(),t.push([e.id,".level_selector[data-level-selector]{float:right;margin-top:5px;position:relative}.level_selector[data-level-selector] button{background-color:transparent;color:#fff;font-family:Roboto,Open Sans,Arial,sans-serif;-webkit-font-smoothing:antialiased;border:none;font-size:10px}.level_selector[data-level-selector] button:hover{color:#c9c9c9}.level_selector[data-level-selector] button.changing{-webkit-animation:pulse .5s infinite alternate}.level_selector[data-level-selector]>ul{list-style-type:none;position:absolute;bottom:25px;border:1px solid #000;display:none;background-color:#e6e6e6}.level_selector[data-level-selector] li{font-size:10px}.level_selector[data-level-selector] li[data-title]{background-color:#c3c2c2;padding:5px}.level_selector[data-level-selector] li a{color:#444;padding:2px 10px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:#555;color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}to{color:#b80000}}",""])},/*!**************************************!*\ +function(e,t,l){t=e.exports=l(5)(),t.push([e.id,".level_selector[data-level-selector]{float:right;margin-top:5px;position:relative}.level_selector[data-level-selector] button{background-color:transparent;color:#fff;font-family:Roboto,Open Sans,Arial,sans-serif;-webkit-font-smoothing:antialiased;border:none;font-size:10px}.level_selector[data-level-selector] button:hover{color:#c9c9c9}.level_selector[data-level-selector] button.changing{-webkit-animation:pulse .5s infinite alternate}.level_selector[data-level-selector]>ul{list-style-type:none;position:absolute;bottom:25px;border:1px solid #000;display:none;background-color:#e6e6e6}.level_selector[data-level-selector] li{font-size:10px}.level_selector[data-level-selector] li[data-title]{background-color:#c3c2c2;padding:5px}.level_selector[data-level-selector] li a{color:#444;padding:2px 10px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:#555;color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}.level_selector[data-level-selector] li.current a{color:red}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}to{color:#b80000}}",""])},/*!**************************************!*\ !*** ./~/css-loader/lib/css-base.js ***! \**************************************/ function(e,t){"use strict";e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/*!******************!*\\\n !*** ./index.js ***!\n \\******************/\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports['default'] = __webpack_require__(/*! ./src/main.js */ 1);module.exports = exports['default'];\n\n/***/ },\n/* 1 */\n/*!*********************!*\\\n !*** ./src/main.js ***!\n \\*********************/\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if('value' in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();var _get=function get(_x2,_x3,_x4){var _again=true;_function: while(_again) {var object=_x2,property=_x3,receiver=_x4;_again = false;if(object === null)object = Function.prototype;var desc=Object.getOwnPropertyDescriptor(object,property);if(desc === undefined){var parent=Object.getPrototypeOf(object);if(parent === null){return undefined;}else {_x2 = parent;_x3 = property;_x4 = receiver;_again = true;desc = parent = undefined;continue _function;}}else if('value' in desc){return desc.value;}else {var getter=desc.get;if(getter === undefined){return undefined;}return getter.call(receiver);}}};function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{'default':obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function');}}function _inherits(subClass,superClass){if(typeof superClass !== 'function' && superClass !== null){throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _Clappr=__webpack_require__(/*! Clappr */ 2);var _publicLevelSelectorHtml=__webpack_require__(/*! ./public/level-selector.html */ 3);var _publicLevelSelectorHtml2=_interopRequireDefault(_publicLevelSelectorHtml);var _publicStyleScss=__webpack_require__(/*! ./public/style.scss */ 4);var _publicStyleScss2=_interopRequireDefault(_publicStyleScss);var AUTO=-1;var LevelSelector=(function(_UICorePlugin){_inherits(LevelSelector,_UICorePlugin);function LevelSelector(){_classCallCheck(this,LevelSelector);_get(Object.getPrototypeOf(LevelSelector.prototype),'constructor',this).apply(this,arguments);}_createClass(LevelSelector,[{key:'bindEvents',value:function bindEvents(){this.listenTo(this.core,_Clappr.Events.CORE_READY,this.bindPlaybackEvents);this.listenTo(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_CONTAINERCHANGED,this.reload);this.listenTo(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_RENDERED,this.render);}},{key:'unBindEvents',value:function unBindEvents(){this.stopListening(this.core,_Clappr.Events.CORE_READY);this.stopListening(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_CONTAINERCHANGED);this.stopListening(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_RENDERED);this.stopListening(this.core.getCurrentPlayback(),_Clappr.Events.PLAYBACK_LEVELS_AVAILABLE);this.stopListening(this.core.getCurrentPlayback(),_Clappr.Events.PLAYBACK_LEVEL_SWITCH_START);this.stopListening(this.core.getCurrentPlayback(),_Clappr.Events.PLAYBACK_LEVEL_SWITCH_END);}},{key:'bindPlaybackEvents',value:function bindPlaybackEvents(){var currentPlayback=this.core.getCurrentPlayback();this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_LEVELS_AVAILABLE,this.fillLevels);this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_LEVEL_SWITCH_START,this.startLevelSwitch);this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_LEVEL_SWITCH_END,this.stopLevelSwitch);var playbackLevelsAvaialbeWasTriggered=currentPlayback.levels && currentPlayback.levels.length > 0;playbackLevelsAvaialbeWasTriggered && this.fillLevels(currentPlayback.levels);}},{key:'reload',value:function reload(){this.unBindEvents();this.bindEvents();}},{key:'shouldRender',value:function shouldRender(){if(!this.core.getCurrentContainer())return false;var currentPlayback=this.core.getCurrentPlayback();if(!currentPlayback)return false;var respondsToCurrentLevel=currentPlayback.currentLevel !== undefined;var hasLevels=!!(this.levels && this.levels.length > 0);return respondsToCurrentLevel && hasLevels;}},{key:'render',value:function render(){if(this.shouldRender()){var style=_Clappr.Styler.getStyleFor(_publicStyleScss2['default'],{baseUrl:this.core.options.baseUrl});this.$el.html(this.template({'levels':this.levels,'title':this.getTitle()}));this.$el.append(style);this.core.mediaControl.$('.media-control-right-panel').append(this.el);this.updateText(this.selectedLevelId);}return this;}},{key:'fillLevels',value:function fillLevels(levels){var initialLevel=arguments.length <= 1 || arguments[1] === undefined?AUTO:arguments[1];this.selectedLevelId = initialLevel;this.levels = levels;this.configureLevelsLabels();this.render();}},{key:'configureLevelsLabels',value:function configureLevelsLabels(){if(this.core.options.levelSelectorConfig === undefined)return;for(var levelId in this.core.options.levelSelectorConfig.labels || {}) {levelId = parseInt(levelId,10);var thereIsLevel=!!this.findLevelBy(levelId);thereIsLevel && this.changeLevelLabelBy(levelId,this.core.options.levelSelectorConfig.labels[levelId]);}}},{key:'findLevelBy',value:function findLevelBy(id){var foundLevel;this.levels.forEach(function(level){if(level.id === id){foundLevel = level;}});return foundLevel;}},{key:'changeLevelLabelBy',value:function changeLevelLabelBy(id,newLabel){var _this=this;this.levels.forEach(function(level,index){if(level.id === id){_this.levels[index].label = newLabel;}});}},{key:'onLevelSelect',value:function onLevelSelect(event){this.selectedLevelId = parseInt(event.target.dataset.levelSelectorSelect,10);this.core.getCurrentPlayback().currentLevel = this.selectedLevelId;this.toggleContextMenu();this.updateText(this.selectedLevelId);event.stopPropagation();return false;}},{key:'onShowLevelSelectMenu',value:function onShowLevelSelectMenu(event){this.toggleContextMenu();}},{key:'toggleContextMenu',value:function toggleContextMenu(){this.$('.level_selector ul').toggle();}},{key:'buttonElement',value:function buttonElement(){return this.$('.level_selector button');}},{key:'getTitle',value:function getTitle(){return (this.core.options.levelSelectorConfig || {}).title;}},{key:'startLevelSwitch',value:function startLevelSwitch(){this.buttonElement().addClass('changing');}},{key:'stopLevelSwitch',value:function stopLevelSwitch(){this.buttonElement().removeClass('changing');this.updateText(this.selectedLevelId);}},{key:'updateText',value:function updateText(level){if(level === AUTO){var playbackLevel=this.core.getCurrentPlayback().currentLevel;this.buttonElement().text(playbackLevel === AUTO?'AUTO':'AUTO (' + this.findLevelBy(playbackLevel).label + ')');}else {this.buttonElement().text(this.findLevelBy(level).label);}}},{key:'name',get:function get(){return 'level_selector';}},{key:'template',get:function get(){return (0,_Clappr.template)(_publicLevelSelectorHtml2['default']);}},{key:'attributes',get:function get(){return {'class':this.name,'data-level-selector':''};}},{key:'events',get:function get(){return {'click [data-level-selector-select]':'onLevelSelect','click [data-level-selector-button]':'onShowLevelSelectMenu'};}}],[{key:'version',get:function get(){return VERSION;}}]);return LevelSelector;})(_Clappr.UICorePlugin);exports['default'] = LevelSelector;module.exports = exports['default'];\n\n/***/ },\n/* 2 */\n/*!*************************!*\\\n !*** external \"Clappr\" ***!\n \\*************************/\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n/***/ },\n/* 3 */\n/*!****************************************!*\\\n !*** ./src/public/level-selector.html ***!\n \\****************************************/\n/***/ function(module, exports) {\n\n\tmodule.exports = \"\\n
    \\n <% if (title) { %>\\n
  • <%= title %>
  • \\n <% }; %>\\n
  • AUTO
  • \\n <% for (var i = 0; i < levels.length; i++) { %>\\n
  • \\\"><%= levels[i].label %>
  • \\n <% }; %>\\n
\\n\";\n\n/***/ },\n/* 4 */\n/*!*******************************!*\\\n !*** ./src/public/style.scss ***!\n \\*******************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\texports = module.exports = __webpack_require__(/*! ./../../~/css-loader/lib/css-base.js */ 5)();\n\t// imports\n\t\n\t\n\t// module\n\texports.push([module.id, \".level_selector[data-level-selector]{float:right;margin-top:5px;position:relative}.level_selector[data-level-selector] button{background-color:transparent;color:#fff;font-family:Roboto,Open Sans,Arial,sans-serif;-webkit-font-smoothing:antialiased;border:none;font-size:10px}.level_selector[data-level-selector] button:hover{color:#c9c9c9}.level_selector[data-level-selector] button.changing{-webkit-animation:pulse .5s infinite alternate}.level_selector[data-level-selector]>ul{list-style-type:none;position:absolute;bottom:25px;border:1px solid #000;display:none;background-color:#e6e6e6}.level_selector[data-level-selector] li{font-size:10px}.level_selector[data-level-selector] li[data-title]{background-color:#c3c2c2;padding:5px}.level_selector[data-level-selector] li a{color:#444;padding:2px 10px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:#555;color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}to{color:#b80000}}\", \"\"]);\n\t\n\t// exports\n\n\n/***/ },\n/* 5 */\n/*!**************************************!*\\\n !*** ./~/css-loader/lib/css-base.js ***!\n \\**************************************/\n/***/ function(module, exports) {\n\n\t/*\r\n\t\tMIT License http://www.opensource.org/licenses/mit-license.php\r\n\t\tAuthor Tobias Koppers @sokra\r\n\t*/ // css base code, injected by the css-loader\n\t\"use strict\";module.exports = function(){var list=[]; // return the list of modules as css string\n\tlist.toString = function toString(){var result=[];for(var i=0;i < this.length;i++) {var item=this[i];if(item[2]){result.push(\"@media \" + item[2] + \"{\" + item[1] + \"}\");}else {result.push(item[1]);}}return result.join(\"\");}; // import a list of modules into the list\n\tlist.i = function(modules,mediaQuery){if(typeof modules === \"string\")modules = [[null,modules,\"\"]];var alreadyImportedModules={};for(var i=0;i < this.length;i++) {var id=this[i][0];if(typeof id === \"number\")alreadyImportedModules[id] = true;}for(i = 0;i < modules.length;i++) {var item=modules[i]; // skip already imported module\n\t// this implementation is not 100% perfect for weird media query combinations\n\t// when a module is imported multiple times with different media queries.\n\t// I hope this will never occur (Hey this way we have smaller bundles)\n\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]){if(mediaQuery && !item[2]){item[2] = mediaQuery;}else if(mediaQuery){item[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";}list.push(item);}}};return list;};\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** level-selector.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"<%=baseUrl%>/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 706cfcc9755a149b6535\n **/","export default require('./src/main.js')\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","import {Events, Styler, UICorePlugin, template} from 'Clappr'\nimport pluginHtml from './public/level-selector.html'\nimport pluginStyle from './public/style.scss'\n\nconst AUTO = -1\n\nexport default class LevelSelector extends UICorePlugin {\n\n static get version() { return VERSION }\n\n get name() { return 'level_selector' }\n get template() { return template(pluginHtml) }\n\n get attributes() {\n return {\n 'class': this.name,\n 'data-level-selector': ''\n }\n }\n\n get events() {\n return {\n 'click [data-level-selector-select]': 'onLevelSelect',\n 'click [data-level-selector-button]': 'onShowLevelSelectMenu'\n }\n }\n\n bindEvents() {\n this.listenTo(this.core, Events.CORE_READY, this.bindPlaybackEvents)\n this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload)\n this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_RENDERED, this.render)\n }\n\n unBindEvents() {\n this.stopListening(this.core, Events.CORE_READY)\n this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED)\n this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_RENDERED)\n this.stopListening(this.core.getCurrentPlayback(), Events.PLAYBACK_LEVELS_AVAILABLE)\n this.stopListening(this.core.getCurrentPlayback(), Events.PLAYBACK_LEVEL_SWITCH_START)\n this.stopListening(this.core.getCurrentPlayback(), Events.PLAYBACK_LEVEL_SWITCH_END)\n }\n\n bindPlaybackEvents() {\n var currentPlayback = this.core.getCurrentPlayback()\n\n this.listenTo(currentPlayback, Events.PLAYBACK_LEVELS_AVAILABLE, this.fillLevels)\n this.listenTo(currentPlayback, Events.PLAYBACK_LEVEL_SWITCH_START, this.startLevelSwitch)\n this.listenTo(currentPlayback, Events.PLAYBACK_LEVEL_SWITCH_END, this.stopLevelSwitch)\n\n var playbackLevelsAvaialbeWasTriggered = currentPlayback.levels && currentPlayback.levels.length > 0\n playbackLevelsAvaialbeWasTriggered && this.fillLevels(currentPlayback.levels)\n }\n\n reload() {\n this.unBindEvents()\n this.bindEvents()\n }\n\n shouldRender() {\n if (!this.core.getCurrentContainer()) return false\n\n var currentPlayback = this.core.getCurrentPlayback()\n if (!currentPlayback) return false\n\n var respondsToCurrentLevel = currentPlayback.currentLevel !== undefined\n var hasLevels = !!(this.levels && this.levels.length > 0)\n\n return respondsToCurrentLevel && hasLevels\n }\n\n render() {\n if (this.shouldRender()) {\n var style = Styler.getStyleFor(pluginStyle, {baseUrl: this.core.options.baseUrl})\n\n this.$el.html(this.template({'levels':this.levels, 'title': this.getTitle()}))\n this.$el.append(style)\n this.core.mediaControl.$('.media-control-right-panel').append(this.el)\n this.updateText(this.selectedLevelId)\n }\n return this\n }\n\n fillLevels(levels, initialLevel = AUTO) {\n this.selectedLevelId = initialLevel\n this.levels = levels\n this.configureLevelsLabels()\n this.render()\n }\n\n configureLevelsLabels() {\n if (this.core.options.levelSelectorConfig === undefined) return\n\n for (var levelId in (this.core.options.levelSelectorConfig.labels || {})) {\n levelId = parseInt(levelId, 10)\n var thereIsLevel = !!this.findLevelBy(levelId)\n thereIsLevel && this.changeLevelLabelBy(levelId, this.core.options.levelSelectorConfig.labels[levelId])\n }\n }\n\n findLevelBy(id) {\n var foundLevel\n this.levels.forEach((level) => { if (level.id === id) {foundLevel = level} })\n return foundLevel\n }\n\n changeLevelLabelBy(id, newLabel) {\n this.levels.forEach((level, index) => {\n if (level.id === id) {\n this.levels[index].label = newLabel\n }\n })\n }\n\n onLevelSelect(event) {\n this.selectedLevelId = parseInt(event.target.dataset.levelSelectorSelect, 10)\n this.core.getCurrentPlayback().currentLevel = this.selectedLevelId\n\n this.toggleContextMenu()\n this.updateText(this.selectedLevelId)\n\n event.stopPropagation()\n return false\n }\n\n onShowLevelSelectMenu(event) { this.toggleContextMenu() }\n\n toggleContextMenu() { this.$('.level_selector ul').toggle() }\n\n buttonElement() { return this.$('.level_selector button') }\n\n getTitle() { return (this.core.options.levelSelectorConfig || {}).title }\n\n startLevelSwitch() { this.buttonElement().addClass('changing') }\n\n stopLevelSwitch() {\n this.buttonElement().removeClass('changing')\n this.updateText(this.selectedLevelId)\n }\n\n updateText(level) {\n if (level === AUTO) {\n var playbackLevel = this.core.getCurrentPlayback().currentLevel;\n this.buttonElement().text((playbackLevel === AUTO) ? 'AUTO' : 'AUTO (' + this.findLevelBy(playbackLevel).label + ')')\n }\n else {\n this.buttonElement().text(this.findLevelBy(level).label)\n }\n }\n}\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/main.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"Clappr\"\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = \"\\n
    \\n <% if (title) { %>\\n
  • <%= title %>
  • \\n <% }; %>\\n
  • AUTO
  • \\n <% for (var i = 0; i < levels.length; i++) { %>\\n
  • \\\"><%= levels[i].label %>
  • \\n <% }; %>\\n
\\n\";\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/public/level-selector.html\n ** module id = 3\n ** module chunks = 0\n **/","exports = module.exports = require(\"./../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \".level_selector[data-level-selector]{float:right;margin-top:5px;position:relative}.level_selector[data-level-selector] button{background-color:transparent;color:#fff;font-family:Roboto,Open Sans,Arial,sans-serif;-webkit-font-smoothing:antialiased;border:none;font-size:10px}.level_selector[data-level-selector] button:hover{color:#c9c9c9}.level_selector[data-level-selector] button.changing{-webkit-animation:pulse .5s infinite alternate}.level_selector[data-level-selector]>ul{list-style-type:none;position:absolute;bottom:25px;border:1px solid #000;display:none;background-color:#e6e6e6}.level_selector[data-level-selector] li{font-size:10px}.level_selector[data-level-selector] li[data-title]{background-color:#c3c2c2;padding:5px}.level_selector[data-level-selector] li a{color:#444;padding:2px 10px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:#555;color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}to{color:#b80000}}\", \"\"]);\n\n// exports\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/public/style.scss\n ** module id = 4\n ** module chunks = 0\n **/","/*\r\n\tMIT License http://www.opensource.org/licenses/mit-license.php\r\n\tAuthor Tobias Koppers @sokra\r\n*/\r\n// css base code, injected by the css-loader\r\nmodule.exports = function() {\r\n\tvar list = [];\r\n\r\n\t// return the list of modules as css string\r\n\tlist.toString = function toString() {\r\n\t\tvar result = [];\r\n\t\tfor(var i = 0; i < this.length; i++) {\r\n\t\t\tvar item = this[i];\r\n\t\t\tif(item[2]) {\r\n\t\t\t\tresult.push(\"@media \" + item[2] + \"{\" + item[1] + \"}\");\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(item[1]);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result.join(\"\");\r\n\t};\r\n\r\n\t// import a list of modules into the list\r\n\tlist.i = function(modules, mediaQuery) {\r\n\t\tif(typeof modules === \"string\")\r\n\t\t\tmodules = [[null, modules, \"\"]];\r\n\t\tvar alreadyImportedModules = {};\r\n\t\tfor(var i = 0; i < this.length; i++) {\r\n\t\t\tvar id = this[i][0];\r\n\t\t\tif(typeof id === \"number\")\r\n\t\t\t\talreadyImportedModules[id] = true;\r\n\t\t}\r\n\t\tfor(i = 0; i < modules.length; i++) {\r\n\t\t\tvar item = modules[i];\r\n\t\t\t// skip already imported module\r\n\t\t\t// this implementation is not 100% perfect for weird media query combinations\r\n\t\t\t// when a module is imported multiple times with different media queries.\r\n\t\t\t// I hope this will never occur (Hey this way we have smaller bundles)\r\n\t\t\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]) {\r\n\t\t\t\tif(mediaQuery && !item[2]) {\r\n\t\t\t\t\titem[2] = mediaQuery;\r\n\t\t\t\t} else if(mediaQuery) {\r\n\t\t\t\t\titem[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";\r\n\t\t\t\t}\r\n\t\t\t\tlist.push(item);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\treturn list;\r\n};\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./~/css-loader/lib/css-base.js\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///level-selector.min.js","webpack:///webpack/bootstrap e528c1f4a8f72b4ba177","webpack:///./index.js","webpack:///./src/main.js","webpack:///external \"Clappr\"","webpack:///./src/public/level-selector.html","webpack:///./src/public/style.scss","webpack:///./~/css-loader/lib/css-base.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_2__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","Object","defineProperty","value","_interopRequireDefault","obj","__esModule","default","_classCallCheck","instance","Constructor","TypeError","_inherits","subClass","superClass","prototype","create","constructor","enumerable","writable","configurable","setPrototypeOf","__proto__","_createClass","defineProperties","target","props","i","length","descriptor","key","protoProps","staticProps","_get","_x2","_x3","_x4","_again","object","property","receiver","Function","desc","getOwnPropertyDescriptor","undefined","getter","get","parent","getPrototypeOf","_Clappr","_publicLevelSelectorHtml","_publicLevelSelectorHtml2","_publicStyleScss","_publicStyleScss2","AUTO","LevelSelector","_UICorePlugin","apply","arguments","listenTo","core","Events","CORE_READY","bindPlaybackEvents","mediaControl","MEDIACONTROL_CONTAINERCHANGED","reload","MEDIACONTROL_RENDERED","render","stopListening","getCurrentPlayback","PLAYBACK_LEVELS_AVAILABLE","PLAYBACK_LEVEL_SWITCH_START","PLAYBACK_LEVEL_SWITCH_END","currentPlayback","fillLevels","startLevelSwitch","stopLevelSwitch","PLAYBACK_BITRATE","updateCurrentLevel","playbackLevelsAvaialbeWasTriggered","levels","unBindEvents","bindEvents","getCurrentContainer","respondsToCurrentLevel","currentLevel","hasLevels","shouldRender","style","Styler","getStyleFor","baseUrl","options","$el","html","template","title","getTitle","append","$","el","updateText","selectedLevelId","highlightCurrentLevel","initialLevel","configureLevelsLabels","levelSelectorConfig","levelId","labels","parseInt","thereIsLevel","findLevelBy","changeLevelLabelBy","foundLevel","forEach","level","newLabel","_this","index","label","event","dataset","levelSelectorSelect","toggleContextMenu","stopPropagation","toggle","isNaN","buttonElement","addClass","removeClass","text","info","levelElement","class","name","data-level-selector","click [data-level-selector-select]","click [data-level-selector-button]","VERSION","UICorePlugin","push","list","toString","result","item","join","mediaQuery","alreadyImportedModules"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,WACA,kBAAAC,gBAAAC,IACAD,QAAA,UAAAJ,GACA,gBAAAC,SACAA,QAAA,cAAAD,EAAAG,QAAA,WAEAJ,EAAA,cAAAC,EAAAD,EAAA,SACCO,KAAA,SAAAC,GACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAT,OAGA,IAAAC,GAAAS,EAAAD,IACAT,WACAW,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAZ,EAAAD,QAAAC,IAAAD,QAAAQ,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ModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"Clappr\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"Clappr\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"LevelSelector\"] = factory(require(\"Clappr\"));\n\telse\n\t\troot[\"LevelSelector\"] = factory(root[\"Clappr\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"Clappr\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"Clappr\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"LevelSelector\"] = factory(require(\"Clappr\"));\n\telse\n\t\troot[\"LevelSelector\"] = factory(root[\"Clappr\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"<%=baseUrl%>/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/*!******************!*\\\n !*** ./index.js ***!\n \\******************/\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports['default'] = __webpack_require__(/*! ./src/main.js */ 1);module.exports = exports['default'];\n\n/***/ },\n/* 1 */\n/*!*********************!*\\\n !*** ./src/main.js ***!\n \\*********************/\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if('value' in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();var _get=function get(_x2,_x3,_x4){var _again=true;_function: while(_again) {var object=_x2,property=_x3,receiver=_x4;_again = false;if(object === null)object = Function.prototype;var desc=Object.getOwnPropertyDescriptor(object,property);if(desc === undefined){var parent=Object.getPrototypeOf(object);if(parent === null){return undefined;}else {_x2 = parent;_x3 = property;_x4 = receiver;_again = true;desc = parent = undefined;continue _function;}}else if('value' in desc){return desc.value;}else {var getter=desc.get;if(getter === undefined){return undefined;}return getter.call(receiver);}}};function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{'default':obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function');}}function _inherits(subClass,superClass){if(typeof superClass !== 'function' && superClass !== null){throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _Clappr=__webpack_require__(/*! Clappr */ 2);var _publicLevelSelectorHtml=__webpack_require__(/*! ./public/level-selector.html */ 3);var _publicLevelSelectorHtml2=_interopRequireDefault(_publicLevelSelectorHtml);var _publicStyleScss=__webpack_require__(/*! ./public/style.scss */ 4);var _publicStyleScss2=_interopRequireDefault(_publicStyleScss);var AUTO=-1;var LevelSelector=(function(_UICorePlugin){_inherits(LevelSelector,_UICorePlugin);function LevelSelector(){_classCallCheck(this,LevelSelector);_get(Object.getPrototypeOf(LevelSelector.prototype),'constructor',this).apply(this,arguments);}_createClass(LevelSelector,[{key:'bindEvents',value:function bindEvents(){this.listenTo(this.core,_Clappr.Events.CORE_READY,this.bindPlaybackEvents);this.listenTo(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_CONTAINERCHANGED,this.reload);this.listenTo(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_RENDERED,this.render);}},{key:'unBindEvents',value:function unBindEvents(){this.stopListening(this.core,_Clappr.Events.CORE_READY);this.stopListening(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_CONTAINERCHANGED);this.stopListening(this.core.mediaControl,_Clappr.Events.MEDIACONTROL_RENDERED);this.stopListening(this.core.getCurrentPlayback(),_Clappr.Events.PLAYBACK_LEVELS_AVAILABLE);this.stopListening(this.core.getCurrentPlayback(),_Clappr.Events.PLAYBACK_LEVEL_SWITCH_START);this.stopListening(this.core.getCurrentPlayback(),_Clappr.Events.PLAYBACK_LEVEL_SWITCH_END);}},{key:'bindPlaybackEvents',value:function bindPlaybackEvents(){var currentPlayback=this.core.getCurrentPlayback();this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_LEVELS_AVAILABLE,this.fillLevels);this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_LEVEL_SWITCH_START,this.startLevelSwitch);this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_LEVEL_SWITCH_END,this.stopLevelSwitch);this.listenTo(currentPlayback,_Clappr.Events.PLAYBACK_BITRATE,this.updateCurrentLevel);var playbackLevelsAvaialbeWasTriggered=currentPlayback.levels && currentPlayback.levels.length > 0;playbackLevelsAvaialbeWasTriggered && this.fillLevels(currentPlayback.levels);}},{key:'reload',value:function reload(){this.unBindEvents();this.bindEvents();this.bindPlaybackEvents();}},{key:'shouldRender',value:function shouldRender(){if(!this.core.getCurrentContainer())return false;var currentPlayback=this.core.getCurrentPlayback();if(!currentPlayback)return false;var respondsToCurrentLevel=currentPlayback.currentLevel !== undefined;var hasLevels=!!(this.levels && this.levels.length > 0);return respondsToCurrentLevel && hasLevels;}},{key:'render',value:function render(){if(this.shouldRender()){var style=_Clappr.Styler.getStyleFor(_publicStyleScss2['default'],{baseUrl:this.core.options.baseUrl});this.$el.html(this.template({'levels':this.levels,'title':this.getTitle()}));this.$el.append(style);this.core.mediaControl.$('.media-control-right-panel').append(this.el);this.updateText(this.selectedLevelId);this.highlightCurrentLevel();}return this;}},{key:'fillLevels',value:function fillLevels(levels){var initialLevel=arguments.length <= 1 || arguments[1] === undefined?AUTO:arguments[1];if(this.selectedLevelId === undefined)this.selectedLevelId = initialLevel;this.levels = levels;this.configureLevelsLabels();this.render();}},{key:'configureLevelsLabels',value:function configureLevelsLabels(){if(this.core.options.levelSelectorConfig === undefined)return;for(var levelId in this.core.options.levelSelectorConfig.labels || {}) {levelId = parseInt(levelId,10);var thereIsLevel=!!this.findLevelBy(levelId);thereIsLevel && this.changeLevelLabelBy(levelId,this.core.options.levelSelectorConfig.labels[levelId]);}}},{key:'findLevelBy',value:function findLevelBy(id){var foundLevel;this.levels.forEach(function(level){if(level.id === id){foundLevel = level;}});return foundLevel;}},{key:'changeLevelLabelBy',value:function changeLevelLabelBy(id,newLabel){var _this=this;this.levels.forEach(function(level,index){if(level.id === id){_this.levels[index].label = newLabel;}});}},{key:'onLevelSelect',value:function onLevelSelect(event){this.selectedLevelId = parseInt(event.target.dataset.levelSelectorSelect,10);this.core.getCurrentPlayback().currentLevel = this.selectedLevelId;this.toggleContextMenu();this.updateText(this.selectedLevelId);event.stopPropagation();return false;}},{key:'onShowLevelSelectMenu',value:function onShowLevelSelectMenu(event){this.toggleContextMenu();}},{key:'toggleContextMenu',value:function toggleContextMenu(){this.$('.level_selector ul').toggle();}},{key:'buttonElement',value:function buttonElement(){return this.$('.level_selector button');}},{key:'levelElement',value:function levelElement(id){return this.$('.level_selector ul a' + (!isNaN(id)?'[data-level-selector-select=\"' + id + '\"]':'')).parent();}},{key:'getTitle',value:function getTitle(){return (this.core.options.levelSelectorConfig || {}).title;}},{key:'startLevelSwitch',value:function startLevelSwitch(){this.buttonElement().addClass('changing');}},{key:'stopLevelSwitch',value:function stopLevelSwitch(){this.buttonElement().removeClass('changing');this.updateText(this.selectedLevelId);}},{key:'updateText',value:function updateText(level){if(level === AUTO){this.buttonElement().text(this.currentLevel?'AUTO (' + this.currentLevel.label + ')':'AUTO');}else {this.buttonElement().text(this.findLevelBy(level).label);}}},{key:'updateCurrentLevel',value:function updateCurrentLevel(info){var level=this.findLevelBy(info.level);this.currentLevel = level?level:null;this.highlightCurrentLevel();}},{key:'highlightCurrentLevel',value:function highlightCurrentLevel(){this.levelElement().removeClass('current');this.currentLevel && this.levelElement(this.currentLevel.id).addClass('current');}},{key:'name',get:function get(){return 'level_selector';}},{key:'template',get:function get(){return (0,_Clappr.template)(_publicLevelSelectorHtml2['default']);}},{key:'attributes',get:function get(){return {'class':this.name,'data-level-selector':''};}},{key:'events',get:function get(){return {'click [data-level-selector-select]':'onLevelSelect','click [data-level-selector-button]':'onShowLevelSelectMenu'};}}],[{key:'version',get:function get(){return VERSION;}}]);return LevelSelector;})(_Clappr.UICorePlugin);exports['default'] = LevelSelector;module.exports = exports['default'];\n\n/***/ },\n/* 2 */\n/*!*************************!*\\\n !*** external \"Clappr\" ***!\n \\*************************/\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n/***/ },\n/* 3 */\n/*!****************************************!*\\\n !*** ./src/public/level-selector.html ***!\n \\****************************************/\n/***/ function(module, exports) {\n\n\tmodule.exports = \"\\n
    \\n <% if (title) { %>\\n
  • <%= title %>
  • \\n <% }; %>\\n
  • AUTO
  • \\n <% for (var i = 0; i < levels.length; i++) { %>\\n
  • \\\"><%= levels[i].label %>
  • \\n <% }; %>\\n
\\n\";\n\n/***/ },\n/* 4 */\n/*!*******************************!*\\\n !*** ./src/public/style.scss ***!\n \\*******************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\texports = module.exports = __webpack_require__(/*! ./../../~/css-loader/lib/css-base.js */ 5)();\n\t// imports\n\t\n\t\n\t// module\n\texports.push([module.id, \".level_selector[data-level-selector]{float:right;margin-top:5px;position:relative}.level_selector[data-level-selector] button{background-color:transparent;color:#fff;font-family:Roboto,Open Sans,Arial,sans-serif;-webkit-font-smoothing:antialiased;border:none;font-size:10px}.level_selector[data-level-selector] button:hover{color:#c9c9c9}.level_selector[data-level-selector] button.changing{-webkit-animation:pulse .5s infinite alternate}.level_selector[data-level-selector]>ul{list-style-type:none;position:absolute;bottom:25px;border:1px solid #000;display:none;background-color:#e6e6e6}.level_selector[data-level-selector] li{font-size:10px}.level_selector[data-level-selector] li[data-title]{background-color:#c3c2c2;padding:5px}.level_selector[data-level-selector] li a{color:#444;padding:2px 10px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:#555;color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}.level_selector[data-level-selector] li.current a{color:red}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}to{color:#b80000}}\", \"\"]);\n\t\n\t// exports\n\n\n/***/ },\n/* 5 */\n/*!**************************************!*\\\n !*** ./~/css-loader/lib/css-base.js ***!\n \\**************************************/\n/***/ function(module, exports) {\n\n\t/*\r\n\t\tMIT License http://www.opensource.org/licenses/mit-license.php\r\n\t\tAuthor Tobias Koppers @sokra\r\n\t*/ // css base code, injected by the css-loader\n\t\"use strict\";module.exports = function(){var list=[]; // return the list of modules as css string\n\tlist.toString = function toString(){var result=[];for(var i=0;i < this.length;i++) {var item=this[i];if(item[2]){result.push(\"@media \" + item[2] + \"{\" + item[1] + \"}\");}else {result.push(item[1]);}}return result.join(\"\");}; // import a list of modules into the list\n\tlist.i = function(modules,mediaQuery){if(typeof modules === \"string\")modules = [[null,modules,\"\"]];var alreadyImportedModules={};for(var i=0;i < this.length;i++) {var id=this[i][0];if(typeof id === \"number\")alreadyImportedModules[id] = true;}for(i = 0;i < modules.length;i++) {var item=modules[i]; // skip already imported module\n\t// this implementation is not 100% perfect for weird media query combinations\n\t// when a module is imported multiple times with different media queries.\n\t// I hope this will never occur (Hey this way we have smaller bundles)\n\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]){if(mediaQuery && !item[2]){item[2] = mediaQuery;}else if(mediaQuery){item[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";}list.push(item);}}};return list;};\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** level-selector.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"<%=baseUrl%>/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap e528c1f4a8f72b4ba177\n **/","export default require('./src/main.js')\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","import {Events, Styler, UICorePlugin, template} from 'Clappr'\nimport pluginHtml from './public/level-selector.html'\nimport pluginStyle from './public/style.scss'\n\nconst AUTO = -1\n\nexport default class LevelSelector extends UICorePlugin {\n\n static get version() { return VERSION }\n\n get name() { return 'level_selector' }\n get template() { return template(pluginHtml) }\n\n get attributes() {\n return {\n 'class': this.name,\n 'data-level-selector': ''\n }\n }\n\n get events() {\n return {\n 'click [data-level-selector-select]': 'onLevelSelect',\n 'click [data-level-selector-button]': 'onShowLevelSelectMenu'\n }\n }\n\n bindEvents() {\n this.listenTo(this.core, Events.CORE_READY, this.bindPlaybackEvents)\n this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload)\n this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_RENDERED, this.render)\n }\n\n unBindEvents() {\n this.stopListening(this.core, Events.CORE_READY)\n this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED)\n this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_RENDERED)\n this.stopListening(this.core.getCurrentPlayback(), Events.PLAYBACK_LEVELS_AVAILABLE)\n this.stopListening(this.core.getCurrentPlayback(), Events.PLAYBACK_LEVEL_SWITCH_START)\n this.stopListening(this.core.getCurrentPlayback(), Events.PLAYBACK_LEVEL_SWITCH_END)\n }\n\n bindPlaybackEvents() {\n var currentPlayback = this.core.getCurrentPlayback()\n\n this.listenTo(currentPlayback, Events.PLAYBACK_LEVELS_AVAILABLE, this.fillLevels)\n this.listenTo(currentPlayback, Events.PLAYBACK_LEVEL_SWITCH_START, this.startLevelSwitch)\n this.listenTo(currentPlayback, Events.PLAYBACK_LEVEL_SWITCH_END, this.stopLevelSwitch)\n this.listenTo(currentPlayback, Events.PLAYBACK_BITRATE, this.updateCurrentLevel)\n\n var playbackLevelsAvaialbeWasTriggered = currentPlayback.levels && currentPlayback.levels.length > 0\n playbackLevelsAvaialbeWasTriggered && this.fillLevels(currentPlayback.levels)\n }\n\n reload() {\n this.unBindEvents()\n this.bindEvents()\n this.bindPlaybackEvents()\n }\n\n shouldRender() {\n if (!this.core.getCurrentContainer()) return false\n\n var currentPlayback = this.core.getCurrentPlayback()\n if (!currentPlayback) return false\n\n var respondsToCurrentLevel = currentPlayback.currentLevel !== undefined\n var hasLevels = !!(this.levels && this.levels.length > 0)\n\n return respondsToCurrentLevel && hasLevels\n }\n\n render() {\n if (this.shouldRender()) {\n var style = Styler.getStyleFor(pluginStyle, {baseUrl: this.core.options.baseUrl})\n\n this.$el.html(this.template({'levels':this.levels, 'title': this.getTitle()}))\n this.$el.append(style)\n this.core.mediaControl.$('.media-control-right-panel').append(this.el)\n this.updateText(this.selectedLevelId)\n this.highlightCurrentLevel()\n }\n return this\n }\n\n fillLevels(levels, initialLevel = AUTO) {\n if (this.selectedLevelId === undefined) this.selectedLevelId = initialLevel\n this.levels = levels\n this.configureLevelsLabels()\n this.render()\n }\n\n configureLevelsLabels() {\n if (this.core.options.levelSelectorConfig === undefined) return\n\n for (var levelId in (this.core.options.levelSelectorConfig.labels || {})) {\n levelId = parseInt(levelId, 10)\n var thereIsLevel = !!this.findLevelBy(levelId)\n thereIsLevel && this.changeLevelLabelBy(levelId, this.core.options.levelSelectorConfig.labels[levelId])\n }\n }\n\n findLevelBy(id) {\n var foundLevel\n this.levels.forEach((level) => { if (level.id === id) {foundLevel = level} })\n return foundLevel\n }\n\n changeLevelLabelBy(id, newLabel) {\n this.levels.forEach((level, index) => {\n if (level.id === id) {\n this.levels[index].label = newLabel\n }\n })\n }\n\n onLevelSelect(event) {\n this.selectedLevelId = parseInt(event.target.dataset.levelSelectorSelect, 10)\n this.core.getCurrentPlayback().currentLevel = this.selectedLevelId\n\n this.toggleContextMenu()\n this.updateText(this.selectedLevelId)\n\n event.stopPropagation()\n return false\n }\n\n onShowLevelSelectMenu(event) { this.toggleContextMenu() }\n\n toggleContextMenu() { this.$('.level_selector ul').toggle() }\n\n buttonElement() { return this.$('.level_selector button') }\n\n levelElement(id) { return this.$('.level_selector ul a'+(!isNaN(id) ? '[data-level-selector-select=\"'+id+'\"]' : '')).parent() }\n\n getTitle() { return (this.core.options.levelSelectorConfig || {}).title }\n\n startLevelSwitch() { this.buttonElement().addClass('changing') }\n\n stopLevelSwitch() {\n this.buttonElement().removeClass('changing')\n this.updateText(this.selectedLevelId)\n }\n\n updateText(level) {\n if (level === AUTO) {\n this.buttonElement().text(this.currentLevel ? 'AUTO (' + this.currentLevel.label + ')' : 'AUTO')\n }\n else {\n this.buttonElement().text(this.findLevelBy(level).label)\n }\n }\n updateCurrentLevel(info) {\n var level = this.findLevelBy(info.level)\n this.currentLevel = level ? level : null\n this.highlightCurrentLevel()\n }\n highlightCurrentLevel() {\n this.levelElement().removeClass('current')\n this.currentLevel && this.levelElement(this.currentLevel.id).addClass('current')\n }\n}\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/main.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"Clappr\"\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = \"\\n
    \\n <% if (title) { %>\\n
  • <%= title %>
  • \\n <% }; %>\\n
  • AUTO
  • \\n <% for (var i = 0; i < levels.length; i++) { %>\\n
  • \\\"><%= levels[i].label %>
  • \\n <% }; %>\\n
\\n\";\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/public/level-selector.html\n ** module id = 3\n ** module chunks = 0\n **/","exports = module.exports = require(\"./../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \".level_selector[data-level-selector]{float:right;margin-top:5px;position:relative}.level_selector[data-level-selector] button{background-color:transparent;color:#fff;font-family:Roboto,Open Sans,Arial,sans-serif;-webkit-font-smoothing:antialiased;border:none;font-size:10px}.level_selector[data-level-selector] button:hover{color:#c9c9c9}.level_selector[data-level-selector] button.changing{-webkit-animation:pulse .5s infinite alternate}.level_selector[data-level-selector]>ul{list-style-type:none;position:absolute;bottom:25px;border:1px solid #000;display:none;background-color:#e6e6e6}.level_selector[data-level-selector] li{font-size:10px}.level_selector[data-level-selector] li[data-title]{background-color:#c3c2c2;padding:5px}.level_selector[data-level-selector] li a{color:#444;padding:2px 10px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:#555;color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}.level_selector[data-level-selector] li.current a{color:red}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}to{color:#b80000}}\", \"\"]);\n\n// exports\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/public/style.scss\n ** module id = 4\n ** module chunks = 0\n **/","/*\r\n\tMIT License http://www.opensource.org/licenses/mit-license.php\r\n\tAuthor Tobias Koppers @sokra\r\n*/\r\n// css base code, injected by the css-loader\r\nmodule.exports = function() {\r\n\tvar list = [];\r\n\r\n\t// return the list of modules as css string\r\n\tlist.toString = function toString() {\r\n\t\tvar result = [];\r\n\t\tfor(var i = 0; i < this.length; i++) {\r\n\t\t\tvar item = this[i];\r\n\t\t\tif(item[2]) {\r\n\t\t\t\tresult.push(\"@media \" + item[2] + \"{\" + item[1] + \"}\");\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(item[1]);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result.join(\"\");\r\n\t};\r\n\r\n\t// import a list of modules into the list\r\n\tlist.i = function(modules, mediaQuery) {\r\n\t\tif(typeof modules === \"string\")\r\n\t\t\tmodules = [[null, modules, \"\"]];\r\n\t\tvar alreadyImportedModules = {};\r\n\t\tfor(var i = 0; i < this.length; i++) {\r\n\t\t\tvar id = this[i][0];\r\n\t\t\tif(typeof id === \"number\")\r\n\t\t\t\talreadyImportedModules[id] = true;\r\n\t\t}\r\n\t\tfor(i = 0; i < modules.length; i++) {\r\n\t\t\tvar item = modules[i];\r\n\t\t\t// skip already imported module\r\n\t\t\t// this implementation is not 100% perfect for weird media query combinations\r\n\t\t\t// when a module is imported multiple times with different media queries.\r\n\t\t\t// I hope this will never occur (Hey this way we have smaller bundles)\r\n\t\t\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]) {\r\n\t\t\t\tif(mediaQuery && !item[2]) {\r\n\t\t\t\t\titem[2] = mediaQuery;\r\n\t\t\t\t} else if(mediaQuery) {\r\n\t\t\t\t\titem[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";\r\n\t\t\t\t}\r\n\t\t\t\tlist.push(item);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\treturn list;\r\n};\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./~/css-loader/lib/css-base.js\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 4614629..96787b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "level-selector", "description": "A simple plugin for Clappr that adds support to manually select level on multi-bitrate streams.", - "version": "0.1.8", + "version": "0.1.9", "license": "MIT", "repository": "clappr/clappr-level-selector-plugin", "main": "index.js",