update tabs

This commit is contained in:
Luke Pulverenti 2015-07-01 11:47:41 -04:00
parent c8eb5f2b0c
commit 5bd79b1ab7
18 changed files with 325 additions and 314 deletions

View file

@ -54,7 +54,7 @@
html += '</div>';
if (result.TotalRecordCount > result.Items.length) {
var href = "homefavorites.html?sectionid=" + section.id;
var href = "index.html?tab=2&sectionid=" + section.id;
html += '<a class="clearLink" href="' + href + '"><paper-button raised class="more">' + Globalize.translate('ButtonMoreItems') + '</paper-button></a>';
}
@ -113,15 +113,20 @@
});
}
$(document).on('pagebeforeshowready', "#favoritesPage", function () {
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
var tabContent = page.querySelector('.homeFavoritesTabContent');
var userId = Dashboard.getCurrentUserId();
$(page.querySelector('neon-animated-pages')).on('iron-select', function () {
if (parseInt(this.selected) == 2) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadSections(tabContent, Dashboard.getCurrentUserId());
}
}
});
if (LibraryBrowser.needsRefresh(page)) {
loadSections(page, userId);
}
});
})(jQuery, document);

View file

@ -5,33 +5,11 @@
return 'Thumb';
}
function getResumeView() {
return 'Poster';
}
function reload(page) {
Dashboard.showLoadingMsg();
var context = '';
if (LibraryMenu.getTopParentId()) {
$('.scopedLibraryViewNav', page).show();
$('.globalNav', page).hide();
$('.scopedContent', page).show();
context = 'tv';
loadResume(page);
} else {
$('.scopedLibraryViewNav', page).hide();
$('.globalNav', page).show();
$('.scopedContent', page).hide();
}
loadNextUp(page, context || 'home-nextup');
loadNextUp(page, 'home-nextup');
}
function loadNextUp(page, context) {
@ -55,11 +33,10 @@
ApiClient.getNextUpEpisodes(query).done(function (result) {
if (result.Items.length) {
$('.noNextUpItems', page).hide();
page.querySelector('.noNextUpItems').classList.add('hide');
} else {
$('.noNextUpItems', page).show();
page.querySelector('.noNextUpItems').classList.remove('hide');
}
var view = getView();
var html = '';
@ -101,95 +78,20 @@
});
}
function enableScrollX() {
return $.browser.mobile && AppInfo.enableAppLayouts;
}
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
function loadResume(page) {
var parentId = LibraryMenu.getTopParentId();
var screenWidth = $(window).width();
var limit = 6;
var options = {
SortBy: "DatePlayed",
SortOrder: "Descending",
IncludeItemTypes: "Episode",
Filters: "IsResumable",
Limit: limit,
Recursive: true,
Fields: "PrimaryImageAspectRatio,SeriesInfo,UserData,SyncInfo",
ExcludeLocationTypes: "Virtual",
ParentId: parentId,
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
if (result.Items.length) {
$('#resumableSection', page).show();
} else {
$('#resumableSection', page).hide();
}
var view = getResumeView();
var html = '';
if (view == 'PosterCard') {
html += LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: getThumbShape(),
showTitle: true,
showParentTitle: true,
lazy: true,
cardLayout: true,
context: 'tv',
showDetailsMenu: true
});
} else if (view == 'Poster') {
html += LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: getThumbShape(),
showTitle: true,
showParentTitle: true,
overlayText: screenWidth >= 800 && !AppInfo.hasLowImageBandwidth,
lazy: true,
context: 'tv',
showDetailsMenu: true
});
}
var elem = page.querySelector('#resumableItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
});
}
$(document).on('pagebeforeshowready', "#homeNextUpPage", function () {
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
var tabContent = page.querySelector('.homeNextUpTabContent');
if (enableScrollX()) {
page.querySelector('#resumableItems').classList.add('hiddenScrollX');
} else {
page.querySelector('#resumableItems').classList.remove('hiddenScrollX');
}
$(page.querySelector('neon-animated-pages')).on('iron-select', function () {
if (parseInt(this.selected) == 1) {
if (LibraryBrowser.needsRefresh(tabContent)) {
if (LibraryBrowser.needsRefresh(page)) {
reload(page);
}
reload(tabContent);
}
}
});
});
})(jQuery, document);

View file

@ -59,14 +59,19 @@
});
}
$(document).on('pagebeforeshowready', "#homeUpcomingPage", function () {
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
var tabContent = page.querySelector('.homeUpcomingTabContent');
if (LibraryBrowser.needsRefresh(page)) {
loadUpcoming(page);
}
$(page.querySelector('neon-animated-pages')).on('iron-select', function () {
if (parseInt(this.selected) == 3) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadUpcoming(tabContent);
}
}
});
});
})(jQuery, document);

View file

@ -164,19 +164,11 @@
});
}
$(document).on('pageinitdepends', "#indexPage", function () {
function loadHomeTab(page) {
var page = this;
var tabContent = page.querySelector('.homeTabContent');
Events.on(page.querySelector('.btnTakeTour'), 'click', function () {
takeTour(page, Dashboard.getCurrentUserId());
});
}).on('pagebeforeshowready', "#indexPage", function () {
var page = this;
if (LibraryBrowser.needsRefresh(page)) {
if (LibraryBrowser.needsRefresh(tabContent)) {
if (window.ApiClient) {
var userId = Dashboard.getCurrentUserId();
@ -186,20 +178,76 @@
Dashboard.getCurrentUser().done(function (user) {
loadSections(page, user, result).done(function () {
loadSections(tabContent, user, result).done(function () {
if (!AppInfo.isNativeApp) {
showWelcomeIfNeeded(page, result);
}
Dashboard.hideLoadingMsg();
LibraryBrowser.setLastRefreshed(page);
LibraryBrowser.setLastRefreshed(tabContent);
});
});
});
}
}
}
function loadTab(page, index) {
switch (index) {
case 0:
loadHomeTab(page);
break;
default:
break;
}
}
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
Events.on(page.querySelector('.btnTakeTour'), 'click', function () {
takeTour(page, Dashboard.getCurrentUserId());
});
var tabs = page.querySelector('paper-tabs');
LibraryBrowser.configurePaperLibraryTabs(page, page.querySelectorAll('paper-tabs')[0], page.querySelectorAll('neon-animated-pages')[0]);
$(tabs).on('iron-select', function () {
var selected = this.selected;
if (LibraryBrowser.navigateOnLibraryTabSelect()) {
if (selected) {
Dashboard.navigate('index.html?tab=' + selected);
} else {
Dashboard.navigate('index.html');
}
} else {
page.querySelector('neon-animated-pages').selected = selected;
}
});
$(page.querySelector('neon-animated-pages')).on('iron-select', function () {
loadTab(page, parseInt(this.selected));
});
}).on('pagebeforeshowready', "#indexPage", function () {
var page = this;
var tabs = page.querySelector('paper-tabs');
var selected = tabs.selected;
if (selected == null) {
selected = parseInt(getParameterByName('tab') || '0');
tabs.selected = selected;
page.querySelector('neon-animated-pages').selected = selected;
}
});
function getDisplayPreferencesAppName() {

View file

@ -112,6 +112,87 @@
elem.classList.add('hasrefreshtime');
},
configureSwipeTabs: function (ownerpage, tabs, pages) {
var pageCount = pages.querySelectorAll('neon-animatable').length;
function allowSwipe(e) {
var target = e.target;
if (target.classList.contains('noSwipe')) {
return false;
}
if ($(target).parents('.noSwipe').length) {
return false;
}
return true;
}
$(ownerpage).on('swipeleft', function (e) {
if (allowSwipe(e)) {
var selected = parseInt(pages.selected || '0');
if (selected < (pageCount - 1)) {
pages.entryAnimation = 'slide-from-right-animation';
pages.exitAnimation = 'slide-left-animation';
tabs.selectNext();
}
}
});
$(ownerpage).on('swiperight', function (e) {
if (allowSwipe(e)) {
var selected = parseInt(pages.selected || '0');
if (selected > 0) {
pages.entryAnimation = 'slide-from-left-animation';
pages.exitAnimation = 'slide-right-animation';
tabs.selectPrevious();
}
}
});
},
enableFullPaperTabs: function () {
return AppInfo.isNativeApp;
},
navigateOnLibraryTabSelect: function () {
return !LibraryBrowser.enableFullPaperTabs();
},
configurePaperLibraryTabs: function (ownerpage, tabs, pages) {
tabs.hideScrollButtons = true;
if (LibraryBrowser.enableFullPaperTabs()) {
$(tabs).show();
LibraryBrowser.configureSwipeTabs(ownerpage, tabs, pages);
$('.libraryViewNav', ownerpage).addClass('paperLibraryViewNav');
} else {
tabs.noSlide = true;
tabs.noink = true;
tabs.noBar = true;
tabs.scrollable = true;
var legacyTabs = $('.legacyTabs', ownerpage).show();
document.body.classList.add('basicPaperLibraryTabs');
$(pages).on('iron-select', function (e) {
var selected = this.selected;
$('a', legacyTabs).removeClass('ui-btn-active')[selected].classList.add('ui-btn-active');
});
}
},
getDateParamValue: function (date) {
function formatDigit(i) {

View file

@ -713,20 +713,6 @@
}
}
function allowSwipe(e) {
var target = $(e.target);
if (target.is('.noSwipe')) {
return false;
}
if (target.parents('.noSwipe').length) {
return false;
}
return true;
}
function onPlayerChange() {
bindToPlayer($($.mobile.activePage)[0], MediaController.getCurrentPlayer());
}
@ -742,42 +728,14 @@
$('.requiresJqmCreate', this).trigger('create');
$(page).on('swipeleft', function (e) {
if (allowSwipe(e)) {
var pages = this.querySelectorAll('neon-animated-pages')[0];
var tabs = this.querySelectorAll('paper-tabs')[0];
var selected = parseInt(pages.selected || '0');
if (selected < 2) {
pages.entryAnimation = 'slide-from-right-animation';
pages.exitAnimation = 'slide-left-animation';
tabs.selectNext();
}
}
});
$(page).on('swiperight', function (e) {
if (allowSwipe(e)) {
var pages = this.querySelectorAll('neon-animated-pages')[0];
var tabs = this.querySelectorAll('paper-tabs')[0];
var selected = parseInt(pages.selected || '0');
if (selected > 0) {
pages.entryAnimation = 'slide-from-left-animation';
pages.exitAnimation = 'slide-right-animation';
tabs.selectPrevious();
}
}
});
LibraryBrowser.configureSwipeTabs(page, page.querySelectorAll('paper-tabs')[0], page.querySelectorAll('neon-animated-pages')[0]);
$(MediaController).on('playerchange', function () {
updateCastIcon(page);
});
$('paper-tabs').on('iron-select', function () {
page.querySelectorAll('neon-animated-pages')[0].selected = this.selected;
page.querySelector('neon-animated-pages').selected = this.selected;
});
}).on('pagebeforeshowready', "#nowPlayingPage", function () {

View file

@ -305,7 +305,7 @@
if (result.Items.length) {
html += '<h1 class="listHeader">' + Globalize.translate('HeaderResume') + '</h1>';
if (enableScrollX()) {
html += '<div class="hiddenScrollX itemsContainer">';
html += '<div class="hiddenScrollX itemsContainer noSwipe">';
} else {
html += '<div class="itemsContainer">';
}