2014-10-15 23:26:39 -04:00
|
|
|
|
(function ($, document) {
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2015-06-07 17:21:30 -04:00
|
|
|
|
var defaultFirstSection = 'smalllibrarytiles';
|
2015-04-14 23:41:29 -04:00
|
|
|
|
|
2014-06-23 12:05:19 -04:00
|
|
|
|
function getDefaultSection(index) {
|
|
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
|
|
|
|
|
|
case 0:
|
2015-04-14 23:41:29 -04:00
|
|
|
|
return defaultFirstSection;
|
2014-06-23 12:05:19 -04:00
|
|
|
|
case 1:
|
|
|
|
|
return 'resume';
|
|
|
|
|
case 2:
|
2014-07-11 22:31:08 -04:00
|
|
|
|
return 'latestmedia';
|
2014-06-23 12:05:19 -04:00
|
|
|
|
case 3:
|
2015-06-25 21:10:56 -04:00
|
|
|
|
return 'latesttvrecordings';
|
2014-06-23 12:05:19 -04:00
|
|
|
|
default:
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 21:14:24 -04:00
|
|
|
|
function loadSection(page, user, displayPreferences, index) {
|
|
|
|
|
|
|
|
|
|
var userId = user.Id;
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
|
|
|
|
var section = displayPreferences.CustomPrefs['home' + index] || getDefaultSection(index);
|
|
|
|
|
|
2015-04-11 17:34:05 -04:00
|
|
|
|
if (section == 'folders') {
|
2015-04-14 23:41:29 -04:00
|
|
|
|
section = defaultFirstSection;
|
2015-04-11 17:34:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 21:58:06 -04:00
|
|
|
|
var showLibraryTileNames = displayPreferences.CustomPrefs.enableLibraryTileNames != '0';
|
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var elem = page.querySelector('.section' + index);
|
2014-06-20 00:50:30 -04:00
|
|
|
|
|
2014-05-21 15:33:46 -04:00
|
|
|
|
if (section == 'latestmedia') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadRecentlyAdded(elem, user);
|
2014-05-21 15:33:46 -04:00
|
|
|
|
}
|
|
|
|
|
else if (section == 'librarytiles') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'backdrop', index, false, showLibraryTileNames);
|
2014-06-07 15:46:24 -04:00
|
|
|
|
}
|
2014-06-24 17:45:21 -04:00
|
|
|
|
else if (section == 'smalllibrarytiles') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'homePageSmallBackdrop', index, false, showLibraryTileNames);
|
2014-07-11 22:31:08 -04:00
|
|
|
|
}
|
|
|
|
|
else if (section == 'smalllibrarytiles-automobile') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'homePageSmallBackdrop', index, true, showLibraryTileNames);
|
2015-03-14 00:50:23 -04:00
|
|
|
|
}
|
|
|
|
|
else if (section == 'librarytiles-automobile') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'backdrop', index, true, showLibraryTileNames);
|
2014-05-21 15:33:46 -04:00
|
|
|
|
}
|
2014-06-24 17:45:21 -04:00
|
|
|
|
else if (section == 'librarybuttons') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadlibraryButtons(elem, userId, index);
|
2014-06-24 17:45:21 -04:00
|
|
|
|
}
|
2014-05-21 15:33:46 -04:00
|
|
|
|
else if (section == 'resume') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadResume(elem, userId);
|
2014-06-23 12:05:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (section == 'latesttvrecordings') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadLatestLiveTvRecordings(elem, userId);
|
2014-05-21 15:33:46 -04:00
|
|
|
|
}
|
2015-04-11 17:34:05 -04:00
|
|
|
|
else if (section == 'latestchannelmedia') {
|
2015-04-12 12:46:29 -04:00
|
|
|
|
return Sections.loadLatestChannelMedia(elem, userId);
|
2014-06-15 19:30:04 -04:00
|
|
|
|
|
2014-05-21 23:35:18 -04:00
|
|
|
|
} else {
|
2014-05-23 21:16:53 -04:00
|
|
|
|
|
2014-05-21 23:35:18 -04:00
|
|
|
|
elem.empty();
|
2015-04-12 12:46:29 -04:00
|
|
|
|
|
|
|
|
|
var deferred = DeferredBuilder.Deferred();
|
|
|
|
|
deferred.resolve();
|
|
|
|
|
return deferred.promise();
|
2014-05-21 15:33:46 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 21:14:24 -04:00
|
|
|
|
function loadSections(page, user, displayPreferences) {
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
|
|
|
|
var i, length;
|
2014-06-15 19:30:04 -04:00
|
|
|
|
var sectionCount = 4;
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var elem = page.querySelector('.sections');
|
2014-05-23 21:16:53 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
if (!elem.innerHTML.length) {
|
2014-05-21 23:35:18 -04:00
|
|
|
|
var html = '';
|
|
|
|
|
for (i = 0, length = sectionCount; i < length; i++) {
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2014-05-21 23:35:18 -04:00
|
|
|
|
html += '<div class="homePageSection section' + i + '"></div>';
|
|
|
|
|
}
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
elem.innerHTML = html;
|
2014-05-21 23:35:18 -04:00
|
|
|
|
}
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2015-04-12 12:46:29 -04:00
|
|
|
|
var promises = [];
|
|
|
|
|
|
2014-05-21 15:33:46 -04:00
|
|
|
|
for (i = 0, length = sectionCount; i < length; i++) {
|
|
|
|
|
|
2015-04-12 12:46:29 -04:00
|
|
|
|
promises.push(loadSection(page, user, displayPreferences, i));
|
2014-05-21 15:33:46 -04:00
|
|
|
|
}
|
2015-04-12 12:46:29 -04:00
|
|
|
|
|
|
|
|
|
return $.when(promises);
|
2014-05-21 15:33:46 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-20 14:04:02 -04:00
|
|
|
|
var homePageDismissValue = '14';
|
2014-09-25 23:47:46 -04:00
|
|
|
|
var homePageTourKey = 'homePageTour';
|
2014-06-07 15:46:24 -04:00
|
|
|
|
|
2014-05-30 17:06:57 -04:00
|
|
|
|
function dismissWelcome(page, userId) {
|
|
|
|
|
|
2015-05-13 00:55:19 -04:00
|
|
|
|
getDisplayPreferences('home', userId).done(function (result) {
|
2014-05-30 17:06:57 -04:00
|
|
|
|
|
2014-09-25 23:47:46 -04:00
|
|
|
|
result.CustomPrefs[homePageTourKey] = homePageDismissValue;
|
2015-05-13 00:55:19 -04:00
|
|
|
|
ApiClient.updateDisplayPreferences('home', result, userId, getDisplayPreferencesAppName());
|
2014-09-25 23:47:46 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-06-07 15:46:24 -04:00
|
|
|
|
|
2015-01-11 13:36:26 -05:00
|
|
|
|
function showWelcomeIfNeeded(page, displayPreferences) {
|
|
|
|
|
|
|
|
|
|
if (displayPreferences.CustomPrefs[homePageTourKey] == homePageDismissValue) {
|
|
|
|
|
$('.welcomeMessage', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
var elem = $('.welcomeMessage', page).show();
|
|
|
|
|
|
|
|
|
|
if (displayPreferences.CustomPrefs[homePageTourKey]) {
|
|
|
|
|
|
|
|
|
|
$('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeBack'));
|
|
|
|
|
$('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTourToSeeWhatsNew'));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-03-21 14:12:12 -04:00
|
|
|
|
$('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeToProjectWebClient'));
|
2015-01-11 13:36:26 -05:00
|
|
|
|
$('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTour'));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-04 14:05:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:47:46 -04:00
|
|
|
|
function takeTour(page, userId) {
|
|
|
|
|
|
2015-05-08 23:48:43 -04:00
|
|
|
|
Dashboard.loadSwipebox().done(function () {
|
|
|
|
|
|
|
|
|
|
$.swipebox([
|
|
|
|
|
{ href: 'css/images/tour/web/tourcontent.jpg', title: Globalize.translate('WebClientTourContent') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmovies.jpg', title: Globalize.translate('WebClientTourMovies') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmouseover.jpg', title: Globalize.translate('WebClientTourMouseOver') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourtaphold.jpg', title: Globalize.translate('WebClientTourTapHold') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmysync.png', title: Globalize.translate('WebClientTourMySync') },
|
|
|
|
|
{ href: 'css/images/tour/web/toureditor.png', title: Globalize.translate('WebClientTourMetadataManager') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourplaylist.png', title: Globalize.translate('WebClientTourPlaylists') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourcollections.jpg', title: Globalize.translate('WebClientTourCollections') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings1.png', title: Globalize.translate('WebClientTourUserPreferences1') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings2.png', title: Globalize.translate('WebClientTourUserPreferences2') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings3.png', title: Globalize.translate('WebClientTourUserPreferences3') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings4.png', title: Globalize.translate('WebClientTourUserPreferences4') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmobile1.jpg', title: Globalize.translate('WebClientTourMobile1') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmobile2.png', title: Globalize.translate('WebClientTourMobile2') },
|
|
|
|
|
{ href: 'css/images/tour/enjoy.jpg', title: Globalize.translate('MessageEnjoyYourStay') }
|
|
|
|
|
], {
|
|
|
|
|
afterClose: function () {
|
|
|
|
|
dismissWelcome(page, userId);
|
|
|
|
|
$('.welcomeMessage', page).hide();
|
|
|
|
|
},
|
|
|
|
|
hideBarsDelay: 30000
|
|
|
|
|
});
|
2014-05-30 17:06:57 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-19 15:15:40 -04:00
|
|
|
|
$(document).on('pageinitdepends', "#indexPage", function () {
|
2014-05-30 17:06:57 -04:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
Events.on(page.querySelector('.btnTakeTour'), 'click', function () {
|
2015-05-19 15:15:40 -04:00
|
|
|
|
takeTour(page, Dashboard.getCurrentUserId());
|
2014-05-30 17:06:57 -04:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-19 00:23:55 -04:00
|
|
|
|
}).on('pagebeforeshowready', "#indexPage", function () {
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2015-06-28 22:05:46 -04:00
|
|
|
|
var args = arguments;
|
2014-05-21 15:33:46 -04:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-05-19 15:15:40 -04:00
|
|
|
|
if (window.ApiClient) {
|
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2015-05-19 15:15:40 -04:00
|
|
|
|
getDisplayPreferences('home', userId).done(function (result) {
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2015-05-19 15:15:40 -04:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
2015-03-24 21:14:24 -04:00
|
|
|
|
|
2015-05-19 15:15:40 -04:00
|
|
|
|
loadSections(page, user, result).done(function () {
|
2015-06-07 17:21:30 -04:00
|
|
|
|
|
|
|
|
|
if (!AppInfo.isNativeApp) {
|
|
|
|
|
showWelcomeIfNeeded(page, result);
|
|
|
|
|
}
|
2015-05-19 15:15:40 -04:00
|
|
|
|
});
|
2015-04-12 12:46:29 -04:00
|
|
|
|
|
2015-05-19 15:15:40 -04:00
|
|
|
|
});
|
2015-03-24 21:14:24 -04:00
|
|
|
|
});
|
2015-05-19 15:15:40 -04:00
|
|
|
|
}
|
2014-05-21 15:33:46 -04:00
|
|
|
|
|
2013-07-23 08:29:28 -04:00
|
|
|
|
});
|
|
|
|
|
|
2015-05-13 00:55:19 -04:00
|
|
|
|
function getDisplayPreferencesAppName() {
|
2015-05-14 22:16:57 -04:00
|
|
|
|
|
2015-05-28 19:37:43 -04:00
|
|
|
|
if (AppInfo.isNativeApp) {
|
2015-05-13 00:55:19 -04:00
|
|
|
|
return 'Emby Mobile';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 'webclient';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDisplayPreferences(key, userId) {
|
|
|
|
|
|
|
|
|
|
return ApiClient.getDisplayPreferences(key, userId, getDisplayPreferencesAppName()).done(function (result) {
|
2015-05-14 22:16:57 -04:00
|
|
|
|
|
2015-05-13 00:55:19 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-25 14:32:58 -04:00
|
|
|
|
})(jQuery, document);
|