diff --git a/dist/iiif-av-component.bundle.js b/dist/iiif-av-component.bundle.js index a59dea5..7e9f016 100644 --- a/dist/iiif-av-component.bundle.js +++ b/dist/iiif-av-component.bundle.js @@ -60,5 +60,5 @@ var _Components; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}]},{},[1])(1) }); -!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.iiifAvComponent=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o0&&(this._data.canvasId=this.canvasInstances[0].getCanvasId())},AVComponent.prototype._getCanvases=function(){return this._data.helper?this._data.helper.getCanvases():[]},AVComponent.prototype._initCanvas=function(canvas){var _this=this,canvasInstance=new IIIFComponents.CanvasInstance({target:document.createElement("div"),data:Object.assign({},{canvas:canvas},this._data)});canvasInstance.logMessage=this._logMessage.bind(this),this._$element.append(canvasInstance.$playerElement),canvasInstance.init(),this.canvasInstances.push(canvasInstance),canvasInstance.on(AVComponent.Events.CANVASREADY,function(){_this.fire(AVComponent.Events.CANVASREADY)},!1),canvasInstance.on(IIIFComponents.AVComponentCanvasInstance.Events.PREVIOUS_RANGE,function(){_this._prevRange()},!1),canvasInstance.on(IIIFComponents.AVComponentCanvasInstance.Events.NEXT_RANGE,function(){_this._nextRange()},!1),canvasInstance.on(AVComponent.Events.RANGE_CHANGED,function(rangeId){_this.fire(AVComponent.Events.RANGE_CHANGED,rangeId)},!1),canvasInstance.on(IIIFComponents.AVVolumeControl.Events.VOLUME_CHANGED,function(volume){_this._setCanvasInstanceVolumes(volume),_this.fire(IIIFComponents.AVVolumeControl.Events.VOLUME_CHANGED,volume)},!1)},AVComponent.prototype._prevRange=function(){if(this._data&&this._data.helper){var prevRange=this._data.helper.getPreviousRange();prevRange?this.playRange(prevRange.id):this._rewind()}},AVComponent.prototype._nextRange=function(){if(this._data&&this._data.helper){var nextRange=this._data.helper.getNextRange();nextRange&&this.playRange(nextRange.id)}},AVComponent.prototype._setCanvasInstanceVolumes=function(volume){this.canvasInstances.forEach(function(canvasInstance){canvasInstance.set({volume:volume})})},AVComponent.prototype._getCanvasInstanceById=function(canvasId){canvasId=Manifesto.Utils.normaliseUrl(canvasId);for(var i=0;i\n '+this.options.data.content.mute+"\n "),this._$volumeSlider=$(''),this._$element.append(this._$volumeMute,this._$volumeSlider);var that=this;return this._$volumeMute.on("click",function(){0!==_this._data.volume?(_this._lastVolume=_this._data.volume,_this._data.volume=0):_this._data.volume=_this._lastVolume,_this._render(),_this.fire(AVVolumeControl.Events.VOLUME_CHANGED,_this._data.volume)}),this._$volumeSlider.on("input",function(){that._data.volume=Number(this.value),0===that._data.volume&&(that._lastVolume=0),that._render(),that.fire(AVVolumeControl.Events.VOLUME_CHANGED,that._data.volume)}),this._$volumeSlider.on("change",function(){that._data.volume=Number(this.value),0===that._data.volume&&(that._lastVolume=0),that._render(),that.fire(AVVolumeControl.Events.VOLUME_CHANGED,that._data.volume)}),success},AVVolumeControl.prototype.set=function(data){this._data=Object.assign(this._data,data),this._render()},AVVolumeControl.prototype._render=function(){this._$volumeSlider.val(this._data.volume),0===this._data.volume?this._$volumeMute.find("i").switchClass("on","off"):this._$volumeMute.find("i").switchClass("off","on")},AVVolumeControl.prototype._resize=function(){},AVVolumeControl}(_Components.BaseComponent);IIIFComponents.AVVolumeControl=AVVolumeControl}(IIIFComponents||(IIIFComponents={})),function(IIIFComponents){var AVVolumeControl;!function(AVVolumeControl){var Events=function(){function Events(){}return Events.VOLUME_CHANGED="volumechanged",Events}();AVVolumeControl.Events=Events}(AVVolumeControl=IIIFComponents.AVVolumeControl||(IIIFComponents.AVVolumeControl={}))}(IIIFComponents||(IIIFComponents={}));var IIIFComponents,__extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();!function(IIIFComponents){var CanvasInstance=function(_super){function CanvasInstance(options){var _this=_super.call(this,options)||this;return _this._canvasClockDuration=0,_this._canvasClockFrequency=25,_this._canvasClockStartDate=0,_this._canvasClockTime=0,_this._canvasHeight=0,_this._canvasWidth=0,_this._data=_this.data(),_this._highPriorityFrequency=25,_this._isPlaying=!1,_this._isStalled=!1,_this._lowPriorityFrequency=250,_this._ranges=[],_this._readyCanvasesCount=0,_this._stallRequestedBy=[],_this._wasPlaying=!1,_this._data=_this.options.data,_this.$playerElement=$('
'),_this}return __extends(CanvasInstance,_super),CanvasInstance.prototype.init=function(){var _this=this;if(!this._data||!this._data.content||!this._data.canvas)return void console.warn("unable to initialise, missing canvas or content");this._$hoverPreviewTemplate=$('
'),this._$canvasContainer=$('
'),this._$optionsContainer=$('
'),this._$rangeTimelineContainer=$('
'),this._$canvasTimelineContainer=$('
'),this._$canvasHoverPreview=this._$hoverPreviewTemplate.clone(),this._$canvasHoverHighlight=$('
'),this._$rangeHoverPreview=this._$hoverPreviewTemplate.clone(),this._$rangeHoverHighlight=$('
'),this._$durationHighlight=$('
'),this._$timelineItemContainer=$('
'),this._$controlsContainer=$('
'),this._$prevButton=$('\n "),this._$playButton=$('\n "),this._$nextButton=$('\n "),this._$timeDisplay=$('
/
'),this._$canvasTime=this._$timeDisplay.find(".canvas-time"),this._$canvasDuration=this._$timeDisplay.find(".canvas-duration");var $volume=$('
');if(this._volume=new IIIFComponents.AVVolumeControl({target:$volume[0],data:Object.assign({},this._data)}),this._volume.on(IIIFComponents.AVVolumeControl.Events.VOLUME_CHANGED,function(value){_this.fire(IIIFComponents.AVVolumeControl.Events.VOLUME_CHANGED,value)},!1),this._$controlsContainer.append(this._$prevButton,this._$playButton,this._$nextButton,this._$timeDisplay,$volume),this._$canvasTimelineContainer.append(this._$canvasHoverPreview,this._$canvasHoverHighlight,this._$durationHighlight),this._$rangeTimelineContainer.append(this._$rangeHoverPreview,this._$rangeHoverHighlight),this._$optionsContainer.append(this._$canvasTimelineContainer,this._$rangeTimelineContainer,this._$timelineItemContainer,this._$controlsContainer),this.$playerElement.append(this._$canvasContainer,this._$optionsContainer),this._$canvasHoverPreview.hide(),this._$rangeHoverPreview.hide(),this._data.helper&&this._data.canvas){var ranges=this._data.helper.getCanvasRanges(this._data.canvas);ranges.forEach(function(range){_this._ranges.push(new IIIFComponents.AVComponentObjects.CanvasRange(range))})}this._canvasClockDuration=this._data.canvas.getDuration();var canvasWidth=this._data.canvas.getWidth(),canvasHeight=this._data.canvas.getHeight();canvasWidth?this._canvasWidth=canvasWidth:this._canvasWidth=this.$playerElement.parent().width(),canvasHeight?this._canvasHeight=canvasHeight:this._canvasHeight=this._canvasWidth*this._data.defaultAspectRatio;var that=this,prevClicks=0,prevTimeout=0;this._$prevButton.on("click",function(){prevClicks++,1===prevClicks?(_this._previous(!1),prevTimeout=setTimeout(function(){prevClicks=0,prevTimeout=0},_this._data.doubleClickMS)):(_this._previous(!0),clearTimeout(prevTimeout),prevClicks=0,prevTimeout=0)}),this._$playButton.on("click",function(){_this._isPlaying?_this._pause():_this._play()}),this._$nextButton.on("click",function(){_this._next()}),this._$canvasTimelineContainer.slider({value:0,step:.01,orientation:"horizontal",range:"min",max:that._canvasClockDuration,animate:!1,create:function(evt,ui){},slide:function(evt,ui){that._setCurrentTime(ui.value)},stop:function(evt,ui){}}),this._$canvasTimelineContainer.mouseout(function(){that._$canvasHoverHighlight.width(0),that._$canvasHoverPreview.hide()}),this._$rangeTimelineContainer.mouseout(function(){that._$rangeHoverHighlight.width(0),that._$rangeHoverPreview.hide()}),this._$canvasTimelineContainer.on("mousemove",function(e){_this._updateHoverPreview(e,_this._$canvasTimelineContainer,_this._canvasClockDuration)}),this._$rangeTimelineContainer.on("mousemove",function(e){_this._data.range&&_this._updateHoverPreview(e,_this._$rangeTimelineContainer,_this._data.range.duration?_this._data.range.duration.getLength():0)}),this._contentAnnotations=[];var items=this._data.canvas.getContent();1===items.length&&this._$timelineItemContainer.hide();for(var i=0;ifullWidth&&(left=fullWidth-hoverPreviewWidth,arrowLeft=hoverPreviewWidth-(fullWidth-x)-6),$hoverPreview.css({left:left,top:hoverPreviewHeight*-1+"px"}).show(),$hoverArrow.css({left:arrowLeft})},CanvasInstance.prototype._previous=function(isDouble){this._data.limitToRange?isDouble?this._isNavigationConstrainedToRange()?this._rewind():this.fire(IIIFComponents.AVComponentCanvasInstance.Events.PREVIOUS_RANGE):this._rewind():this._data.range?isDouble?(this.set({range:void 0}),this._rewind()):this.fire(IIIFComponents.AVComponentCanvasInstance.Events.PREVIOUS_RANGE):this._rewind()},CanvasInstance.prototype._next=function(){this._data.limitToRange&&this._isNavigationConstrainedToRange()?this._fastforward():this.fire(IIIFComponents.AVComponentCanvasInstance.Events.NEXT_RANGE)},CanvasInstance.prototype.destroy=function(){window.clearInterval(this._highPriorityInterval),window.clearInterval(this._lowPriorityInterval),window.clearInterval(this._canvasClockInterval)},CanvasInstance.prototype._convertToPercentage=function(pixelValue,maxValue){var percentage=pixelValue/maxValue*100;return percentage},CanvasInstance.prototype._renderMediaElement=function(data){var $mediaElement,_this=this,type=data.type.toString().toLowerCase();switch(type){case"image":$mediaElement=$('');break;case"video":$mediaElement=$('