-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeaturedVideo.min.js
More file actions
8 lines (8 loc) · 6.39 KB
/
featuredVideo.min.js
File metadata and controls
8 lines (8 loc) · 6.39 KB
1
2
3
4
5
6
7
8
/*!
featuredVideo v1.1.8 (https://github.com/TechTarget/featuredVideo)
Author: Morgan Wigmanich <okize123@gmail.com> (http://github.com/okize)
Copyright (c) 2013 | Licensed under the MIT license
http://www.opensource.org/licenses/mit-license.php
*/
(function(){!function(t){return"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){"use strict";var i,e,o;o="featuredVideo",e={autoplayFirstVideo:!0,maintainState:!0,showPlaylist:!0,showPlaylistTooltips:!0,tooltipHtml:'<div class="featuredVideoPlaylistTooltip"></div>'},i=function(){function i(i,o){this.element=i,this.el=t(this.element),this.options=t.extend({},e,o),this.player=this.el.find(".featuredplayer"),this.playlist=this.el.find(".featuredVideoPlaylist"),this.playlistVideos=this.playlist.find("li"),this.playlistVideosCount=this.playlistVideos.length,this.playlistFirstVideoId=this.playlistVideos.eq(0).data("videoId")||null,this.playType=this.options.autoplayFirstVideo?"load":"cue",this.stateKey="videoId",this.activeVideoId=null,this.hashVideoId=this.getIdFromUrl(),this.hashObject=null,this.init()}return i.prototype.init=function(){return this.sanityCheck(),this.getPlayer(),this.watchHash()},i.prototype.sanityCheck=function(){var i;return this.playlistVideosCount<=0?(this.el.hide(),t.error("no videos in the playlist!")):this.playlistFirstVideoId&&""!==this.playlistFirstVideoId?(i=this.getDuplicatePlaylistIds(),i.length>0&&"object"==typeof console?console.error("WARNING! duplicate ids found in the playlist: ",i):void 0):(this.el.hide(),t.error("no video ids specified in playlist!"))},i.prototype.player={},i.prototype.getPlayer=function(){var i,e,o=this;return i={url:"http://admin.brightcove.com/js/BrightcoveExperiences.js",isLoaded:t(document).data("playerScriptLoaded")||!1},e=i.isLoaded?this.resolve():this.loadPlayerScript(i.url),t.when(e).done(function(){return o.initializePlayer()}).fail(function(){return t.error("Brightcove script failed to load")})},i.prototype.loadPlayerScript=function(i){var e;return e=t.ajax(i,{dataType:"script"})},i.prototype.initializePlayer=function(){var t,i=this;return t=window.brightcove||{},window.brightcovePlayerLoaded=function(e){var o;return o=t.api.getExperience(e),i.player=o.getModule(t.api.modules.APIModules.VIDEO_PLAYER)},window.brightcovePlayerReady=function(){return i.updateState(i.getVideo(),i.playType,void 0),i.initializePlaylist()},t.createExperiences()},i.prototype.playVideo=function(t,i){return"load"===t?this.player.loadVideoByID(i):"cue"===t?this.player.cueVideoByID(i):void 0},i.prototype.getVideo=function(i){return this.activeVideoId="undefined"!=typeof i?t(i).data("videoId"):this.hashVideoId&&this.hasValidId(this.hashVideoId)?this.hashVideoId:this.playlistFirstVideoId,this.activeVideoId},i.prototype.hasValidId=function(t){var i,e,o;for(e=this.getPlaylistIds(),i=0,o=e.length;o>i;){if(e[i]===t)return!0;i++}return!1},i.prototype.selectPlaylistItem=function(t,i){return"undefined"==typeof t&&(t=this.playlist.find("li[data-video-id="+this.activeVideoId+"]")),"click"!==i&&this.bringPlaylistItemIntoView(t.get(0)),this.playlistVideos.removeClass("active"),t.addClass("active")},i.prototype.bringPlaylistItemIntoView=function(t){return"undefined"==typeof t?!1:t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded(!0):t.scrollIntoView(!0)},i.prototype.initializePlaylist=function(){var t=this;return this.options.showPlaylist?(this.playlist.on("click","li",function(i){return i.preventDefault(),t.updateState(t.getVideo(i.currentTarget),"load",i)}),this.options.showPlaylistTooltips&&this.initializePlaylistTooltips(),this.playlist.css("visibility","visible")):(this.el.addClass("noPlaylist"),this.playlist.remove(),void 0)},i.prototype.initializePlaylistTooltips=function(){var i,e;return e=t(this.options.tooltipHtml),i=this.playlist.offset(),this.el.append(e),this.playlistVideos.on({mouseenter:function(){var o,s,n;return o=t(this),n=o.find(".featuredVideoSummary").text(),s={top:o.offset().top-i.top},""!==n?e.text(n).css("top",s.top).show():void 0},mouseleave:function(){return e.hide()}})},i.prototype.getPlaylistIds=function(){var i;return i=[],this.playlistVideos.each(function(){var e;return e=t(this).data("videoId").toString(),i.push(e)}),i},i.prototype.getDuplicatePlaylistIds=function(){var t,i,e,o,s,n;for(o=this.getPlaylistIds(),i=[],t={},s=void 0,e=0,n=o.length;n>e;)s=o[e].toString(),"undefined"==typeof t[s]?t[s]=!0:i.push(s),e++;return i},i.prototype.watchHash=function(){var i=this;return"onhashchange"in window?t(window).on("hashchange",function(t){var e;return t.preventDefault(),e=i.getIdFromUrl(),void 0!==e&&e!==i.hashObject[i.stateKey]?(i.hashVideoId=i.activeVideoId=e,i.updateState(i.getVideo(),"load",void 0)):void 0}):void 0},i.prototype.getStateFromHash=function(){var t,i;return this.hashObject=this.getHashObject(),this.hashObject?(t=null!=(i=this.hashObject[this.stateKey])?i:null,t?this.activeTab=this.hashObject[this.stateKey]:null):null},i.prototype.updateUrlHash=function(t){return this.options.maintainState?window.location.hash="videoId="+t:void 0},i.prototype.getUrlHash=function(){return window.location.hash?window.location.hash.substring(1):null},i.prototype.getHashObject=function(){var t,i,e,o,s,n,a;if(o=this.getUrlHash(),!o)return null;for(i={},e=o.split("&"),n=0,a=e.length;a>n;n++)s=e[n],t=s.split("="),i[t[0]]=t.length>1?t[1]:void 0;return i},i.prototype.getIdFromUrl=function(){var t,i;return t=this.getHashObject(),i=null!=t?t[this.stateKey]:this.getIdFromQueryString(),("undefined"==typeof i||""===i)&&(i=null),i},i.prototype.getIdFromQueryString=function(){var t;return t=window.location.search.match(new RegExp("[?&]bctid=([^&]+)(&|$)")),t&&decodeURIComponent(t[1].replace(/\+/g," "))},i.prototype.buildHashObject=function(){return t.param(this.hashObject)},i.prototype.updateHash=function(t){return t+="",this.hashObject=this.getHashObject(),this.hashObject||(this.hashObject={}),this.hashObject[this.stateKey]=t,this.setUrlHash(this.buildHashObject())},i.prototype.setUrlHash=function(t){return window.location.hash=t},i.prototype.updateState=function(i,e,o){var s,n;return this.activeVideoId=i,this.options.maintainState&&this.updateHash(this.activeVideoId),this.playVideo(e,i),this.options.showPlaylist?(n=o&&o.currentTarget?t(o.currentTarget):void 0,s=o&&o.type?o.type:"none",this.selectPlaylistItem(n,s)):void 0},i}(),t.fn[o]=function(e){return this.each(function(){t.data(this,"plugin_#{pluginName}")||t.data(this,"plugin_#{pluginName}",new i(this,e))})}})}).call(this);
//# sourceMappingURL=featuredVideo.min.js.map