jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/layoutmanager.js

1 line
1.0 KiB
JavaScript
Raw Normal View History

2017-01-27 16:07:14 -07:00
define(["browser","appSettings","events"],function(browser,appSettings,events){"use strict";function setLayout(self,layout,selectedLayout){layout===selectedLayout?(self[layout]=!0,document.documentElement.classList.add("layout-"+layout)):(self[layout]=!1,document.documentElement.classList.remove("layout-"+layout))}function LayoutManager(){var self=this;self.setLayout=function(layout,save){layout&&"auto"!==layout?(setLayout(self,"mobile",layout),setLayout(self,"tv",layout),setLayout(self,"desktop",layout),save!==!1&&appSettings.set("layout",layout)):(self.autoLayout(),save!==!1&&appSettings.set("layout","")),events.trigger(self,"modechange")},self.getSavedLayout=function(layout){return appSettings.get("layout")},self.autoLayout=function(){browser.mobile?self.setLayout("mobile",!1):browser.tv||browser.xboxOne?self.setLayout("tv",!1):self.setLayout(self.undetectedAutoLayout||"desktop",!1)},self.init=function(){var saved=self.getSavedLayout();saved?self.setLayout(saved,!1):self.autoLayout()}}return new LayoutManager});