hide image buttons when there are no providers

This commit is contained in:
Luke Pulverenti 2013-11-05 10:38:59 -05:00
parent 3b7184b5f4
commit 4583cf5b52
4 changed files with 53 additions and 18 deletions

View File

@ -342,6 +342,23 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
return urlPrefix;
}
self.getRemoteImageProviders = function (options) {
if (!options) {
throw new Error("null options");
}
var urlPrefix = getRemoteImagePrefix(options);
var url = self.getUrl(urlPrefix + "/RemoteImages/Providers", options);
return self.ajax({
type: "GET",
url: url,
dataType: "json"
});
};
self.getAvailableRemoteImages = function (options) {
if (!options) {

View File

@ -23,8 +23,13 @@
</div>
<div style="margin: -25px 0 1em;">
<a class="lnkBrowseImages" href="#popupDownload" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="plus" data-mini="true" data-transition="pop">Browse Online Images</a>
<a href="#popupUpload" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="plus" data-mini="true" data-transition="pop">Upload Image</a>
<div style="display: inline-block;">
<a class="lnkBrowseImages lnkBrowseAllImages hide" href="#popupDownload" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="plus" data-mini="true" data-transition="pop">Browse Online Images</a>
</div>
<div style="display: inline-block;">
<a href="#popupUpload" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="plus" data-mini="true" data-transition="pop">Upload Image</a>
</div>
</div>
<div id="imagesContainer" style="display: none;">

View File

@ -261,7 +261,7 @@
return html;
}
function reload(page) {
Dashboard.showLoadingMsg();
@ -270,6 +270,23 @@
currentItem = item;
ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).done(function(providers) {
if (providers.length) {
$('.lnkBrowseAllImages', page).removeClass('hide');
} else {
$('.lnkBrowseAllImages', page).addClass('hide');
}
ApiClient.getItemImageInfos(currentItem.Id, currentItem.Type, currentItem.Name).done(function (imageInfos) {
renderStandardImages(page, item, imageInfos, providers);
renderBackdrops(page, item, imageInfos, providers);
renderScreenshots(page, item, imageInfos, providers);
Dashboard.hideLoadingMsg();
});
});
LibraryBrowser.renderName(item, $('.itemName', page), true);
updateTabs(page, item);
@ -280,16 +297,10 @@
$('#btnEditPeople', page).show();
}
ApiClient.getItemImageInfos(currentItem.Id, currentItem.Type, currentItem.Name).done(function (imageInfos) {
renderStandardImages(page, item, imageInfos);
renderBackdrops(page, item, imageInfos);
renderScreenshots(page, item, imageInfos);
Dashboard.hideLoadingMsg();
});
});
}
function renderImages(page, item, images, elem) {
function renderImages(page, item, images, imageProviders, elem) {
var html = '';
@ -327,7 +338,9 @@
html += '<button type="button" data-icon="delete" data-mini="true" data-inline="true" data-iconpos="notext" onclick="EditItemImagesPage.deleteImage(\'' + image.ImageType + '\', ' + (image.ImageIndex != null ? image.ImageIndex : "null") + ');">Delete</button>';
html += '<button type="button" data-icon="cloud" data-mini="true" data-inline="true" data-iconpos="notext" onclick="EditItemImagesPage.showDownloadMenu(\'' + image.ImageType + '\');">Browse Online Images</button>';
if (imageProviders.length) {
html += '<button type="button" data-icon="cloud" data-mini="true" data-inline="true" data-iconpos="notext" onclick="EditItemImagesPage.showDownloadMenu(\'' + image.ImageType + '\');">Browse Online Images</button>';
}
html += '</p>';
@ -339,7 +352,7 @@
elem.html(html).trigger('create');
}
function renderStandardImages(page, item, imageInfos) {
function renderStandardImages(page, item, imageInfos, imageProviders) {
var images = imageInfos.filter(function (i) {
return i.ImageType != "Screenshot" && i.ImageType != "Backdrop" && i.ImageType != "Chapter";
@ -347,13 +360,13 @@
if (images.length) {
$('#imagesContainer', page).show();
renderImages(page, item, images, $('#images', page));
renderImages(page, item, images, imageProviders, $('#images', page));
} else {
$('#imagesContainer', page).hide();
}
}
function renderBackdrops(page, item, imageInfos) {
function renderBackdrops(page, item, imageInfos, imageProviders) {
var images = imageInfos.filter(function (i) {
return i.ImageType == "Backdrop";
@ -364,13 +377,13 @@
if (images.length) {
$('#backdropsContainer', page).show();
renderImages(page, item, images, $('#backdrops', page));
renderImages(page, item, images, imageProviders, $('#backdrops', page));
} else {
$('#backdropsContainer', page).hide();
}
}
function renderScreenshots(page, item, imageInfos) {
function renderScreenshots(page, item, imageInfos, imageProviders) {
var images = imageInfos.filter(function (i) {
return i.ImageType == "Screenshot";
@ -381,7 +394,7 @@
if (images.length) {
$('#screenshotsContainer', page).show();
renderImages(page, item, images, $('#screenshots', page));
renderImages(page, item, images, imageProviders, $('#screenshots', page));
} else {
$('#screenshotsContainer', page).hide();
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.189" targetFramework="net45" />
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.190" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.62" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
</packages>