2017-10-17 12:48:17 -07:00
|
|
|
define(["appSettings","dom","browser","datetime","appRouter","events","scrollStyles"],function(appSettings,dom,browser,datetime,appRouter,events){"use strict";var pageSizeKey="pagesize_v4",libraryBrowser={getDefaultPageSize:function(key,defaultValue){return 100},getSavedQueryKey:function(modifier){return window.location.href.split("#")[0]+(modifier||"")},loadSavedQueryValues:function(key,query){var values=appSettings.get(key+"_"+Dashboard.getCurrentUserId());return values?(values=JSON.parse(values),Object.assign(query,values)):query},saveQueryValues:function(key,query){var values={};query.SortBy&&(values.SortBy=query.SortBy),query.SortOrder&&(values.SortOrder=query.SortOrder);try{appSettings.set(key+"_"+Dashboard.getCurrentUserId(),JSON.stringify(values))}catch(e){}},saveViewSetting:function(key,value){try{appSettings.set(key+"_"+Dashboard.getCurrentUserId()+"_view",value)}catch(e){}},getSavedView:function(key){var val=appSettings.get(key+"_"+Dashboard.getCurrentUserId()+"_view");return val},getSavedViewSetting:function(key){return new Promise(function(resolve,reject){var val=libraryBrowser.getSavedView(key);resolve(val)})},getArtistLinksHtml:function(artists,serverId,cssClass){var html=[];cssClass=cssClass?cssClass+" button-link":"button-link";for(var i=0,length=artists.length;i<length;i++){var artist=artists[i],css=cssClass?' class="'+cssClass+'"':"";html.push("<a"+css+' is="emby-linkbutton" href="itemdetails.html?serverId='+serverId+"&id="+artist.Id+'">'+artist.Name+"</a>")}return html=html.join(" / ")},getListItemInfo:function(elem){for(var elemWithAttributes=elem;!elemWithAttributes.getAttribute("data-id");)elemWithAttributes=elemWithAttributes.parentNode;var itemId=elemWithAttributes.getAttribute("data-id"),index=elemWithAttributes.getAttribute("data-index"),mediaType=elemWithAttributes.getAttribute("data-mediatype");return{id:itemId,index:index,mediaType:mediaType,context:elemWithAttributes.getAttribute("data-context")}},renderName:function(item,nameElem,linkToElement,context){require(["itemHelper"],function(itemHelper){var name=itemHelper.getDisplayName(item,{includeParentInfo:!1});linkToElement?nameElem.innerHTML='<a class="detailPageParentLink button-link" is="emby-linkbutton" href="'+appRouter.getRouteUrl(item,{context:context})+'">'+name+"</a>":nameElem.innerHTML=name})},renderParentName:function(item,parentNameElem,context){var html=[],contextParam=context?"&context="+context:"";item.AlbumArtists?html.push(libraryBrowser.getArtistLinksHtml(item.AlbumArtists,item.ServerId,"detailPageParentLink")):item.ArtistItems&&item.ArtistItems.length&&"MusicVideo"==item.Type?html.push(libraryBrowser.getArtistLinksHtml(item.ArtistItems,item.ServerId,"detailPageParentLink")):item.SeriesName&&"Episode"==item.Type?html.push('<a class="detailPageParentLink button-link" is="emby-linkbutton" href="itemdetails.html?id='+item.SeriesId+contextParam+'">'+item.SeriesName+"</a>"):(item.IsSeries||item.EpisodeTitle)&&html.push(item.Name),item.SeriesName&&"Season"==item.Type?html.push('<a class="detailPageParentLink button-link" is="emby-linkbutton" href="itemdetails.html?id='+item.SeriesId+contextParam+'">'+item.SeriesName+"</a>"):null!=item.ParentIndexNumber&&"Episode"==item.Type?html.push('<a class="detailPageParentLink button-link" is="emby-linkbutton" href="itemdetails.html?id='+item.SeasonId+contextParam+'">'+item.SeasonName+"</a>"):null!=item.ParentIndexNumber&&item.IsSeries?html.push(item.SeasonName||"S"+item.ParentIndexNumber):item.Album&&"Audio"==item.Type&&(item.AlbumId||item.ParentId)?html.push('<a class="detailPageParentLink button-link" is="emby-linkbutton" href="itemdetails.html?id='+(item.AlbumId||item.ParentId)+contextParam+'">'+item.Album+"</a>"):item.Album&&"MusicVideo"==item.Type&&item.AlbumId?html.push('<a class="detailPageParentLink button-link" is="emby-linkbutton" href="itemdetails.html?id='+item.AlbumId+contextParam+'">'+item.Album+"</a>"):item.Album&&html.push(item.Album),html.length?(parentNameElem.classList.remove("hide"),parentNameElem.innerHTML=html.join(" - ")):parentNameElem.classList.add("hide")},showLay
|