From 93c5157b1e224b82b1da32602787594ea9b68914 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Tue, 26 Feb 2019 23:28:16 +0000 Subject: [PATCH 01/30] refactor and module resolution for appStorage --- src/bower_components/apiclient/appStorage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bower_components/apiclient/appStorage.js b/src/bower_components/apiclient/appStorage.js index 8be2bb4d7f..6083bb4953 100644 --- a/src/bower_components/apiclient/appStorage.js +++ b/src/bower_components/apiclient/appStorage.js @@ -30,7 +30,7 @@ define([], function() { this.getItem = function(name) { return localStorage.getItem(name); }; - + this.removeItem = function(name) { localStorage.removeItem(name); From afde8bebe710c3b724bdc224a65bddfae85f8cbc Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:26:23 +0000 Subject: [PATCH 02/30] removed module emby-linkbutton: same as emby-button --- src/components/collectioneditor/collectioneditor.js | 2 +- src/components/directorybrowser/directorybrowser.js | 2 +- src/components/displaysettings/displaysettings.js | 2 +- src/components/filtermenu/filtermenu.js | 2 +- src/components/homesections/homesections.js | 2 +- src/components/imagedownloader/imagedownloader.js | 2 +- src/components/maintabsmanager.js | 2 +- src/components/mediainfo/mediainfo.js | 2 +- src/components/medialibrarycreator/medialibrarycreator.js | 2 +- src/components/search/searchresults.js | 2 +- src/components/sortmenu/sortmenu.js | 2 +- src/components/tvproviders/schedulesdirect.js | 2 +- src/components/viewsettings/viewsettings.js | 2 +- src/controllers/addpluginpage.js | 2 +- src/controllers/addserver.js | 2 +- src/controllers/dashboardgeneral.js | 2 +- src/controllers/dashboardpage.js | 2 +- src/controllers/devices.js | 2 +- src/controllers/itemdetailpage.js | 2 +- src/controllers/librarydisplay.js | 2 +- src/controllers/librarysettings.js | 2 +- src/controllers/logpage.js | 2 +- src/controllers/mypreferencescommon.js | 2 +- src/controllers/myprofile.js | 2 +- src/controllers/notificationsettings.js | 2 +- src/controllers/plugincatalogpage.js | 2 +- src/controllers/scheduledtaskspage.js | 2 +- src/controllers/userpasswordpage.js | 2 +- src/controllers/wizarduserpage.js | 2 +- src/scripts/dlnaprofile.js | 2 +- src/scripts/dlnaprofiles.js | 2 +- src/scripts/itembynamedetailpage.js | 2 +- src/scripts/livetvsettings.js | 2 +- src/scripts/livetvstatus.js | 2 +- src/scripts/moviegenres.js | 2 +- src/scripts/pluginspage.js | 2 +- src/scripts/site.js | 3 +-- src/scripts/tvgenres.js | 2 +- src/scripts/userprofilespage.js | 2 +- src/scripts/wizardagreement.js | 2 +- 40 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/components/collectioneditor/collectioneditor.js b/src/components/collectioneditor/collectioneditor.js index 4473c661e7..8c14405330 100644 --- a/src/components/collectioneditor/collectioneditor.js +++ b/src/components/collectioneditor/collectioneditor.js @@ -1,4 +1,4 @@ -define(['dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-linkbutton', 'flexStyles'], function (dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize) { +define(['dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize) { 'use strict'; var currentServerId; diff --git a/src/components/directorybrowser/directorybrowser.js b/src/components/directorybrowser/directorybrowser.js index c6d811e959..35bc914301 100644 --- a/src/components/directorybrowser/directorybrowser.js +++ b/src/components/directorybrowser/directorybrowser.js @@ -1,4 +1,4 @@ -define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-button', 'paper-icon-button-light', 'css!./directorybrowser', 'formDialogStyle', 'emby-linkbutton'], function(loading, dialogHelper, dom) { +define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-button', 'paper-icon-button-light', 'css!./directorybrowser', 'formDialogStyle', 'emby-button'], function(loading, dialogHelper, dom) { 'use strict'; function getSystemInfo() { diff --git a/src/components/displaysettings/displaysettings.js b/src/components/displaysettings/displaysettings.js index a33dba8e07..680c6b634b 100644 --- a/src/components/displaysettings/displaysettings.js +++ b/src/components/displaysettings/displaysettings.js @@ -1,4 +1,4 @@ -define(['require', 'browser', 'layoutManager', 'appSettings', 'pluginManager', 'apphost', 'focusManager', 'datetime', 'globalize', 'loading', 'connectionManager', 'skinManager', 'dom', 'events', 'emby-select', 'emby-checkbox', 'emby-linkbutton'], function (require, browser, layoutManager, appSettings, pluginManager, appHost, focusManager, datetime, globalize, loading, connectionManager, skinManager, dom, events) { +define(['require', 'browser', 'layoutManager', 'appSettings', 'pluginManager', 'apphost', 'focusManager', 'datetime', 'globalize', 'loading', 'connectionManager', 'skinManager', 'dom', 'events', 'emby-select', 'emby-checkbox', 'emby-button'], function (require, browser, layoutManager, appSettings, pluginManager, appHost, focusManager, datetime, globalize, loading, connectionManager, skinManager, dom, events) { "use strict"; function fillThemes(select, isDashboard) { diff --git a/src/components/filtermenu/filtermenu.js b/src/components/filtermenu/filtermenu.js index 42bd101129..02b35880b9 100644 --- a/src/components/filtermenu/filtermenu.js +++ b/src/components/filtermenu/filtermenu.js @@ -1,4 +1,4 @@ -define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-linkbutton', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) { +define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) { 'use strict'; function onSubmit(e) { diff --git a/src/components/homesections/homesections.js b/src/components/homesections/homesections.js index 9c2ec05aac..bf2a05ffba 100644 --- a/src/components/homesections/homesections.js +++ b/src/components/homesections/homesections.js @@ -1,4 +1,4 @@ -define(['connectionManager', 'cardBuilder', 'appSettings', 'dom', 'apphost', 'layoutManager', 'imageLoader', 'globalize', 'itemShortcuts', 'itemHelper', 'appRouter', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer', 'emby-scroller', 'emby-linkbutton', 'css!./homesections'], function (connectionManager, cardBuilder, appSettings, dom, appHost, layoutManager, imageLoader, globalize, itemShortcuts, itemHelper, appRouter) { +define(['connectionManager', 'cardBuilder', 'appSettings', 'dom', 'apphost', 'layoutManager', 'imageLoader', 'globalize', 'itemShortcuts', 'itemHelper', 'appRouter', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer', 'emby-scroller', 'emby-button', 'css!./homesections'], function (connectionManager, cardBuilder, appSettings, dom, appHost, layoutManager, imageLoader, globalize, itemShortcuts, itemHelper, appRouter) { 'use strict'; function getDefaultSection(index) { diff --git a/src/components/imagedownloader/imagedownloader.js b/src/components/imagedownloader/imagedownloader.js index f24acbb655..9c6aab2725 100644 --- a/src/components/imagedownloader/imagedownloader.js +++ b/src/components/imagedownloader/imagedownloader.js @@ -1,4 +1,4 @@ -define(['loading', 'apphost', 'dialogHelper', 'connectionManager', 'imageLoader', 'browser', 'layoutManager', 'scrollHelper', 'globalize', 'require', 'emby-checkbox', 'emby-button', 'paper-icon-button-light', 'emby-linkbutton', 'formDialogStyle', 'cardStyle'], function (loading, appHost, dialogHelper, connectionManager, imageLoader, browser, layoutManager, scrollHelper, globalize, require) { +define(['loading', 'apphost', 'dialogHelper', 'connectionManager', 'imageLoader', 'browser', 'layoutManager', 'scrollHelper', 'globalize', 'require', 'emby-checkbox', 'emby-button', 'paper-icon-button-light', 'emby-button', 'formDialogStyle', 'cardStyle'], function (loading, appHost, dialogHelper, connectionManager, imageLoader, browser, layoutManager, scrollHelper, globalize, require) { 'use strict'; var currentItemId; diff --git a/src/components/maintabsmanager.js b/src/components/maintabsmanager.js index b8da631df9..fa2922aafb 100644 --- a/src/components/maintabsmanager.js +++ b/src/components/maintabsmanager.js @@ -1,4 +1,4 @@ -define(['dom', 'browser', 'events', 'emby-tabs', 'emby-button', 'emby-linkbutton'], function (dom, browser, events) { +define(['dom', 'browser', 'events', 'emby-tabs', 'emby-button', 'emby-button'], function (dom, browser, events) { 'use strict'; var tabOwnerView; diff --git a/src/components/mediainfo/mediainfo.js b/src/components/mediainfo/mediainfo.js index 3f92425034..441adac3dd 100644 --- a/src/components/mediainfo/mediainfo.js +++ b/src/components/mediainfo/mediainfo.js @@ -1,4 +1,4 @@ -define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'material-icons', 'css!./mediainfo.css', 'programStyles', 'emby-linkbutton'], function (datetime, globalize, appRouter, itemHelper, indicators) { +define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'material-icons', 'css!./mediainfo.css', 'programStyles', 'emby-button'], function (datetime, globalize, appRouter, itemHelper, indicators) { 'use strict'; function getTimerIndicator(item) { diff --git a/src/components/medialibrarycreator/medialibrarycreator.js b/src/components/medialibrarycreator/medialibrarycreator.js index af51d2ef54..d02f0940cb 100644 --- a/src/components/medialibrarycreator/medialibrarycreator.js +++ b/src/components/medialibrarycreator/medialibrarycreator.js @@ -1,4 +1,4 @@ -define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionseditor/libraryoptionseditor", "emby-toggle", "emby-input", "emby-select", "paper-icon-button-light", "listViewStyle", "formDialogStyle", "emby-linkbutton", "flexStyles"], function(loading, dialogHelper, dom, $, libraryoptionseditor) { +define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionseditor/libraryoptionseditor", "emby-toggle", "emby-input", "emby-select", "paper-icon-button-light", "listViewStyle", "formDialogStyle", "emby-button", "flexStyles"], function(loading, dialogHelper, dom, $, libraryoptionseditor) { "use strict"; function onSubmit(e) { diff --git a/src/components/search/searchresults.js b/src/components/search/searchresults.js index 1b8161d333..e42088c066 100644 --- a/src/components/search/searchresults.js +++ b/src/components/search/searchresults.js @@ -1,4 +1,4 @@ -define(['layoutManager', 'globalize', 'require', 'events', 'connectionManager', 'cardBuilder', 'appRouter', 'emby-scroller', 'emby-itemscontainer', 'emby-linkbutton'], function (layoutManager, globalize, require, events, connectionManager, cardBuilder, appRouter) { +define(['layoutManager', 'globalize', 'require', 'events', 'connectionManager', 'cardBuilder', 'appRouter', 'emby-scroller', 'emby-itemscontainer', 'emby-button'], function (layoutManager, globalize, require, events, connectionManager, cardBuilder, appRouter) { 'use strict'; function loadSuggestions(instance, context, apiClient) { diff --git a/src/components/sortmenu/sortmenu.js b/src/components/sortmenu/sortmenu.js index 90dc1790d1..06e75c59cc 100644 --- a/src/components/sortmenu/sortmenu.js +++ b/src/components/sortmenu/sortmenu.js @@ -1,4 +1,4 @@ -define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'globalize', 'userSettings', 'emby-select', 'paper-icon-button-light', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-linkbutton', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, layoutManager, connectionManager, globalize, userSettings) { +define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'globalize', 'userSettings', 'emby-select', 'paper-icon-button-light', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, layoutManager, connectionManager, globalize, userSettings) { 'use strict'; function onSubmit(e) { diff --git a/src/components/tvproviders/schedulesdirect.js b/src/components/tvproviders/schedulesdirect.js index 0eb54a472d..9af7e5be72 100644 --- a/src/components/tvproviders/schedulesdirect.js +++ b/src/components/tvproviders/schedulesdirect.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "emby-checkbox", "listViewStyle", "emby-input", "emby-select", "emby-linkbutton", "flexStyles"], function($, loading) { +define(["jQuery", "loading", "emby-checkbox", "listViewStyle", "emby-input", "emby-select", "emby-button", "flexStyles"], function($, loading) { "use strict"; return function(page, providerId, options) { function reload() { diff --git a/src/components/viewsettings/viewsettings.js b/src/components/viewsettings/viewsettings.js index af2167fa6f..bfeb7e66ff 100644 --- a/src/components/viewsettings/viewsettings.js +++ b/src/components/viewsettings/viewsettings.js @@ -1,4 +1,4 @@ -define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-linkbutton', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) { +define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) { 'use strict'; function onSubmit(e) { diff --git a/src/controllers/addpluginpage.js b/src/controllers/addpluginpage.js index 6ad5b05d3f..32f71b8027 100644 --- a/src/controllers/addpluginpage.js +++ b/src/controllers/addpluginpage.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "libraryMenu", "globalize", "connectionManager", "emby-linkbutton"], function($, loading, libraryMenu, globalize, connectionManager) { +define(["jQuery", "loading", "libraryMenu", "globalize", "connectionManager", "emby-button"], function($, loading, libraryMenu, globalize, connectionManager) { "use strict"; function populateHistory(packageInfo, page) { diff --git a/src/controllers/addserver.js b/src/controllers/addserver.js index 3afb9c68a8..45fa427420 100644 --- a/src/controllers/addserver.js +++ b/src/controllers/addserver.js @@ -1,4 +1,4 @@ -define(["appSettings", "loading", "browser", "emby-linkbutton"], function(appSettings, loading, browser) { +define(["appSettings", "loading", "browser", "emby-button"], function(appSettings, loading, browser) { "use strict"; function handleConnectionResult(page, result) { diff --git a/src/controllers/dashboardgeneral.js b/src/controllers/dashboardgeneral.js index c02717fdbb..09aa1ec08e 100644 --- a/src/controllers/dashboardgeneral.js +++ b/src/controllers/dashboardgeneral.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emby-input", "emby-select", "emby-linkbutton"], function($, loading) { +define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emby-input", "emby-select", "emby-button"], function($, loading) { "use strict"; function loadPage(page, config, languageOptions, systemInfo) { diff --git a/src/controllers/dashboardpage.js b/src/controllers/dashboardpage.js index c0a363d65c..446a7c6d6f 100644 --- a/src/controllers/dashboardpage.js +++ b/src/controllers/dashboardpage.js @@ -1,4 +1,4 @@ -define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globalize", "loading", "connectionManager", "playMethodHelper", "cardBuilder", "imageLoader", "components/activitylog", "humanedate", "listViewStyle", "emby-linkbutton", "flexStyles", "emby-button", "emby-itemscontainer"], function (datetime, events, itemHelper, serverNotifications, dom, globalize, loading, connectionManager, playMethodHelper, cardBuilder, imageLoader, ActivityLog) { +define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globalize", "loading", "connectionManager", "playMethodHelper", "cardBuilder", "imageLoader", "components/activitylog", "humanedate", "listViewStyle", "emby-button", "flexStyles", "emby-button", "emby-itemscontainer"], function (datetime, events, itemHelper, serverNotifications, dom, globalize, loading, connectionManager, playMethodHelper, cardBuilder, imageLoader, ActivityLog) { "use strict"; function buttonEnabled(elem, enabled) { diff --git a/src/controllers/devices.js b/src/controllers/devices.js index e5e5d16dc7..e4c2f6b44b 100644 --- a/src/controllers/devices.js +++ b/src/controllers/devices.js @@ -1,4 +1,4 @@ -define(["loading", "dom", "libraryMenu", "globalize", "humanedate", "emby-linkbutton", "emby-itemscontainer", "cardStyle"], function(loading, dom, libraryMenu, globalize) { +define(["loading", "dom", "libraryMenu", "globalize", "humanedate", "emby-button", "emby-itemscontainer", "cardStyle"], function(loading, dom, libraryMenu, globalize) { "use strict"; function canDelete(deviceId) { diff --git a/src/controllers/itemdetailpage.js b/src/controllers/itemdetailpage.js index 685927a09d..3a0e776d3f 100644 --- a/src/controllers/itemdetailpage.js +++ b/src/controllers/itemdetailpage.js @@ -1,4 +1,4 @@ -define(["loading", "appRouter", "layoutManager", "connectionManager", "cardBuilder", "datetime", "mediaInfo", "backdrop", "listView", "itemContextMenu", "itemHelper", "dom", "indicators", "apphost", "imageLoader", "libraryMenu", "globalize", "browser", "events", "scrollHelper", "playbackManager", "libraryBrowser", "scrollStyles", "emby-itemscontainer", "emby-checkbox", "emby-linkbutton", "emby-playstatebutton", "emby-ratingbutton", "emby-scroller", "emby-select"], function(loading, appRouter, layoutManager, connectionManager, cardBuilder, datetime, mediaInfo, backdrop, listView, itemContextMenu, itemHelper, dom, indicators, appHost, imageLoader, libraryMenu, globalize, browser, events, scrollHelper, playbackManager, libraryBrowser) { +define(["loading", "appRouter", "layoutManager", "connectionManager", "cardBuilder", "datetime", "mediaInfo", "backdrop", "listView", "itemContextMenu", "itemHelper", "dom", "indicators", "apphost", "imageLoader", "libraryMenu", "globalize", "browser", "events", "scrollHelper", "playbackManager", "libraryBrowser", "scrollStyles", "emby-itemscontainer", "emby-checkbox", "emby-button", "emby-playstatebutton", "emby-ratingbutton", "emby-scroller", "emby-select"], function(loading, appRouter, layoutManager, connectionManager, cardBuilder, datetime, mediaInfo, backdrop, listView, itemContextMenu, itemHelper, dom, indicators, appHost, imageLoader, libraryMenu, globalize, browser, events, scrollHelper, playbackManager, libraryBrowser) { "use strict"; function getPromise(apiClient, params) { diff --git a/src/controllers/librarydisplay.js b/src/controllers/librarydisplay.js index 924641d743..80f5bbc09b 100644 --- a/src/controllers/librarydisplay.js +++ b/src/controllers/librarydisplay.js @@ -1,4 +1,4 @@ -define(["globalize", "loading", "libraryMenu", "emby-checkbox", "emby-button", "emby-linkbutton"], function(globalize, loading, libraryMenu) { +define(["globalize", "loading", "libraryMenu", "emby-checkbox", "emby-button", "emby-button"], function(globalize, loading, libraryMenu) { "use strict"; function getTabs() { diff --git a/src/controllers/librarysettings.js b/src/controllers/librarysettings.js index 5e700b6fb0..997ccdfd4d 100644 --- a/src/controllers/librarysettings.js +++ b/src/controllers/librarysettings.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "libraryMenu", "fnchecked", "emby-checkbox", "emby-linkbutton"], function($, loading, libraryMenu) { +define(["jQuery", "loading", "libraryMenu", "fnchecked", "emby-checkbox", "emby-button"], function($, loading, libraryMenu) { "use strict"; function loadPage(page, config) { diff --git a/src/controllers/logpage.js b/src/controllers/logpage.js index 0c29389255..4b288b288f 100644 --- a/src/controllers/logpage.js +++ b/src/controllers/logpage.js @@ -1,4 +1,4 @@ -define(["datetime", "loading", "apphost", "listViewStyle", "emby-linkbutton", "flexStyles"], function(datetime, loading, appHost) { +define(["datetime", "loading", "apphost", "listViewStyle", "emby-button", "flexStyles"], function(datetime, loading, appHost) { "use strict"; return function(view, params) { view.querySelector("#chkDebugLog").addEventListener("change", function() { diff --git a/src/controllers/mypreferencescommon.js b/src/controllers/mypreferencescommon.js index c30d6f723a..e52fcc1b34 100644 --- a/src/controllers/mypreferencescommon.js +++ b/src/controllers/mypreferencescommon.js @@ -1,4 +1,4 @@ -define(["apphost", "connectionManager", "listViewStyle", "emby-linkbutton"], function(appHost, connectionManager) { +define(["apphost", "connectionManager", "listViewStyle", "emby-button"], function(appHost, connectionManager) { "use strict"; return function(view, params) { diff --git a/src/controllers/myprofile.js b/src/controllers/myprofile.js index 71baf40a41..be8f1b446e 100644 --- a/src/controllers/myprofile.js +++ b/src/controllers/myprofile.js @@ -1,4 +1,4 @@ -define(["controllers/userpasswordpage", "loading", "libraryMenu", "apphost", "emby-linkbutton"], function (Userpasswordpage, loading, libraryMenu, appHost) { +define(["controllers/userpasswordpage", "loading", "libraryMenu", "apphost", "emby-button"], function (Userpasswordpage, loading, libraryMenu, appHost) { "use strict"; function reloadUser(page) { diff --git a/src/controllers/notificationsettings.js b/src/controllers/notificationsettings.js index b167ca00e4..092d92e24b 100644 --- a/src/controllers/notificationsettings.js +++ b/src/controllers/notificationsettings.js @@ -1,4 +1,4 @@ -define(["loading", "libraryMenu", "globalize", "listViewStyle", "emby-linkbutton"], function(loading, libraryMenu, globalize) { +define(["loading", "libraryMenu", "globalize", "listViewStyle", "emby-button"], function(loading, libraryMenu, globalize) { "use strict"; function reload(page) { diff --git a/src/controllers/plugincatalogpage.js b/src/controllers/plugincatalogpage.js index b399ba098a..c823d7c372 100644 --- a/src/controllers/plugincatalogpage.js +++ b/src/controllers/plugincatalogpage.js @@ -1,4 +1,4 @@ -define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", "emby-checkbox", "emby-select"], function (loading, libraryMenu, globalize) { +define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-button", "emby-checkbox", "emby-select"], function (loading, libraryMenu, globalize) { "use strict"; function reloadList(page) { diff --git a/src/controllers/scheduledtaskspage.js b/src/controllers/scheduledtaskspage.js index 50c2ef53a0..1580f1a4c3 100644 --- a/src/controllers/scheduledtaskspage.js +++ b/src/controllers/scheduledtaskspage.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "events", "globalize", "serverNotifications", "humanedate", "listViewStyle", "emby-linkbutton"], function($, loading, events, globalize, serverNotifications) { +define(["jQuery", "loading", "events", "globalize", "serverNotifications", "humanedate", "listViewStyle", "emby-button"], function($, loading, events, globalize, serverNotifications) { "use strict"; function reloadList(page) { diff --git a/src/controllers/userpasswordpage.js b/src/controllers/userpasswordpage.js index 478ba95724..d1eef004f6 100644 --- a/src/controllers/userpasswordpage.js +++ b/src/controllers/userpasswordpage.js @@ -1,4 +1,4 @@ -define(["loading", "libraryMenu", "emby-linkbutton"], function(loading, libraryMenu) { +define(["loading", "libraryMenu", "emby-button"], function(loading, libraryMenu) { "use strict"; function loadUser(page, params) { diff --git a/src/controllers/wizarduserpage.js b/src/controllers/wizarduserpage.js index c3508efc12..a3654edf0e 100644 --- a/src/controllers/wizarduserpage.js +++ b/src/controllers/wizarduserpage.js @@ -1,4 +1,4 @@ -define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "emby-linkbutton"], function(loading, globalize) { +define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "emby-button"], function(loading, globalize) { "use strict"; function getApiClient() { diff --git a/src/scripts/dlnaprofile.js b/src/scripts/dlnaprofile.js index f9d72a3540..026c228d2d 100644 --- a/src/scripts/dlnaprofile.js +++ b/src/scripts/dlnaprofile.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "fnchecked", "emby-select", "emby-button", "emby-input", "emby-checkbox", "listViewStyle", "emby-linkbutton"], function($, loading) { +define(["jQuery", "loading", "fnchecked", "emby-select", "emby-button", "emby-input", "emby-checkbox", "listViewStyle", "emby-button"], function($, loading) { "use strict"; function loadProfile(page) { diff --git a/src/scripts/dlnaprofiles.js b/src/scripts/dlnaprofiles.js index 1f0fd1e791..b77b31e3b3 100644 --- a/src/scripts/dlnaprofiles.js +++ b/src/scripts/dlnaprofiles.js @@ -1,4 +1,4 @@ -define(["jQuery", "globalize", "loading", "libraryMenu", "listViewStyle", "emby-linkbutton"], function($, globalize, loading, libraryMenu) { +define(["jQuery", "globalize", "loading", "libraryMenu", "listViewStyle", "emby-button"], function($, globalize, loading, libraryMenu) { "use strict"; function loadProfiles(page) { diff --git a/src/scripts/itembynamedetailpage.js b/src/scripts/itembynamedetailpage.js index 31abfdfc31..727532a386 100644 --- a/src/scripts/itembynamedetailpage.js +++ b/src/scripts/itembynamedetailpage.js @@ -1,4 +1,4 @@ -define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryBrowser", "emby-itemscontainer", "emby-linkbutton"], function(connectionManager, listView, cardBuilder, imageLoader, libraryBrowser) { +define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryBrowser", "emby-itemscontainer", "emby-button"], function(connectionManager, listView, cardBuilder, imageLoader, libraryBrowser) { "use strict"; function renderItems(page, item) { diff --git a/src/scripts/livetvsettings.js b/src/scripts/livetvsettings.js index 4d659ad6b4..422257e33d 100644 --- a/src/scripts/livetvsettings.js +++ b/src/scripts/livetvsettings.js @@ -1,4 +1,4 @@ -define(["jQuery", "loading", "fnchecked", "emby-linkbutton"], function($, loading) { +define(["jQuery", "loading", "fnchecked", "emby-button"], function($, loading) { "use strict"; function loadPage(page, config) { diff --git a/src/scripts/livetvstatus.js b/src/scripts/livetvstatus.js index 3a7078ccd8..1ed1402d6d 100644 --- a/src/scripts/livetvstatus.js +++ b/src/scripts/livetvstatus.js @@ -1,4 +1,4 @@ -define(["jQuery", "globalize", "scripts/taskbutton", "dom", "libraryMenu", "layoutManager", "loading", "listViewStyle", "flexStyles", "emby-itemscontainer", "cardStyle", "material-icons", "emby-linkbutton"], function($, globalize, taskButton, dom, libraryMenu, layoutManager, loading) { +define(["jQuery", "globalize", "scripts/taskbutton", "dom", "libraryMenu", "layoutManager", "loading", "listViewStyle", "flexStyles", "emby-itemscontainer", "cardStyle", "material-icons", "emby-button"], function($, globalize, taskButton, dom, libraryMenu, layoutManager, loading) { "use strict"; function getDeviceHtml(device) { diff --git a/src/scripts/moviegenres.js b/src/scripts/moviegenres.js index baac9fbc8c..b3a313a06d 100644 --- a/src/scripts/moviegenres.js +++ b/src/scripts/moviegenres.js @@ -1,4 +1,4 @@ -define(["layoutManager", "loading", "libraryBrowser", "cardBuilder", "lazyLoader", "apphost", "globalize", "appRouter", "dom", "emby-linkbutton"], function(layoutManager, loading, libraryBrowser, cardBuilder, lazyLoader, appHost, globalize, appRouter, dom) { +define(["layoutManager", "loading", "libraryBrowser", "cardBuilder", "lazyLoader", "apphost", "globalize", "appRouter", "dom", "emby-button"], function(layoutManager, loading, libraryBrowser, cardBuilder, lazyLoader, appHost, globalize, appRouter, dom) { "use strict"; return function(view, params, tabContent) { function getPageData() { diff --git a/src/scripts/pluginspage.js b/src/scripts/pluginspage.js index 6264f012e0..86f49d809c 100644 --- a/src/scripts/pluginspage.js +++ b/src/scripts/pluginspage.js @@ -1,4 +1,4 @@ -define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-linkbutton"], function(loading, libraryMenu, dom, globalize) { +define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-button"], function(loading, libraryMenu, dom, globalize) { "use strict"; function deletePlugin(page, uniqueid, name) { diff --git a/src/scripts/site.js b/src/scripts/site.js index 6eb45b86d9..d1812e2e89 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -743,7 +743,6 @@ var AppInfo = {}; define("libraryMenu", ["scripts/librarymenu"], returnFirstDependency); define("emby-collapse", [componentsPath + "/emby-collapse/emby-collapse"], returnFirstDependency); define("emby-button", [componentsPath + "/emby-button/emby-button"], returnFirstDependency); - define("emby-linkbutton", ["emby-button"], returnFirstDependency); define("emby-itemscontainer", [componentsPath + "/emby-itemscontainer/emby-itemscontainer"], returnFirstDependency); define("alphaNumericShortcuts", [componentsPath + "/alphanumericshortcuts/alphanumericshortcuts"], returnFirstDependency); define("emby-scroller", [componentsPath + "/emby-scroller/emby-scroller"], returnFirstDependency); @@ -882,7 +881,7 @@ var AppInfo = {}; return jQuery; }); define("fnchecked", ["legacy/fnchecked"], returnFirstDependency); - define("dialogHelper", [componentsPath + "/dialoghelper/dialoghelper"], returnFirstDependency); + define("dialogHelper", [componentsPath + "/dialogHelper/dialogHelper"], returnFirstDependency); define("inputmanager", ["inputManager"], returnFirstDependency); define("serverNotifications", [componentsPath + "/apiInput/apiInput"], returnFirstDependency); define("headroom-window", ["headroom"], createWindowHeadroom); diff --git a/src/scripts/tvgenres.js b/src/scripts/tvgenres.js index 39191edd81..8a5d769969 100644 --- a/src/scripts/tvgenres.js +++ b/src/scripts/tvgenres.js @@ -1,4 +1,4 @@ -define(["layoutManager", "loading", "libraryBrowser", "cardBuilder", "lazyLoader", "apphost", "globalize", "appRouter", "dom", "emby-linkbutton"], function(layoutManager, loading, libraryBrowser, cardBuilder, lazyLoader, appHost, globalize, appRouter, dom) { +define(["layoutManager", "loading", "libraryBrowser", "cardBuilder", "lazyLoader", "apphost", "globalize", "appRouter", "dom", "emby-button"], function(layoutManager, loading, libraryBrowser, cardBuilder, lazyLoader, appHost, globalize, appRouter, dom) { "use strict"; return function(view, params, tabContent) { function getPageData() { diff --git a/src/scripts/userprofilespage.js b/src/scripts/userprofilespage.js index e34ad45412..c0d1d0d87b 100644 --- a/src/scripts/userprofilespage.js +++ b/src/scripts/userprofilespage.js @@ -1,4 +1,4 @@ -define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light", "cardStyle", "emby-linkbutton", "indicators", "flexStyles"], function (loading, dom, globalize) { +define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light", "cardStyle", "emby-button", "indicators", "flexStyles"], function (loading, dom, globalize) { "use strict"; function deleteUser(page, id) { diff --git a/src/scripts/wizardagreement.js b/src/scripts/wizardagreement.js index dfb9d70646..77c12fb664 100644 --- a/src/scripts/wizardagreement.js +++ b/src/scripts/wizardagreement.js @@ -1,4 +1,4 @@ -define(["dom", "emby-linkbutton"], function(dom) { +define(["dom", "emby-button"], function(dom) { "use strict"; function onSubmit(e) { From c2555d071dd5a18691230dfb856fc772fc7638c1 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:29:33 +0000 Subject: [PATCH 03/30] added package.json for modules resolution --- src/components/emby-radio/package.json | 3 +++ src/components/emby-tabs/package.json | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 src/components/emby-radio/package.json create mode 100644 src/components/emby-tabs/package.json diff --git a/src/components/emby-radio/package.json b/src/components/emby-radio/package.json new file mode 100644 index 0000000000..2c1b97bd32 --- /dev/null +++ b/src/components/emby-radio/package.json @@ -0,0 +1,3 @@ +{ + "main": "emby-radio.js" +} \ No newline at end of file diff --git a/src/components/emby-tabs/package.json b/src/components/emby-tabs/package.json new file mode 100644 index 0000000000..0813d041c7 --- /dev/null +++ b/src/components/emby-tabs/package.json @@ -0,0 +1,3 @@ +{ + "main": "emby-tabs.js" +} \ No newline at end of file From ecf316d67100768bc2b609f9c4cd393e8fada1e2 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:30:13 +0000 Subject: [PATCH 04/30] removed polyfill fetch --- src/bower_components/fetch/fetch.js | 263 ---------------------------- src/scripts/site.js | 5 - 2 files changed, 268 deletions(-) delete mode 100644 src/bower_components/fetch/fetch.js diff --git a/src/bower_components/fetch/fetch.js b/src/bower_components/fetch/fetch.js deleted file mode 100644 index cd40b3ed2d..0000000000 --- a/src/bower_components/fetch/fetch.js +++ /dev/null @@ -1,263 +0,0 @@ -! function(self) { - "use strict"; - - function normalizeName(name) { - if ("string" != typeof name && (name = String(name)), /[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) throw new TypeError("Invalid character in header field name"); - return name.toLowerCase() - } - - function normalizeValue(value) { - return "string" != typeof value && (value = String(value)), value - } - - function iteratorFor(items) { - var iterator = { - next: function() { - var value = items.shift(); - return { - done: void 0 === value, - value: value - } - } - }; - return support.iterable && (iterator[Symbol.iterator] = function() { - return iterator - }), iterator - } - - function Headers(headers) { - this.map = {}, headers instanceof Headers ? headers.forEach(function(value, name) { - this.append(name, value) - }, this) : headers && Object.getOwnPropertyNames(headers).forEach(function(name) { - this.append(name, headers[name]) - }, this) - } - - function consumed(body) { - if (body.bodyUsed) return Promise.reject(new TypeError("Already read")); - body.bodyUsed = !0 - } - - function fileReaderReady(reader) { - return new Promise(function(resolve, reject) { - reader.onload = function() { - resolve(reader.result) - }, reader.onerror = function() { - reject(reader.error) - } - }) - } - - function readBlobAsArrayBuffer(blob) { - var reader = new FileReader, - promise = fileReaderReady(reader); - return reader.readAsArrayBuffer(blob), promise - } - - function readBlobAsText(blob) { - var reader = new FileReader, - promise = fileReaderReady(reader); - return reader.readAsText(blob), promise - } - - function readArrayBufferAsText(buf) { - for (var view = new Uint8Array(buf), chars = new Array(view.length), i = 0; i < view.length; i++) chars[i] = String.fromCharCode(view[i]); - return chars.join("") - } - - function bufferClone(buf) { - if (buf.slice) return buf.slice(0); - var view = new Uint8Array(buf.byteLength); - return view.set(new Uint8Array(buf)), view.buffer - } - - function Body() { - return this.bodyUsed = !1, this._initBody = function(body) { - if (this._bodyInit = body, body) - if ("string" == typeof body) this._bodyText = body; - else if (support.blob && Blob.prototype.isPrototypeOf(body)) this._bodyBlob = body; - else if (support.formData && FormData.prototype.isPrototypeOf(body)) this._bodyFormData = body; - else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) this._bodyText = body.toString(); - else if (support.arrayBuffer && support.blob && isDataView(body)) this._bodyArrayBuffer = bufferClone(body.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer]); - else { - if (!support.arrayBuffer || !ArrayBuffer.prototype.isPrototypeOf(body) && !isArrayBufferView(body)) throw new Error("unsupported BodyInit type"); - this._bodyArrayBuffer = bufferClone(body) - } else this._bodyText = ""; - this.headers.get("content-type") || ("string" == typeof body ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : support.searchParams && URLSearchParams.prototype.isPrototypeOf(body) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8")) - }, support.blob && (this.blob = function() { - var rejected = consumed(this); - if (rejected) return rejected; - if (this._bodyBlob) return Promise.resolve(this._bodyBlob); - if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer])); - if (this._bodyFormData) throw new Error("could not read FormData body as blob"); - return Promise.resolve(new Blob([this._bodyText])) - }, this.arrayBuffer = function() { - return this._bodyArrayBuffer ? consumed(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(readBlobAsArrayBuffer) - }), this.text = function() { - var rejected = consumed(this); - if (rejected) return rejected; - if (this._bodyBlob) return readBlobAsText(this._bodyBlob); - if (this._bodyArrayBuffer) return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); - if (this._bodyFormData) throw new Error("could not read FormData body as text"); - return Promise.resolve(this._bodyText) - }, support.formData && (this.formData = function() { - return this.text().then(decode) - }), this.json = function() { - return this.text().then(JSON.parse) - }, this - } - - function normalizeMethod(method) { - var upcased = method.toUpperCase(); - return methods.indexOf(upcased) > -1 ? upcased : method - } - - function Request(input, options) { - options = options || {}; - var body = options.body; - if ("string" == typeof input) this.url = input; - else { - if (input.bodyUsed) throw new TypeError("Already read"); - this.url = input.url, this.credentials = input.credentials, options.headers || (this.headers = new Headers(input.headers)), this.method = input.method, this.mode = input.mode, body || null == input._bodyInit || (body = input._bodyInit, input.bodyUsed = !0) - } - if (this.credentials = options.credentials || this.credentials || "omit", !options.headers && this.headers || (this.headers = new Headers(options.headers)), this.method = normalizeMethod(options.method || this.method || "GET"), this.mode = options.mode || this.mode || null, this.referrer = null, ("GET" === this.method || "HEAD" === this.method) && body) throw new TypeError("Body not allowed for GET or HEAD requests"); - this._initBody(body) - } - - function decode(body) { - var form = new FormData; - return body.trim().split("&").forEach(function(bytes) { - if (bytes) { - var split = bytes.split("="), - name = split.shift().replace(/\+/g, " "), - value = split.join("=").replace(/\+/g, " "); - form.append(decodeURIComponent(name), decodeURIComponent(value)) - } - }), form - } - - function parseHeaders(rawHeaders) { - var headers = new Headers; - return rawHeaders.split("\r\n").forEach(function(line) { - var parts = line.split(":"), - key = parts.shift().trim(); - if (key) { - var value = parts.join(":").trim(); - headers.append(key, value) - } - }), headers - } - - function Response(bodyInit, options) { - options || (options = {}), this.type = "default", this.status = "status" in options ? options.status : 200, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in options ? options.statusText : "OK", this.headers = new Headers(options.headers), this.url = options.url || "", this._initBody(bodyInit) - } - if (!self.fetch) { - var support = { - searchParams: "URLSearchParams" in self, - iterable: "Symbol" in self && "iterator" in Symbol, - blob: "FileReader" in self && "Blob" in self && function() { - try { - return new Blob, !0 - } catch (e) { - return !1 - } - }(), - formData: "FormData" in self, - arrayBuffer: "ArrayBuffer" in self - }; - if (support.arrayBuffer) var viewClasses = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], - isDataView = function(obj) { - return obj && DataView.prototype.isPrototypeOf(obj) - }, - isArrayBufferView = ArrayBuffer.isView || function(obj) { - return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 - }; - Headers.prototype.append = function(name, value) { - name = normalizeName(name), value = normalizeValue(value); - var list = this.map[name]; - list || (list = [], this.map[name] = list), list.push(value) - }, Headers.prototype.delete = function(name) { - delete this.map[normalizeName(name)] - }, Headers.prototype.get = function(name) { - var values = this.map[normalizeName(name)]; - return values ? values[0] : null - }, Headers.prototype.getAll = function(name) { - return this.map[normalizeName(name)] || [] - }, Headers.prototype.has = function(name) { - return this.map.hasOwnProperty(normalizeName(name)) - }, Headers.prototype.set = function(name, value) { - this.map[normalizeName(name)] = [normalizeValue(value)] - }, Headers.prototype.forEach = function(callback, thisArg) { - Object.getOwnPropertyNames(this.map).forEach(function(name) { - this.map[name].forEach(function(value) { - callback.call(thisArg, value, name, this) - }, this) - }, this) - }, Headers.prototype.keys = function() { - var items = []; - return this.forEach(function(value, name) { - items.push(name) - }), iteratorFor(items) - }, Headers.prototype.values = function() { - var items = []; - return this.forEach(function(value) { - items.push(value) - }), iteratorFor(items) - }, Headers.prototype.entries = function() { - var items = []; - return this.forEach(function(value, name) { - items.push([name, value]) - }), iteratorFor(items) - }, support.iterable && (Headers.prototype[Symbol.iterator] = Headers.prototype.entries); - var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; - Request.prototype.clone = function() { - return new Request(this, { - body: this._bodyInit - }) - }, Body.call(Request.prototype), Body.call(Response.prototype), Response.prototype.clone = function() { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }) - }, Response.error = function() { - var response = new Response(null, { - status: 0, - statusText: "" - }); - return response.type = "error", response - }; - var redirectStatuses = [301, 302, 303, 307, 308]; - Response.redirect = function(url, status) { - if (-1 === redirectStatuses.indexOf(status)) throw new RangeError("Invalid status code"); - return new Response(null, { - status: status, - headers: { - location: url - } - }) - }, self.Headers = Headers, self.Request = Request, self.Response = Response, self.fetch = function(input, init) { - return new Promise(function(resolve, reject) { - var request = new Request(input, init), - xhr = new XMLHttpRequest; - xhr.onload = function() { - var options = { - status: xhr.status, - statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || "") - }; - options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL"); - var body = "response" in xhr ? xhr.response : xhr.responseText; - resolve(new Response(body, options)) - }, xhr.onerror = function() { - reject(new TypeError("Network request failed")) - }, xhr.ontimeout = function() { - reject(new TypeError("Network request failed")) - }, xhr.open(request.method, request.url, !0), "include" === request.credentials && (xhr.withCredentials = !0), "responseType" in xhr && support.blob && (xhr.responseType = "blob"), request.headers.forEach(function(value, name) { - xhr.setRequestHeader(name, value) - }), xhr.send(void 0 === request._bodyInit ? null : request._bodyInit) - }) - }, self.fetch.polyfill = !0 - } -}("undefined" != typeof self ? self : this); \ No newline at end of file diff --git a/src/scripts/site.js b/src/scripts/site.js index d1812e2e89..4e3c06548f 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -473,10 +473,6 @@ var AppInfo = {}; define("buttonenabled", ["legacy/buttonenabled"], returnFirstDependency); var promises = []; - if (!window.fetch) { - promises.push(require(["fetch"])); - } - Promise.all(promises).then(function () { createConnectionManager().then(function () { console.log("initAfterDependencies promises resolved"); @@ -834,7 +830,6 @@ var AppInfo = {}; define("jstree", ["thirdparty/jstree/jstree", "css!thirdparty/jstree/themes/default/style.css"], returnFirstDependency); define("dashboardcss", ["css!css/dashboard"], returnFirstDependency); define("slideshow", [componentsPath + "/slideshow/slideshow"], returnFirstDependency); - define("fetch", [bowerPath + "/fetch/fetch"], returnFirstDependency); define("clearButtonStyle", ["css!" + componentsPath + "/clearbutton"], returnFirstDependency); define("userdataButtons", [componentsPath + "/userdatabuttons/userdatabuttons"], returnFirstDependency); define("emby-playstatebutton", [componentsPath + "/userdatabuttons/emby-playstatebutton"], returnFirstDependency); From e0ac97c1096f803a14025515d614cb03d3bedab2 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:38:10 +0000 Subject: [PATCH 05/30] remove duplicated component viewcontainer-lite --- .../viewmanager/viewcontainer-lite.js | 313 ------------------ src/scripts/site.js | 2 +- 2 files changed, 1 insertion(+), 314 deletions(-) delete mode 100644 src/components/viewmanager/viewcontainer-lite.js diff --git a/src/components/viewmanager/viewcontainer-lite.js b/src/components/viewmanager/viewcontainer-lite.js deleted file mode 100644 index 57c8fe926c..0000000000 --- a/src/components/viewmanager/viewcontainer-lite.js +++ /dev/null @@ -1,313 +0,0 @@ -define(['browser', 'dom', 'layoutManager', 'css!./viewcontainer-lite'], function (browser, dom, layoutManager) { - 'use strict'; - - var mainAnimatedPages = document.querySelector('.mainAnimatedPages'); - var allPages = []; - var currentUrls = []; - var pageContainerCount = 3; - var selectedPageIndex = -1; - - function enableAnimation() { - - // too slow - if (browser.tv) { - return false; - } - - return browser.supportsCssAnimation(); - } - - function findLastView(parent, className) { - - var nodes = parent.childNodes; - for (var i = nodes.length - 1; i >= 0; i--) { - var node = nodes[i]; - var classList = node.classList; - if (classList && classList.contains(className)) { - return node; - } - } - } - - function findViewBefore(elem, className) { - - var node = elem.previousSibling; - while (node) { - var classList = node.classList; - if (classList && classList.contains(className)) { - return node; - } - - node = node.previousSibling; - } - } - - function loadView(options) { - - if (options.cancel) { - return; - } - - cancelActiveAnimations(); - - var selected = selectedPageIndex; - var previousAnimatable = selected === -1 ? null : allPages[selected]; - var pageIndex = selected + 1; - - if (pageIndex >= pageContainerCount) { - pageIndex = 0; - } - - var viewHtml = options.view; - - var properties = []; - if (options.fullscreen) { - properties.push('fullscreen'); - } - - var currentPage = allPages[pageIndex]; - - var view; - - if (currentPage) { - triggerDestroy(currentPage); - currentPage.insertAdjacentHTML('beforebegin', viewHtml); - view = findViewBefore(currentPage, 'view'); - - mainAnimatedPages.removeChild(currentPage); - - } else { - mainAnimatedPages.insertAdjacentHTML('beforeend', viewHtml); - - view = findLastView(mainAnimatedPages, 'view'); - } - - view.classList.add('mainAnimatedPage'); - - if (properties.length) { - view.setAttribute('data-properties', properties.join(',')); - } - - if (options.type) { - view.setAttribute('data-type', options.type); - } - - allPages[pageIndex] = view; - - if (onBeforeChange) { - onBeforeChange(view, false, options); - } - - beforeAnimate(allPages, pageIndex, selected); - - // animate here - return animate(view, previousAnimatable, options.transition, options.isBack).then(function () { - - selectedPageIndex = pageIndex; - currentUrls[pageIndex] = options.url; - if (!options.cancel && previousAnimatable) { - afterAnimate(allPages, pageIndex); - } - - return view; - }); - } - - function beforeAnimate(allPages, newPageIndex, oldPageIndex) { - for (var i = 0, length = allPages.length; i < length; i++) { - if (newPageIndex === i || oldPageIndex === i) { - //allPages[i].classList.remove('hide'); - } else { - allPages[i].classList.add('hide'); - } - } - } - - function afterAnimate(allPages, newPageIndex) { - for (var i = 0, length = allPages.length; i < length; i++) { - if (newPageIndex === i) { - //allPages[i].classList.remove('hide'); - } else { - allPages[i].classList.add('hide'); - } - } - } - - function animate(newAnimatedPage, oldAnimatedPage, transition, isBack) { - - if (enableAnimation() && oldAnimatedPage) { - if (transition === 'slide') { - return slide(newAnimatedPage, oldAnimatedPage, transition, isBack); - } else if (transition === 'fade') { - return fade(newAnimatedPage, oldAnimatedPage, transition, isBack); - } else { - clearAnimation(newAnimatedPage); - if (oldAnimatedPage) { - clearAnimation(oldAnimatedPage); - } - } - } - - return Promise.resolve(); - } - - function clearAnimation(elem) { - setAnimation(elem, 'none'); - } - - function slide(newAnimatedPage, oldAnimatedPage, transition, isBack) { - - return new Promise(function (resolve, reject) { - - var duration = layoutManager.tv ? 450 : 160; - - var animations = []; - - if (oldAnimatedPage) { - if (isBack) { - setAnimation(oldAnimatedPage, 'view-slideright-r ' + duration + 'ms ease-out normal both'); - } else { - setAnimation(oldAnimatedPage, 'view-slideleft-r ' + duration + 'ms ease-out normal both'); - } - animations.push(oldAnimatedPage); - } - - if (isBack) { - setAnimation(newAnimatedPage, 'view-slideright ' + duration + 'ms ease-out normal both'); - } else { - setAnimation(newAnimatedPage, 'view-slideleft ' + duration + 'ms ease-out normal both'); - } - animations.push(newAnimatedPage); - - currentAnimations = animations; - - var onAnimationComplete = function () { - dom.removeEventListener(newAnimatedPage, dom.whichAnimationEvent(), onAnimationComplete, { - once: true - }); - resolve(); - }; - - dom.addEventListener(newAnimatedPage, dom.whichAnimationEvent(), onAnimationComplete, { - once: true - }); - }); - } - - function fade(newAnimatedPage, oldAnimatedPage, transition, isBack) { - - return new Promise(function (resolve, reject) { - - var duration = layoutManager.tv ? 450 : 270; - var animations = []; - - newAnimatedPage.style.opacity = 0; - setAnimation(newAnimatedPage, 'view-fadein ' + duration + 'ms ease-in normal both'); - animations.push(newAnimatedPage); - - if (oldAnimatedPage) { - setAnimation(oldAnimatedPage, 'view-fadeout ' + duration + 'ms ease-out normal both'); - animations.push(oldAnimatedPage); - } - - currentAnimations = animations; - - var onAnimationComplete = function () { - dom.removeEventListener(newAnimatedPage, dom.whichAnimationEvent(), onAnimationComplete, { - once: true - }); - resolve(); - }; - - dom.addEventListener(newAnimatedPage, dom.whichAnimationEvent(), onAnimationComplete, { - once: true - }); - }); - } - - function setAnimation(elem, value) { - - requestAnimationFrame(function () { - elem.style.animation = value; - }); - } - - var currentAnimations = []; - function cancelActiveAnimations() { - - var animations = currentAnimations; - for (var i = 0, length = animations.length; i < length; i++) { - animations[i].style.animation = 'none'; - } - } - - var onBeforeChange; - function setOnBeforeChange(fn) { - onBeforeChange = fn; - } - - function tryRestoreView(options) { - - var url = options.url; - var index = currentUrls.indexOf(url); - - if (index !== -1) { - - var animatable = allPages[index]; - var view = animatable; - - if (view) { - - if (options.cancel) { - return; - } - - cancelActiveAnimations(); - - var selected = selectedPageIndex; - var previousAnimatable = selected === -1 ? null : allPages[selected]; - - if (onBeforeChange) { - onBeforeChange(view, true, options); - } - - beforeAnimate(allPages, index, selected); - - animatable.classList.remove('hide'); - - return animate(animatable, previousAnimatable, options.transition, options.isBack).then(function () { - - selectedPageIndex = index; - if (!options.cancel && previousAnimatable) { - afterAnimate(allPages, index); - } - return view; - }); - } - } - - return Promise.reject(); - } - - function triggerDestroy(view) { - - view.dispatchEvent(new CustomEvent('viewdestroy', { - cancelable: false - })); - } - - function reset() { - - allPages = []; - currentUrls = []; - mainAnimatedPages.innerHTML = ''; - selectedPageIndex = -1; - } - - return { - loadView: loadView, - tryRestoreView: tryRestoreView, - reset: reset, - setOnBeforeChange: setOnBeforeChange - }; -}); \ No newline at end of file diff --git a/src/scripts/site.js b/src/scripts/site.js index 4e3c06548f..d951fd3c7e 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -864,7 +864,7 @@ var AppInfo = {}; define("imageUploader", [componentsPath + "/imageuploader/imageuploader"], returnFirstDependency); define("navdrawer", ["components/navdrawer/navdrawer"], returnFirstDependency); define("htmlMediaHelper", [componentsPath + "/htmlvideoplayer/htmlmediahelper"], returnFirstDependency); - define("viewcontainer", ["components/viewcontainer-lite", "css!" + componentsPath + "/viewmanager/viewcontainer-lite"], returnFirstDependency); + define("viewcontainer", ["components/viewcontainer-lite"], returnFirstDependency); define("queryString", [bowerPath + "/query-string/index"], function () { return queryString; }); From 86c19ee4a390dc9295a8c19474c0a2a3cc04d46d Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:48:30 +0000 Subject: [PATCH 06/30] module resolution for fullscreenManager --- src/components/fullscreen/fullscreen-dc.js | 26 ------------------ ...lscreenmanager.js => fullscreenManager.js} | 27 ++++++++++++++++++- src/scripts/site.js | 8 ++---- 3 files changed, 28 insertions(+), 33 deletions(-) delete mode 100644 src/components/fullscreen/fullscreen-dc.js rename src/components/{fullscreen/fullscreenmanager.js => fullscreenManager.js} (76%) diff --git a/src/components/fullscreen/fullscreen-dc.js b/src/components/fullscreen/fullscreen-dc.js deleted file mode 100644 index bc12a6a76d..0000000000 --- a/src/components/fullscreen/fullscreen-dc.js +++ /dev/null @@ -1,26 +0,0 @@ -define(['dom', 'fullscreenManager'], function (dom, fullscreenManager) { - 'use strict'; - - function isTargetValid(target) { - - if (dom.parentWithTag(target, ['BUTTON', 'INPUT', 'TEXTAREA'])) { - return false; - } - - return true; - } - - dom.addEventListener(window, 'dblclick', function (e) { - - if (isTargetValid(e.target)) { - if (fullscreenManager.isFullScreen()) { - fullscreenManager.exitFullscreen(); - } else { - fullscreenManager.requestFullscreen(); - } - } - - }, { - passive: true - }); -}); \ No newline at end of file diff --git a/src/components/fullscreen/fullscreenmanager.js b/src/components/fullscreenManager.js similarity index 76% rename from src/components/fullscreen/fullscreenmanager.js rename to src/components/fullscreenManager.js index 5773e57d07..0a43a764a5 100644 --- a/src/components/fullscreen/fullscreenmanager.js +++ b/src/components/fullscreenManager.js @@ -1,4 +1,4 @@ -define(['events', 'dom'], function (events, dom) { +define(['events', 'dom', 'apphost', 'browser'], function (events, dom, appHost, browser) { 'use strict'; function fullscreenManager() { @@ -79,5 +79,30 @@ define(['events', 'dom'], function (events, dom) { passive: true }); + if (appHost.supports("fullscreenchange") && (browser.edgeUwp || -1 !== navigator.userAgent.toLowerCase().indexOf("electron"))) { + function isTargetValid(target) { + + if (dom.parentWithTag(target, ['BUTTON', 'INPUT', 'TEXTAREA'])) { + return false; + } + + return true; + } + + dom.addEventListener(window, 'dblclick', function (e) { + + if (isTargetValid(e.target)) { + if (manager.isFullScreen()) { + manager.exitFullscreen(); + } else { + manager.requestFullscreen(); + } + } + + }, { + passive: true + }); + } + return manager; }); diff --git a/src/scripts/site.js b/src/scripts/site.js index d951fd3c7e..12526a56b9 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -618,11 +618,7 @@ var AppInfo = {}; } } - require(["playerSelectionMenu"]); - - if (appHost.supports("fullscreenchange") && (browser.edgeUwp || -1 !== navigator.userAgent.toLowerCase().indexOf("electron"))) { - require(["fullscreen-doubleclick"]); - } + require(["playerSelectionMenu", "fullscreenManager"]); if (appHost.supports("sync")) { initLocalSyncEvents(); @@ -779,7 +775,7 @@ var AppInfo = {}; define("searchResults", [componentsPath + "/search/searchresults"], returnFirstDependency); define("upNextDialog", [componentsPath + "/upnextdialog/upnextdialog"], returnFirstDependency); define("fullscreen-doubleclick", [componentsPath + "/fullscreen/fullscreen-dc"], returnFirstDependency); - define("fullscreenManager", [componentsPath + "/fullscreen/fullscreenmanager", "events"], returnFirstDependency); + define("fullscreenManager", [componentsPath + "/fullscreenManager", "events"], returnFirstDependency); define("headroom", [componentsPath + "/headroom/headroom"], returnFirstDependency); define("subtitleAppearanceHelper", [componentsPath + "/subtitlesettings/subtitleappearancehelper"], returnFirstDependency); define("subtitleSettings", [componentsPath + "/subtitlesettings/subtitlesettings"], returnFirstDependency); From 00c875b8935cb3527ece83d397a18be84abd945c Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:58:19 +0000 Subject: [PATCH 07/30] module resolution for headroom --- src/components/headroom/package.json | 3 +++ src/scripts/librarymenu.js | 2 +- src/scripts/site.js | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/components/headroom/package.json diff --git a/src/components/headroom/package.json b/src/components/headroom/package.json new file mode 100644 index 0000000000..9c6c42c82a --- /dev/null +++ b/src/components/headroom/package.json @@ -0,0 +1,3 @@ +{ + "main": "headroom.js" +} \ No newline at end of file diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 56339b7075..8ade3edb88 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -724,7 +724,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " } function initHeadRoom(elem) { - require(["headroom-window"], function (headroom) { + require(["headroom"], function (headroom) { headroom.add(elem); }); } diff --git a/src/scripts/site.js b/src/scripts/site.js index 12526a56b9..ff2e5449e2 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -875,7 +875,6 @@ var AppInfo = {}; define("dialogHelper", [componentsPath + "/dialogHelper/dialogHelper"], returnFirstDependency); define("inputmanager", ["inputManager"], returnFirstDependency); define("serverNotifications", [componentsPath + "/apiInput/apiInput"], returnFirstDependency); - define("headroom-window", ["headroom"], createWindowHeadroom); define("appFooter-shared", ["appFooter"], createSharedAppFooter); define("skinManager", [componentsPath + "/skinManager"], returnFirstDependency); define("connectionManager", [], function () { From 1ba0c7501e406efa041baaad74351f5d1bf56b8b Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 22:58:36 +0000 Subject: [PATCH 08/30] remove debugger from loginpage.js --- src/controllers/loginpage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/loginpage.js b/src/controllers/loginpage.js index e848bfde46..fc8369c29a 100644 --- a/src/controllers/loginpage.js +++ b/src/controllers/loginpage.js @@ -87,7 +87,7 @@ define(["appSettings", "dom", "connectionManager", "loading", "cardStyle", "emby }), view.addEventListener("viewshow", function(e) { loading.show(); var apiClient = getApiClient(); - apiClient.getPublicUsers().then(function(users) {debugger; + apiClient.getPublicUsers().then(function(users) { if (users.length) { if (users[0].EnableAutoLogin) { authenticateUserByName(view, apiClient, users[0].Name, ""); From 4a5fc817fbf5c07bf22ba526a2f7f3c65a656b2a Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 23:26:11 +0000 Subject: [PATCH 09/30] module resolution for viewManager --- src/components/viewmanager/package.json | 3 +++ src/scripts/site.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 src/components/viewmanager/package.json diff --git a/src/components/viewmanager/package.json b/src/components/viewmanager/package.json new file mode 100644 index 0000000000..819371af71 --- /dev/null +++ b/src/components/viewmanager/package.json @@ -0,0 +1,3 @@ +{ + "main": "viewManager.js" +} \ No newline at end of file diff --git a/src/scripts/site.js b/src/scripts/site.js index ff2e5449e2..cfd2d58f55 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -801,7 +801,7 @@ var AppInfo = {}; define("programStyles", ["css!" + componentsPath + "/guide/programs"], returnFirstDependency); define("guide-settings-dialog", [componentsPath + "/guide/guide-settings"], returnFirstDependency); define("loadingDialog", [componentsPath + "/loadingdialog/loadingdialog"], returnFirstDependency); - define("viewManager", [componentsPath + "/viewmanager/viewmanager"], function (viewManager) { + define("viewManager", [componentsPath + "/viewManager/viewManager"], function (viewManager) { window.ViewManager = viewManager; viewManager.dispatchPageEvents(true); return viewManager; From a03502646c0970b9a637853ae6cd050831be3ddf Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 23:26:28 +0000 Subject: [PATCH 10/30] bug fixes for headroom --- src/components/emby-scroller/emby-scroller.js | 3 +- src/components/headroom/headroom.js | 109 +++++++++--------- src/scripts/librarymenu.js | 3 +- src/scripts/site.js | 1 - 4 files changed, 56 insertions(+), 60 deletions(-) diff --git a/src/components/emby-scroller/emby-scroller.js b/src/components/emby-scroller/emby-scroller.js index d3718cedf3..7ef39eea0a 100644 --- a/src/components/emby-scroller/emby-scroller.js +++ b/src/components/emby-scroller/emby-scroller.js @@ -108,8 +108,7 @@ define(['scroller', 'dom', 'layoutManager', 'inputManager', 'focusManager', 'bro var headroom = new Headroom([], { scroller: elem }); - // initialise - headroom.init(); + headroom.add(document.querySelector('.skinHeader')); elem.headroom = headroom; }); diff --git a/src/components/headroom/headroom.js b/src/components/headroom/headroom.js index 9cb1cac04d..a3cc5b0435 100644 --- a/src/components/headroom/headroom.js +++ b/src/components/headroom/headroom.js @@ -75,47 +75,25 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay this.pinnedClass = options.pinnedClass; this.state = 'clear'; - } - function onScroll() { + this.options = { + offset: 0, + scroller: window, + initialClass: 'headroom', + unPinnedClass: 'headroom--unpinned', + pinnedClass: 'headroom--pinned' + }; - if (this.paused) { - return; - } - - requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this))); - } - - Headroom.prototype = { - constructor: Headroom, - - /** - * Initialises the widget - */ - init: function () { - - if (browser.supportsCssAnimation()) { - for (var i = 0, length = this.elems.length; i < length; i++) { - this.elems[i].classList.add(this.initialClass); - this.elems[i].addEventListener('clearheadroom', onHeadroomClearedExternally.bind(this)); - } - - this.attachEvent(); - } - - return this; - }, - - add: function (elem) { + this.add = function (elem) { if (browser.supportsCssAnimation()) { elem.classList.add(this.initialClass); elem.addEventListener('clearheadroom', onHeadroomClearedExternally.bind(this)); this.elems.push(elem); } - }, + }; - remove: function (elem) { + this.remove = function (elem) { elem.classList.remove(this.unPinnedClass); elem.classList.remove(this.initialClass); @@ -125,20 +103,20 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay if (i !== -1) { this.elems.splice(i, 1); } - }, + }; - pause: function () { + this.pause = function () { this.paused = true; - }, + }; - resume: function () { + this.resume = function () { this.paused = false; - }, + }; /** * Unattaches events and removes any classes that were added */ - destroy: function () { + this.destroy = function () { this.initialised = false; @@ -157,13 +135,13 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay capture: false, passive: true }); - }, + }; /** * Attaches the scroll event * @private */ - attachEvent: function () { + this.attachEvent = function () { if (!this.initialised) { this.lastKnownScrollY = this.getScrollY(); this.initialised = true; @@ -177,12 +155,12 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay this.update(); } - }, + }; /** * Unpins the header if it's currently pinned */ - clear: function () { + this.clear = function () { if (this.state === 'clear') { return; @@ -199,12 +177,12 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay classList.remove(unpinnedClass); //classList.remove(pinnedClass); } - }, + }; /** * Unpins the header if it's currently pinned */ - pin: function () { + this.pin = function () { if (this.state === 'pin') { return; @@ -221,12 +199,12 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay classList.remove(unpinnedClass); classList.add(pinnedClass); } - }, + }; /** * Unpins the header if it's currently pinned */ - unpin: function () { + this.unpin = function () { if (this.state === 'unpin') { return; @@ -243,14 +221,14 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay classList.add(unpinnedClass); //classList.remove(pinnedClass); } - }, + }; /** * Gets the Y scroll position * @see https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY * @return {Number} pixels the page has scrolled along the Y-axis */ - getScrollY: function () { + this.getScrollY = function () { var scroller = this.scroller; @@ -269,36 +247,36 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay } return (document.documentElement || document.body).scrollTop; - }, + }; /** * determine if it is appropriate to unpin * @param {int} currentScrollY the current y scroll position * @return {bool} true if should unpin, false otherwise */ - shouldUnpin: function (currentScrollY) { + this.shouldUnpin = function (currentScrollY) { var scrollingDown = currentScrollY > this.lastKnownScrollY, pastOffset = currentScrollY >= this.offset; return scrollingDown && pastOffset; - }, + }; /** * determine if it is appropriate to pin * @param {int} currentScrollY the current y scroll position * @return {bool} true if should pin, false otherwise */ - shouldPin: function (currentScrollY) { + this.shouldPin = function (currentScrollY) { var scrollingUp = currentScrollY < this.lastKnownScrollY, pastOffset = currentScrollY <= this.offset; return scrollingUp || pastOffset; - }, + }; /** * Handles updating the state of the widget */ - update: function () { + this.update = function () { if (this.paused) { return; @@ -330,8 +308,28 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay } this.lastKnownScrollY = currentScrollY; + }; + + + if (browser.supportsCssAnimation()) { + for (var i = 0, length = this.elems.length; i < length; i++) { + this.elems[i].classList.add(this.initialClass); + this.elems[i].addEventListener('clearheadroom', onHeadroomClearedExternally.bind(this)); + } + + this.attachEvent(); } - }; + } + + function onScroll() { + + if (this.paused) { + return; + } + + requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this))); + } + /** * Default options * @type {Object} @@ -345,5 +343,4 @@ define(['dom', 'layoutManager', 'browser', 'css!./headroom'], function (dom, lay }; return Headroom; - }); \ No newline at end of file diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 8ade3edb88..9f21b81c16 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -724,7 +724,8 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " } function initHeadRoom(elem) { - require(["headroom"], function (headroom) { + require(["headroom"], function (Headroom) { + var headroom = new Headroom([], {}); headroom.add(elem); }); } diff --git a/src/scripts/site.js b/src/scripts/site.js index cfd2d58f55..1cd32d5273 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -345,7 +345,6 @@ var AppInfo = {}; function createWindowHeadroom(Headroom) { var headroom = new Headroom([], {}); - headroom.init(); return headroom; } From 578a1670f44c06ee618f94ed7349b99895dcc338 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Wed, 27 Feb 2019 23:29:13 +0000 Subject: [PATCH 11/30] module resoltion for viewContainer --- src/components/{viewcontainer-lite.js => viewContainer.js} | 2 +- .../viewmanager/{viewcontainer-lite.css => viewContainer.css} | 0 src/scripts/site.js | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/components/{viewcontainer-lite.js => viewContainer.js} (98%) rename src/components/viewmanager/{viewcontainer-lite.css => viewContainer.css} (100%) diff --git a/src/components/viewcontainer-lite.js b/src/components/viewContainer.js similarity index 98% rename from src/components/viewcontainer-lite.js rename to src/components/viewContainer.js index fbcc2754e0..7dd036bc96 100644 --- a/src/components/viewcontainer-lite.js +++ b/src/components/viewContainer.js @@ -1,4 +1,4 @@ -define(["browser", "dom", "layoutManager", "css!components/viewmanager/viewcontainer-lite"], function(browser, dom, layoutManager) { +define(["browser", "dom", "layoutManager", "css!components/viewmanager/viewContainer"], function(browser, dom, layoutManager) { "use strict"; function setControllerClass(view, options) { diff --git a/src/components/viewmanager/viewcontainer-lite.css b/src/components/viewmanager/viewContainer.css similarity index 100% rename from src/components/viewmanager/viewcontainer-lite.css rename to src/components/viewmanager/viewContainer.css diff --git a/src/scripts/site.js b/src/scripts/site.js index 1cd32d5273..dc3c7bfcf3 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -859,7 +859,7 @@ var AppInfo = {}; define("imageUploader", [componentsPath + "/imageuploader/imageuploader"], returnFirstDependency); define("navdrawer", ["components/navdrawer/navdrawer"], returnFirstDependency); define("htmlMediaHelper", [componentsPath + "/htmlvideoplayer/htmlmediahelper"], returnFirstDependency); - define("viewcontainer", ["components/viewcontainer-lite"], returnFirstDependency); + define("viewcontainer", ["components/viewContainer"], returnFirstDependency); define("queryString", [bowerPath + "/query-string/index"], function () { return queryString; }); From ba89941fce474933cf259c1b04bf6dbf8ed229df Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Feb 2019 00:01:07 +0000 Subject: [PATCH 12/30] module resolution for toast and serverRestartDialog --- .../serverrestartdialog.js => serverRestartDialog.js} | 0 src/components/toast/package.json | 3 +++ src/scripts/site.js | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) rename src/components/{serverrestartdialog/serverrestartdialog.js => serverRestartDialog.js} (100%) create mode 100644 src/components/toast/package.json diff --git a/src/components/serverrestartdialog/serverrestartdialog.js b/src/components/serverRestartDialog.js similarity index 100% rename from src/components/serverrestartdialog/serverrestartdialog.js rename to src/components/serverRestartDialog.js diff --git a/src/components/toast/package.json b/src/components/toast/package.json new file mode 100644 index 0000000000..2e64841a7f --- /dev/null +++ b/src/components/toast/package.json @@ -0,0 +1,3 @@ +{ + "main": "toast.js" +} \ No newline at end of file diff --git a/src/scripts/site.js b/src/scripts/site.js index dc3c7bfcf3..f8e348b5ab 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -754,7 +754,7 @@ var AppInfo = {}; define("emby-radio", [componentsPath + "/emby-radio/emby-radio"], returnFirstDependency); define("emby-textarea", [componentsPath + "/emby-textarea/emby-textarea"], returnFirstDependency); define("collectionEditor", [componentsPath + "/collectioneditor/collectioneditor"], returnFirstDependency); - define("serverRestartDialog", [componentsPath + "/serverrestartdialog/serverrestartdialog"], returnFirstDependency); + define("serverRestartDialog", [componentsPath + "/serverRestartDialog"], returnFirstDependency); define("playlistEditor", [componentsPath + "/playlisteditor/playlisteditor"], returnFirstDependency); define("recordingCreator", [componentsPath + "/recordingcreator/recordingcreator"], returnFirstDependency); define("recordingEditor", [componentsPath + "/recordingcreator/recordingeditor"], returnFirstDependency); From d57629d90f1ddfcf31ad402a91817e4bee3a1b5e Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Feb 2019 00:06:23 +0000 Subject: [PATCH 13/30] module resolution for serverNotifications --- src/components/apiInput/package.json | 3 --- .../{apiInput => serverNotifications}/gamepadtokey.js | 0 .../{apiInput => serverNotifications}/mouseManager.js | 0 src/components/serverNotifications/package.json | 3 +++ .../serverNotifications.js} | 4 ++-- src/scripts/site.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 src/components/apiInput/package.json rename src/components/{apiInput => serverNotifications}/gamepadtokey.js (100%) rename src/components/{apiInput => serverNotifications}/mouseManager.js (100%) create mode 100644 src/components/serverNotifications/package.json rename src/components/{apiInput/apiInput.js => serverNotifications/serverNotifications.js} (98%) diff --git a/src/components/apiInput/package.json b/src/components/apiInput/package.json deleted file mode 100644 index 6c542951b2..0000000000 --- a/src/components/apiInput/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "apiInput.js" -} \ No newline at end of file diff --git a/src/components/apiInput/gamepadtokey.js b/src/components/serverNotifications/gamepadtokey.js similarity index 100% rename from src/components/apiInput/gamepadtokey.js rename to src/components/serverNotifications/gamepadtokey.js diff --git a/src/components/apiInput/mouseManager.js b/src/components/serverNotifications/mouseManager.js similarity index 100% rename from src/components/apiInput/mouseManager.js rename to src/components/serverNotifications/mouseManager.js diff --git a/src/components/serverNotifications/package.json b/src/components/serverNotifications/package.json new file mode 100644 index 0000000000..779da202d2 --- /dev/null +++ b/src/components/serverNotifications/package.json @@ -0,0 +1,3 @@ +{ + "main": "serverNotifications.js" +} \ No newline at end of file diff --git a/src/components/apiInput/apiInput.js b/src/components/serverNotifications/serverNotifications.js similarity index 98% rename from src/components/apiInput/apiInput.js rename to src/components/serverNotifications/serverNotifications.js index 388fb11beb..2537723b68 100644 --- a/src/components/apiInput/apiInput.js +++ b/src/components/serverNotifications/serverNotifications.js @@ -248,10 +248,10 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus }); if (!enableNativeGamepadKeyMapping() && isGamepadSupported()) { - require(["components/apiInput/gamepadtokey"]); + require(["components/serverNotifications/gamepadtokey"]); } - require(["components/apiInput/mouseManager"]); + require(["components/serverNotifications/mouseManager"]); return serverNotifications; }); diff --git a/src/scripts/site.js b/src/scripts/site.js index f8e348b5ab..f4574c36f8 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -873,7 +873,7 @@ var AppInfo = {}; define("fnchecked", ["legacy/fnchecked"], returnFirstDependency); define("dialogHelper", [componentsPath + "/dialogHelper/dialogHelper"], returnFirstDependency); define("inputmanager", ["inputManager"], returnFirstDependency); - define("serverNotifications", [componentsPath + "/apiInput/apiInput"], returnFirstDependency); + define("serverNotifications", [componentsPath + "/serverNotifications/serverNotifications"], returnFirstDependency); define("appFooter-shared", ["appFooter"], createSharedAppFooter); define("skinManager", [componentsPath + "/skinManager"], returnFirstDependency); define("connectionManager", [], function () { From 52af8d487eea5bc50aa82b15411452cafbbfe7ed Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Feb 2019 00:10:39 +0000 Subject: [PATCH 14/30] module resolution for scroller --- src/components/{scroller/smoothscroller.js => scroller.js} | 0 src/scripts/site.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/components/{scroller/smoothscroller.js => scroller.js} (100%) diff --git a/src/components/scroller/smoothscroller.js b/src/components/scroller.js similarity index 100% rename from src/components/scroller/smoothscroller.js rename to src/components/scroller.js diff --git a/src/scripts/site.js b/src/scripts/site.js index f4574c36f8..17a264667b 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -845,7 +845,7 @@ var AppInfo = {}; define("itemrepository", [apiClientBowerPath + "/sync/itemrepository"], returnFirstDependency); define("useractionrepository", [apiClientBowerPath + "/sync/useractionrepository"], returnFirstDependency); define("swiper", [bowerPath + "/Swiper/dist/js/swiper.min", "css!" + bowerPath + "/Swiper/dist/css/swiper.min"], returnFirstDependency); - define("scroller", [componentsPath + "/scroller/smoothscroller"], returnFirstDependency); + define("scroller", [componentsPath + "/scroller"], returnFirstDependency); define("toast", [componentsPath + "/toast/toast"], returnFirstDependency); define("scrollHelper", [componentsPath + "/scrollhelper"], returnFirstDependency); define("touchHelper", [componentsPath + "/touchhelper"], returnFirstDependency); From f56a82b800ac8f705c13b8bb1939882f9ca466c2 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Feb 2019 00:32:37 +0000 Subject: [PATCH 15/30] module resolution for loading, page and playerSelectionMenu --- src/components/appRouter.js | 2 +- .../loading/{loading-lite.css => loading.css} | 0 .../loading/{loading-lite.js => loading.js} | 6 +- .../{loading-legacy.css => loadingLegacy.css} | 0 .../{loading-legacy.js => loadingLegacy.js} | 2 +- src/components/loading/package.json | 3 + src/components/navdrawer/package.json | 3 + src/{thirdparty/pagejs => components}/page.js | 0 ...yerselection.js => playerSelectionMenu.js} | 0 src/scripts/site.js | 11 +- src/thirdparty/page.js | 1077 +++++++++++++++++ 11 files changed, 1093 insertions(+), 11 deletions(-) rename src/components/loading/{loading-lite.css => loading.css} (100%) rename src/components/loading/{loading-lite.js => loading.js} (93%) rename src/components/loading/{loading-legacy.css => loadingLegacy.css} (100%) rename src/components/loading/{loading-legacy.js => loadingLegacy.js} (90%) create mode 100644 src/components/loading/package.json create mode 100644 src/components/navdrawer/package.json rename src/{thirdparty/pagejs => components}/page.js (100%) rename src/components/playback/{playerselection.js => playerSelectionMenu.js} (100%) create mode 100644 src/thirdparty/page.js diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 92950c66f6..ffe3065bbb 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -1,4 +1,4 @@ -define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinManager', 'pluginManager', 'backdrop', 'browser', 'pageJs', 'appSettings', 'apphost', 'connectionManager'], function (loading, globalize, events, viewManager, layoutManager, skinManager, pluginManager, backdrop, browser, page, appSettings, appHost, connectionManager) { +define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinManager', 'pluginManager', 'backdrop', 'browser', 'page', 'appSettings', 'apphost', 'connectionManager'], function (loading, globalize, events, viewManager, layoutManager, skinManager, pluginManager, backdrop, browser, page, appSettings, appHost, connectionManager) { 'use strict'; var appRouter = { diff --git a/src/components/loading/loading-lite.css b/src/components/loading/loading.css similarity index 100% rename from src/components/loading/loading-lite.css rename to src/components/loading/loading.css diff --git a/src/components/loading/loading-lite.js b/src/components/loading/loading.js similarity index 93% rename from src/components/loading/loading-lite.js rename to src/components/loading/loading.js index 00aff8f0f8..ad9aea950a 100644 --- a/src/components/loading/loading-lite.js +++ b/src/components/loading/loading.js @@ -1,6 +1,10 @@ -define(['css!./loading-lite'], function () { +define(['components/loading/loadingLegacy', 'browser', 'css!./loading'], function (loadingLegacy, browser) { 'use strict'; + if (browser.tizen || browser.operaTv || browser.chromecast || browser.orsay || browser.web0s || browser.ps4) { + return loadingLegacy; + } + var loadingElem; var layer1; var layer2; diff --git a/src/components/loading/loading-legacy.css b/src/components/loading/loadingLegacy.css similarity index 100% rename from src/components/loading/loading-legacy.css rename to src/components/loading/loadingLegacy.css diff --git a/src/components/loading/loading-legacy.js b/src/components/loading/loadingLegacy.js similarity index 90% rename from src/components/loading/loading-legacy.js rename to src/components/loading/loadingLegacy.js index bb8d8a99ab..c5ffd8dc6b 100644 --- a/src/components/loading/loading-legacy.js +++ b/src/components/loading/loadingLegacy.js @@ -1,4 +1,4 @@ -define(['require', 'css!./loading-legacy'], function (require) { +define(['require', 'css!./loadingLegacy'], function (require) { 'use strict'; var loadingElem; diff --git a/src/components/loading/package.json b/src/components/loading/package.json new file mode 100644 index 0000000000..79fd41b0f8 --- /dev/null +++ b/src/components/loading/package.json @@ -0,0 +1,3 @@ +{ + "main": "loading.js" +} \ No newline at end of file diff --git a/src/components/navdrawer/package.json b/src/components/navdrawer/package.json new file mode 100644 index 0000000000..d02800957b --- /dev/null +++ b/src/components/navdrawer/package.json @@ -0,0 +1,3 @@ +{ + "main": "navdrawer.js" +} \ No newline at end of file diff --git a/src/thirdparty/pagejs/page.js b/src/components/page.js similarity index 100% rename from src/thirdparty/pagejs/page.js rename to src/components/page.js diff --git a/src/components/playback/playerselection.js b/src/components/playback/playerSelectionMenu.js similarity index 100% rename from src/components/playback/playerselection.js rename to src/components/playback/playerSelectionMenu.js diff --git a/src/scripts/site.js b/src/scripts/site.js index 17a264667b..f2c91d0a81 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -445,12 +445,7 @@ var AppInfo = {}; define("prompt", [componentsPath + "/prompt/prompt"], returnFirstDependency); } - if (browser.tizen || browser.operaTv || browser.chromecast || browser.orsay || browser.web0s || browser.ps4) { - define("loading", [componentsPath + "/loading/loading-legacy"], returnFirstDependency); - } else { - define("loading", [componentsPath + "/loading/loading-lite"], returnFirstDependency); - } - + define("loading", [componentsPath + "/loading/loading"], returnFirstDependency); define("multi-download", [componentsPath + "/multidownload"], returnFirstDependency); define("fileDownloader", [componentsPath + "/filedownloader"], returnFirstDependency); define("localassetmanager", [apiClientBowerPath + "/localassetmanager"], returnFirstDependency); @@ -701,7 +696,7 @@ var AppInfo = {}; inputManager: componentsPath + "/inputmanager", qualityoptions: componentsPath + "/qualityoptions", hammer: bowerPath + "/hammerjs/hammer.min", - pageJs: "thirdparty/pagejs/page", + page: "thirdparty/page", focusManager: componentsPath + "/focusmanager", datetime: componentsPath + "/datetime", globalize: componentsPath + "/globalize", @@ -727,7 +722,7 @@ var AppInfo = {}; define("directorybrowser", ["components/directorybrowser/directorybrowser"], returnFirstDependency); define("metadataEditor", [componentsPath + "/metadataeditor/metadataeditor"], returnFirstDependency); define("personEditor", [componentsPath + "/metadataeditor/personeditor"], returnFirstDependency); - define("playerSelectionMenu", [componentsPath + "/playback/playerselection"], returnFirstDependency); + define("playerSelectionMenu", [componentsPath + "/playback/playerSelectionMenu"], returnFirstDependency); define("playerSettingsMenu", [componentsPath + "/playback/playersettingsmenu"], returnFirstDependency); define("playMethodHelper", [componentsPath + "/playback/playmethodhelper"], returnFirstDependency); define("brightnessOsd", [componentsPath + "/playback/brightnessosd"], returnFirstDependency); diff --git a/src/thirdparty/page.js b/src/thirdparty/page.js new file mode 100644 index 0000000000..ce96fd185e --- /dev/null +++ b/src/thirdparty/page.js @@ -0,0 +1,1077 @@ +define([], function () { + + 'use strict'; + + /** + * Detect click event + */ + var clickEvent = ('undefined' !== typeof document) && document.ontouchstart ? 'touchstart' : 'click'; + + /** + * To work properly with the URL + * history.location generated polyfill in https://github.com/devote/HTML5-History-API + */ + + var location = ('undefined' !== typeof window) && (window.history.location || window.location); + + /** + * Perform initial dispatch. + */ + + var dispatch = true; + + + /** + * Decode URL components (query string, pathname, hash). + * Accommodates both regular percent encoding and x-www-form-urlencoded format. + */ + var decodeURLComponents = true; + + /** + * Base path. + */ + + var base = ''; + + /** + * Running flag. + */ + + var running; + + /** + * HashBang option + */ + + var hashbang = false; + + var enableHistory = false; + + /** + * Previous context, for capturing + * page exit events. + */ + + var prevContext; + + var prevPageContext; + + /** + * Register `path` with callback `fn()`, + * or route `path`, or redirection, + * or `page.start()`. + * + * page(fn); + * page('*', fn); + * page('/user/:id', load, user); + * page('/user/' + user.id, { some: 'thing' }); + * page('/user/' + user.id); + * page('/from', '/to') + * page(); + * + * @param {String|Function} path + * @param {Function} fn... + * @api public + */ + + function page(path, fn) { + // + if ('function' === typeof path) { + return page('*', path); + } + + // route to + if ('function' === typeof fn) { + var route = new Route(path); + for (var i = 1; i < arguments.length; ++i) { + page.callbacks.push(route.middleware(arguments[i])); + } + // show with [state] + } else if ('string' === typeof path) { + page['string' === typeof fn ? 'redirect' : 'show'](path, fn); + // start [options] + } else { + page.start(path); + } + } + + /** + * Callback functions. + */ + + page.callbacks = []; + page.exits = []; + + /** + * Current path being processed + * @type {String} + */ + page.current = ''; + + /** + * Number of pages navigated to. + * @type {number} + * + * page.len == 0; + * page('/login'); + * page.len == 1; + */ + + page.len = 0; + + /** + * Get or set basepath to `path`. + * + * @param {String} path + * @api public + */ + + page.base = function (path) { + if (0 === arguments.length) { + return base; + } + base = path; + }; + + /** + * Bind with the given `options`. + * + * Options: + * + * - `click` bind to click events [true] + * - `popstate` bind to popstate [true] + * - `dispatch` perform initial dispatch [true] + * + * @param {Object} options + * @api public + */ + + page.start = function (options) { + options = options || {}; + if (running) { + return; + } + running = true; + if (false === options.dispatch) { + dispatch = false; + } + if (false === options.decodeURLComponents) { + decodeURLComponents = false; + } + if (false !== options.popstate) { + window.addEventListener('popstate', onpopstate, false); + } + if (false !== options.click) { + document.addEventListener(clickEvent, onclick, false); + } + if (options.enableHistory != null) { + enableHistory = options.enableHistory; + } + if (true === options.hashbang) { + hashbang = true; + } + if (!dispatch) { + return; + } + + var url; + + if (hashbang && ~location.hash.indexOf('#!')) { + + url = location.hash.substr(2); + + var href = location.href.toString(); + if (href.indexOf('?') >= href.indexOf('#!')) { + url += location.search; + } + } + else { + url = location.pathname + location.search + location.hash; + } + + page.replace(url, null, true, dispatch); + }; + + /** + * Unbind click and popstate event handlers. + * + * @api public + */ + + page.stop = function () { + if (!running) { + return; + } + page.current = ''; + page.len = 0; + running = false; + document.removeEventListener(clickEvent, onclick, false); + window.removeEventListener('popstate', onpopstate, false); + }; + + /** + * Show `path` with optional `state` object. + * + * @param {String} path + * @param {Object} state + * @param {Boolean} dispatch + * @return {Context} + * @api public + */ + + page.show = function (path, state, dispatch, push, isBack) { + var ctx = new Context(path, state); + ctx.isBack = isBack; + page.current = ctx.path; + if (false !== dispatch) { + page.dispatch(ctx); + } + if (false !== ctx.handled && false !== push) { + ctx.pushState(); + } + return ctx; + }; + + page.restorePreviousState = function () { + + prevContext = prevPageContext; + page.show(prevContext.pathname, prevContext.state, false, true, false); + }; + + /** + * Goes back in the history + * Back should always let the current route push state and then go back. + * + * @param {String} path - fallback path to go back if no more history exists, if undefined defaults to page.base + * @param {Object} [state] + * @api public + */ + + page.back = function (path, state) { + + if (enableHistory) { + // Keep it simple and mimic browser back + history.back(); + return; + } + + if (page.len > 0) { + // this may need more testing to see if all browsers + // wait for the next tick to go back in history + if (enableHistory) { + history.back(); + } else { + + if (backStack.length > 2) { + backStack.length--; + var previousState = backStack[backStack.length - 1]; + page.show(previousState.path, previousState.state, true, false, true); + } + } + page.len--; + } else if (path) { + setTimeout(function () { + page.show(path, state); + }); + } else { + setTimeout(function () { + page.show(base, state); + }); + } + }; + + page.enableNativeHistory = function () { + return enableHistory; + }; + + page.canGoBack = function () { + if (enableHistory) { + return history.length > 1; + } + return (page.len || 0) > 0; + }; + + /** + * Register route to redirect from one path to other + * or just redirect to another route + * + * @param {String} from - if param 'to' is undefined redirects to 'from' + * @param {String} [to] + * @api public + */ + page.redirect = function (from, to) { + // Define route from a path to another + if ('string' === typeof from && 'string' === typeof to) { + page(from, function (e) { + setTimeout(function () { + page.replace(to); + }, 0); + }); + } + + // Wait for the push state and replace it with another + if ('string' === typeof from && 'undefined' === typeof to) { + setTimeout(function () { + page.replace(from); + }, 0); + } + }; + + /** + * Replace `path` with optional `state` object. + * + * @param {String} path + * @param {Object} state + * @return {Context} + * @api public + */ + + + page.replace = function (path, state, init, dispatch, isBack) { + var ctx = new Context(path, state); + ctx.isBack = isBack; + page.current = ctx.path; + ctx.init = init; + ctx.save(); // save before dispatching, which may redirect + if (false !== dispatch) { + page.dispatch(ctx); + } + return ctx; + }; + + /** + * Dispatch the given `ctx`. + * + * @param {Object} ctx + * @api private + */ + + page.dispatch = function (ctx) { + var prev = prevContext, + i = 0, + j = 0; + + prevPageContext = prevContext; + prevContext = ctx; + + function nextExit() { + var fn = page.exits[j++]; + if (!fn) { + return nextEnter(); + } + fn(prev, nextExit); + } + + function nextEnter() { + var fn = page.callbacks[i++]; + + if (ctx.path !== page.current) { + ctx.handled = false; + return; + } + if (!fn) { + return unhandled(ctx); + } + fn(ctx, nextEnter); + } + + if (prev) { + nextExit(); + } else { + nextEnter(); + } + }; + + /** + * Unhandled `ctx`. When it's not the initial + * popstate then redirect. If you wish to handle + * 404s on your own use `page('*', callback)`. + * + * @param {Context} ctx + * @api private + */ + + function unhandled(ctx) { + if (ctx.handled) { + return; + } + var current; + + if (hashbang) { + current = base + location.hash.replace('#!', ''); + } else { + current = location.pathname + location.search; + } + + if (current === ctx.canonicalPath) { + return; + } + page.stop(); + ctx.handled = false; + location.href = ctx.canonicalPath; + } + + /** + * Register an exit route on `path` with + * callback `fn()`, which will be called + * on the previous context when a new + * page is visited. + */ + page.exit = function (path, fn) { + if (typeof path === 'function') { + return page.exit('*', path); + } + + var route = new Route(path); + for (var i = 1; i < arguments.length; ++i) { + page.exits.push(route.middleware(arguments[i])); + } + }; + + /** + * Remove URL encoding from the given `str`. + * Accommodates whitespace in both x-www-form-urlencoded + * and regular percent-encoded form. + * + * @param {str} URL component to decode + */ + function decodeURLEncodedURIComponent(val) { + if (typeof val !== 'string') { return val; } + return decodeURLComponents ? decodeURIComponent(val.replace(/\+/g, ' ')) : val; + } + + /** + * Initialize a new "request" `Context` + * with the given `path` and optional initial `state`. + * + * @param {String} path + * @param {Object} state + * @api public + */ + + function Context(path, state) { + if ('/' === path[0] && 0 !== path.indexOf(base)) { + path = base + (hashbang ? '#!' : '') + path; + } + var i = path.indexOf('?'); + + this.canonicalPath = path; + this.path = path.replace(base, '') || '/'; + if (hashbang) { + this.path = this.path.replace('#!', '') || '/'; + } + + this.title = document.title; + this.state = state || {}; + this.state.path = path; + this.querystring = ~i ? decodeURLEncodedURIComponent(path.slice(i + 1)) : ''; + this.pathname = decodeURLEncodedURIComponent(~i ? path.slice(0, i) : path); + this.params = {}; + + // fragment + this.hash = ''; + if (!hashbang) { + if (!~this.path.indexOf('#')) { + return; + } + var parts = this.path.split('#'); + this.path = parts[0]; + this.hash = decodeURLEncodedURIComponent(parts[1]) || ''; + this.querystring = this.querystring.split('#')[0]; + } + } + + /** + * Expose `Context`. + */ + + page.Context = Context; + var backStack = []; + + /** + * Push state. + * + * @api private + */ + + Context.prototype.pushState = function () { + page.len++; + + if (enableHistory) { + history.pushState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); + } else { + backStack.push({ + state: this.state, + title: this.title, + url: (hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath), + path: this.path + }); + } + }; + + /** + * Save the context state. + * + * @api public + */ + + Context.prototype.save = function () { + + if (enableHistory) { + history.replaceState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); + } else { + backStack[page.len || 0] = { + state: this.state, + title: this.title, + url: (hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath), + path: this.path + }; + } + }; + + /** + * Initialize `Route` with the given HTTP `path`, + * and an array of `callbacks` and `options`. + * + * Options: + * + * - `sensitive` enable case-sensitive routes + * - `strict` enable strict matching for trailing slashes + * + * @param {String} path + * @param {Object} options. + * @api private + */ + + function Route(path, options) { + options = options || {}; + this.path = (path === '*') ? '(.*)' : path; + this.method = 'GET'; + this.regexp = pathToRegexp(this.path, + this.keys = [], + options.sensitive, + options.strict); + } + + /** + * Expose `Route`. + */ + + page.Route = Route; + + /** + * Return route middleware with + * the given callback `fn()`. + * + * @param {Function} fn + * @return {Function} + * @api public + */ + + Route.prototype.middleware = function (fn) { + var self = this; + return function (ctx, next) { + if (self.match(ctx.path, ctx.params)) { + return fn(ctx, next); + } + next(); + }; + }; + + /** + * Check if this route matches `path`, if so + * populate `params`. + * + * @param {String} path + * @param {Object} params + * @return {Boolean} + * @api private + */ + + Route.prototype.match = function (path, params) { + var keys = this.keys, + qsIndex = path.indexOf('?'), + pathname = ~qsIndex ? path.slice(0, qsIndex) : path, + m = this.regexp.exec(decodeURIComponent(pathname)); + + if (!m) { + return false; + } + + for (var i = 1, len = m.length; i < len; ++i) { + var key = keys[i - 1]; + var val = decodeURLEncodedURIComponent(m[i]); + if (val !== undefined || !(hasOwnProperty.call(params, key.name))) { + params[key.name] = val; + } + } + + return true; + }; + + + var previousPopState = {}; + + function ignorePopState(event) { + + var state = event.state || {}; + + if (previousPopState.navigate === false) { + // Ignore + previousPopState = state; + return true; + } + + previousPopState = state; + return false; + } + + page.pushState = function (state, title, url) { + + if (hashbang) { + url = '#!' + url; + } + + history.pushState(state, title, url); + previousPopState = state; + }; + + /** + * Handle "populate" events. + */ + + var onpopstate = (function () { + var loaded = false; + if ('undefined' === typeof window) { + return; + } + if (document.readyState === 'complete') { + loaded = true; + } else { + window.addEventListener('load', function () { + setTimeout(function () { + loaded = true; + }, 0); + }); + } + return function onpopstate(e) { + if (!loaded) { + return; + } + if (ignorePopState(e)) { + return; + } + if (e.state) { + var path = e.state.path; + page.replace(path, e.state, null, null, true); + } else { + page.show(location.pathname + location.hash, undefined, undefined, false, true); + } + }; + })(); + /** + * Handle "click" events. + */ + + function onclick(e, checkWhich) { + + if (1 !== which(e) && checkWhich !== false) { + return; + } + + if (e.metaKey || e.ctrlKey || e.shiftKey) { + return; + } + if (e.defaultPrevented) { + return; + } + + + // ensure link + var el = e.target; + + while (el && 'A' !== el.nodeName) { + el = el.parentNode; + } + if (!el || 'A' !== el.nodeName) { + return; + } + + + // Ignore if tag has + // 1. "download" attribute + // 2. rel="external" attribute + if (el.hasAttribute('download') || el.getAttribute('rel') === 'external') { + return; + } + + // ensure non-hash for the same path + var link = el.getAttribute('href'); + if (link === '#') { + e.preventDefault(); + return; + } + + if (!hashbang && el.pathname === location.pathname && (el.hash || '#' === link)) { + return; + } + + // check target + if (el.target) { + return; + } + + // x-origin + if (!sameOrigin(el.href)) { + return; + } + + // rebuild path + var path = el.pathname + el.search + (el.hash || ''); + + // same page + var orig = path; + + if (path.indexOf(base) === 0) { + path = path.substr(base.length); + } + + if (hashbang) { + path = path.replace('#!', ''); + } + + if (base && orig === path) { + // This is causing navigation to be canceled in edge uwp + // If needed this can be changed to only be skipped when called via handleAnchorClick + //return; + } + + e.preventDefault(); + page.show(orig); + } + + page.handleAnchorClick = onclick; + + /** + * Event button. + */ + + function which(e) { + e = e || window.event; + return null === e.which ? e.button : e.which; + } + + /** + * Check if `href` is the same origin. + */ + + function sameOrigin(href) { + var origin = location.protocol + '//' + location.hostname; + if (location.port) { + origin += ':' + location.port; + } + return (href && (0 === href.indexOf(origin))); + } + + page.sameOrigin = sameOrigin; + + /** + * The main path matching regexp utility. + * + * @type {RegExp} + */ + var PATH_REGEXP = new RegExp([ + // Match escaped characters that would otherwise appear in future matches. + // This allows the user to escape special characters that won't transform. + '(\\\\.)', + // Match Express-style parameters and un-named parameters with a prefix + // and optional suffixes. Matches appear as: + // + // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] + // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] + // "/*" => ["/", undefined, undefined, undefined, undefined, "*"] + '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))' + ].join('|'), 'g'); + + /** + * Parse a string for the raw tokens. + * + * @param {String} str + * @return {Array} + */ + function parse(str) { + var tokens = []; + var key = 0; + var index = 0; + var path = ''; + var res; + + while ((res = PATH_REGEXP.exec(str)) != null) { + var m = res[0]; + var escaped = res[1]; + var offset = res.index; + path += str.slice(index, offset); + index = offset + m.length; + + // Ignore already escaped sequences. + if (escaped) { + path += escaped[1]; + continue; + } + + // Push the current path onto the tokens. + if (path) { + tokens.push(path); + path = ''; + } + + var prefix = res[2]; + var name = res[3]; + var capture = res[4]; + var group = res[5]; + var suffix = res[6]; + var asterisk = res[7]; + + var repeat = suffix === '+' || suffix === '*'; + var optional = suffix === '?' || suffix === '*'; + var delimiter = prefix || '/'; + var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?'); + + tokens.push({ + name: name || key++, + prefix: prefix || '', + delimiter: delimiter, + optional: optional, + repeat: repeat, + pattern: escapeGroup(pattern) + }); + } + + // Match any characters still remaining. + if (index < str.length) { + path += str.substr(index); + } + + // If the path exists, push it onto the end. + if (path) { + tokens.push(path); + } + + return tokens; + } + + var isarray = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) === '[object Array]'; + }; + + /** + * Escape a regular expression string. + * + * @param {String} str + * @return {String} + */ + function escapeString(str) { + return str.replace(/([.+*?=^!:${}()[\]|\/])/g, '\\$1'); + } + + /** + * Escape the capturing group by escaping special characters and meaning. + * + * @param {String} group + * @return {String} + */ + function escapeGroup(group) { + return group.replace(/([=!:$\/()])/g, '\\$1'); + } + + /** + * Attach the keys as a property of the regexp. + * + * @param {RegExp} re + * @param {Array} keys + * @return {RegExp} + */ + function attachKeys(re, keys) { + re.keys = keys; + return re; + } + + /** + * Get the flags for a regexp from the options. + * + * @param {Object} options + * @return {String} + */ + function flags(options) { + return options.sensitive ? '' : 'i'; + } + + /** + * Pull out keys from a regexp. + * + * @param {RegExp} path + * @param {Array} keys + * @return {RegExp} + */ + function regexpToRegexp(path, keys) { + // Use a negative lookahead to match only capturing groups. + var groups = path.source.match(/\((?!\?)/g); + + if (groups) { + for (var i = 0; i < groups.length; i++) { + keys.push({ + name: i, + prefix: null, + delimiter: null, + optional: false, + repeat: false, + pattern: null + }); + } + } + + return attachKeys(path, keys); + } + + /** + * Transform an array into a regexp. + * + * @param {Array} path + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + */ + function arrayToRegexp(path, keys, options) { + var parts = []; + + for (var i = 0; i < path.length; i++) { + parts.push(pathToRegexp(path[i], keys, options).source); + } + + var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)); + + return attachKeys(regexp, keys); + } + + /** + * Create a path regexp from string input. + * + * @param {String} path + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + */ + function stringToRegexp(path, keys, options) { + var tokens = parse(path); + var re = tokensToRegExp(tokens, options); + + // Attach keys back to the regexp. + for (var i = 0; i < tokens.length; i++) { + if (typeof tokens[i] !== 'string') { + keys.push(tokens[i]); + } + } + + return attachKeys(re, keys); + } + + /** + * Expose a function for taking tokens and returning a RegExp. + * + * @param {Array} tokens + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + */ + function tokensToRegExp(tokens, options) { + options = options || {}; + + var strict = options.strict; + var end = options.end !== false; + var route = ''; + var lastToken = tokens[tokens.length - 1]; + var endsWithSlash = typeof lastToken === 'string' && /\/$/.test(lastToken); + + // Iterate over the tokens and create our regexp string. + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + + if (typeof token === 'string') { + route += escapeString(token); + } else { + var prefix = escapeString(token.prefix); + var capture = token.pattern; + + if (token.repeat) { + capture += '(?:' + prefix + capture + ')*'; + } + + if (token.optional) { + if (prefix) { + capture = '(?:' + prefix + '(' + capture + '))?'; + } else { + capture = '(' + capture + ')?'; + } + } else { + capture = prefix + '(' + capture + ')'; + } + + route += capture; + } + } + + // In non-strict mode we allow a slash at the end of match. If the path to + // match already ends with a slash, we remove it for consistency. The slash + // is valid at the end of a path match, not in the middle. This is important + // in non-ending mode, where "/test/" shouldn't match "/test//route". + if (!strict) { + route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?'; + } + + if (end) { + route += '$'; + } else { + // In non-ending mode, we need the capturing groups to match as much as + // possible by using a positive lookahead to the end or next path segment. + route += strict && endsWithSlash ? '' : '(?=\\/|$)'; + } + + return new RegExp('^' + route, flags(options)); + } + + /** + * Normalize the given path string, returning a regular expression. + * + * An empty array can be passed in for the keys, which will hold the + * placeholder key descriptions. For example, using `/user/:id`, `keys` will + * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. + * + * @param {(String|RegExp|Array)} path + * @param {Array} [keys] + * @param {Object} [options] + * @return {RegExp} + */ + function pathToRegexp(path, keys, options) { + keys = keys || []; + + if (!isarray(keys)) { + options = keys; + keys = []; + } else if (!options) { + options = {}; + } + + if (path instanceof RegExp) { + return regexpToRegexp(path, keys, options); + } + + if (isarray(path)) { + return arrayToRegexp(path, keys, options); + } + + return stringToRegexp(path, keys, options); + } + + return page; + +}); \ No newline at end of file From 725340617771ab6f7b44ff5b170e9670dc1c0815 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Feb 2019 00:36:12 +0000 Subject: [PATCH 16/30] module resolution for images modules --- .../images/{basicimagefetcher.js => imageFetcher.js} | 0 src/components/images/{imagehelper.js => imageLoader.js} | 0 src/scripts/site.js | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/components/images/{basicimagefetcher.js => imageFetcher.js} (100%) rename src/components/images/{imagehelper.js => imageLoader.js} (100%) diff --git a/src/components/images/basicimagefetcher.js b/src/components/images/imageFetcher.js similarity index 100% rename from src/components/images/basicimagefetcher.js rename to src/components/images/imageFetcher.js diff --git a/src/components/images/imagehelper.js b/src/components/images/imageLoader.js similarity index 100% rename from src/components/images/imagehelper.js rename to src/components/images/imageLoader.js diff --git a/src/scripts/site.js b/src/scripts/site.js index f2c91d0a81..bb1a1dca84 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -424,7 +424,7 @@ var AppInfo = {}; define("registerElement", [bowerPath + "/document-register-element/build/document-register-element"], returnFirstDependency); } - define("imageFetcher", [componentsPath + "/images/basicimagefetcher"], returnFirstDependency); + define("imageFetcher", [componentsPath + "/images/imageFetcher"], returnFirstDependency); var preferNativeAlerts = browser.tv; @@ -717,7 +717,7 @@ var AppInfo = {}; define("libjass", [bowerPath + "/libjass/libjass.min", "css!" + bowerPath + "/libjass/libjass"], returnFirstDependency); define("tunerPicker", ["components/tunerpicker"], returnFirstDependency); define("mainTabsManager", [componentsPath + "/maintabsmanager"], returnFirstDependency); - define("imageLoader", [componentsPath + "/images/imagehelper"], returnFirstDependency); + define("imageLoader", [componentsPath + "/images/imageLoader"], returnFirstDependency); define("appFooter", [componentsPath + "/appfooter/appfooter"], returnFirstDependency); define("directorybrowser", ["components/directorybrowser/directorybrowser"], returnFirstDependency); define("metadataEditor", [componentsPath + "/metadataeditor/metadataeditor"], returnFirstDependency); From d751ff2c194085233fa7f6197b6c744c1b2a8ab2 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Feb 2019 00:50:03 +0000 Subject: [PATCH 17/30] module resolution for htmlMediaHelper --- .../{htmlvideoplayer/htmlmediahelper.js => htmlMediaHelper.js} | 0 src/scripts/site.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/components/{htmlvideoplayer/htmlmediahelper.js => htmlMediaHelper.js} (100%) diff --git a/src/components/htmlvideoplayer/htmlmediahelper.js b/src/components/htmlMediaHelper.js similarity index 100% rename from src/components/htmlvideoplayer/htmlmediahelper.js rename to src/components/htmlMediaHelper.js diff --git a/src/scripts/site.js b/src/scripts/site.js index bb1a1dca84..42bb9f1587 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -853,7 +853,7 @@ var AppInfo = {}; define("scrollStyles", ["css!" + componentsPath + "/scrollstyles"], returnFirstDependency); define("imageUploader", [componentsPath + "/imageuploader/imageuploader"], returnFirstDependency); define("navdrawer", ["components/navdrawer/navdrawer"], returnFirstDependency); - define("htmlMediaHelper", [componentsPath + "/htmlvideoplayer/htmlmediahelper"], returnFirstDependency); + define("htmlMediaHelper", [componentsPath + "/htmlMediaHelper"], returnFirstDependency); define("viewcontainer", ["components/viewContainer"], returnFirstDependency); define("queryString", [bowerPath + "/query-string/index"], function () { return queryString; From 258cea0b8126e73943e93523f393a2174aa0f13a Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Sun, 24 Mar 2019 11:38:51 +0000 Subject: [PATCH 18/30] rename viewmanager to viewManager --- src/components/viewManager/package.json | 3 + src/components/viewManager/viewContainer.css | 69 +++++++ .../viewManager.js} | 0 src/components/viewmanager/viewManager.js | 183 ++++++++++++++++++ 4 files changed, 255 insertions(+) create mode 100644 src/components/viewManager/package.json create mode 100644 src/components/viewManager/viewContainer.css rename src/components/{viewmanager/viewmanager.js => viewManager/viewManager.js} (100%) create mode 100644 src/components/viewmanager/viewManager.js diff --git a/src/components/viewManager/package.json b/src/components/viewManager/package.json new file mode 100644 index 0000000000..819371af71 --- /dev/null +++ b/src/components/viewManager/package.json @@ -0,0 +1,3 @@ +{ + "main": "viewManager.js" +} \ No newline at end of file diff --git a/src/components/viewManager/viewContainer.css b/src/components/viewManager/viewContainer.css new file mode 100644 index 0000000000..edfa101976 --- /dev/null +++ b/src/components/viewManager/viewContainer.css @@ -0,0 +1,69 @@ +.mainAnimatedPage { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + contain: layout style size; + /* Can't use will-change because it causes the alpha picker to move when the page scrolls*/ + /*will-change: transform;*/ +} + +@keyframes view-fadeout { + from { + opacity: 1; + } + + to { + opacity: 0; + } +} +@keyframes view-fadein { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} + +@keyframes view-slideleft { + from { + transform: translate3d(100%, 0, 0); + } + + to { + transform: none; + } +} + +@keyframes view-slideleft-r { + from { + transform: none; + } + + to { + transform: translate3d(-100%, 0, 0); + } +} + +@keyframes view-slideright { + from { + transform: translate3d(-100%, 0, 0); + } + + to { + transform: none; + } +} + +@keyframes view-slideright-r { + from { + transform: none; + } + + to { + transform: translate3d(100%, 0, 0); + } +} \ No newline at end of file diff --git a/src/components/viewmanager/viewmanager.js b/src/components/viewManager/viewManager.js similarity index 100% rename from src/components/viewmanager/viewmanager.js rename to src/components/viewManager/viewManager.js diff --git a/src/components/viewmanager/viewManager.js b/src/components/viewmanager/viewManager.js new file mode 100644 index 0000000000..606c7e98c1 --- /dev/null +++ b/src/components/viewmanager/viewManager.js @@ -0,0 +1,183 @@ +define(['viewcontainer', 'focusManager', 'queryString', 'layoutManager'], function (viewcontainer, focusManager, queryString, layoutManager) { + 'use strict'; + + var currentView; + var dispatchPageEvents; + + viewcontainer.setOnBeforeChange(function (newView, isRestored, options) { + + var lastView = currentView; + if (lastView) { + + var beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true); + + if (!beforeHideResult) { + // todo: cancel + } + } + + var eventDetail = getViewEventDetail(newView, options, isRestored); + + if (!newView.initComplete) { + newView.initComplete = true; + + if (options.controllerFactory) { + + // Use controller method + var controller = new options.controllerFactory(newView, eventDetail.detail.params); + } + + if (!options.controllerFactory || dispatchPageEvents) { + dispatchViewEvent(newView, eventDetail, 'viewinit'); + } + } + + dispatchViewEvent(newView, eventDetail, 'viewbeforeshow'); + }); + + function onViewChange(view, options, isRestore) { + + var lastView = currentView; + if (lastView) { + dispatchViewEvent(lastView, null, 'viewhide'); + } + + currentView = view; + + var eventDetail = getViewEventDetail(view, options, isRestore); + + if (!isRestore) { + if (options.autoFocus !== false) { + focusManager.autoFocus(view); + } + } + else if (!layoutManager.mobile) { + if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) { + focusManager.focus(view.activeElement); + } else { + focusManager.autoFocus(view); + } + } + + view.dispatchEvent(new CustomEvent('viewshow', eventDetail)); + + if (dispatchPageEvents) { + view.dispatchEvent(new CustomEvent('pageshow', eventDetail)); + } + } + + function getProperties(view) { + var props = view.getAttribute('data-properties'); + + if (props) { + return props.split(','); + } + + return []; + } + + function dispatchViewEvent(view, eventInfo, eventName, isCancellable) { + + if (!eventInfo) { + eventInfo = { + detail: { + type: view.getAttribute('data-type'), + properties: getProperties(view) + }, + bubbles: true, + cancelable: isCancellable + }; + } + + eventInfo.cancelable = isCancellable || false; + + var eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo)); + + if (dispatchPageEvents) { + eventInfo.cancelable = false; + view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo)); + } + + return eventResult; + } + + function getViewEventDetail(view, options, isRestore) { + + var url = options.url; + var index = url.indexOf('?'); + var params = index === -1 ? {} : queryString.parse(url.substring(index + 1)); + + return { + detail: { + type: view.getAttribute('data-type'), + properties: getProperties(view), + params: params, + isRestored: isRestore, + state: options.state, + + // The route options + options: options.options || {} + }, + bubbles: true, + cancelable: false + }; + } + + function resetCachedViews() { + // Reset all cached views whenever the skin changes + viewcontainer.reset(); + } + + document.addEventListener('skinunload', resetCachedViews); + + function ViewManager() { + } + + ViewManager.prototype.loadView = function (options) { + + var lastView = currentView; + + // Record the element that has focus + if (lastView) { + lastView.activeElement = document.activeElement; + } + + if (options.cancel) { + return; + } + + viewcontainer.loadView(options).then(function (view) { + + onViewChange(view, options); + }); + }; + + ViewManager.prototype.tryRestoreView = function (options, onViewChanging) { + + if (options.cancel) { + return Promise.reject({ cancelled: true }); + } + + // Record the element that has focus + if (currentView) { + currentView.activeElement = document.activeElement; + } + + return viewcontainer.tryRestoreView(options).then(function (view) { + + onViewChanging(); + onViewChange(view, options, true); + + }); + }; + + ViewManager.prototype.currentView = function () { + return currentView; + }; + + ViewManager.prototype.dispatchPageEvents = function (value) { + dispatchPageEvents = value; + }; + + return new ViewManager(); +}); From 2b9559b4a999c98b1dd5327d79f935caf8a21641 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Sun, 24 Mar 2019 11:44:33 +0000 Subject: [PATCH 19/30] resolve typo for viewContainer dep --- src/components/viewContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/viewContainer.js b/src/components/viewContainer.js index 7dd036bc96..4c02ba3c6e 100644 --- a/src/components/viewContainer.js +++ b/src/components/viewContainer.js @@ -1,4 +1,4 @@ -define(["browser", "dom", "layoutManager", "css!components/viewmanager/viewContainer"], function(browser, dom, layoutManager) { +define(["browser", "dom", "layoutManager", "css!components/viewManager/viewContainer"], function(browser, dom, layoutManager) { "use strict"; function setControllerClass(view, options) { From f783509e33b1bfa38d8ecaa7c9ac2bb2adb1f46d Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Sun, 24 Mar 2019 11:47:48 +0000 Subject: [PATCH 20/30] rename dialoghelper to dialogHelper --- .../dialogHelper.js} | 0 src/components/dialogHelper/dialoghelper.css | 173 +++++++ src/components/dialogHelper/package.json | 3 + src/components/dialoghelper/dialogHelper.js | 486 ++++++++++++++++++ 4 files changed, 662 insertions(+) rename src/components/{dialoghelper/dialoghelper.js => dialogHelper/dialogHelper.js} (100%) create mode 100644 src/components/dialogHelper/dialoghelper.css create mode 100644 src/components/dialogHelper/package.json create mode 100644 src/components/dialoghelper/dialogHelper.js diff --git a/src/components/dialoghelper/dialoghelper.js b/src/components/dialogHelper/dialogHelper.js similarity index 100% rename from src/components/dialoghelper/dialoghelper.js rename to src/components/dialogHelper/dialogHelper.js diff --git a/src/components/dialogHelper/dialoghelper.css b/src/components/dialogHelper/dialoghelper.css new file mode 100644 index 0000000000..2cc20b5ff2 --- /dev/null +++ b/src/components/dialogHelper/dialoghelper.css @@ -0,0 +1,173 @@ +.dialogContainer { + display: flex; + align-items: center; + justify-content: center; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 999999 !important; + contain: strict; + overflow: hidden; + overscroll-behavior: contain; +} + +.dialog { + margin: 0; + border-radius: .2em; + -webkit-font-smoothing: antialiased; + border: 0; + padding: 0; + will-change: transform, opacity; + /* Strict does not work well with actionsheet */ + contain: style paint; + box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.4); +} + +.dialog-fixedSize { + border-radius: 0; + max-height: none; + max-width: none; + contain: layout style paint; +} + +.dialog-fullscreen { + /* Needed due to formDialog style */ + position: fixed !important; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: 0; + box-shadow: none; +} + +@keyframes scaledown { + from { + opacity: 1; + transform: none; + } + + to { + opacity: 0; + transform: scale(.5); + } +} + +@keyframes scaleup { + from { + transform: scale(.5); + opacity: 0; + } + + to { + transform: none; + opacity: 1; + } +} + +@keyframes fadein { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} + +@keyframes fadeout { + + from { + opacity: 1; + } + + to { + opacity: 0; + } +} + +@keyframes slideup { + from { + opacity: 0; + transform: translate3d(0, 30%, 0); + } + + to { + opacity: 1; + transform: none; + } +} + +@keyframes slidedown { + + from { + opacity: 1; + transform: none; + } + + to { + opacity: 0; + transform: translate3d(0, 20%, 0); + } +} + +@media all and (max-width: 80em), all and (max-height: 45em) { + + .dialog-fixedSize, .dialog-fullscreen-lowres { + position: fixed !important; + top: 0 !important; + bottom: 0 !important; + left: 0 !important; + right: 0 !important; + margin: 0 !important; + box-shadow: none; + } +} + +@media all and (min-width: 80em) and (min-height: 45em) { + + .dialog-medium { + width: 80%; + height: 80%; + } + + .dialog-medium-tall { + width: 80%; + height: 90%; + } + + .dialog-small { + width: 60%; + height: 80%; + } + + .dialog-fullscreen-border { + width: 90%; + height: 90%; + } +} + +.noScroll { + overflow-x: hidden !important; + overflow-y: hidden !important; +} + +.dialogBackdrop { + background-color: #000; + opacity: 0; + position: fixed !important; + top: 0 !important; + bottom: 0 !important; + left: 0 !important; + right: 0 !important; + margin: 0 !important; + z-index: 999999 !important; + transition: opacity ease-out 0.2s; + will-change: opacity; +} + +.dialogBackdropOpened { + opacity: .5; +} diff --git a/src/components/dialogHelper/package.json b/src/components/dialogHelper/package.json new file mode 100644 index 0000000000..71863d045f --- /dev/null +++ b/src/components/dialogHelper/package.json @@ -0,0 +1,3 @@ +{ + "main": "dialogHelper.js" +} \ No newline at end of file diff --git a/src/components/dialoghelper/dialogHelper.js b/src/components/dialoghelper/dialogHelper.js new file mode 100644 index 0000000000..36bb23bfd7 --- /dev/null +++ b/src/components/dialoghelper/dialogHelper.js @@ -0,0 +1,486 @@ +define(['appRouter', 'focusManager', 'browser', 'layoutManager', 'inputManager', 'dom', 'css!./dialoghelper.css', 'scrollStyles'], function (appRouter, focusManager, browser, layoutManager, inputManager, dom) { + 'use strict'; + + var globalOnOpenCallback; + + function enableAnimation() { + + // too slow + if (browser.tv) { + return false; + } + + return browser.supportsCssAnimation(); + } + + function removeCenterFocus(dlg) { + + if (layoutManager.tv) { + if (dlg.classList.contains('scrollX')) { + centerFocus(dlg, true, false); + } + else if (dlg.classList.contains('smoothScrollY')) { + centerFocus(dlg, false, false); + } + } + } + + function tryRemoveElement(elem) { + var parentNode = elem.parentNode; + if (parentNode) { + + // Seeing crashes in edge webview + try { + parentNode.removeChild(elem); + } catch (err) { + console.log('Error removing dialog element: ' + err); + } + } + } + + function DialogHashHandler(dlg, hash, resolve) { + + var self = this; + self.originalUrl = window.location.href; + var activeElement = document.activeElement; + var removeScrollLockOnClose = false; + + function onHashChange(e) { + + var isBack = self.originalUrl === window.location.href; + + if (isBack || !isOpened(dlg)) { + window.removeEventListener('popstate', onHashChange); + } + + if (isBack) { + self.closedByBack = true; + closeDialog(dlg); + } + } + + function onBackCommand(e) { + + if (e.detail.command === 'back') { + self.closedByBack = true; + e.preventDefault(); + e.stopPropagation(); + closeDialog(dlg); + } + } + + function onDialogClosed() { + + if (!isHistoryEnabled(dlg)) { + inputManager.off(dlg, onBackCommand); + } + + window.removeEventListener('popstate', onHashChange); + + removeBackdrop(dlg); + dlg.classList.remove('opened'); + + if (removeScrollLockOnClose) { + document.body.classList.remove('noScroll'); + } + + if (!self.closedByBack && isHistoryEnabled(dlg)) { + var state = history.state || {}; + if (state.dialogId === hash) { + history.back(); + } + } + + if (layoutManager.tv) { + focusManager.focus(activeElement); + } + + if (dlg.getAttribute('data-removeonclose') !== 'false') { + removeCenterFocus(dlg); + + var dialogContainer = dlg.dialogContainer; + if (dialogContainer) { + tryRemoveElement(dialogContainer); + dlg.dialogContainer = null; + } else { + tryRemoveElement(dlg); + } + } + + //resolve(); + // if we just called history.back(), then use a timeout to allow the history events to fire first + setTimeout(function () { + resolve({ + element: dlg, + closedByBack: self.closedByBack + }); + }, 1); + } + + dlg.addEventListener('close', onDialogClosed); + + var center = !dlg.classList.contains('dialog-fixedSize'); + if (center) { + dlg.classList.add('centeredDialog'); + } + + dlg.classList.remove('hide'); + + addBackdropOverlay(dlg); + + dlg.classList.add('opened'); + dlg.dispatchEvent(new CustomEvent('open', { + bubbles: false, + cancelable: false + })); + + if (dlg.getAttribute('data-lockscroll') === 'true' && !document.body.classList.contains('noScroll')) { + document.body.classList.add('noScroll'); + removeScrollLockOnClose = true; + } + + animateDialogOpen(dlg); + + if (isHistoryEnabled(dlg)) { + appRouter.pushState({ dialogId: hash }, "Dialog", '#' + hash); + + window.addEventListener('popstate', onHashChange); + } else { + inputManager.on(dlg, onBackCommand); + } + } + + function addBackdropOverlay(dlg) { + + var backdrop = document.createElement('div'); + backdrop.classList.add('dialogBackdrop'); + + var backdropParent = dlg.dialogContainer || dlg; + backdropParent.parentNode.insertBefore(backdrop, backdropParent); + dlg.backdrop = backdrop; + + // trigger reflow or the backdrop will not animate + void backdrop.offsetWidth; + backdrop.classList.add('dialogBackdropOpened'); + + dom.addEventListener((dlg.dialogContainer || backdrop), 'click', function (e) { + if (e.target === dlg.dialogContainer) { + close(dlg); + } + }, { + passive: true + }); + } + + function isHistoryEnabled(dlg) { + return dlg.getAttribute('data-history') === 'true'; + } + + function open(dlg) { + + if (globalOnOpenCallback) { + globalOnOpenCallback(dlg); + } + + var parent = dlg.parentNode; + if (parent) { + parent.removeChild(dlg); + } + + var dialogContainer = document.createElement('div'); + dialogContainer.classList.add('dialogContainer'); + dialogContainer.appendChild(dlg); + dlg.dialogContainer = dialogContainer; + document.body.appendChild(dialogContainer); + + return new Promise(function (resolve, reject) { + + new DialogHashHandler(dlg, 'dlg' + new Date().getTime(), resolve); + }); + } + + function isOpened(dlg) { + + //return dlg.opened; + return !dlg.classList.contains('hide'); + } + + function close(dlg) { + + if (isOpened(dlg)) { + if (isHistoryEnabled(dlg)) { + history.back(); + } else { + closeDialog(dlg); + } + } + } + + function closeDialog(dlg) { + + if (!dlg.classList.contains('hide')) { + + dlg.dispatchEvent(new CustomEvent('closing', { + bubbles: false, + cancelable: false + })); + + var onAnimationFinish = function () { + focusManager.popScope(dlg); + + dlg.classList.add('hide'); + dlg.dispatchEvent(new CustomEvent('close', { + bubbles: false, + cancelable: false + })); + }; + + animateDialogClose(dlg, onAnimationFinish); + } + } + + function animateDialogOpen(dlg) { + + var onAnimationFinish = function () { + focusManager.pushScope(dlg); + if (dlg.getAttribute('data-autofocus') === 'true') { + focusManager.autoFocus(dlg); + } + }; + + if (enableAnimation()) { + + var onFinish = function () { + dom.removeEventListener(dlg, dom.whichAnimationEvent(), onFinish, { + once: true + }); + onAnimationFinish(); + }; + dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, { + once: true + }); + return; + } + + onAnimationFinish(); + } + + function animateDialogClose(dlg, onAnimationFinish) { + + if (enableAnimation()) { + + var animated = true; + + switch (dlg.animationConfig.exit.name) { + + case 'fadeout': + dlg.style.animation = 'fadeout ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both'; + break; + case 'scaledown': + dlg.style.animation = 'scaledown ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both'; + break; + case 'slidedown': + dlg.style.animation = 'slidedown ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both'; + break; + default: + animated = false; + break; + } + var onFinish = function () { + dom.removeEventListener(dlg, dom.whichAnimationEvent(), onFinish, { + once: true + }); + onAnimationFinish(); + }; + dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, { + once: true + }); + + if (animated) { + return; + } + } + + onAnimationFinish(); + } + + var supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style; + + function shouldLockDocumentScroll(options) { + + if (supportsOverscrollBehavior && (options.size || !browser.touch)) { + return false; + } + + if (options.lockScroll != null) { + return options.lockScroll; + } + + if (options.size === 'fullscreen') { + return true; + } + + if (options.size) { + return true; + } + + return browser.touch; + } + + function removeBackdrop(dlg) { + + var backdrop = dlg.backdrop; + + if (!backdrop) { + return; + } + + dlg.backdrop = null; + + var onAnimationFinish = function () { + tryRemoveElement(backdrop); + }; + + if (enableAnimation()) { + + backdrop.classList.remove('dialogBackdropOpened'); + + // this is not firing animatonend + setTimeout(onAnimationFinish, 300); + return; + } + + onAnimationFinish(); + } + + function centerFocus(elem, horiz, on) { + require(['scrollHelper'], function (scrollHelper) { + var fn = on ? 'on' : 'off'; + scrollHelper.centerFocus[fn](elem, horiz); + }); + } + + function createDialog(options) { + + options = options || {}; + + // If there's no native dialog support, use a plain div + // Also not working well in samsung tizen browser, content inside not clickable + // Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog + var dlg = document.createElement('div'); + + dlg.classList.add('focuscontainer'); + dlg.classList.add('hide'); + + if (shouldLockDocumentScroll(options)) { + dlg.setAttribute('data-lockscroll', 'true'); + } + + if (options.enableHistory !== false && appRouter.enableNativeHistory()) { + dlg.setAttribute('data-history', 'true'); + } + + // without this safari will scroll the background instead of the dialog contents + // but not needed here since this is already on top of an existing dialog + // but skip it in IE because it's causing the entire browser to hang + // Also have to disable for firefox because it's causing select elements to not be clickable + if (options.modal !== false) { + dlg.setAttribute('modal', 'modal'); + } + + if (options.autoFocus !== false) { + dlg.setAttribute('data-autofocus', 'true'); + } + + var defaultEntryAnimation; + var defaultExitAnimation; + + defaultEntryAnimation = 'scaleup'; + defaultExitAnimation = 'scaledown'; + var entryAnimation = options.entryAnimation || defaultEntryAnimation; + var exitAnimation = options.exitAnimation || defaultExitAnimation; + + // If it's not fullscreen then lower the default animation speed to make it open really fast + var entryAnimationDuration = options.entryAnimationDuration || (options.size !== 'fullscreen' ? 180 : 280); + var exitAnimationDuration = options.exitAnimationDuration || (options.size !== 'fullscreen' ? 120 : 220); + + dlg.animationConfig = { + // scale up + 'entry': { + name: entryAnimation, + timing: { + duration: entryAnimationDuration, + easing: 'ease-out' + } + }, + // fade out + 'exit': { + name: exitAnimation, + timing: { + duration: exitAnimationDuration, + easing: 'ease-out', + fill: 'both' + } + } + }; + + dlg.classList.add('dialog'); + + if (options.scrollX) { + dlg.classList.add('scrollX'); + dlg.classList.add('smoothScrollX'); + + if (layoutManager.tv) { + centerFocus(dlg, true, true); + } + } + else if (options.scrollY !== false) { + dlg.classList.add('smoothScrollY'); + + if (layoutManager.tv) { + centerFocus(dlg, false, true); + } + } + + if (options.removeOnClose) { + dlg.setAttribute('data-removeonclose', 'true'); + } + + if (options.size) { + dlg.classList.add('dialog-fixedSize'); + dlg.classList.add('dialog-' + options.size); + } + + if (enableAnimation()) { + + switch (dlg.animationConfig.entry.name) { + + case 'fadein': + dlg.style.animation = 'fadein ' + entryAnimationDuration + 'ms ease-out normal'; + break; + case 'scaleup': + dlg.style.animation = 'scaleup ' + entryAnimationDuration + 'ms ease-out normal both'; + break; + case 'slideup': + dlg.style.animation = 'slideup ' + entryAnimationDuration + 'ms ease-out normal'; + break; + case 'slidedown': + dlg.style.animation = 'slidedown ' + entryAnimationDuration + 'ms ease-out normal'; + break; + default: + break; + } + } + + return dlg; + } + + return { + open: open, + close: close, + createDialog: createDialog, + setOnOpen: function (val) { + globalOnOpenCallback = val; + } + }; +}); \ No newline at end of file From c42ac7e6507110c4ebdfebff85767bea57dc4680 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Sun, 24 Mar 2019 11:58:55 +0000 Subject: [PATCH 21/30] remove emby-linkbutton requires --- src/addplugin.html | 2 +- src/useredit.html | 2 +- src/userlibraryaccess.html | 2 +- src/userparentalcontrol.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/addplugin.html b/src/addplugin.html index 08c36fb194..38de32c207 100644 --- a/src/addplugin.html +++ b/src/addplugin.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/useredit.html b/src/useredit.html index a8247fa771..9acf162e89 100644 --- a/src/useredit.html +++ b/src/useredit.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/userlibraryaccess.html b/src/userlibraryaccess.html index e267e992a3..cb39571fab 100644 --- a/src/userlibraryaccess.html +++ b/src/userlibraryaccess.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/userparentalcontrol.html b/src/userparentalcontrol.html index 5184de66db..2ac8e01925 100644 --- a/src/userparentalcontrol.html +++ b/src/userparentalcontrol.html @@ -1,4 +1,4 @@ -
+
From ad813701c51a6a131cdef23cbfd9c012825ab3b3 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Sun, 24 Mar 2019 12:15:13 +0000 Subject: [PATCH 22/30] fix eslint error for appRouter module --- src/components/appRouter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index ffe3065bbb..f9761d4d61 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -410,7 +410,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM if (apiClient && apiClient.isLoggedIn()) { console.log('appRouter - user is authenticated'); - + if (route.isDefaultRoute) { console.log('appRouter - loading skin home page'); loadUserSkinWithOptions(ctx); From b8cdb3d94e1afbed6e758422fb46cfff6cf0c291 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Mon, 25 Mar 2019 22:57:08 +0000 Subject: [PATCH 23/30] removed old dialoghelper --- src/components/dialoghelper/dialogHelper.js | 486 ------------------- src/components/dialoghelper/dialoghelper.css | 173 ------- src/components/dialoghelper/package.json | 3 - 3 files changed, 662 deletions(-) delete mode 100644 src/components/dialoghelper/dialogHelper.js delete mode 100644 src/components/dialoghelper/dialoghelper.css delete mode 100644 src/components/dialoghelper/package.json diff --git a/src/components/dialoghelper/dialogHelper.js b/src/components/dialoghelper/dialogHelper.js deleted file mode 100644 index 36bb23bfd7..0000000000 --- a/src/components/dialoghelper/dialogHelper.js +++ /dev/null @@ -1,486 +0,0 @@ -define(['appRouter', 'focusManager', 'browser', 'layoutManager', 'inputManager', 'dom', 'css!./dialoghelper.css', 'scrollStyles'], function (appRouter, focusManager, browser, layoutManager, inputManager, dom) { - 'use strict'; - - var globalOnOpenCallback; - - function enableAnimation() { - - // too slow - if (browser.tv) { - return false; - } - - return browser.supportsCssAnimation(); - } - - function removeCenterFocus(dlg) { - - if (layoutManager.tv) { - if (dlg.classList.contains('scrollX')) { - centerFocus(dlg, true, false); - } - else if (dlg.classList.contains('smoothScrollY')) { - centerFocus(dlg, false, false); - } - } - } - - function tryRemoveElement(elem) { - var parentNode = elem.parentNode; - if (parentNode) { - - // Seeing crashes in edge webview - try { - parentNode.removeChild(elem); - } catch (err) { - console.log('Error removing dialog element: ' + err); - } - } - } - - function DialogHashHandler(dlg, hash, resolve) { - - var self = this; - self.originalUrl = window.location.href; - var activeElement = document.activeElement; - var removeScrollLockOnClose = false; - - function onHashChange(e) { - - var isBack = self.originalUrl === window.location.href; - - if (isBack || !isOpened(dlg)) { - window.removeEventListener('popstate', onHashChange); - } - - if (isBack) { - self.closedByBack = true; - closeDialog(dlg); - } - } - - function onBackCommand(e) { - - if (e.detail.command === 'back') { - self.closedByBack = true; - e.preventDefault(); - e.stopPropagation(); - closeDialog(dlg); - } - } - - function onDialogClosed() { - - if (!isHistoryEnabled(dlg)) { - inputManager.off(dlg, onBackCommand); - } - - window.removeEventListener('popstate', onHashChange); - - removeBackdrop(dlg); - dlg.classList.remove('opened'); - - if (removeScrollLockOnClose) { - document.body.classList.remove('noScroll'); - } - - if (!self.closedByBack && isHistoryEnabled(dlg)) { - var state = history.state || {}; - if (state.dialogId === hash) { - history.back(); - } - } - - if (layoutManager.tv) { - focusManager.focus(activeElement); - } - - if (dlg.getAttribute('data-removeonclose') !== 'false') { - removeCenterFocus(dlg); - - var dialogContainer = dlg.dialogContainer; - if (dialogContainer) { - tryRemoveElement(dialogContainer); - dlg.dialogContainer = null; - } else { - tryRemoveElement(dlg); - } - } - - //resolve(); - // if we just called history.back(), then use a timeout to allow the history events to fire first - setTimeout(function () { - resolve({ - element: dlg, - closedByBack: self.closedByBack - }); - }, 1); - } - - dlg.addEventListener('close', onDialogClosed); - - var center = !dlg.classList.contains('dialog-fixedSize'); - if (center) { - dlg.classList.add('centeredDialog'); - } - - dlg.classList.remove('hide'); - - addBackdropOverlay(dlg); - - dlg.classList.add('opened'); - dlg.dispatchEvent(new CustomEvent('open', { - bubbles: false, - cancelable: false - })); - - if (dlg.getAttribute('data-lockscroll') === 'true' && !document.body.classList.contains('noScroll')) { - document.body.classList.add('noScroll'); - removeScrollLockOnClose = true; - } - - animateDialogOpen(dlg); - - if (isHistoryEnabled(dlg)) { - appRouter.pushState({ dialogId: hash }, "Dialog", '#' + hash); - - window.addEventListener('popstate', onHashChange); - } else { - inputManager.on(dlg, onBackCommand); - } - } - - function addBackdropOverlay(dlg) { - - var backdrop = document.createElement('div'); - backdrop.classList.add('dialogBackdrop'); - - var backdropParent = dlg.dialogContainer || dlg; - backdropParent.parentNode.insertBefore(backdrop, backdropParent); - dlg.backdrop = backdrop; - - // trigger reflow or the backdrop will not animate - void backdrop.offsetWidth; - backdrop.classList.add('dialogBackdropOpened'); - - dom.addEventListener((dlg.dialogContainer || backdrop), 'click', function (e) { - if (e.target === dlg.dialogContainer) { - close(dlg); - } - }, { - passive: true - }); - } - - function isHistoryEnabled(dlg) { - return dlg.getAttribute('data-history') === 'true'; - } - - function open(dlg) { - - if (globalOnOpenCallback) { - globalOnOpenCallback(dlg); - } - - var parent = dlg.parentNode; - if (parent) { - parent.removeChild(dlg); - } - - var dialogContainer = document.createElement('div'); - dialogContainer.classList.add('dialogContainer'); - dialogContainer.appendChild(dlg); - dlg.dialogContainer = dialogContainer; - document.body.appendChild(dialogContainer); - - return new Promise(function (resolve, reject) { - - new DialogHashHandler(dlg, 'dlg' + new Date().getTime(), resolve); - }); - } - - function isOpened(dlg) { - - //return dlg.opened; - return !dlg.classList.contains('hide'); - } - - function close(dlg) { - - if (isOpened(dlg)) { - if (isHistoryEnabled(dlg)) { - history.back(); - } else { - closeDialog(dlg); - } - } - } - - function closeDialog(dlg) { - - if (!dlg.classList.contains('hide')) { - - dlg.dispatchEvent(new CustomEvent('closing', { - bubbles: false, - cancelable: false - })); - - var onAnimationFinish = function () { - focusManager.popScope(dlg); - - dlg.classList.add('hide'); - dlg.dispatchEvent(new CustomEvent('close', { - bubbles: false, - cancelable: false - })); - }; - - animateDialogClose(dlg, onAnimationFinish); - } - } - - function animateDialogOpen(dlg) { - - var onAnimationFinish = function () { - focusManager.pushScope(dlg); - if (dlg.getAttribute('data-autofocus') === 'true') { - focusManager.autoFocus(dlg); - } - }; - - if (enableAnimation()) { - - var onFinish = function () { - dom.removeEventListener(dlg, dom.whichAnimationEvent(), onFinish, { - once: true - }); - onAnimationFinish(); - }; - dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, { - once: true - }); - return; - } - - onAnimationFinish(); - } - - function animateDialogClose(dlg, onAnimationFinish) { - - if (enableAnimation()) { - - var animated = true; - - switch (dlg.animationConfig.exit.name) { - - case 'fadeout': - dlg.style.animation = 'fadeout ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both'; - break; - case 'scaledown': - dlg.style.animation = 'scaledown ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both'; - break; - case 'slidedown': - dlg.style.animation = 'slidedown ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both'; - break; - default: - animated = false; - break; - } - var onFinish = function () { - dom.removeEventListener(dlg, dom.whichAnimationEvent(), onFinish, { - once: true - }); - onAnimationFinish(); - }; - dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, { - once: true - }); - - if (animated) { - return; - } - } - - onAnimationFinish(); - } - - var supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style; - - function shouldLockDocumentScroll(options) { - - if (supportsOverscrollBehavior && (options.size || !browser.touch)) { - return false; - } - - if (options.lockScroll != null) { - return options.lockScroll; - } - - if (options.size === 'fullscreen') { - return true; - } - - if (options.size) { - return true; - } - - return browser.touch; - } - - function removeBackdrop(dlg) { - - var backdrop = dlg.backdrop; - - if (!backdrop) { - return; - } - - dlg.backdrop = null; - - var onAnimationFinish = function () { - tryRemoveElement(backdrop); - }; - - if (enableAnimation()) { - - backdrop.classList.remove('dialogBackdropOpened'); - - // this is not firing animatonend - setTimeout(onAnimationFinish, 300); - return; - } - - onAnimationFinish(); - } - - function centerFocus(elem, horiz, on) { - require(['scrollHelper'], function (scrollHelper) { - var fn = on ? 'on' : 'off'; - scrollHelper.centerFocus[fn](elem, horiz); - }); - } - - function createDialog(options) { - - options = options || {}; - - // If there's no native dialog support, use a plain div - // Also not working well in samsung tizen browser, content inside not clickable - // Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog - var dlg = document.createElement('div'); - - dlg.classList.add('focuscontainer'); - dlg.classList.add('hide'); - - if (shouldLockDocumentScroll(options)) { - dlg.setAttribute('data-lockscroll', 'true'); - } - - if (options.enableHistory !== false && appRouter.enableNativeHistory()) { - dlg.setAttribute('data-history', 'true'); - } - - // without this safari will scroll the background instead of the dialog contents - // but not needed here since this is already on top of an existing dialog - // but skip it in IE because it's causing the entire browser to hang - // Also have to disable for firefox because it's causing select elements to not be clickable - if (options.modal !== false) { - dlg.setAttribute('modal', 'modal'); - } - - if (options.autoFocus !== false) { - dlg.setAttribute('data-autofocus', 'true'); - } - - var defaultEntryAnimation; - var defaultExitAnimation; - - defaultEntryAnimation = 'scaleup'; - defaultExitAnimation = 'scaledown'; - var entryAnimation = options.entryAnimation || defaultEntryAnimation; - var exitAnimation = options.exitAnimation || defaultExitAnimation; - - // If it's not fullscreen then lower the default animation speed to make it open really fast - var entryAnimationDuration = options.entryAnimationDuration || (options.size !== 'fullscreen' ? 180 : 280); - var exitAnimationDuration = options.exitAnimationDuration || (options.size !== 'fullscreen' ? 120 : 220); - - dlg.animationConfig = { - // scale up - 'entry': { - name: entryAnimation, - timing: { - duration: entryAnimationDuration, - easing: 'ease-out' - } - }, - // fade out - 'exit': { - name: exitAnimation, - timing: { - duration: exitAnimationDuration, - easing: 'ease-out', - fill: 'both' - } - } - }; - - dlg.classList.add('dialog'); - - if (options.scrollX) { - dlg.classList.add('scrollX'); - dlg.classList.add('smoothScrollX'); - - if (layoutManager.tv) { - centerFocus(dlg, true, true); - } - } - else if (options.scrollY !== false) { - dlg.classList.add('smoothScrollY'); - - if (layoutManager.tv) { - centerFocus(dlg, false, true); - } - } - - if (options.removeOnClose) { - dlg.setAttribute('data-removeonclose', 'true'); - } - - if (options.size) { - dlg.classList.add('dialog-fixedSize'); - dlg.classList.add('dialog-' + options.size); - } - - if (enableAnimation()) { - - switch (dlg.animationConfig.entry.name) { - - case 'fadein': - dlg.style.animation = 'fadein ' + entryAnimationDuration + 'ms ease-out normal'; - break; - case 'scaleup': - dlg.style.animation = 'scaleup ' + entryAnimationDuration + 'ms ease-out normal both'; - break; - case 'slideup': - dlg.style.animation = 'slideup ' + entryAnimationDuration + 'ms ease-out normal'; - break; - case 'slidedown': - dlg.style.animation = 'slidedown ' + entryAnimationDuration + 'ms ease-out normal'; - break; - default: - break; - } - } - - return dlg; - } - - return { - open: open, - close: close, - createDialog: createDialog, - setOnOpen: function (val) { - globalOnOpenCallback = val; - } - }; -}); \ No newline at end of file diff --git a/src/components/dialoghelper/dialoghelper.css b/src/components/dialoghelper/dialoghelper.css deleted file mode 100644 index 2cc20b5ff2..0000000000 --- a/src/components/dialoghelper/dialoghelper.css +++ /dev/null @@ -1,173 +0,0 @@ -.dialogContainer { - display: flex; - align-items: center; - justify-content: center; - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 999999 !important; - contain: strict; - overflow: hidden; - overscroll-behavior: contain; -} - -.dialog { - margin: 0; - border-radius: .2em; - -webkit-font-smoothing: antialiased; - border: 0; - padding: 0; - will-change: transform, opacity; - /* Strict does not work well with actionsheet */ - contain: style paint; - box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.4); -} - -.dialog-fixedSize { - border-radius: 0; - max-height: none; - max-width: none; - contain: layout style paint; -} - -.dialog-fullscreen { - /* Needed due to formDialog style */ - position: fixed !important; - top: 0; - bottom: 0; - left: 0; - right: 0; - margin: 0; - box-shadow: none; -} - -@keyframes scaledown { - from { - opacity: 1; - transform: none; - } - - to { - opacity: 0; - transform: scale(.5); - } -} - -@keyframes scaleup { - from { - transform: scale(.5); - opacity: 0; - } - - to { - transform: none; - opacity: 1; - } -} - -@keyframes fadein { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -@keyframes fadeout { - - from { - opacity: 1; - } - - to { - opacity: 0; - } -} - -@keyframes slideup { - from { - opacity: 0; - transform: translate3d(0, 30%, 0); - } - - to { - opacity: 1; - transform: none; - } -} - -@keyframes slidedown { - - from { - opacity: 1; - transform: none; - } - - to { - opacity: 0; - transform: translate3d(0, 20%, 0); - } -} - -@media all and (max-width: 80em), all and (max-height: 45em) { - - .dialog-fixedSize, .dialog-fullscreen-lowres { - position: fixed !important; - top: 0 !important; - bottom: 0 !important; - left: 0 !important; - right: 0 !important; - margin: 0 !important; - box-shadow: none; - } -} - -@media all and (min-width: 80em) and (min-height: 45em) { - - .dialog-medium { - width: 80%; - height: 80%; - } - - .dialog-medium-tall { - width: 80%; - height: 90%; - } - - .dialog-small { - width: 60%; - height: 80%; - } - - .dialog-fullscreen-border { - width: 90%; - height: 90%; - } -} - -.noScroll { - overflow-x: hidden !important; - overflow-y: hidden !important; -} - -.dialogBackdrop { - background-color: #000; - opacity: 0; - position: fixed !important; - top: 0 !important; - bottom: 0 !important; - left: 0 !important; - right: 0 !important; - margin: 0 !important; - z-index: 999999 !important; - transition: opacity ease-out 0.2s; - will-change: opacity; -} - -.dialogBackdropOpened { - opacity: .5; -} diff --git a/src/components/dialoghelper/package.json b/src/components/dialoghelper/package.json deleted file mode 100644 index 71863d045f..0000000000 --- a/src/components/dialoghelper/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "dialogHelper.js" -} \ No newline at end of file From 4013ac8c8fce0ef1c42bbc0538bed109d65f4edb Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Mon, 25 Mar 2019 23:02:39 +0000 Subject: [PATCH 24/30] removed duplicate emby-button module as dependency --- src/components/collectioneditor/collectioneditor.js | 2 +- src/components/directorybrowser/directorybrowser.js | 2 +- src/components/filtermenu/filtermenu.js | 2 +- src/components/homesections/homesections.js | 2 +- src/components/imagedownloader/imagedownloader.js | 4 ++-- src/components/maintabsmanager.js | 2 +- src/components/sortmenu/sortmenu.js | 2 +- src/components/viewsettings/viewsettings.js | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/collectioneditor/collectioneditor.js b/src/components/collectioneditor/collectioneditor.js index 8c14405330..5c1bd5c6f8 100644 --- a/src/components/collectioneditor/collectioneditor.js +++ b/src/components/collectioneditor/collectioneditor.js @@ -1,4 +1,4 @@ -define(['dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize) { +define(['dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize) { 'use strict'; var currentServerId; diff --git a/src/components/directorybrowser/directorybrowser.js b/src/components/directorybrowser/directorybrowser.js index 35bc914301..e4ceecc0ca 100644 --- a/src/components/directorybrowser/directorybrowser.js +++ b/src/components/directorybrowser/directorybrowser.js @@ -1,4 +1,4 @@ -define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-button', 'paper-icon-button-light', 'css!./directorybrowser', 'formDialogStyle', 'emby-button'], function(loading, dialogHelper, dom) { +define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'paper-icon-button-light', 'css!./directorybrowser', 'formDialogStyle', 'emby-button'], function(loading, dialogHelper, dom) { 'use strict'; function getSystemInfo() { diff --git a/src/components/filtermenu/filtermenu.js b/src/components/filtermenu/filtermenu.js index 02b35880b9..89457aa4e6 100644 --- a/src/components/filtermenu/filtermenu.js +++ b/src/components/filtermenu/filtermenu.js @@ -1,4 +1,4 @@ -define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) { +define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) { 'use strict'; function onSubmit(e) { diff --git a/src/components/homesections/homesections.js b/src/components/homesections/homesections.js index bf2a05ffba..0c30a015cc 100644 --- a/src/components/homesections/homesections.js +++ b/src/components/homesections/homesections.js @@ -1,4 +1,4 @@ -define(['connectionManager', 'cardBuilder', 'appSettings', 'dom', 'apphost', 'layoutManager', 'imageLoader', 'globalize', 'itemShortcuts', 'itemHelper', 'appRouter', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer', 'emby-scroller', 'emby-button', 'css!./homesections'], function (connectionManager, cardBuilder, appSettings, dom, appHost, layoutManager, imageLoader, globalize, itemShortcuts, itemHelper, appRouter) { +define(['connectionManager', 'cardBuilder', 'appSettings', 'dom', 'apphost', 'layoutManager', 'imageLoader', 'globalize', 'itemShortcuts', 'itemHelper', 'appRouter', 'paper-icon-button-light', 'emby-itemscontainer', 'emby-scroller', 'emby-button', 'css!./homesections'], function (connectionManager, cardBuilder, appSettings, dom, appHost, layoutManager, imageLoader, globalize, itemShortcuts, itemHelper, appRouter) { 'use strict'; function getDefaultSection(index) { diff --git a/src/components/imagedownloader/imagedownloader.js b/src/components/imagedownloader/imagedownloader.js index 9c6aab2725..729bce3382 100644 --- a/src/components/imagedownloader/imagedownloader.js +++ b/src/components/imagedownloader/imagedownloader.js @@ -1,4 +1,4 @@ -define(['loading', 'apphost', 'dialogHelper', 'connectionManager', 'imageLoader', 'browser', 'layoutManager', 'scrollHelper', 'globalize', 'require', 'emby-checkbox', 'emby-button', 'paper-icon-button-light', 'emby-button', 'formDialogStyle', 'cardStyle'], function (loading, appHost, dialogHelper, connectionManager, imageLoader, browser, layoutManager, scrollHelper, globalize, require) { +define(['loading', 'apphost', 'dialogHelper', 'connectionManager', 'imageLoader', 'browser', 'layoutManager', 'scrollHelper', 'globalize', 'require', 'emby-checkbox', 'paper-icon-button-light', 'emby-button', 'formDialogStyle', 'cardStyle'], function (loading, appHost, dialogHelper, connectionManager, imageLoader, browser, layoutManager, scrollHelper, globalize, require) { 'use strict'; var currentItemId; @@ -364,7 +364,7 @@ define(['loading', 'apphost', 'dialogHelper', 'connectionManager', 'imageLoader' scrollHelper.centerFocus.on(dlg, false); } - // Has to be assigned a z-index after the call to .open() + // Has to be assigned a z-index after the call to .open() dlg.addEventListener('close', onDialogClosed); dialogHelper.open(dlg); diff --git a/src/components/maintabsmanager.js b/src/components/maintabsmanager.js index fa2922aafb..64e25b4870 100644 --- a/src/components/maintabsmanager.js +++ b/src/components/maintabsmanager.js @@ -1,4 +1,4 @@ -define(['dom', 'browser', 'events', 'emby-tabs', 'emby-button', 'emby-button'], function (dom, browser, events) { +define(['dom', 'browser', 'events', 'emby-tabs', 'emby-button'], function (dom, browser, events) { 'use strict'; var tabOwnerView; diff --git a/src/components/sortmenu/sortmenu.js b/src/components/sortmenu/sortmenu.js index 06e75c59cc..da2fcdaa7c 100644 --- a/src/components/sortmenu/sortmenu.js +++ b/src/components/sortmenu/sortmenu.js @@ -1,4 +1,4 @@ -define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'globalize', 'userSettings', 'emby-select', 'paper-icon-button-light', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, layoutManager, connectionManager, globalize, userSettings) { +define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'globalize', 'userSettings', 'emby-select', 'paper-icon-button-light', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, layoutManager, connectionManager, globalize, userSettings) { 'use strict'; function onSubmit(e) { diff --git a/src/components/viewsettings/viewsettings.js b/src/components/viewsettings/viewsettings.js index bfeb7e66ff..617e021115 100644 --- a/src/components/viewsettings/viewsettings.js +++ b/src/components/viewsettings/viewsettings.js @@ -1,4 +1,4 @@ -define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) { +define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) { 'use strict'; function onSubmit(e) { From b3e6d6a83557eb5e2bf61bf35e76e536a175a161 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Mon, 25 Mar 2019 23:04:15 +0000 Subject: [PATCH 25/30] add missing emby-button dependency for addplugin --- src/addplugin.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/addplugin.html b/src/addplugin.html index 38de32c207..5d5d5799d3 100644 --- a/src/addplugin.html +++ b/src/addplugin.html @@ -1,4 +1,4 @@ -
+
From 02c5fd688fa20af749653fc36ecbea1d1929327c Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Mon, 25 Mar 2019 23:08:04 +0000 Subject: [PATCH 26/30] removed old duplicate files for viewmanager --- src/components/viewmanager/package.json | 3 - src/components/viewmanager/viewContainer.css | 69 ------- src/components/viewmanager/viewManager.js | 183 ------------------- src/controllers/librarysettings.js | 2 +- 4 files changed, 1 insertion(+), 256 deletions(-) delete mode 100644 src/components/viewmanager/package.json delete mode 100644 src/components/viewmanager/viewContainer.css delete mode 100644 src/components/viewmanager/viewManager.js diff --git a/src/components/viewmanager/package.json b/src/components/viewmanager/package.json deleted file mode 100644 index 819371af71..0000000000 --- a/src/components/viewmanager/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "viewManager.js" -} \ No newline at end of file diff --git a/src/components/viewmanager/viewContainer.css b/src/components/viewmanager/viewContainer.css deleted file mode 100644 index edfa101976..0000000000 --- a/src/components/viewmanager/viewContainer.css +++ /dev/null @@ -1,69 +0,0 @@ -.mainAnimatedPage { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - contain: layout style size; - /* Can't use will-change because it causes the alpha picker to move when the page scrolls*/ - /*will-change: transform;*/ -} - -@keyframes view-fadeout { - from { - opacity: 1; - } - - to { - opacity: 0; - } -} -@keyframes view-fadein { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -@keyframes view-slideleft { - from { - transform: translate3d(100%, 0, 0); - } - - to { - transform: none; - } -} - -@keyframes view-slideleft-r { - from { - transform: none; - } - - to { - transform: translate3d(-100%, 0, 0); - } -} - -@keyframes view-slideright { - from { - transform: translate3d(-100%, 0, 0); - } - - to { - transform: none; - } -} - -@keyframes view-slideright-r { - from { - transform: none; - } - - to { - transform: translate3d(100%, 0, 0); - } -} \ No newline at end of file diff --git a/src/components/viewmanager/viewManager.js b/src/components/viewmanager/viewManager.js deleted file mode 100644 index 606c7e98c1..0000000000 --- a/src/components/viewmanager/viewManager.js +++ /dev/null @@ -1,183 +0,0 @@ -define(['viewcontainer', 'focusManager', 'queryString', 'layoutManager'], function (viewcontainer, focusManager, queryString, layoutManager) { - 'use strict'; - - var currentView; - var dispatchPageEvents; - - viewcontainer.setOnBeforeChange(function (newView, isRestored, options) { - - var lastView = currentView; - if (lastView) { - - var beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true); - - if (!beforeHideResult) { - // todo: cancel - } - } - - var eventDetail = getViewEventDetail(newView, options, isRestored); - - if (!newView.initComplete) { - newView.initComplete = true; - - if (options.controllerFactory) { - - // Use controller method - var controller = new options.controllerFactory(newView, eventDetail.detail.params); - } - - if (!options.controllerFactory || dispatchPageEvents) { - dispatchViewEvent(newView, eventDetail, 'viewinit'); - } - } - - dispatchViewEvent(newView, eventDetail, 'viewbeforeshow'); - }); - - function onViewChange(view, options, isRestore) { - - var lastView = currentView; - if (lastView) { - dispatchViewEvent(lastView, null, 'viewhide'); - } - - currentView = view; - - var eventDetail = getViewEventDetail(view, options, isRestore); - - if (!isRestore) { - if (options.autoFocus !== false) { - focusManager.autoFocus(view); - } - } - else if (!layoutManager.mobile) { - if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) { - focusManager.focus(view.activeElement); - } else { - focusManager.autoFocus(view); - } - } - - view.dispatchEvent(new CustomEvent('viewshow', eventDetail)); - - if (dispatchPageEvents) { - view.dispatchEvent(new CustomEvent('pageshow', eventDetail)); - } - } - - function getProperties(view) { - var props = view.getAttribute('data-properties'); - - if (props) { - return props.split(','); - } - - return []; - } - - function dispatchViewEvent(view, eventInfo, eventName, isCancellable) { - - if (!eventInfo) { - eventInfo = { - detail: { - type: view.getAttribute('data-type'), - properties: getProperties(view) - }, - bubbles: true, - cancelable: isCancellable - }; - } - - eventInfo.cancelable = isCancellable || false; - - var eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo)); - - if (dispatchPageEvents) { - eventInfo.cancelable = false; - view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo)); - } - - return eventResult; - } - - function getViewEventDetail(view, options, isRestore) { - - var url = options.url; - var index = url.indexOf('?'); - var params = index === -1 ? {} : queryString.parse(url.substring(index + 1)); - - return { - detail: { - type: view.getAttribute('data-type'), - properties: getProperties(view), - params: params, - isRestored: isRestore, - state: options.state, - - // The route options - options: options.options || {} - }, - bubbles: true, - cancelable: false - }; - } - - function resetCachedViews() { - // Reset all cached views whenever the skin changes - viewcontainer.reset(); - } - - document.addEventListener('skinunload', resetCachedViews); - - function ViewManager() { - } - - ViewManager.prototype.loadView = function (options) { - - var lastView = currentView; - - // Record the element that has focus - if (lastView) { - lastView.activeElement = document.activeElement; - } - - if (options.cancel) { - return; - } - - viewcontainer.loadView(options).then(function (view) { - - onViewChange(view, options); - }); - }; - - ViewManager.prototype.tryRestoreView = function (options, onViewChanging) { - - if (options.cancel) { - return Promise.reject({ cancelled: true }); - } - - // Record the element that has focus - if (currentView) { - currentView.activeElement = document.activeElement; - } - - return viewcontainer.tryRestoreView(options).then(function (view) { - - onViewChanging(); - onViewChange(view, options, true); - - }); - }; - - ViewManager.prototype.currentView = function () { - return currentView; - }; - - ViewManager.prototype.dispatchPageEvents = function (value) { - dispatchPageEvents = value; - }; - - return new ViewManager(); -}); diff --git a/src/controllers/librarysettings.js b/src/controllers/librarysettings.js index 997ccdfd4d..3fc9c40d98 100644 --- a/src/controllers/librarysettings.js +++ b/src/controllers/librarysettings.js @@ -88,4 +88,4 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked", "emby-checkbox", "emby- }); }); } -}); +}); \ No newline at end of file From 7a5d66c792060b288c91162175d18ef28d51e4c2 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Mon, 25 Mar 2019 23:43:03 +0000 Subject: [PATCH 27/30] refactor fullscreenManager suggested by JustAMan --- src/components/fullscreenManager.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/fullscreenManager.js b/src/components/fullscreenManager.js index 0a43a764a5..079267a6c4 100644 --- a/src/components/fullscreenManager.js +++ b/src/components/fullscreenManager.js @@ -81,16 +81,11 @@ define(['events', 'dom', 'apphost', 'browser'], function (events, dom, appHost, if (appHost.supports("fullscreenchange") && (browser.edgeUwp || -1 !== navigator.userAgent.toLowerCase().indexOf("electron"))) { function isTargetValid(target) { - - if (dom.parentWithTag(target, ['BUTTON', 'INPUT', 'TEXTAREA'])) { - return false; - } - - return true; + return !dom.parentWithTag(target, ['BUTTON', 'INPUT', 'TEXTAREA']); } - + dom.addEventListener(window, 'dblclick', function (e) { - + if (isTargetValid(e.target)) { if (manager.isFullScreen()) { manager.exitFullscreen(); @@ -98,7 +93,7 @@ define(['events', 'dom', 'apphost', 'browser'], function (events, dom, appHost, manager.requestFullscreen(); } } - + }, { passive: true }); From ac13bcb43ec9f383a7a54c5ba92e57d13e71a128 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Tue, 26 Mar 2019 01:44:33 +0000 Subject: [PATCH 28/30] force emby-button load before routes --- src/scripts/site.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/site.js b/src/scripts/site.js index 42bb9f1587..f984f20ebb 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -581,7 +581,7 @@ var AppInfo = {}; window.Emby.Page = appRouter; - require(['scripts/themeloader', 'libraryMenu', 'scripts/routes'], function () { + require(['emby-button', 'scripts/themeloader', 'libraryMenu', 'scripts/routes'], function () { Emby.Page.start({ click: false, hashbang: true From 67f04532bed2eac19abc0216f951dd872997bb29 Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Tue, 26 Mar 2019 01:45:36 +0000 Subject: [PATCH 29/30] fix minor bug for listItemImage background sizing --- src/components/listview/listview.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/listview/listview.css b/src/components/listview/listview.css index 4b4e88f842..312bf14a16 100644 --- a/src/components/listview/listview.css +++ b/src/components/listview/listview.css @@ -100,7 +100,7 @@ min-width: 2.78em; min-height: 2.78em; background-repeat: no-repeat; - background-size: contain; + background-size: cover; flex-shrink: 0; background-position: center center; position: relative; From 5ff34f5eb4d44522e2aa9aa0bc86bca539c2607f Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Thu, 28 Mar 2019 22:17:46 +0000 Subject: [PATCH 30/30] removed unecessary file page.js from components --- src/components/page.js | 1077 ---------------------------------------- 1 file changed, 1077 deletions(-) delete mode 100644 src/components/page.js diff --git a/src/components/page.js b/src/components/page.js deleted file mode 100644 index ce96fd185e..0000000000 --- a/src/components/page.js +++ /dev/null @@ -1,1077 +0,0 @@ -define([], function () { - - 'use strict'; - - /** - * Detect click event - */ - var clickEvent = ('undefined' !== typeof document) && document.ontouchstart ? 'touchstart' : 'click'; - - /** - * To work properly with the URL - * history.location generated polyfill in https://github.com/devote/HTML5-History-API - */ - - var location = ('undefined' !== typeof window) && (window.history.location || window.location); - - /** - * Perform initial dispatch. - */ - - var dispatch = true; - - - /** - * Decode URL components (query string, pathname, hash). - * Accommodates both regular percent encoding and x-www-form-urlencoded format. - */ - var decodeURLComponents = true; - - /** - * Base path. - */ - - var base = ''; - - /** - * Running flag. - */ - - var running; - - /** - * HashBang option - */ - - var hashbang = false; - - var enableHistory = false; - - /** - * Previous context, for capturing - * page exit events. - */ - - var prevContext; - - var prevPageContext; - - /** - * Register `path` with callback `fn()`, - * or route `path`, or redirection, - * or `page.start()`. - * - * page(fn); - * page('*', fn); - * page('/user/:id', load, user); - * page('/user/' + user.id, { some: 'thing' }); - * page('/user/' + user.id); - * page('/from', '/to') - * page(); - * - * @param {String|Function} path - * @param {Function} fn... - * @api public - */ - - function page(path, fn) { - // - if ('function' === typeof path) { - return page('*', path); - } - - // route to - if ('function' === typeof fn) { - var route = new Route(path); - for (var i = 1; i < arguments.length; ++i) { - page.callbacks.push(route.middleware(arguments[i])); - } - // show with [state] - } else if ('string' === typeof path) { - page['string' === typeof fn ? 'redirect' : 'show'](path, fn); - // start [options] - } else { - page.start(path); - } - } - - /** - * Callback functions. - */ - - page.callbacks = []; - page.exits = []; - - /** - * Current path being processed - * @type {String} - */ - page.current = ''; - - /** - * Number of pages navigated to. - * @type {number} - * - * page.len == 0; - * page('/login'); - * page.len == 1; - */ - - page.len = 0; - - /** - * Get or set basepath to `path`. - * - * @param {String} path - * @api public - */ - - page.base = function (path) { - if (0 === arguments.length) { - return base; - } - base = path; - }; - - /** - * Bind with the given `options`. - * - * Options: - * - * - `click` bind to click events [true] - * - `popstate` bind to popstate [true] - * - `dispatch` perform initial dispatch [true] - * - * @param {Object} options - * @api public - */ - - page.start = function (options) { - options = options || {}; - if (running) { - return; - } - running = true; - if (false === options.dispatch) { - dispatch = false; - } - if (false === options.decodeURLComponents) { - decodeURLComponents = false; - } - if (false !== options.popstate) { - window.addEventListener('popstate', onpopstate, false); - } - if (false !== options.click) { - document.addEventListener(clickEvent, onclick, false); - } - if (options.enableHistory != null) { - enableHistory = options.enableHistory; - } - if (true === options.hashbang) { - hashbang = true; - } - if (!dispatch) { - return; - } - - var url; - - if (hashbang && ~location.hash.indexOf('#!')) { - - url = location.hash.substr(2); - - var href = location.href.toString(); - if (href.indexOf('?') >= href.indexOf('#!')) { - url += location.search; - } - } - else { - url = location.pathname + location.search + location.hash; - } - - page.replace(url, null, true, dispatch); - }; - - /** - * Unbind click and popstate event handlers. - * - * @api public - */ - - page.stop = function () { - if (!running) { - return; - } - page.current = ''; - page.len = 0; - running = false; - document.removeEventListener(clickEvent, onclick, false); - window.removeEventListener('popstate', onpopstate, false); - }; - - /** - * Show `path` with optional `state` object. - * - * @param {String} path - * @param {Object} state - * @param {Boolean} dispatch - * @return {Context} - * @api public - */ - - page.show = function (path, state, dispatch, push, isBack) { - var ctx = new Context(path, state); - ctx.isBack = isBack; - page.current = ctx.path; - if (false !== dispatch) { - page.dispatch(ctx); - } - if (false !== ctx.handled && false !== push) { - ctx.pushState(); - } - return ctx; - }; - - page.restorePreviousState = function () { - - prevContext = prevPageContext; - page.show(prevContext.pathname, prevContext.state, false, true, false); - }; - - /** - * Goes back in the history - * Back should always let the current route push state and then go back. - * - * @param {String} path - fallback path to go back if no more history exists, if undefined defaults to page.base - * @param {Object} [state] - * @api public - */ - - page.back = function (path, state) { - - if (enableHistory) { - // Keep it simple and mimic browser back - history.back(); - return; - } - - if (page.len > 0) { - // this may need more testing to see if all browsers - // wait for the next tick to go back in history - if (enableHistory) { - history.back(); - } else { - - if (backStack.length > 2) { - backStack.length--; - var previousState = backStack[backStack.length - 1]; - page.show(previousState.path, previousState.state, true, false, true); - } - } - page.len--; - } else if (path) { - setTimeout(function () { - page.show(path, state); - }); - } else { - setTimeout(function () { - page.show(base, state); - }); - } - }; - - page.enableNativeHistory = function () { - return enableHistory; - }; - - page.canGoBack = function () { - if (enableHistory) { - return history.length > 1; - } - return (page.len || 0) > 0; - }; - - /** - * Register route to redirect from one path to other - * or just redirect to another route - * - * @param {String} from - if param 'to' is undefined redirects to 'from' - * @param {String} [to] - * @api public - */ - page.redirect = function (from, to) { - // Define route from a path to another - if ('string' === typeof from && 'string' === typeof to) { - page(from, function (e) { - setTimeout(function () { - page.replace(to); - }, 0); - }); - } - - // Wait for the push state and replace it with another - if ('string' === typeof from && 'undefined' === typeof to) { - setTimeout(function () { - page.replace(from); - }, 0); - } - }; - - /** - * Replace `path` with optional `state` object. - * - * @param {String} path - * @param {Object} state - * @return {Context} - * @api public - */ - - - page.replace = function (path, state, init, dispatch, isBack) { - var ctx = new Context(path, state); - ctx.isBack = isBack; - page.current = ctx.path; - ctx.init = init; - ctx.save(); // save before dispatching, which may redirect - if (false !== dispatch) { - page.dispatch(ctx); - } - return ctx; - }; - - /** - * Dispatch the given `ctx`. - * - * @param {Object} ctx - * @api private - */ - - page.dispatch = function (ctx) { - var prev = prevContext, - i = 0, - j = 0; - - prevPageContext = prevContext; - prevContext = ctx; - - function nextExit() { - var fn = page.exits[j++]; - if (!fn) { - return nextEnter(); - } - fn(prev, nextExit); - } - - function nextEnter() { - var fn = page.callbacks[i++]; - - if (ctx.path !== page.current) { - ctx.handled = false; - return; - } - if (!fn) { - return unhandled(ctx); - } - fn(ctx, nextEnter); - } - - if (prev) { - nextExit(); - } else { - nextEnter(); - } - }; - - /** - * Unhandled `ctx`. When it's not the initial - * popstate then redirect. If you wish to handle - * 404s on your own use `page('*', callback)`. - * - * @param {Context} ctx - * @api private - */ - - function unhandled(ctx) { - if (ctx.handled) { - return; - } - var current; - - if (hashbang) { - current = base + location.hash.replace('#!', ''); - } else { - current = location.pathname + location.search; - } - - if (current === ctx.canonicalPath) { - return; - } - page.stop(); - ctx.handled = false; - location.href = ctx.canonicalPath; - } - - /** - * Register an exit route on `path` with - * callback `fn()`, which will be called - * on the previous context when a new - * page is visited. - */ - page.exit = function (path, fn) { - if (typeof path === 'function') { - return page.exit('*', path); - } - - var route = new Route(path); - for (var i = 1; i < arguments.length; ++i) { - page.exits.push(route.middleware(arguments[i])); - } - }; - - /** - * Remove URL encoding from the given `str`. - * Accommodates whitespace in both x-www-form-urlencoded - * and regular percent-encoded form. - * - * @param {str} URL component to decode - */ - function decodeURLEncodedURIComponent(val) { - if (typeof val !== 'string') { return val; } - return decodeURLComponents ? decodeURIComponent(val.replace(/\+/g, ' ')) : val; - } - - /** - * Initialize a new "request" `Context` - * with the given `path` and optional initial `state`. - * - * @param {String} path - * @param {Object} state - * @api public - */ - - function Context(path, state) { - if ('/' === path[0] && 0 !== path.indexOf(base)) { - path = base + (hashbang ? '#!' : '') + path; - } - var i = path.indexOf('?'); - - this.canonicalPath = path; - this.path = path.replace(base, '') || '/'; - if (hashbang) { - this.path = this.path.replace('#!', '') || '/'; - } - - this.title = document.title; - this.state = state || {}; - this.state.path = path; - this.querystring = ~i ? decodeURLEncodedURIComponent(path.slice(i + 1)) : ''; - this.pathname = decodeURLEncodedURIComponent(~i ? path.slice(0, i) : path); - this.params = {}; - - // fragment - this.hash = ''; - if (!hashbang) { - if (!~this.path.indexOf('#')) { - return; - } - var parts = this.path.split('#'); - this.path = parts[0]; - this.hash = decodeURLEncodedURIComponent(parts[1]) || ''; - this.querystring = this.querystring.split('#')[0]; - } - } - - /** - * Expose `Context`. - */ - - page.Context = Context; - var backStack = []; - - /** - * Push state. - * - * @api private - */ - - Context.prototype.pushState = function () { - page.len++; - - if (enableHistory) { - history.pushState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); - } else { - backStack.push({ - state: this.state, - title: this.title, - url: (hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath), - path: this.path - }); - } - }; - - /** - * Save the context state. - * - * @api public - */ - - Context.prototype.save = function () { - - if (enableHistory) { - history.replaceState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); - } else { - backStack[page.len || 0] = { - state: this.state, - title: this.title, - url: (hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath), - path: this.path - }; - } - }; - - /** - * Initialize `Route` with the given HTTP `path`, - * and an array of `callbacks` and `options`. - * - * Options: - * - * - `sensitive` enable case-sensitive routes - * - `strict` enable strict matching for trailing slashes - * - * @param {String} path - * @param {Object} options. - * @api private - */ - - function Route(path, options) { - options = options || {}; - this.path = (path === '*') ? '(.*)' : path; - this.method = 'GET'; - this.regexp = pathToRegexp(this.path, - this.keys = [], - options.sensitive, - options.strict); - } - - /** - * Expose `Route`. - */ - - page.Route = Route; - - /** - * Return route middleware with - * the given callback `fn()`. - * - * @param {Function} fn - * @return {Function} - * @api public - */ - - Route.prototype.middleware = function (fn) { - var self = this; - return function (ctx, next) { - if (self.match(ctx.path, ctx.params)) { - return fn(ctx, next); - } - next(); - }; - }; - - /** - * Check if this route matches `path`, if so - * populate `params`. - * - * @param {String} path - * @param {Object} params - * @return {Boolean} - * @api private - */ - - Route.prototype.match = function (path, params) { - var keys = this.keys, - qsIndex = path.indexOf('?'), - pathname = ~qsIndex ? path.slice(0, qsIndex) : path, - m = this.regexp.exec(decodeURIComponent(pathname)); - - if (!m) { - return false; - } - - for (var i = 1, len = m.length; i < len; ++i) { - var key = keys[i - 1]; - var val = decodeURLEncodedURIComponent(m[i]); - if (val !== undefined || !(hasOwnProperty.call(params, key.name))) { - params[key.name] = val; - } - } - - return true; - }; - - - var previousPopState = {}; - - function ignorePopState(event) { - - var state = event.state || {}; - - if (previousPopState.navigate === false) { - // Ignore - previousPopState = state; - return true; - } - - previousPopState = state; - return false; - } - - page.pushState = function (state, title, url) { - - if (hashbang) { - url = '#!' + url; - } - - history.pushState(state, title, url); - previousPopState = state; - }; - - /** - * Handle "populate" events. - */ - - var onpopstate = (function () { - var loaded = false; - if ('undefined' === typeof window) { - return; - } - if (document.readyState === 'complete') { - loaded = true; - } else { - window.addEventListener('load', function () { - setTimeout(function () { - loaded = true; - }, 0); - }); - } - return function onpopstate(e) { - if (!loaded) { - return; - } - if (ignorePopState(e)) { - return; - } - if (e.state) { - var path = e.state.path; - page.replace(path, e.state, null, null, true); - } else { - page.show(location.pathname + location.hash, undefined, undefined, false, true); - } - }; - })(); - /** - * Handle "click" events. - */ - - function onclick(e, checkWhich) { - - if (1 !== which(e) && checkWhich !== false) { - return; - } - - if (e.metaKey || e.ctrlKey || e.shiftKey) { - return; - } - if (e.defaultPrevented) { - return; - } - - - // ensure link - var el = e.target; - - while (el && 'A' !== el.nodeName) { - el = el.parentNode; - } - if (!el || 'A' !== el.nodeName) { - return; - } - - - // Ignore if tag has - // 1. "download" attribute - // 2. rel="external" attribute - if (el.hasAttribute('download') || el.getAttribute('rel') === 'external') { - return; - } - - // ensure non-hash for the same path - var link = el.getAttribute('href'); - if (link === '#') { - e.preventDefault(); - return; - } - - if (!hashbang && el.pathname === location.pathname && (el.hash || '#' === link)) { - return; - } - - // check target - if (el.target) { - return; - } - - // x-origin - if (!sameOrigin(el.href)) { - return; - } - - // rebuild path - var path = el.pathname + el.search + (el.hash || ''); - - // same page - var orig = path; - - if (path.indexOf(base) === 0) { - path = path.substr(base.length); - } - - if (hashbang) { - path = path.replace('#!', ''); - } - - if (base && orig === path) { - // This is causing navigation to be canceled in edge uwp - // If needed this can be changed to only be skipped when called via handleAnchorClick - //return; - } - - e.preventDefault(); - page.show(orig); - } - - page.handleAnchorClick = onclick; - - /** - * Event button. - */ - - function which(e) { - e = e || window.event; - return null === e.which ? e.button : e.which; - } - - /** - * Check if `href` is the same origin. - */ - - function sameOrigin(href) { - var origin = location.protocol + '//' + location.hostname; - if (location.port) { - origin += ':' + location.port; - } - return (href && (0 === href.indexOf(origin))); - } - - page.sameOrigin = sameOrigin; - - /** - * The main path matching regexp utility. - * - * @type {RegExp} - */ - var PATH_REGEXP = new RegExp([ - // Match escaped characters that would otherwise appear in future matches. - // This allows the user to escape special characters that won't transform. - '(\\\\.)', - // Match Express-style parameters and un-named parameters with a prefix - // and optional suffixes. Matches appear as: - // - // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] - // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] - // "/*" => ["/", undefined, undefined, undefined, undefined, "*"] - '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))' - ].join('|'), 'g'); - - /** - * Parse a string for the raw tokens. - * - * @param {String} str - * @return {Array} - */ - function parse(str) { - var tokens = []; - var key = 0; - var index = 0; - var path = ''; - var res; - - while ((res = PATH_REGEXP.exec(str)) != null) { - var m = res[0]; - var escaped = res[1]; - var offset = res.index; - path += str.slice(index, offset); - index = offset + m.length; - - // Ignore already escaped sequences. - if (escaped) { - path += escaped[1]; - continue; - } - - // Push the current path onto the tokens. - if (path) { - tokens.push(path); - path = ''; - } - - var prefix = res[2]; - var name = res[3]; - var capture = res[4]; - var group = res[5]; - var suffix = res[6]; - var asterisk = res[7]; - - var repeat = suffix === '+' || suffix === '*'; - var optional = suffix === '?' || suffix === '*'; - var delimiter = prefix || '/'; - var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?'); - - tokens.push({ - name: name || key++, - prefix: prefix || '', - delimiter: delimiter, - optional: optional, - repeat: repeat, - pattern: escapeGroup(pattern) - }); - } - - // Match any characters still remaining. - if (index < str.length) { - path += str.substr(index); - } - - // If the path exists, push it onto the end. - if (path) { - tokens.push(path); - } - - return tokens; - } - - var isarray = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) === '[object Array]'; - }; - - /** - * Escape a regular expression string. - * - * @param {String} str - * @return {String} - */ - function escapeString(str) { - return str.replace(/([.+*?=^!:${}()[\]|\/])/g, '\\$1'); - } - - /** - * Escape the capturing group by escaping special characters and meaning. - * - * @param {String} group - * @return {String} - */ - function escapeGroup(group) { - return group.replace(/([=!:$\/()])/g, '\\$1'); - } - - /** - * Attach the keys as a property of the regexp. - * - * @param {RegExp} re - * @param {Array} keys - * @return {RegExp} - */ - function attachKeys(re, keys) { - re.keys = keys; - return re; - } - - /** - * Get the flags for a regexp from the options. - * - * @param {Object} options - * @return {String} - */ - function flags(options) { - return options.sensitive ? '' : 'i'; - } - - /** - * Pull out keys from a regexp. - * - * @param {RegExp} path - * @param {Array} keys - * @return {RegExp} - */ - function regexpToRegexp(path, keys) { - // Use a negative lookahead to match only capturing groups. - var groups = path.source.match(/\((?!\?)/g); - - if (groups) { - for (var i = 0; i < groups.length; i++) { - keys.push({ - name: i, - prefix: null, - delimiter: null, - optional: false, - repeat: false, - pattern: null - }); - } - } - - return attachKeys(path, keys); - } - - /** - * Transform an array into a regexp. - * - * @param {Array} path - * @param {Array} keys - * @param {Object} options - * @return {RegExp} - */ - function arrayToRegexp(path, keys, options) { - var parts = []; - - for (var i = 0; i < path.length; i++) { - parts.push(pathToRegexp(path[i], keys, options).source); - } - - var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)); - - return attachKeys(regexp, keys); - } - - /** - * Create a path regexp from string input. - * - * @param {String} path - * @param {Array} keys - * @param {Object} options - * @return {RegExp} - */ - function stringToRegexp(path, keys, options) { - var tokens = parse(path); - var re = tokensToRegExp(tokens, options); - - // Attach keys back to the regexp. - for (var i = 0; i < tokens.length; i++) { - if (typeof tokens[i] !== 'string') { - keys.push(tokens[i]); - } - } - - return attachKeys(re, keys); - } - - /** - * Expose a function for taking tokens and returning a RegExp. - * - * @param {Array} tokens - * @param {Array} keys - * @param {Object} options - * @return {RegExp} - */ - function tokensToRegExp(tokens, options) { - options = options || {}; - - var strict = options.strict; - var end = options.end !== false; - var route = ''; - var lastToken = tokens[tokens.length - 1]; - var endsWithSlash = typeof lastToken === 'string' && /\/$/.test(lastToken); - - // Iterate over the tokens and create our regexp string. - for (var i = 0; i < tokens.length; i++) { - var token = tokens[i]; - - if (typeof token === 'string') { - route += escapeString(token); - } else { - var prefix = escapeString(token.prefix); - var capture = token.pattern; - - if (token.repeat) { - capture += '(?:' + prefix + capture + ')*'; - } - - if (token.optional) { - if (prefix) { - capture = '(?:' + prefix + '(' + capture + '))?'; - } else { - capture = '(' + capture + ')?'; - } - } else { - capture = prefix + '(' + capture + ')'; - } - - route += capture; - } - } - - // In non-strict mode we allow a slash at the end of match. If the path to - // match already ends with a slash, we remove it for consistency. The slash - // is valid at the end of a path match, not in the middle. This is important - // in non-ending mode, where "/test/" shouldn't match "/test//route". - if (!strict) { - route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?'; - } - - if (end) { - route += '$'; - } else { - // In non-ending mode, we need the capturing groups to match as much as - // possible by using a positive lookahead to the end or next path segment. - route += strict && endsWithSlash ? '' : '(?=\\/|$)'; - } - - return new RegExp('^' + route, flags(options)); - } - - /** - * Normalize the given path string, returning a regular expression. - * - * An empty array can be passed in for the keys, which will hold the - * placeholder key descriptions. For example, using `/user/:id`, `keys` will - * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. - * - * @param {(String|RegExp|Array)} path - * @param {Array} [keys] - * @param {Object} [options] - * @return {RegExp} - */ - function pathToRegexp(path, keys, options) { - keys = keys || []; - - if (!isarray(keys)) { - options = keys; - keys = []; - } else if (!options) { - options = {}; - } - - if (path instanceof RegExp) { - return regexpToRegexp(path, keys, options); - } - - if (isarray(path)) { - return arrayToRegexp(path, keys, options); - } - - return stringToRegexp(path, keys, options); - } - - return page; - -}); \ No newline at end of file