2017-08-06 15:59:00 -07:00
|
|
|
define(["jQuery","apphost","scripts/taskbutton","loading","libraryMenu","globalize","dom","indicators","cardStyle","emby-itemrefreshindicator"],function($,appHost,taskButton,loading,libraryMenu,globalize,dom,indicators){"use strict";function changeCollectionType(page,virtualFolder){require(["alert"],function(alert){alert({title:globalize.translate("HeaderChangeFolderType"),text:globalize.translate("HeaderChangeFolderTypeHelp")})})}function addVirtualFolder(page){require(["medialibrarycreator"],function(medialibrarycreator){(new medialibrarycreator).show({collectionTypeOptions:getCollectionTypeOptions().filter(function(f){return!f.hidden}),refresh:shouldRefreshLibraryAfterChanges(page)}).then(function(hasChanges){hasChanges&&reloadLibrary(page)})})}function editVirtualFolder(page,virtualFolder){require(["medialibraryeditor"],function(medialibraryeditor){(new medialibraryeditor).show({refresh:shouldRefreshLibraryAfterChanges(page),library:virtualFolder}).then(function(hasChanges){hasChanges&&reloadLibrary(page)})})}function deleteVirtualFolder(page,virtualFolder){var msg=globalize.translate("MessageAreYouSureYouWishToRemoveMediaFolder");virtualFolder.Locations.length&&(msg+="<br/><br/>"+globalize.translate("MessageTheFollowingLocationWillBeRemovedFromLibrary")+"<br/><br/>",msg+=virtualFolder.Locations.join("<br/>")),require(["confirm"],function(confirm){confirm(msg,globalize.translate("HeaderRemoveMediaFolder")).then(function(){var refreshAfterChange=shouldRefreshLibraryAfterChanges(page);ApiClient.removeVirtualFolder(virtualFolder.Name,refreshAfterChange).then(function(){reloadLibrary(page)})})})}function refreshVirtualFolder(page,virtualFolder){require(["refreshDialog"],function(refreshDialog){new refreshDialog({itemIds:[virtualFolder.ItemId],serverId:ApiClient.serverId(),mode:"scan"}).show()})}function renameVirtualFolder(page,virtualFolder){require(["prompt"],function(prompt){prompt({label:globalize.translate("LabelNewName"),confirmText:globalize.translate("ButtonRename")}).then(function(newName){if(newName&&newName!=virtualFolder.Name){var refreshAfterChange=shouldRefreshLibraryAfterChanges(page);ApiClient.renameVirtualFolder(virtualFolder.Name,newName,refreshAfterChange).then(function(){reloadLibrary(page)})}})})}function showCardMenu(page,elem,virtualFolders){var card=dom.parentWithClass(elem,"card"),index=parseInt(card.getAttribute("data-index")),virtualFolder=virtualFolders[index],menuItems=[];menuItems.push({name:globalize.translate("ButtonChangeContentType"),id:"changetype",ironIcon:"videocam"}),menuItems.push({name:globalize.translate("ButtonEditImages"),id:"editimages",ironIcon:"photo"}),menuItems.push({name:globalize.translate("ButtonManageFolders"),id:"edit",ironIcon:"folder_open"}),menuItems.push({name:globalize.translate("ButtonRemove"),id:"delete",ironIcon:"remove"}),menuItems.push({name:globalize.translate("ButtonRename"),id:"rename",ironIcon:"mode_edit"}),menuItems.push({name:globalize.translate("ScanLibrary"),id:"refresh",ironIcon:"refresh"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(resultId){switch(resultId){case"changetype":changeCollectionType(page,virtualFolder);break;case"edit":editVirtualFolder(page,virtualFolder);break;case"editimages":editImages(page,virtualFolder);break;case"rename":renameVirtualFolder(page,virtualFolder);break;case"delete":deleteVirtualFolder(page,virtualFolder);break;case"refresh":refreshVirtualFolder(page,virtualFolder)}}})})}function reloadLibrary(page){loading.show(),ApiClient.getVirtualFolders().then(function(result){reloadVirtualFolders(page,result)})}function shouldRefreshLibraryAfterChanges(page){return"mediaLibraryPage"===page.id}function reloadVirtualFolders(page,virtualFolders){var html="";virtualFolders.push({Name:globalize.translate("ButtonAddMediaLibrary"),icon:"add_circle",Locations:[],showType:!1,showLocations:!1,showMenu:!1,showNameWithIcon:!0});for(var i=0,length=virtualFolders.length;i<length;i++){var virtualFolder=virtualFolders[i];html+=getVirtualFolderHtml(page,virtualFolder,i)}var
|