diff --git a/dist/clappr-context-menu-plugin.js b/dist/clappr-context-menu-plugin.js index a7b697a1..8639d61e 100644 --- a/dist/clappr-context-menu-plugin.js +++ b/dist/clappr-context-menu-plugin.js @@ -1,13 +1,13 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("Clappr")); + module.exports = factory(require("clappr")); else if(typeof define === 'function' && define.amd) - define(["Clappr"], factory); + define(["clappr"], factory); else if(typeof exports === 'object') - exports["ContextMenuPlugin"] = factory(require("Clappr")); + exports["ContextMenuPlugin"] = factory(require("clappr")); else root["ContextMenuPlugin"] = factory(root["Clappr"]); -})(window, function(__WEBPACK_EXTERNAL_MODULE_Clappr__) { +})(window, function(__WEBPACK_EXTERNAL_MODULE_clappr__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -116,7 +116,7 @@ eval("\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\n\nvar _Clappr = __webpack_require__(/*! Clappr */ \"Clappr\");\n\nvar _context_menu = _interopRequireDefault(__webpack_require__(/*! ./public/context_menu.scss */ \"./src/public/context_menu.scss\"));\n\nvar _context_menu2 = _interopRequireDefault(__webpack_require__(/*! ./public/context_menu.html */ \"./src/public/context_menu.html\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar ContextMenuPlugin =\n/*#__PURE__*/\nfunction (_UICorePlugin) {\n _inherits(ContextMenuPlugin, _UICorePlugin);\n\n _createClass(ContextMenuPlugin, [{\n key: \"name\",\n get: function get() {\n return 'context_menu';\n }\n }, {\n key: \"attributes\",\n get: function get() {\n return {\n 'class': 'context-menu'\n };\n }\n }, {\n key: \"template\",\n get: function get() {\n return (0, _Clappr.template)(_context_menu2[\"default\"]);\n }\n }, {\n key: \"loopEnable\",\n get: function get() {\n return this.core.activePlayback.el.loop;\n }\n }, {\n key: \"playerVersion\",\n get: function get() {\n return {\n label: \"Clappr Player v\".concat(Clappr.version),\n name: 'playerVersion'\n };\n }\n }, {\n key: \"copyURL\",\n get: function get() {\n return {\n label: 'Copy URL',\n name: 'copyURL'\n };\n }\n }, {\n key: \"copyURLCurrentTime\",\n get: function get() {\n return {\n label: 'Copy URL on current time',\n name: 'copyURLCurrentTime'\n };\n }\n }, {\n key: \"loop\",\n get: function get() {\n return {\n label: 'Loop: ',\n name: 'loop',\n \"class\": this.core.options.loop ? 'on' : 'off'\n };\n }\n }, {\n key: \"events\",\n get: function get() {\n var _this2 = this;\n\n var events = {\n 'click [data-copyURL]': 'onCopyURL',\n 'click [data-copyURLCurrentTime]': 'onCopyURLCurrentTime',\n 'click [data-loop]': 'onToggleLoop'\n };\n this.extraOptions && this.extraOptions.forEach(function (item) {\n if (typeof item.callback === 'function') {\n var callbackName = \"\".concat(item.name, \"Callback\");\n _this2[callbackName] = item.callback;\n events[\"click [data-\".concat(item.name, \"]\")] = callbackName;\n }\n });\n return events;\n }\n }]);\n\n function ContextMenuPlugin(core) {\n var _this;\n\n _classCallCheck(this, ContextMenuPlugin);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(ContextMenuPlugin).call(this, core));\n _this.extraOptions = _this.options.contextMenu && _this.options.contextMenu.extraOptions || [];\n\n _this.delegateEvents(_this.events);\n\n _this.bindEvents();\n\n return _this;\n }\n\n _createClass(ContextMenuPlugin, [{\n key: \"bindEvents\",\n value: function bindEvents() {\n var coreEventListenerData = [{\n object: this.core,\n event: _Clappr.Events.CORE_ACTIVE_CONTAINER_CHANGED,\n callback: this.containerChanged\n }];\n this.stopListening(coreEventListenerData[0].object, coreEventListenerData[0].event, coreEventListenerData[0].callback);\n this.listenTo(coreEventListenerData[0].object, coreEventListenerData[0].event, coreEventListenerData[0].callback);\n this.bindCustomEvents();\n }\n }, {\n key: \"bindContainerEvents\",\n value: function bindContainerEvents() {\n var _this3 = this;\n\n var containerEventListenerData = [{\n object: this.container,\n event: _Clappr.Events.CONTAINER_CONTEXTMENU,\n callback: this.toggleContextMenu\n }, {\n object: this.container,\n event: _Clappr.Events.CONTAINER_CLICK,\n callback: this.hide\n }];\n\n if (this.container) {\n containerEventListenerData.forEach(function (item) {\n return _this3.stopListening(item.object, item.event, item.callback);\n });\n containerEventListenerData.forEach(function (item) {\n return _this3.listenTo(item.object, item.event, item.callback);\n });\n }\n }\n }, {\n key: \"bindCustomEvents\",\n value: function bindCustomEvents() {\n $('body').off('click', this.hide.bind(this));\n $('body').on('click', this.hide.bind(this));\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n $('body').off('click', this.hide.bind(this));\n this.stopListening();\n\n _get(_getPrototypeOf(ContextMenuPlugin.prototype), \"destroy\", this).call(this);\n }\n }, {\n key: \"containerChanged\",\n value: function containerChanged() {\n this.container = this.core.activeContainer;\n this.bindContainerEvents();\n }\n }, {\n key: \"toggleContextMenu\",\n value: function toggleContextMenu(event) {\n event.preventDefault();\n this.show(event.offsetY, event.offsetX);\n }\n }, {\n key: \"show\",\n value: function show(top, left) {\n !this.playerElement && this.calculateContextMenuLimit();\n var finalTop = top > this.maxHeight ? this.maxHeight : top;\n var finalLeft = left > this.maxWidth ? this.maxWidth : left;\n this.hide();\n this.$el.css({\n top: finalTop,\n left: finalLeft\n });\n this.$el.show();\n }\n }, {\n key: \"calculateContextMenuLimit\",\n value: function calculateContextMenuLimit() {\n this.playerElement = document.querySelector('[data-player]');\n this.maxWidth = this.playerElement.clientWidth - 160;\n this.maxHeight = this.playerElement.clientHeight - 200;\n }\n }, {\n key: \"hide\",\n value: function hide() {\n this.$el.hide();\n }\n }, {\n key: \"copyToClipboard\",\n value: function copyToClipboard(value, $el) {\n if (!$el) return;\n var $copyTextarea = $('