2017-01-27 16:07:14 -07:00
|
|
|
define(["dialogHelper","require","layoutManager","globalize","userSettings","connectionManager","loading","focusManager","dom","apphost","emby-select","listViewStyle","paper-icon-button-light","css!./../formdialog","material-icons","css!./subtitleeditor","emby-button"],function(dialogHelper,require,layoutManager,globalize,userSettings,connectionManager,loading,focusManager,dom,appHost){"use strict";function downloadRemoteSubtitles(context,id){var url="Items/"+currentItem.Id+"/RemoteSearch/Subtitles/"+id,apiClient=connectionManager.getApiClient(currentItem.ServerId);apiClient.ajax({type:"POST",url:apiClient.getUrl(url)}).then(function(){hasChanges=!0,require(["toast"],function(toast){toast(globalize.translate("sharedcomponents#MessageDownloadQueued"))}),focusManager.autoFocus(context)})}function deleteLocalSubtitle(context,index){var msg=globalize.translate("sharedcomponents#MessageAreYouSureDeleteSubtitles");require(["confirm"],function(confirm){confirm({title:globalize.translate("sharedcomponents#ConfirmDeletion"),text:msg,confirmText:globalize.translate("sharedcomponents#Delete"),primary:"cancel"}).then(function(){loading.show();var itemId=currentItem.Id,url="Videos/"+itemId+"/Subtitles/"+index,apiClient=connectionManager.getApiClient(currentItem.ServerId);apiClient.ajax({type:"DELETE",url:apiClient.getUrl(url)}).then(function(){hasChanges=!0,reload(context,apiClient,itemId)})})})}function fillSubtitleList(context,item){var streams=item.MediaStreams||[],subs=streams.filter(function(s){return"Subtitle"===s.Type}),html="";subs.length&&(html+="<h1>"+globalize.translate("sharedcomponents#MySubtitles")+"</h1>",html+=layoutManager.tv?'<div class="paperList paperList-clear">':'<div class="paperList">',html+=subs.map(function(s){var itemHtml="",tagName=layoutManager.tv?"button":"div",className=layoutManager.tv&&s.Path?"listItem btnDelete":"listItem";return layoutManager.tv&&(className+=" listItem-focusscale listItem-button"),className+=" listItem-noborder",itemHtml+="<"+tagName+' class="'+className+'" data-index="'+s.Index+'">',itemHtml+='<i class="listItemIcon md-icon">closed_caption</i>',itemHtml+='<div class="listItemBody two-line">',itemHtml+="<div>",itemHtml+=s.DisplayTitle||"",itemHtml+="</div>",s.Path&&(itemHtml+='<div class="secondary listItemBodyText">'+s.Path+"</div>"),itemHtml+="</a>",itemHtml+="</div>",layoutManager.tv||s.Path&&(itemHtml+='<button is="paper-icon-button-light" data-index="'+s.Index+'" title="'+globalize.translate("sharedcomponents#Delete")+'" class="btnDelete listItemButton"><i class="md-icon">delete</i></button>'),itemHtml+="</"+tagName+">"}).join(""),html+="</div>");var elem=context.querySelector(".subtitleList");subs.length?elem.classList.remove("hide"):elem.classList.add("hide"),elem.innerHTML=html}function fillLanguages(context,apiClient,languages){var selectLanguage=context.querySelector("#selectLanguage");selectLanguage.innerHTML=languages.map(function(l){return'<option value="'+l.ThreeLetterISOLanguageName+'">'+l.DisplayName+"</option>"});var lastLanguage=userSettings.get("subtitleeditor-language");lastLanguage?selectLanguage.value=lastLanguage:apiClient.getCurrentUser().then(function(user){var lang=user.Configuration.SubtitleLanguagePreference;lang&&(selectLanguage.value=lang)})}function renderSearchResults(context,results){var lastProvider="",html="";if(!results.length)return context.querySelector(".noSearchResults").classList.remove("hide"),context.querySelector(".subtitleResults").innerHTML="",void loading.hide();context.querySelector(".noSearchResults").classList.add("hide");for(var moreIcon="dots-horiz"===appHost.moreIcon?"":"",i=0,length=results.length;i<length;i++){var result=results[i],provider=result.ProviderName;provider!==lastProvider&&(i>0&&(html+="</div>"),html+="<h1>"+provider+"</h1>",html+=layoutManager.tv?'<div class="paperList paperList-clear">':'<div class="paperList">',lastProvider=provider);var tagName=layoutManager.tv?"button":"div",className=layoutManager.tv?"listItem btnOptions":"listItem";layoutManager.tv&&(className+=" listItem-focusscale listItem-b
|