2017-11-01 11:35:02 -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)})},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")}},showLayoutMenu:function(button,currentLayout,views){var dispatchEvent=!0;views||(dispatchEvent=!1,views=button.getAttribute("data-layouts"),views=views?views.split(","):["List","Poster","PosterCard","Thumb","ThumbCard"]);var menuItems=views.map(function(v){return{name:Globalize.translate("Option"+v),id:v,selected:currentLayout==v}});require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:button,callback:function(id){button.dispatchEvent(new CustomEvent("layoutchange",{detail:{viewStyle:id},bubbles:!0,cancelable:!1})),dispatchEvent||window.$&&$(button).trigger("layoutchange",[id])}})})},getQueryPagingHtml:function(options){var startIndex=options.startIndex,limit=options.limit,totalRecordCount=options.totalRecordCount;if(limit&&options.updatePageSizeSetting!==!1)try{appSettings.set(options.pageSizeKey||pageSizeKey,limit)}catch(e){}var html="",recordsEnd=Math.min(startIndex+limit,totalRecordCount),showControls=limit<totalRecordCount;if(html+='<div class="listPaging">',showControls){html+='<span style="vertical-align:middle;">';var startAtDisplay=totalRecordCount?startIndex+1:0;html+=startAtDisplay+"-"+recordsEnd+" of "+totalRecordCount,html+="</span>"}return(showControls||options.viewButton||options.filterButton||options.sortButton||options.addLayoutButton)&&(html+='<div style="display:inline-block;">',showControls&&(html+='<button is="paper-icon-button-light" class="btnPreviousPage autoSize" '+(startIndex?"":"disabled")+'><i class="md-icon"></i></button>',html+='<button is="paper-icon-button-light" class="btnNextPage autoSize" '+(startIndex+limit>=totalRecordCount?"disabled":"")+'><i class="md-icon"></i></button>'),options.addLayoutButton&&(html+='<button is="paper-icon-button-light" title="'+Globalize.translate("ButtonSelectView")+'" class="btnChangeLayout autoSize" data-layouts="'+(options.layouts||"")+'" onclick="LibraryBrowser.showLayoutMenu(this, \''+(options.currentLayout||"")+'\');"><i class="md-icon"></i></button>'),options.sortButton&&(html+='<button is="paper-icon-button-light" class="btnSort autoSize" title="'+Globalize.translate("ButtonSort")+'"><i class="md-icon"></i></button>'),options.filterButton&&(html+='<button is="paper-icon-button-light" class="btnFilter autoSize" title="'+Globalize.translate("ButtonFilter")+'"><i class="md-icon"></i></button>'),html+="</div>"),html+="</div>"},showSortMenu:function(options){require(["dialogHelper","emby-radio"],function(dialogHelper){function onSortByCha
|