{"version":3,"sources":["webpack:///javascripts/23-257c10c0995a4d25fa59.min.js","webpack:///./app/assets/javascripts/directives/wistiaPlayer.ts","webpack:///./app/assets/html/wistia-player.html"],"names":["webpackJsonp","CTLc","module","exports","__webpack_require__","Object","defineProperty","value","tslib_1","RescaleSvc_1","underscore_extensions_1","WistiaPlayer","$element","$rootScope","wistiaSvc","stopPlaySvcFactory","_this","this","showPreview","wistiaId","options","handHeld","video","mobileWistiaId","onModalClose","_","noop","onReady","calcTime","Utils","modalShowListener","defaultOptions","autoPlay","fullscreenChange","document","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","wistiaPlayer","play","volume","isPlayBtn","inModal","canPlay","isMobile","__assign","setWistiaMedia","stopPlaySvc","isPlaying","isVideoPlaying","playVideo","scrollCentredOn","loadVideo","$inject","prototype","$onDestroy","unbind","deactivate","$onChanges","onChangesObj","canOpenModal","obj","previousValue","currentValue","time","playInModal","playInside","el","$on","querySelector","style","opacity","getPlayer","then","videoPlayer","maxWidth","window","innerWidth","maxHeight","innerHeight","_a","RescaleSvc","resizeWithAspectRatio","width","height","assign","modalCloseHandler","getMedia","media","preview","thumbnail","url","duration","getWistiaPlayer","bind","Math","floor","getBoundingClientRect","constrain","pause","angular","component","bindings","isDuration","controller","templateUrl","ze4q","p"],"mappings":"AAAAA,cAAc,KAERC,KACA,SAAUC,EAAQC,EAASC,GAEjC,YCJAC,QAAOC,eAAeH,EAAS,cAAgBI,OAAO,GACtD,IAAIC,GAAUJ,EAAQ,QAAtBK,EAAAL,EAAA,QACAM,EAAAN,EAAA,QAEAO,EAAA,WAyBI,QAAAA,GAAoBC,EACAC,EACAC,EACAC,GAHpB,GAAAC,GAAAC,IAAoBA,MAAAL,WACAK,KAAAJ,aACAI,KAAAH,YACAG,KAAAF,qBA1BpBE,KAAAC,aAAc,EAKdD,KAAAE,SAAWC,QAAQC,UAAYJ,KAAKK,MAAMC,eAAiBN,KAAKK,MAAMC,eAAiBN,KAAKK,MAAMH,S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B,aAAawD,KAAK,eAAgB/E,EAAKiB,kBAC5CjB,EAAKW,SAASL,MAAON,EAAKuB,eACnBoC,KAgBXhE,EAAA4C,UAAAJ,UAAR,WACI,GAAIlC,KAAKsB,aAAc,CAEnB,IAAKtB,KAAK0B,QAAS,CACf,GAAMyC,GAAQY,KAAKC,MAAMhF,KAAKL,SAAS,GAAGsF,wBAAwBd,MAClEnE,MAAKsB,aAAa6C,MAAMA,GAAQe,WAAW,IAG/BlF,KAAK0B,SAAW1B,KAAKiC,gBAEjCjC,KAAKsB,aAAaC,OAClBvB,KAAKC,YAAcD,KAAK0B,SAExB1B,KAAKsB,aAAa6D,QAGlBnF,KAAKiC,gBAAkBjC,KAAKgD,MAAQhD,KAAKgD,KAAO,IAChDhD,KAAKsB,aAAa0B,KAAKhD,KAAKgD,MAC5BhD,KAAKsB,aAAaC,UAIlC7B,IA/KaR,GAAAQ,eAiLb0F,QAAQnG,OAAO,gCAAiCoG,UAAU,gBACtDC,UACI/E,aAAc,KACdG,QAAS,KACTgB,QAAS,IACTrB,MAAO,IACP2C,KAAM,KACNvB,UAAW,KACX8D,WAAY,KACZpF,QAAS,MAEbqF,WAAY9F,EACZ+F,YAAatG,EAAQ,WD1BnBuG,KACA,SAAUzG,EAAQC,EAASC,GEzKjCF,EAAAC,QAAAC,EAAAwG,EAAA","file":"javascripts/23-257c10c0995a4d25fa59.min.js","sourcesContent":["webpackJsonp([23],{\n\n/***/ \"CTLc\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar tslib_1 = __webpack_require__(\"TToO\");\r\nvar RescaleSvc_1 = __webpack_require__(\"7T+Z\");\r\nvar underscore_extensions_1 = __webpack_require__(\"R0iF\");\r\nvar WistiaPlayer = (function () {\r\n WistiaPlayer.$inject = [\"$element\", \"$rootScope\", \"wistiaSvc\", \"stopPlaySvcFactory\"];\r\n function WistiaPlayer($element, $rootScope, wistiaSvc, stopPlaySvcFactory) {\r\n var _this = this;\r\n this.$element = $element;\r\n this.$rootScope = $rootScope;\r\n this.wistiaSvc = wistiaSvc;\r\n this.stopPlaySvcFactory = stopPlaySvcFactory;\r\n this.showPreview = true;\r\n this.wistiaId = options.handHeld && this.video.mobileWistiaId ? this.video.mobileWistiaId : this.video.wistiaId;\r\n this.onModalClose = this.onModalClose || _.noop;\r\n this.onReady = this.onReady || _.noop;\r\n this.calcTime = underscore_extensions_1.Utils.calcTime;\r\n this.modalShowListener = _.noop;\r\n this.defaultOptions = {\r\n autoPlay: false\r\n };\r\n this.fullscreenChange = function () {\r\n var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement ||\r\n document.webkitFullscreenElement || document.msFullscreenElement;\r\n if (fullscreenElement != null) {\r\n _this.wistiaPlayer.play();\r\n _this.wistiaPlayer.volume(100);\r\n }\r\n else {\r\n _this.wistiaPlayer.volume(_this.options.volume);\r\n }\r\n };\r\n if (options.handHeld) {\r\n this.isPlayBtn = false;\r\n this.inModal = false;\r\n }\r\n this.canPlay = !this.isPlayBtn && (this.video.isMobile || !options.handHeld);\r\n this.options = tslib_1.__assign({}, this.defaultOptions, this.options);\r\n this.setWistiaMedia();\r\n this.stopPlaySvc = this.stopPlaySvcFactory(this.$element, function (isPlaying) {\r\n _this.isVideoPlaying = isPlaying;\r\n _this.playVideo();\r\n }, this.video.scrollCentredOn);\r\n if (this.canPlay) {\r\n this.loadVideo();\r\n }\r\n }\r\n WistiaPlayer.prototype.$onDestroy = function () {\r\n this.wistiaPlayer && this.wistiaPlayer.unbind('heightchange', this.fullscreenChange);\r\n this.stopPlaySvc && this.stopPlaySvc.deactivate();\r\n };\r\n WistiaPlayer.prototype.$onChanges = function (onChangesObj) {\r\n var isUpdated = function (obj) { return obj && obj.previousValue !== obj.currentValue; };\r\n this.canOpenModal = this.inModal && this.canPlay;\r\n if (this.wistiaPlayer && isUpdated(onChangesObj.time)) {\r\n this.wistiaPlayer.time(this.time);\r\n }\r\n };\r\n WistiaPlayer.prototype.loadVideo = function () {\r\n this.canPlay = this.video.isMobile || !options.handHeld;\r\n if (!this.canPlay)\r\n return;\r\n if (this.inModal) {\r\n this.playInModal();\r\n }\r\n else {\r\n this.playInside();\r\n }\r\n };\r\n WistiaPlayer.prototype.playInModal = function () {\r\n var el;\r\n this.modalShowListener = this.$rootScope.$on('modal:show', function () {\r\n el = document.querySelector('.modal-wistia-player');\r\n el.style.opacity = '0';\r\n });\r\n this.canOpenModal = true;\r\n this.getPlayer().then(function (videoPlayer) {\r\n var maxWidth = (window.innerWidth / 1.4);\r\n var maxHeight = (window.innerHeight / 1.2);\r\n var _a = RescaleSvc_1.RescaleSvc.resizeWithAspectRatio(videoPlayer.width(), videoPlayer.height(), maxWidth, maxHeight, true, true), width = _a.width, height = _a.height;\r\n var modalPadding = 20;\r\n videoPlayer.width(width - modalPadding);\r\n videoPlayer.height(height - modalPadding);\r\n Object.assign(el.style, {\r\n width: width + \"px\",\r\n height: height + \"px\",\r\n opacity: '1'\r\n });\r\n });\r\n };\r\n WistiaPlayer.prototype.playInside = function () {\r\n var _this = this;\r\n this.getPlayer().then(function () {\r\n _this.playVideo();\r\n });\r\n };\r\n WistiaPlayer.prototype.modalCloseHandler = function () {\r\n this.canOpenModal = false;\r\n this.showPreview = true;\r\n this.onModalClose();\r\n this.modalShowListener();\r\n };\r\n WistiaPlayer.prototype.setWistiaMedia = function () {\r\n var _this = this;\r\n this.wistiaSvc.getMedia(this.wistiaId).then(function (media) {\r\n _this.video.preview = _this.video.preview || media.thumbnail.url;\r\n _this.video.duration = _this.calcTime(media.duration);\r\n });\r\n };\r\n WistiaPlayer.prototype.getPlayer = function () {\r\n var _this = this;\r\n return this.wistiaSvc.getWistiaPlayer(this.wistiaId, this.options)\r\n .then(function (videoPlayer) {\r\n _this.wistiaPlayer = videoPlayer;\r\n _this.wistiaPlayer.bind('heightchange', _this.fullscreenChange);\r\n _this.onReady({ video: _this.wistiaPlayer });\r\n return videoPlayer;\r\n });\r\n };\r\n WistiaPlayer.prototype.playVideo = function () {\r\n if (this.wistiaPlayer) {\r\n // fix bug with incorrect height in wistia player\r\n if (!this.inModal) {\r\n var width = Math.floor(this.$element[0].getBoundingClientRect().width);\r\n this.wistiaPlayer.width(width, { constrain: true });\r\n }\r\n var canPlay = this.inModal || this.isVideoPlaying;\r\n if (canPlay) {\r\n this.wistiaPlayer.play();\r\n this.showPreview = this.inModal;\r\n }\r\n else {\r\n this.wistiaPlayer.pause();\r\n }\r\n if (this.isVideoPlaying && this.time && this.time > 0) {\r\n this.wistiaPlayer.time(this.time);\r\n this.wistiaPlayer.play();\r\n }\r\n }\r\n };\r\n return WistiaPlayer;\r\n}());\r\nexports.WistiaPlayer = WistiaPlayer;\r\nangular.module('animatronApp.wistiaPlayer', []).component('wistiaPlayer', {\r\n bindings: {\r\n onModalClose: '&?',\r\n onReady: '&?',\r\n inModal: '<',\r\n video: '<',\r\n time: ' void = this.onModalClose || _.noop;\n onReady: (video: any) => void = this.onReady || _.noop;\n calcTime = Utils.calcTime;\n\n private stopPlaySvc: StopPlaySvc;\n private modalShowListener: Function = _.noop;\n private time: number;\n private options: any;\n private defaultOptions = {\n autoPlay: false\n };\n private play: boolean;\n private isPlayBtn: boolean;\n private wistiaPlayer: any;\n private isVideoPlaying: boolean;\n\n constructor(private $element: ng.IAugmentedJQuery,\n private $rootScope: ng.IRootScopeService,\n private wistiaSvc: WistiaSvc,\n private stopPlaySvcFactory: StopPlaySvcFactory) {\n if (options.handHeld) {\n this.isPlayBtn = false;\n this.inModal = false;\n }\n this.canPlay = !this.isPlayBtn && (this.video.isMobile || !options.handHeld);\n\n this.options = {...this.defaultOptions, ...this.options};\n this.setWistiaMedia();\n\n this.stopPlaySvc = this.stopPlaySvcFactory(\n this.$element,\n isPlaying => {\n this.isVideoPlaying = isPlaying;\n this.playVideo();\n },\n this.video.scrollCentredOn\n );\n\n if (this.canPlay) {\n this.loadVideo();\n }\n }\n\n $onDestroy() {\n this.wistiaPlayer && this.wistiaPlayer.unbind('heightchange', this.fullscreenChange);\n this.stopPlaySvc && this.stopPlaySvc.deactivate();\n }\n\n $onChanges(onChangesObj: ng.IOnChangesObject) {\n const isUpdated = (obj: ng.IChangesObject) => obj && obj.previousValue !== obj.currentValue;\n this.canOpenModal = this.inModal && this.canPlay;\n\n if (this.wistiaPlayer && isUpdated(onChangesObj.time)) {\n this.wistiaPlayer.time(this.time);\n }\n }\n\n loadVideo() {\n this.canPlay = this.video.isMobile || !options.handHeld;\n if (!this.canPlay) return;\n\n if (this.inModal) {\n this.playInModal();\n } else {\n this.playInside();\n }\n }\n\n playInModal() {\n let el: HTMLElement;\n this.modalShowListener = this.$rootScope.$on('modal:show', () => {\n el = document.querySelector('.modal-wistia-player');\n\n el.style.opacity = '0';\n });\n\n this.canOpenModal = true;\n\n this.getPlayer().then((videoPlayer: any) => {\n const maxWidth = (window.innerWidth / 1.4);\n const maxHeight = (window.innerHeight / 1.2);\n\n const {width, height} = RescaleSvc.resizeWithAspectRatio(\n videoPlayer.width(),\n videoPlayer.height(),\n maxWidth,\n maxHeight,\n true, true\n );\n\n const modalPadding = 20;\n videoPlayer.width(width - modalPadding);\n videoPlayer.height(height - modalPadding);\n\n Object.assign(el.style, {\n width: `${width}px`,\n height: `${height}px`,\n opacity: '1'\n });\n });\n }\n\n playInside() {\n this.getPlayer().then(() => {\n this.playVideo();\n });\n }\n\n modalCloseHandler() {\n this.canOpenModal = false;\n this.showPreview = true;\n this.onModalClose();\n this.modalShowListener();\n }\n\n private setWistiaMedia() {\n this.wistiaSvc.getMedia(this.wistiaId).then(media => {\n this.video.preview = this.video.preview || media.thumbnail.url;\n this.video.duration = this.calcTime(media.duration);\n });\n }\n\n private getPlayer() {\n return this.wistiaSvc.getWistiaPlayer(this.wistiaId, this.options)\n .then((videoPlayer: any) => {\n this.wistiaPlayer = videoPlayer;\n this.wistiaPlayer.bind('heightchange', this.fullscreenChange);\n this.onReady({video: this.wistiaPlayer});\n return videoPlayer;\n });\n }\n\n private fullscreenChange = () => {\n const fullscreenElement = document.fullscreenElement || document.mozFullScreenElement ||\n document.webkitFullscreenElement || document.msFullscreenElement;\n\n if (fullscreenElement != null) {\n this.wistiaPlayer.play();\n this.wistiaPlayer.volume(100);\n } else {\n this.wistiaPlayer.volume(this.options.volume);\n }\n };\n\n private playVideo() {\n if (this.wistiaPlayer) {\n // fix bug with incorrect height in wistia player\n if (!this.inModal) {\n const width = Math.floor(this.$element[0].getBoundingClientRect().width);\n this.wistiaPlayer.width(width, {constrain: true});\n }\n\n const canPlay = this.inModal || this.isVideoPlaying;\n if (canPlay) {\n this.wistiaPlayer.play();\n this.showPreview = this.inModal;\n } else {\n this.wistiaPlayer.pause();\n }\n\n if (this.isVideoPlaying && this.time && this.time > 0) {\n this.wistiaPlayer.time(this.time);\n this.wistiaPlayer.play();\n }\n }\n }\n}\n\nangular.module('animatronApp.wistiaPlayer', []).component('wistiaPlayer', {\n bindings: {\n onModalClose: '&?',\n onReady: '&?',\n inModal: '<',\n video: '<',\n time: '