forked from jasder/forgeplus
1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("Clappr")):"function"==typeof define&&define.amd?define(["Clappr"],e):"object"==typeof exports?exports.ClapprThumbnailsPlugin=e(require("Clappr")):t.ClapprThumbnailsPlugin=e(t.Clappr)}(this,function(t){return function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),a=n(7),c=n(3),l=n(6),h=o(l),f=n(5),d=o(f),p=function(t){function e(t){i(this,e);var n=r(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n._thumbsLoaded=!1,n._show=!1,n._hoverPosition=0,n._oldContainer=null,n._thumbs=[],n._onThumbsLoaded=new c.Promise(function(t){n._onThumbsLoadedResolve=t}),n._buildThumbsFromOptions().then(function(){n._thumbsLoaded=!0,n._onThumbsLoadedResolve(),n._init()})["catch"](function(t){throw t}),n}return u(e,t),s(e,[{key:"name",get:function(){return"scrub-thumbnails"}},{key:"attributes",get:function(){return{"class":this.name}}},{key:"template",get:function(){return(0,a.template)(h["default"])}}],[{key:"buildSpriteConfig",value:function(t,e,n,o,i,r,u){u=u||0;for(var s=[],a=0;a<e;a++)s.push({url:t,time:u+a*r,w:n,h:o,x:a%i*n,y:Math.floor(a/i)*o});return s}}]),s(e,[{key:"bindEvents",value:function(){this.listenTo(this.core.mediaControl,a.Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR,this._onMouseMove),this.listenTo(this.core.mediaControl,a.Events.MEDIACONTROL_MOUSELEAVE_SEEKBAR,this._onMouseLeave),this.listenTo(this.core.mediaControl,a.Events.MEDIACONTROL_RENDERED,this._init),this.listenTo(this.core.mediaControl,a.Events.MEDIACONTROL_CONTAINERCHANGED,this._onMediaControlContainerChanged)}},{key:"_bindContainerEvents",value:function(){this._oldContainer&&this.stopListening(this._oldContainer,a.Events.CONTAINER_TIMEUPDATE,this._renderPlugin),this._oldContainer=this.core.mediaControl.container,this.listenTo(this.core.mediaControl.container,a.Events.CONTAINER_TIMEUPDATE,this._renderPlugin)}},{key:"_onMediaControlContainerChanged",value:function(){this._bindContainerEvents()}},{key:"addThumbnail",value:function(t){var e=this,n=t.constructor===Array?t:[t];return this._onThumbsLoaded.then(function(){var t=n.map(function(t){return e._addThumbFromSrc(t).then(function(t){if(e._getOptions().backdropHeight){var n=e._thumbs.indexOf(t),o=e._buildImg(t,e._getOptions().backdropHeight);e._$backdropCarouselImgs.splice(n,0,o),1===e._$backdropCarouselImgs.length?e._$carousel.append(o):0===n?e._$backdropCarouselImgs[1].before(o):e._$backdropCarouselImgs[n-1].after(o)}})});return c.Promise.all(t).then(function(){t.length>0&&e._renderPlugin()})})}},{key:"removeThumbnail",value:function(t){var e=this,n=t.constructor===Array?t:[t];return this._onThumbsLoaded.then(function(){var t=!0,o=!1;return n.forEach(function(n){var i=e._thumbs.some(function(t,o){return t.src===n&&(e._thumbs.splice(o,1),e._getOptions().backdropHeight&&(e._$backdropCarouselImgs[o].remove(),e._$backdropCarouselImgs.splice(o,1)),!0)});i?o=!0:t=!1}),o&&e._renderPlugin(),c.Promise.resolve(t)})}},{key:"_init",value:function()
|