mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-16 10:28:18 -07:00
Merge pull request #1663 from Camc314/migrate-to-ES6-44
Migration of libraryBrowser and multiDownload to ES6 modules
This commit is contained in:
commit
231c965ad9
@ -248,6 +248,8 @@
|
|||||||
"src/scripts/imagehelper.js",
|
"src/scripts/imagehelper.js",
|
||||||
"src/scripts/inputManager.js",
|
"src/scripts/inputManager.js",
|
||||||
"src/scripts/keyboardNavigation.js",
|
"src/scripts/keyboardNavigation.js",
|
||||||
|
"src/scripts/libraryBrowser.js",
|
||||||
|
"src/scripts/multiDownload.js",
|
||||||
"src/scripts/playlists.js",
|
"src/scripts/playlists.js",
|
||||||
"src/scripts/settings/appSettings.js",
|
"src/scripts/settings/appSettings.js",
|
||||||
"src/scripts/settings/userSettings.js",
|
"src/scripts/settings/userSettings.js",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'userSettings', 'emby-itemscontainer'], function (cardBuilder, imageLoader, libraryBrowser, loading, events, userSettings) {
|
define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'userSettings', 'emby-itemscontainer'], function (cardBuilder, imageLoader, libraryBrowser, loading, events, userSettings) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData() {
|
function getPageData() {
|
||||||
if (!pageData) {
|
if (!pageData) {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (loading, events, libraryBrowser, imageLoader, listView, cardBuilder, userSettings, globalize) {
|
define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (loading, events, libraryBrowser, imageLoader, listView, cardBuilder, userSettings, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData(context) {
|
function getPageData(context) {
|
||||||
var key = getSavedQueryKey(context);
|
var key = getSavedQueryKey(context);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader', 'apphost', 'globalize', 'appRouter', 'dom', 'emby-button'], 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';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData() {
|
function getPageData() {
|
||||||
var key = getSavedQueryKey();
|
var key = getSavedQueryKey();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser', 'alphaPicker', 'listView', 'cardBuilder', 'globalize', 'emby-itemscontainer'], function (loading, layoutManager, userSettings, events, libraryBrowser, AlphaPicker, listView, cardBuilder, globalize) {
|
define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser', 'alphaPicker', 'listView', 'cardBuilder', 'globalize', 'emby-itemscontainer'], function (loading, layoutManager, userSettings, events, libraryBrowser, AlphaPicker, listView, cardBuilder, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent, options) {
|
return function (view, params, tabContent, options) {
|
||||||
function onViewStyleChange() {
|
function onViewStyleChange() {
|
||||||
if (self.getCurrentViewStyle() == 'List') {
|
if (self.getCurrentViewStyle() == 'List') {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, userSettings, globalize) {
|
define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, userSettings, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData(context) {
|
function getPageData(context) {
|
||||||
var key = getSavedQueryKey(context);
|
var key = getSavedQueryKey(context);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, playbackManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, userSettings, globalize) {
|
define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, playbackManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, userSettings, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function playAll() {
|
function playAll() {
|
||||||
ApiClient.getItem(ApiClient.getCurrentUserId(), params.topParentId).then(function (item) {
|
ApiClient.getItem(ApiClient.getCurrentUserId(), params.topParentId).then(function (item) {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'apphost', 'userSettings', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, appHost, userSettings) {
|
define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'apphost', 'userSettings', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, appHost, userSettings) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData(context) {
|
function getPageData(context) {
|
||||||
var key = getSavedQueryKey(context);
|
var key = getSavedQueryKey(context);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['libraryBrowser', 'cardBuilder', 'apphost', 'imageLoader', 'loading'], function (libraryBrowser, cardBuilder, appHost, imageLoader, loading) {
|
define(['libraryBrowser', 'cardBuilder', 'apphost', 'imageLoader', 'loading'], function (libraryBrowser, cardBuilder, appHost, imageLoader, loading) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData() {
|
function getPageData() {
|
||||||
var key = getSavedQueryKey();
|
var key = getSavedQueryKey();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['libraryBrowser', 'cardBuilder', 'apphost', 'imageLoader', 'loading'], function (libraryBrowser, cardBuilder, appHost, imageLoader, loading) {
|
define(['libraryBrowser', 'cardBuilder', 'apphost', 'imageLoader', 'loading'], function (libraryBrowser, cardBuilder, appHost, imageLoader, loading) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData() {
|
function getPageData() {
|
||||||
var key = getSavedQueryKey();
|
var key = getSavedQueryKey();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userSettings', 'globalize', 'emby-itemscontainer'], function (events, libraryBrowser, imageLoader, listView, loading, userSettings, globalize) {
|
define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userSettings', 'globalize', 'emby-itemscontainer'], function (events, libraryBrowser, imageLoader, listView, loading, userSettings, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
libraryBrowser = libraryBrowser.default || libraryBrowser;
|
||||||
|
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
function getPageData(context) {
|
function getPageData(context) {
|
||||||
var key = getSavedQueryKey(context);
|
var key = getSavedQueryKey(context);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
import * as userSettings from 'userSettings';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
|
||||||
var libraryBrowser = {
|
export function getSavedQueryKey(modifier) {
|
||||||
getSavedQueryKey: function (modifier) {
|
|
||||||
return window.location.href.split('#')[0] + (modifier || '');
|
return window.location.href.split('#')[0] + (modifier || '');
|
||||||
},
|
}
|
||||||
loadSavedQueryValues: function (key, query) {
|
|
||||||
|
export function loadSavedQueryValues(key, query) {
|
||||||
var values = userSettings.get(key);
|
var values = userSettings.get(key);
|
||||||
|
|
||||||
if (values) {
|
if (values) {
|
||||||
@ -14,8 +14,9 @@ define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
},
|
}
|
||||||
saveQueryValues: function (key, query) {
|
|
||||||
|
export function saveQueryValues(key, query) {
|
||||||
var values = {};
|
var values = {};
|
||||||
|
|
||||||
if (query.SortBy) {
|
if (query.SortBy) {
|
||||||
@ -27,14 +28,17 @@ define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userSettings.set(key, JSON.stringify(values));
|
userSettings.set(key, JSON.stringify(values));
|
||||||
},
|
}
|
||||||
saveViewSetting: function (key, value) {
|
|
||||||
|
export function saveViewSetting (key, value) {
|
||||||
userSettings.set(key + '-_view', value);
|
userSettings.set(key + '-_view', value);
|
||||||
},
|
}
|
||||||
getSavedView: function (key) {
|
|
||||||
|
export function getSavedView (key) {
|
||||||
return userSettings.get(key + '-_view');
|
return userSettings.get(key + '-_view');
|
||||||
},
|
}
|
||||||
showLayoutMenu: function (button, currentLayout, views) {
|
|
||||||
|
export function showLayoutMenu (button, currentLayout, views) {
|
||||||
var dispatchEvent = true;
|
var dispatchEvent = true;
|
||||||
|
|
||||||
if (!views) {
|
if (!views) {
|
||||||
@ -51,7 +55,7 @@ define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
require(['actionsheet'], function (actionsheet) {
|
import('actionsheet').then(({default: actionsheet}) => {
|
||||||
actionsheet.show({
|
actionsheet.show({
|
||||||
items: menuItems,
|
items: menuItems,
|
||||||
positionTo: button,
|
positionTo: button,
|
||||||
@ -72,8 +76,9 @@ define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
getQueryPagingHtml: function (options) {
|
|
||||||
|
export function getQueryPagingHtml (options) {
|
||||||
var startIndex = options.startIndex;
|
var startIndex = options.startIndex;
|
||||||
var limit = options.limit;
|
var limit = options.limit;
|
||||||
var totalRecordCount = options.totalRecordCount;
|
var totalRecordCount = options.totalRecordCount;
|
||||||
@ -111,8 +116,9 @@ define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html += '</div>';
|
return html += '</div>';
|
||||||
},
|
}
|
||||||
showSortMenu: function (options) {
|
|
||||||
|
export function showSortMenu (options) {
|
||||||
require(['dialogHelper', 'emby-radio'], function (dialogHelper) {
|
require(['dialogHelper', 'emby-radio'], function (dialogHelper) {
|
||||||
function onSortByChange() {
|
function onSortByChange() {
|
||||||
var newValue = this.value;
|
var newValue = this.value;
|
||||||
@ -192,8 +198,19 @@ define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
|||||||
sortOrders[i].addEventListener('change', onSortOrderChange);
|
sortOrders[i].addEventListener('change', onSortOrderChange);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
window.LibraryBrowser = libraryBrowser;
|
const libraryBrowser = {
|
||||||
return libraryBrowser;
|
getSavedQueryKey,
|
||||||
});
|
loadSavedQueryValues,
|
||||||
|
saveQueryValues,
|
||||||
|
saveViewSetting,
|
||||||
|
getSavedView,
|
||||||
|
showLayoutMenu,
|
||||||
|
getQueryPagingHtml,
|
||||||
|
showSortMenu
|
||||||
|
};
|
||||||
|
|
||||||
|
window.LibraryBrowser = libraryBrowser;
|
||||||
|
|
||||||
|
export default libraryBrowser;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
define(['browser'], function (browser) {
|
import browser from 'browser';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function fallback(urls) {
|
function fallback(urls) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
(function createIframe() {
|
(function createIframe() {
|
||||||
@ -26,24 +25,24 @@ define(['browser'], function (browser) {
|
|||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sameDomain(url) {
|
function sameDomain(url) {
|
||||||
var a = document.createElement('a');
|
var a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
|
|
||||||
return location.hostname === a.hostname && location.protocol === a.protocol;
|
return location.hostname === a.hostname && location.protocol === a.protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
function download(url) {
|
function download(url) {
|
||||||
var a = document.createElement('a');
|
var a = document.createElement('a');
|
||||||
a.download = '';
|
a.download = '';
|
||||||
a.href = url;
|
a.href = url;
|
||||||
// firefox doesn't support `a.click()`...
|
// firefox doesn't support `a.click()`...
|
||||||
a.dispatchEvent(new MouseEvent('click'));
|
a.dispatchEvent(new MouseEvent('click'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (urls) {
|
export default function (urls) {
|
||||||
if (!urls) {
|
if (!urls) {
|
||||||
throw new Error('`urls` required');
|
throw new Error('`urls` required');
|
||||||
}
|
}
|
||||||
@ -62,5 +61,5 @@ define(['browser'], function (browser) {
|
|||||||
|
|
||||||
download(url);
|
download(url);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
Loading…
Reference in New Issue
Block a user