2017-01-27 20:16:59 -07:00
|
|
|
define(["userSettingsBuilder","listViewStyle"],function(userSettingsBuilder){"use strict";function renderViews(page,user,result){var folderHtml="";folderHtml+='<div class="checkboxList">',folderHtml+=result.map(function(i){var currentHtml="",id="chkGroupFolder"+i.Id,isChecked=user.Configuration.GroupedFolders.indexOf(i.Id)!=-1,checkedHtml=isChecked?' checked="checked"':"";return currentHtml+="<label>",currentHtml+='<input type="checkbox" is="emby-checkbox" class="chkGroupFolder" data-folderid="'+i.Id+'" id="'+id+'"'+checkedHtml+"/>",currentHtml+="<span>"+i.Name+"</span>",currentHtml+="</label>"}).join(""),folderHtml+="</div>",page.querySelector(".folderGroupList").innerHTML=folderHtml}function renderLatestItems(page,user,result){var folderHtml="";folderHtml+='<div class="checkboxList">';var excludeViewTypes=["playlists","livetv","boxsets","channels"],excludeItemTypes=["Channel"];folderHtml+=result.Items.map(function(i){if(excludeViewTypes.indexOf(i.CollectionType||[])!==-1)return"";if(excludeItemTypes.indexOf(i.Type)!==-1)return"";var currentHtml="",id="chkIncludeInLatest"+i.Id,isChecked=user.Configuration.LatestItemsExcludes.indexOf(i.Id)==-1,checkedHtml=isChecked?' checked="checked"':"";return currentHtml+="<label>",currentHtml+='<input type="checkbox" is="emby-checkbox" class="chkIncludeInLatest" data-folderid="'+i.Id+'" id="'+id+'"'+checkedHtml+"/>",currentHtml+="<span>"+i.Name+"</span>",currentHtml+="</label>"}).join(""),folderHtml+="</div>",page.querySelector(".latestItemsList").innerHTML=folderHtml}function renderViewOrder(page,user,result){var html="",index=0;html+=result.Items.map(function(view){var currentHtml="";return currentHtml+='<div class="listItem viewItem" data-viewid="'+view.Id+'">',currentHtml+='<button type="button" is="emby-button" class="fab mini autoSize" item-icon><i class="md-icon">folder_open</i></button>',currentHtml+='<div class="listItemBody">',currentHtml+="<div>",currentHtml+=view.Name,currentHtml+="</div>",currentHtml+="</div>",index>0?currentHtml+='<button type="button" is="paper-icon-button-light" class="btnViewItemUp btnViewItemMove autoSize" title="'+Globalize.translate("ButtonUp")+'"><i class="md-icon">keyboard_arrow_up</i></button>':result.Items.length>1&&(currentHtml+='<button type="button" is="paper-icon-button-light" class="btnViewItemDown btnViewItemMove autoSize" title="'+Globalize.translate("ButtonDown")+'"><i class="md-icon">keyboard_arrow_down</i></button>'),currentHtml+="</div>",index++,currentHtml}).join(""),page.querySelector(".viewOrderList").innerHTML=html}function loadForm(page,user,userSettings){page.querySelector(".chkHidePlayedFromLatest").checked=user.Configuration.HidePlayedInLatest||!1,page.querySelector("#selectHomeSection1").value=userSettings.get("homesection0")||"",page.querySelector("#selectHomeSection2").value=userSettings.get("homesection1")||"",page.querySelector("#selectHomeSection3").value=userSettings.get("homesection2")||"",page.querySelector("#selectHomeSection4").value=userSettings.get("homesection3")||"";var promise1=ApiClient.getUserViews({},user.Id),promise2=ApiClient.getJSON(ApiClient.getUrl("Users/"+user.Id+"/GroupingOptions"));Promise.all([promise1,promise2]).then(function(responses){renderViews(page,user,responses[1]),renderLatestItems(page,user,responses[0]),renderViewOrder(page,user,responses[0]),Dashboard.hideLoadingMsg()})}function getCheckboxItems(selector,page,isChecked){for(var inputs=page.querySelectorAll(selector),list=[],i=0,length=inputs.length;i<length;i++)inputs[i].checked==isChecked&&list.push(inputs[i]);return list}function refreshGlobalUserSettings(userSettingsInstance){require(["userSettings"],function(userSettings){userSettings.importFrom(userSettingsInstance)})}function saveUser(page,user,userSettingsInstance){user.Configuration.HidePlayedInLatest=page.querySelector(".chkHidePlayedFromLatest").checked,user.Configuration.LatestItemsExcludes=getCheckboxItems(".chkIncludeInLatest",page,!1).map(function(i){return i.getAttribute("data-folderid")}),user.Configuration.GroupedFolders=getCheckboxItems(".chkGroupFolder",page,!0).map
|