2017-02-08 12:52:49 -07:00
|
|
|
define(["dialogHelper","connectionManager","loading","dom","layoutManager","focusManager","globalize","scrollHelper","imageLoader","require","cardStyle","formDialogStyle","emby-button","paper-icon-button-light","css!./imageeditor"],function(dialogHelper,connectionManager,loading,dom,layoutManager,focusManager,globalize,scrollHelper,imageLoader,require){"use strict";function getBaseRemoteOptions(){var options={};return options.itemId=currentItem.Id,options}function reload(page,item,focusContext){loading.show();var apiClient;item?(apiClient=connectionManager.getApiClient(item.ServerId),reloadItem(page,item,apiClient,focusContext)):(apiClient=connectionManager.getApiClient(currentItem.ServerId),apiClient.getItem(apiClient.getCurrentUserId(),currentItem.Id).then(function(item){reloadItem(page,item,apiClient,focusContext)}))}function addListeners(container,className,eventName,fn){container.addEventListener(eventName,function(e){var elem=dom.parentWithClass(e.target,className);elem&&fn.call(elem,e)})}function reloadItem(page,item,apiClient,focusContext){currentItem=item,apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function(providers){for(var btnBrowseAllImages=page.querySelectorAll(".btnBrowseAllImages"),i=0,length=btnBrowseAllImages.length;i<length;i++)providers.length?btnBrowseAllImages[i].classList.remove("hide"):btnBrowseAllImages[i].classList.add("hide");apiClient.getItemImageInfos(currentItem.Id).then(function(imageInfos){renderStandardImages(page,apiClient,item,imageInfos,providers),renderBackdrops(page,apiClient,item,imageInfos,providers),renderScreenshots(page,apiClient,item,imageInfos,providers),loading.hide(),layoutManager.tv&&focusManager.autoFocus(focusContext||page)})})}function getImageUrl(item,apiClient,type,index,options){return options=options||{},options.type=type,options.index=index,"Backdrop"===type?options.tag=item.BackdropImageTags[index]:"Screenshot"===type?options.tag=item.ScreenshotImageTags[index]:"Primary"===type?options.tag=item.PrimaryImageTag||item.ImageTags[type]:options.tag=item.ImageTags[type],apiClient.getScaledImageUrl(item.Id||item.ItemId,options)}function getCardHtml(image,index,numImages,apiClient,imageProviders,imageSize,tagName,enableFooterButtons){var html="",cssClass="card scalableCard imageEditorCard",cardBoxCssClass="cardBox visualCardBox";cssClass+=" backdropCard backdropCard-scalable","button"===tagName?(cssClass+=" card-focusscale btnImageCard",cardBoxCssClass+=" cardBox-focustransform",html+='<button type="button" class="'+cssClass+'"'):html+='<div class="'+cssClass+'"',html+=' data-id="'+currentItem.Id+'" data-serverid="'+apiClient.serverId()+'" data-index="'+index+'" data-numimages="'+numImages+'" data-imagetype="'+image.ImageType+'" data-providers="'+imageProviders.length+'"',html+=">",html+='<div class="'+cardBoxCssClass+'">',html+='<div class="cardScalable visualCardBox-cardScalable" style="background-color:transparent;">',html+='<div class="cardPadder-backdrop"></div>',html+='<div class="cardContent">';var imageUrl=getImageUrl(currentItem,apiClient,image.ImageType,image.ImageIndex,{maxWidth:imageSize});return html+='<div class="cardImageContainer" style="background-image:url(\''+imageUrl+"');background-position:center bottom;\"></div>",html+="</div>",html+="</div>",html+='<div class="cardFooter visualCardBox-cardFooter">',html+='<h3 class="cardText cardTextCentered" style="margin:0;">'+image.ImageType+"</h3>",html+='<div class="cardText cardText-secondary cardTextCentered">',html+=image.Width&&image.Height?image.Width+" X "+image.Height:" ",html+="</div>",enableFooterButtons&&(html+='<div class="cardText cardTextCentered">',"Backdrop"===image.ImageType||"Screenshot"===image.ImageType?(html+=index>0?'<button type="button" is="paper-icon-button-light" class="btnMoveImage autoSize" data-imagetype="'+image.ImageType+'" data-index="'+image.ImageIndex+'" data-newindex="'+(image.ImageIndex-1)+'" title="'+globalize.translate("sharedcomponents#MoveLeft")+'"><i class="md-icon">chevron_left</i></button>':'<button type="button" is="paper-icon-button-light" clas
|