From ce83cebd9fd733ca1f0af74840670095e3e1cac6 Mon Sep 17 00:00:00 2001 From: edsilv Date: Mon, 24 Oct 2016 16:30:07 +0100 Subject: [PATCH] check label is not null --- dist/iiif-metadata-component.bundle.js | 7 +++++-- dist/iiif-metadata-component.css | 6 ------ dist/iiif-metadata-component.js | 2 +- dist/iiif-metadata-component.min.js | 2 +- examples/css/iiif-metadata-component.css | 6 ------ examples/js/iiif-metadata-component.js | 2 +- examples/js/manifold.bundle.js | 5 ++++- src/MetadataComponent.ts | 2 +- src/css/iiif-metadata-component.less | 3 +-- 9 files changed, 14 insertions(+), 21 deletions(-) diff --git a/dist/iiif-metadata-component.bundle.js b/dist/iiif-metadata-component.bundle.js index 3022411..1766fa9 100644 --- a/dist/iiif-metadata-component.bundle.js +++ b/dist/iiif-metadata-component.bundle.js @@ -2756,7 +2756,10 @@ var Manifesto; TranslationCollection.parse = function (translation, defaultLocale) { var tc = []; var t; - if (_isArray(translation)) { + if (!translation) { + return tc; + } + else if (_isArray(translation)) { for (var i = 0; i < translation.length; i++) { var value = translation[i]; if (_isString(value)) { @@ -17319,4 +17322,4 @@ var Utils; Utils.Urls = Urls; })(Utils || (Utils = {})); -!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.iiifMetadataComponent=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;o
'),this._$metadataItemTemplate=$('
'),this._$metadataItemValueTemplate=$('
'),this._$copyTextTemplate=$('
'+this.options.content.copiedToClipboard+"
"),this._$metadataGroups=$('
'),this._$element.append(this._$metadataGroups),this._$noData=$('
'+this.options.content.noData+"
"),this._$element.append(this._$noData),success},MetadataComponent.prototype._getDefaultOptions=function(){return{aggregateValues:"",canvases:null,canvasDisplayOrder:"",canvasExclude:"",canvasLabels:"",content:{attribution:"Attribution",canvasHeader:"About the canvas",copiedToClipboard:"Copied to clipboard",copyToClipboard:"Copy to clipboard",description:"Description",imageHeader:"About the image",less:"less",license:"License",logo:"Logo",manifestHeader:"About the item",more:"more",noData:"No data to display",rangeHeader:"About the range",sequenceHeader:"About the sequence"},copiedMessageDuration:2e3,copyToClipboardEnabled:!1,helper:null,licenseFormatter:null,limit:4,limitType:IIIFComponents.MetadataComponentOptions.LimitType.LINES,manifestDisplayOrder:"",manifestExclude:"",range:null,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",sanitizer:function(html){return html},showAllLanguages:!1}},MetadataComponent.prototype._getManifestGroup=function(){return this._metadataGroups.en().where(function(x){return x.resource.isManifest()}).first()},MetadataComponent.prototype._getCanvasGroups=function(){return this._metadataGroups.en().where(function(x){return x.resource.isCanvas()}).toArray()},MetadataComponent.prototype.databind=function(){var _this=this;this._$metadataGroups.empty();var options={canvases:this.options.canvases,licenseFormatter:this.options.licenseFormatter,range:this.options.range};if(this._metadataGroups=this.options.helper.getMetadata(options),this.options.manifestDisplayOrder){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._sort(manifestGroup.items,this._readCSV(this.options.manifestDisplayOrder))}if(this.options.canvasDisplayOrder){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._sort(canvasGroup.items,_this._readCSV(_this.options.canvasDisplayOrder))})}if(this.options.canvasLabels&&this._label(this._getCanvasGroups(),this._readCSV(this.options.canvasLabels,!1)),this.options.manifestExclude){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._exclude(manifestGroup.items,this._readCSV(this.options.manifestExclude))}if(this.options.canvasExclude){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._exclude(canvasGroup.items,_this._readCSV(_this.options.canvasExclude))})}return this._metadataGroups.length?(this._$noData.hide(),void this._render()):void this._$noData.show()},MetadataComponent.prototype._sort=function(items,displayOrder){var _this=this,sorted=[],unsorted=items.clone();return $.each(displayOrder,function(index,item){var match=unsorted.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&(sorted.push(match),unsorted.remove(match))}),$.each(unsorted,function(index,item){sorted.push(item)}),sorted},MetadataComponent.prototype._label=function(groups,labels){$.each(groups,function(index,group){group.label=labels[index]})},MetadataComponent.prototype._exclude=function(items,excludeConfig){var _this=this;return $.each(excludeConfig,function(index,item){var match=items.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&items.remove(match)}),items},MetadataComponent.prototype._normalise=function(value){return value?value.toLowerCase().replace(/ /g,""):null},MetadataComponent.prototype._render=function(){var _this=this;$.each(this._metadataGroups,function(index,metadataGroup){var $metadataGroup=_this._buildMetadataGroup(metadataGroup);_this._$metadataGroups.append($metadataGroup),_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.LINES?$metadataGroup.find(".value").toggleExpandTextByLines(_this.options.limit,_this.options.content.less,_this.options.content.more,function(){}):_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.CHARS&&$metadataGroup.find(".value").ellipsisHtmlFixed(_this.options.limit,null)})},MetadataComponent.prototype._buildMetadataGroup=function(metadataGroup){var $metadataGroup=this._$metadataGroupTemplate.clone(),$header=$metadataGroup.find(">.header");if(metadataGroup.resource.isManifest()&&this.options.content.manifestHeader)$header.html(this._sanitize(this.options.content.manifestHeader));else if(metadataGroup.resource.isSequence()&&this.options.content.sequenceHeader)$header.html(this._sanitize(this.options.content.sequenceHeader));else if(metadataGroup.resource.isRange()&&this.options.content.rangeHeader)$header.html(this._sanitize(this.options.content.rangeHeader));else if(metadataGroup.resource.isCanvas()&&(metadataGroup.label||this.options.content.canvasHeader)){var header=metadataGroup.label||this.options.content.canvasHeader;$header.html(this._sanitize(header))}else metadataGroup.resource.isAnnotation()&&this.options.content.imageHeader&&$header.html(this._sanitize(this.options.content.imageHeader));$header.text()||$header.hide();for(var $items=$metadataGroup.find(".items"),i=0;i1)for(var i=0;i");var $value=this._$metadataItemValueTemplate.clone();return $value.html(value),$value.targetBlank(),locale&&this._addReadingDirection($value,locale),$value},MetadataComponent.prototype._addReadingDirection=function($elem,locale){locale=Manifesto.Utils.getInexactLocale(locale);var rtlLanguages=this._readCSV(this.options.rtlLanguageCodes),match=rtlLanguages.en().where(function(x){return x===locale}).toArray().length>0;match&&($elem.prop("dir","rtl"),$elem.addClass("rtl"))},MetadataComponent.prototype._addCopyButton=function($elem,$header){var $copyBtn=this._$copyTextTemplate.clone(),$copiedText=$copyBtn.children();$header.append($copyBtn),Utils.Device.isTouch()?$copyBtn.show():($elem.on("mouseenter",function(){$copyBtn.show()}),$elem.on("mouseleave",function(){$copyBtn.hide()}),$copyBtn.on("mouseleave",function(){$copiedText.hide()}));var that=this;$copyBtn.on("click",function(e){var $this=$(this),$item=$this.closest(".item");that._copyItemValues($this,$item)})},MetadataComponent.prototype._copyItemValues=function($copyButton,$item){for(var $values=$item.find(".value"),values="",i=0;i<$values.length;i++){var value=$($values[i]).text();values+=values.length?"\n"+value:value}Utils.Clipboard.copy(values);var $copiedText=$copyButton.find(".copiedText");$copiedText.show(),setTimeout(function(){$copiedText.hide()},this.options.copiedMessageDuration)},MetadataComponent.prototype._readCSV=function(config,normalise){void 0===normalise&&(normalise=!0);var csv=[];if(config&&(csv=config.split(","),normalise))for(var i=0;i
'),this._$metadataItemTemplate=$('
'),this._$metadataItemValueTemplate=$('
'),this._$copyTextTemplate=$('
'+this.options.content.copiedToClipboard+"
"),this._$metadataGroups=$('
'),this._$element.append(this._$metadataGroups),this._$noData=$('
'+this.options.content.noData+"
"),this._$element.append(this._$noData),success},MetadataComponent.prototype._getDefaultOptions=function(){return{aggregateValues:"",canvases:null,canvasDisplayOrder:"",canvasExclude:"",canvasLabels:"",content:{attribution:"Attribution",canvasHeader:"About the canvas",copiedToClipboard:"Copied to clipboard",copyToClipboard:"Copy to clipboard",description:"Description",imageHeader:"About the image",less:"less",license:"License",logo:"Logo",manifestHeader:"About the item",more:"more",noData:"No data to display",rangeHeader:"About the range",sequenceHeader:"About the sequence"},copiedMessageDuration:2e3,copyToClipboardEnabled:!1,helper:null,licenseFormatter:null,limit:4,limitType:IIIFComponents.MetadataComponentOptions.LimitType.LINES,manifestDisplayOrder:"",manifestExclude:"",range:null,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",sanitizer:function(html){return html},showAllLanguages:!1}},MetadataComponent.prototype._getManifestGroup=function(){return this._metadataGroups.en().where(function(x){return x.resource.isManifest()}).first()},MetadataComponent.prototype._getCanvasGroups=function(){return this._metadataGroups.en().where(function(x){return x.resource.isCanvas()}).toArray()},MetadataComponent.prototype.databind=function(){var _this=this;this._$metadataGroups.empty();var options={canvases:this.options.canvases,licenseFormatter:this.options.licenseFormatter,range:this.options.range};if(this._metadataGroups=this.options.helper.getMetadata(options),this.options.manifestDisplayOrder){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._sort(manifestGroup.items,this._readCSV(this.options.manifestDisplayOrder))}if(this.options.canvasDisplayOrder){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._sort(canvasGroup.items,_this._readCSV(_this.options.canvasDisplayOrder))})}if(this.options.canvasLabels&&this._label(this._getCanvasGroups(),this._readCSV(this.options.canvasLabels,!1)),this.options.manifestExclude){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._exclude(manifestGroup.items,this._readCSV(this.options.manifestExclude))}if(this.options.canvasExclude){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._exclude(canvasGroup.items,_this._readCSV(_this.options.canvasExclude))})}return this._metadataGroups.length?(this._$noData.hide(),void this._render()):void this._$noData.show()},MetadataComponent.prototype._sort=function(items,displayOrder){var _this=this,sorted=[],unsorted=items.clone();return $.each(displayOrder,function(index,item){var match=unsorted.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&(sorted.push(match),unsorted.remove(match))}),$.each(unsorted,function(index,item){sorted.push(item)}),sorted},MetadataComponent.prototype._label=function(groups,labels){$.each(groups,function(index,group){group.label=labels[index]})},MetadataComponent.prototype._exclude=function(items,excludeConfig){var _this=this;return $.each(excludeConfig,function(index,item){var match=items.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&items.remove(match)}),items},MetadataComponent.prototype._normalise=function(value){return value?value.toLowerCase().replace(/ /g,""):null},MetadataComponent.prototype._render=function(){var _this=this;$.each(this._metadataGroups,function(index,metadataGroup){var $metadataGroup=_this._buildMetadataGroup(metadataGroup);_this._$metadataGroups.append($metadataGroup),_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.LINES?$metadataGroup.find(".value").toggleExpandTextByLines(_this.options.limit,_this.options.content.less,_this.options.content.more,function(){}):_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.CHARS&&$metadataGroup.find(".value").ellipsisHtmlFixed(_this.options.limit,null)})},MetadataComponent.prototype._buildMetadataGroup=function(metadataGroup){var $metadataGroup=this._$metadataGroupTemplate.clone(),$header=$metadataGroup.find(">.header");if(metadataGroup.resource.isManifest()&&this.options.content.manifestHeader)$header.html(this._sanitize(this.options.content.manifestHeader));else if(metadataGroup.resource.isSequence()&&this.options.content.sequenceHeader)$header.html(this._sanitize(this.options.content.sequenceHeader));else if(metadataGroup.resource.isRange()&&this.options.content.rangeHeader)$header.html(this._sanitize(this.options.content.rangeHeader));else if(metadataGroup.resource.isCanvas()&&(metadataGroup.label||this.options.content.canvasHeader)){var header=metadataGroup.label||this.options.content.canvasHeader;$header.html(this._sanitize(header))}else metadataGroup.resource.isAnnotation()&&this.options.content.imageHeader&&$header.html(this._sanitize(this.options.content.imageHeader));$header.text()||$header.hide();for(var $items=$metadataGroup.find(".items"),i=0;i1)for(var i=0;i");var $value=this._$metadataItemValueTemplate.clone();return $value.html(value),$value.targetBlank(),locale&&this._addReadingDirection($value,locale),$value},MetadataComponent.prototype._addReadingDirection=function($elem,locale){locale=Manifesto.Utils.getInexactLocale(locale);var rtlLanguages=this._readCSV(this.options.rtlLanguageCodes),match=rtlLanguages.en().where(function(x){return x===locale}).toArray().length>0;match&&($elem.prop("dir","rtl"),$elem.addClass("rtl"))},MetadataComponent.prototype._addCopyButton=function($elem,$header){var $copyBtn=this._$copyTextTemplate.clone(),$copiedText=$copyBtn.children();$header.append($copyBtn),Utils.Device.isTouch()?$copyBtn.show():($elem.on("mouseenter",function(){$copyBtn.show()}),$elem.on("mouseleave",function(){$copyBtn.hide()}),$copyBtn.on("mouseleave",function(){$copiedText.hide()}));var that=this;$copyBtn.on("click",function(e){var $this=$(this),$item=$this.closest(".item");that._copyItemValues($this,$item)})},MetadataComponent.prototype._copyItemValues=function($copyButton,$item){for(var $values=$item.find(".value"),values="",i=0;i<$values.length;i++){var value=$($values[i]).text();values+=values.length?"\n"+value:value}Utils.Clipboard.copy(values);var $copiedText=$copyButton.find(".copiedText");$copiedText.show(),setTimeout(function(){$copiedText.hide()},this.options.copiedMessageDuration)},MetadataComponent.prototype._readCSV=function(config,normalise){void 0===normalise&&(normalise=!0);var csv=[];if(config&&(csv=config.split(","),normalise))for(var i=0;i
'),this._$metadataItemTemplate=$('
'),this._$metadataItemValueTemplate=$('
'),this._$copyTextTemplate=$('
'+this.options.content.copiedToClipboard+"
"),this._$metadataGroups=$('
'),this._$element.append(this._$metadataGroups),this._$noData=$('
'+this.options.content.noData+"
"),this._$element.append(this._$noData),success},MetadataComponent.prototype._getDefaultOptions=function(){return{aggregateValues:"",canvases:null,canvasDisplayOrder:"",canvasExclude:"",canvasLabels:"",content:{attribution:"Attribution",canvasHeader:"About the canvas",copiedToClipboard:"Copied to clipboard",copyToClipboard:"Copy to clipboard",description:"Description",imageHeader:"About the image",less:"less",license:"License",logo:"Logo",manifestHeader:"About the item",more:"more",noData:"No data to display",rangeHeader:"About the range",sequenceHeader:"About the sequence"},copiedMessageDuration:2e3,copyToClipboardEnabled:!1,helper:null,licenseFormatter:null,limit:4,limitType:IIIFComponents.MetadataComponentOptions.LimitType.LINES,manifestDisplayOrder:"",manifestExclude:"",range:null,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",sanitizer:function(html){return html},showAllLanguages:!1}},MetadataComponent.prototype._getManifestGroup=function(){return this._metadataGroups.en().where(function(x){return x.resource.isManifest()}).first()},MetadataComponent.prototype._getCanvasGroups=function(){return this._metadataGroups.en().where(function(x){return x.resource.isCanvas()}).toArray()},MetadataComponent.prototype.databind=function(){var _this=this;this._$metadataGroups.empty();var options={canvases:this.options.canvases,licenseFormatter:this.options.licenseFormatter,range:this.options.range};if(this._metadataGroups=this.options.helper.getMetadata(options),this.options.manifestDisplayOrder){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._sort(manifestGroup.items,this._readCSV(this.options.manifestDisplayOrder))}if(this.options.canvasDisplayOrder){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._sort(canvasGroup.items,_this._readCSV(_this.options.canvasDisplayOrder))})}if(this.options.canvasLabels&&this._label(this._getCanvasGroups(),this._readCSV(this.options.canvasLabels,!1)),this.options.manifestExclude){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._exclude(manifestGroup.items,this._readCSV(this.options.manifestExclude))}if(this.options.canvasExclude){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._exclude(canvasGroup.items,_this._readCSV(_this.options.canvasExclude))})}return this._metadataGroups.length?(this._$noData.hide(),void this._render()):void this._$noData.show()},MetadataComponent.prototype._sort=function(items,displayOrder){var _this=this,sorted=[],unsorted=items.clone();return $.each(displayOrder,function(index,item){var match=unsorted.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&(sorted.push(match),unsorted.remove(match))}),$.each(unsorted,function(index,item){sorted.push(item)}),sorted},MetadataComponent.prototype._label=function(groups,labels){$.each(groups,function(index,group){group.label=labels[index]})},MetadataComponent.prototype._exclude=function(items,excludeConfig){var _this=this;return $.each(excludeConfig,function(index,item){var match=items.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&items.remove(match)}),items},MetadataComponent.prototype._normalise=function(value){return value?value.toLowerCase().replace(/ /g,""):null},MetadataComponent.prototype._render=function(){var _this=this;$.each(this._metadataGroups,function(index,metadataGroup){var $metadataGroup=_this._buildMetadataGroup(metadataGroup);_this._$metadataGroups.append($metadataGroup),_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.LINES?$metadataGroup.find(".value").toggleExpandTextByLines(_this.options.limit,_this.options.content.less,_this.options.content.more,function(){}):_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.CHARS&&$metadataGroup.find(".value").ellipsisHtmlFixed(_this.options.limit,null)})},MetadataComponent.prototype._buildMetadataGroup=function(metadataGroup){var $metadataGroup=this._$metadataGroupTemplate.clone(),$header=$metadataGroup.find(">.header");if(metadataGroup.resource.isManifest()&&this.options.content.manifestHeader)$header.html(this._sanitize(this.options.content.manifestHeader));else if(metadataGroup.resource.isSequence()&&this.options.content.sequenceHeader)$header.html(this._sanitize(this.options.content.sequenceHeader));else if(metadataGroup.resource.isRange()&&this.options.content.rangeHeader)$header.html(this._sanitize(this.options.content.rangeHeader));else if(metadataGroup.resource.isCanvas()&&(metadataGroup.label||this.options.content.canvasHeader)){var header=metadataGroup.label||this.options.content.canvasHeader;$header.html(this._sanitize(header))}else metadataGroup.resource.isAnnotation()&&this.options.content.imageHeader&&$header.html(this._sanitize(this.options.content.imageHeader));$header.text()||$header.hide();for(var $items=$metadataGroup.find(".items"),i=0;i1)for(var i=0;i");var $value=this._$metadataItemValueTemplate.clone();return $value.html(value),$value.targetBlank(),locale&&this._addReadingDirection($value,locale),$value},MetadataComponent.prototype._addReadingDirection=function($elem,locale){locale=Manifesto.Utils.getInexactLocale(locale);var rtlLanguages=this._readCSV(this.options.rtlLanguageCodes),match=rtlLanguages.en().where(function(x){return x===locale}).toArray().length>0;match&&($elem.prop("dir","rtl"),$elem.addClass("rtl"))},MetadataComponent.prototype._addCopyButton=function($elem,$header){var $copyBtn=this._$copyTextTemplate.clone(),$copiedText=$copyBtn.children();$header.append($copyBtn),Utils.Device.isTouch()?$copyBtn.show():($elem.on("mouseenter",function(){$copyBtn.show()}),$elem.on("mouseleave",function(){$copyBtn.hide()}),$copyBtn.on("mouseleave",function(){$copiedText.hide()}));var that=this;$copyBtn.on("click",function(e){var $this=$(this),$item=$this.closest(".item");that._copyItemValues($this,$item)})},MetadataComponent.prototype._copyItemValues=function($copyButton,$item){for(var $values=$item.find(".value"),values="",i=0;i<$values.length;i++){var value=$($values[i]).text();values+=values.length?"\n"+value:value}Utils.Clipboard.copy(values);var $copiedText=$copyButton.find(".copiedText");$copiedText.show(),setTimeout(function(){$copiedText.hide()},this.options.copiedMessageDuration)},MetadataComponent.prototype._readCSV=function(config,normalise){void 0===normalise&&(normalise=!0);var csv=[];if(config&&(csv=config.split(","),normalise))for(var i=0;i
'),this._$metadataItemTemplate=$('
'),this._$metadataItemValueTemplate=$('
'),this._$copyTextTemplate=$('
'+this.options.content.copiedToClipboard+"
"),this._$metadataGroups=$('
'),this._$element.append(this._$metadataGroups),this._$noData=$('
'+this.options.content.noData+"
"),this._$element.append(this._$noData),success},MetadataComponent.prototype._getDefaultOptions=function(){return{aggregateValues:"",canvases:null,canvasDisplayOrder:"",canvasExclude:"",canvasLabels:"",content:{attribution:"Attribution",canvasHeader:"About the canvas",copiedToClipboard:"Copied to clipboard",copyToClipboard:"Copy to clipboard",description:"Description",imageHeader:"About the image",less:"less",license:"License",logo:"Logo",manifestHeader:"About the item",more:"more",noData:"No data to display",rangeHeader:"About the range",sequenceHeader:"About the sequence"},copiedMessageDuration:2e3,copyToClipboardEnabled:!1,helper:null,licenseFormatter:null,limit:4,limitType:IIIFComponents.MetadataComponentOptions.LimitType.LINES,manifestDisplayOrder:"",manifestExclude:"",range:null,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",sanitizer:function(html){return html},showAllLanguages:!1}},MetadataComponent.prototype._getManifestGroup=function(){return this._metadataGroups.en().where(function(x){return x.resource.isManifest()}).first()},MetadataComponent.prototype._getCanvasGroups=function(){return this._metadataGroups.en().where(function(x){return x.resource.isCanvas()}).toArray()},MetadataComponent.prototype.databind=function(){var _this=this;this._$metadataGroups.empty();var options={canvases:this.options.canvases,licenseFormatter:this.options.licenseFormatter,range:this.options.range};if(this._metadataGroups=this.options.helper.getMetadata(options),this.options.manifestDisplayOrder){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._sort(manifestGroup.items,this._readCSV(this.options.manifestDisplayOrder))}if(this.options.canvasDisplayOrder){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._sort(canvasGroup.items,_this._readCSV(_this.options.canvasDisplayOrder))})}if(this.options.canvasLabels&&this._label(this._getCanvasGroups(),this._readCSV(this.options.canvasLabels,!1)),this.options.manifestExclude){var manifestGroup=this._getManifestGroup();manifestGroup.items=this._exclude(manifestGroup.items,this._readCSV(this.options.manifestExclude))}if(this.options.canvasExclude){var canvasGroups=this._getCanvasGroups();$.each(canvasGroups,function(index,canvasGroup){canvasGroup.items=_this._exclude(canvasGroup.items,_this._readCSV(_this.options.canvasExclude))})}return this._metadataGroups.length?(this._$noData.hide(),void this._render()):void this._$noData.show()},MetadataComponent.prototype._sort=function(items,displayOrder){var _this=this,sorted=[],unsorted=items.clone();return $.each(displayOrder,function(index,item){var match=unsorted.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&(sorted.push(match),unsorted.remove(match))}),$.each(unsorted,function(index,item){sorted.push(item)}),sorted},MetadataComponent.prototype._label=function(groups,labels){$.each(groups,function(index,group){group.label=labels[index]})},MetadataComponent.prototype._exclude=function(items,excludeConfig){var _this=this;return $.each(excludeConfig,function(index,item){var match=items.en().where(function(x){return _this._normalise(x.getLabel())===item}).first();match&&items.remove(match)}),items},MetadataComponent.prototype._normalise=function(value){return value?value.toLowerCase().replace(/ /g,""):null},MetadataComponent.prototype._render=function(){var _this=this;$.each(this._metadataGroups,function(index,metadataGroup){var $metadataGroup=_this._buildMetadataGroup(metadataGroup);_this._$metadataGroups.append($metadataGroup),_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.LINES?$metadataGroup.find(".value").toggleExpandTextByLines(_this.options.limit,_this.options.content.less,_this.options.content.more,function(){}):_this.options.limitType===IIIFComponents.MetadataComponentOptions.LimitType.CHARS&&$metadataGroup.find(".value").ellipsisHtmlFixed(_this.options.limit,null)})},MetadataComponent.prototype._buildMetadataGroup=function(metadataGroup){var $metadataGroup=this._$metadataGroupTemplate.clone(),$header=$metadataGroup.find(">.header");if(metadataGroup.resource.isManifest()&&this.options.content.manifestHeader)$header.html(this._sanitize(this.options.content.manifestHeader));else if(metadataGroup.resource.isSequence()&&this.options.content.sequenceHeader)$header.html(this._sanitize(this.options.content.sequenceHeader));else if(metadataGroup.resource.isRange()&&this.options.content.rangeHeader)$header.html(this._sanitize(this.options.content.rangeHeader));else if(metadataGroup.resource.isCanvas()&&(metadataGroup.label||this.options.content.canvasHeader)){var header=metadataGroup.label||this.options.content.canvasHeader;$header.html(this._sanitize(header))}else metadataGroup.resource.isAnnotation()&&this.options.content.imageHeader&&$header.html(this._sanitize(this.options.content.imageHeader));$header.text()||$header.hide();for(var $items=$metadataGroup.find(".items"),i=0;i1)for(var i=0;i");var $value=this._$metadataItemValueTemplate.clone();return $value.html(value),$value.targetBlank(),locale&&this._addReadingDirection($value,locale),$value},MetadataComponent.prototype._addReadingDirection=function($elem,locale){locale=Manifesto.Utils.getInexactLocale(locale);var rtlLanguages=this._readCSV(this.options.rtlLanguageCodes),match=rtlLanguages.en().where(function(x){return x===locale}).toArray().length>0;match&&($elem.prop("dir","rtl"),$elem.addClass("rtl"))},MetadataComponent.prototype._addCopyButton=function($elem,$header){var $copyBtn=this._$copyTextTemplate.clone(),$copiedText=$copyBtn.children();$header.append($copyBtn),Utils.Device.isTouch()?$copyBtn.show():($elem.on("mouseenter",function(){$copyBtn.show()}),$elem.on("mouseleave",function(){$copyBtn.hide()}),$copyBtn.on("mouseleave",function(){$copiedText.hide()}));var that=this;$copyBtn.on("click",function(e){var $this=$(this),$item=$this.closest(".item");that._copyItemValues($this,$item)})},MetadataComponent.prototype._copyItemValues=function($copyButton,$item){for(var $values=$item.find(".value"),values="",i=0;i<$values.length;i++){var value=$($values[i]).text();values+=values.length?"\n"+value:value}Utils.Clipboard.copy(values);var $copiedText=$copyButton.find(".copiedText");$copiedText.show(),setTimeout(function(){$copiedText.hide()},this.options.copiedMessageDuration)},MetadataComponent.prototype._readCSV=function(config,normalise){void 0===normalise&&(normalise=!0);var csv=[];if(config&&(csv=config.split(","),normalise))for(var i=0;i