update indiancinema info view, id dialog and metadata dialog

This commit is contained in:
rolux 2013-02-28 11:53:19 +00:00
parent ce06fc077d
commit a6078fa905
3 changed files with 83 additions and 25 deletions

View file

@ -25,6 +25,8 @@ pandora.ui.idDialog = function(data) {
}) })
), ),
$content,
$input = [],
$checkboxGroup, $checkboxGroup,
that = Ox.Dialog({ that = Ox.Dialog({
@ -43,7 +45,7 @@ pandora.ui.idDialog = function(data) {
{}, {},
Ox.Button({ Ox.Button({
id: 'cancel', id: 'cancel',
title: 'Don\'t Update IMDb ID' title: 'Don\'t Update'
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
@ -87,12 +89,13 @@ pandora.ui.idDialog = function(data) {
} }
}); });
pandora.api.getIds(get, function(result) { pandora.api.getIds(get, function(result) {
var checkboxes = [], var checkboxes = [];
$content = Ox.Element() $content = Ox.Element()
.css({padding: '13px', overflowY: 'auto'}); .css({padding: '13px', overflowY: 'auto'});
if (result.data.items) { if (result.data.items) {
['title', 'director', 'year'].forEach(function(key) { ['title', 'director', 'year'].forEach(function(key) {
Ox.Input({ $input.push(
Ox.Input({
label: Ox.toTitleCase(key), label: Ox.toTitleCase(key),
labelWidth: 128, labelWidth: 128,
value: key == 'director' value: key == 'director'
@ -110,14 +113,23 @@ pandora.ui.idDialog = function(data) {
getIds(); getIds();
} }
}) })
.appendTo($content); .appendTo($content)
);
}); });
$('<div>') $('<div>')
.css({width: '1px', height: '8px'}) .css({width: '1px', height: '8px'})
.appendTo($content); .appendTo($content);
if (!data.imdbId) { if (!data.imdbId) {
checkboxes.push( checkboxes.push(
{id: 'none', title: getTitle(data)} {
id: 'none',
title: getTitle({
id: data.imdbId,
title: data.title,
director: data.director,
year: data.year
})
}
); );
} }
( (
@ -126,15 +138,20 @@ pandora.ui.idDialog = function(data) {
? pandora.api.findId ? pandora.api.findId
: Ox.noop : Ox.noop
)({id: data.imdbId}, function(result_) { )({id: data.imdbId}, function(result_) {
result_ && Ox.print(result_, '...', result_ && result_.data.items)
if (result_ && result_.data.items) { if (result_ && result_.data.items) {
checkboxes.push( checkboxes.push(
{id: data.imdbId, title: getTitle(result_.data.items[0])} {
id: data.imdbId,
title: getTitle(result_.data.items[0])
}
) )
} }
checkboxes = checkboxes.concat( checkboxes = checkboxes.concat(
result.data.items.map(function(item) { result.data.items.map(function(item) {
return {id: item.id, title: getTitle(item)}; return {
id: item.id,
title: getTitle(item)
};
}) })
); );
$checkboxGroup = Ox.CheckboxGroup({ $checkboxGroup = Ox.CheckboxGroup({
@ -148,6 +165,7 @@ pandora.ui.idDialog = function(data) {
change: updateButton change: updateButton
}) })
.appendTo($content); .appendTo($content);
var elements = $checkboxGroup.find('.OxCheckbox:not(.OxButton)');
checkboxes.forEach(function(checkbox, index) { checkboxes.forEach(function(checkbox, index) {
if (checkbox.id != 'none') { if (checkbox.id != 'none') {
Ox.Button({ Ox.Button({
@ -156,9 +174,8 @@ pandora.ui.idDialog = function(data) {
type: 'image' type: 'image'
}) })
.css({ .css({
position: 'absolute', float: 'right',
top: 96 + index * 24 + 'px', marginTop: '-18px'
right: 16 + Ox.UI.SCROLLBAR_SIZE + 'px'
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
@ -168,9 +185,9 @@ pandora.ui.idDialog = function(data) {
), '_blank'); ), '_blank');
} }
}) })
.appendTo($content); .appendTo(elements[index])
} }
}) });
that.options({content: $content}); that.options({content: $content});
updateButton(); updateButton();
}); });
@ -178,19 +195,49 @@ pandora.ui.idDialog = function(data) {
}); });
} }
function getTitle(data) { function getTitle(item) {
if (item.id && item.id == data.imdbId) {
item.id = highlightTitle(item.id);
}
if (item.title == data.title) {
item.title = highlightTitle(item.title);
}
if (item.originalTitle == data.title) {
item.originalTitle = highlightTitle(item.originalTitle);
}
if (item.director) {
item.director.forEach(function(director, i) {
if (Ox.contains(data.director, director)) {
item.director[i] = highlightTitle(director);
}
})
}
if (item.year && item.year == data.year) {
item.year = highlightTitle(item.year);
}
return Ox.filter([ return Ox.filter([
data.imdbId || data.id, item.id,
data.title + (data.originalTitle ? ' (' + data.originalTitle + ')' : ''), item.title + (item.originalTitle ? ' (' + item.originalTitle + ')' : ''),
data.director ? data.director.join(', ') : '', item.director ? item.director.join(', ') : '',
data.year item.year
]).join(' &mdash; '); ]).join(' &mdash; ');
} }
function setSize() { function highlightTitle(value) {
return '<span style="font-weight: bold">' + value + '</span>';
}
function isEmpty(value) {
return Ox.isEmpty(value) || Ox.isUndefined(value);
}
function setSize(data) {
dialogHeight = data.height; dialogHeight = data.height;
dialogWidth = data.width; dialogWidth = data.width;
formWidth = getFormWidth(); formWidth = getFormWidth();
$input.forEach(function($element) {
$element.options({width: formWidth});
});
$checkboxGroup.options({width: formWidth}); $checkboxGroup.options({width: formWidth});
} }

View file

@ -283,6 +283,11 @@ pandora.ui.infoView = function(data) {
title: 'Update Metadata...' title: 'Update Metadata...'
}, },
{}, {},
{
id: 'upload',
title: 'Upload Video...'
},
{},
{ {
id: 'delete', id: 'delete',
title: 'Delete ' + pandora.site.itemName.singular + '...', title: 'Delete ' + pandora.site.itemName.singular + '...',
@ -299,6 +304,8 @@ pandora.ui.infoView = function(data) {
pandora.$ui.idDialog = pandora.ui.idDialog(data).open(); pandora.$ui.idDialog = pandora.ui.idDialog(data).open();
} else if (data_.id == 'metadata') { } else if (data_.id == 'metadata') {
pandora.$ui.metadataDialog = pandora.ui.metadataDialog(data).open(); pandora.$ui.metadataDialog = pandora.ui.metadataDialog(data).open();
} else if (data_.id == 'upload') {
pandora.$ui.uploadDialog = pandora.ui.uploadDialog(data).open();
} else if (data_.id == 'delete') { } else if (data_.id == 'delete') {
pandora.$ui.deleteItemDialog = pandora.ui.deleteItemDialog(data).open(); pandora.$ui.deleteItemDialog = pandora.ui.deleteItemDialog(data).open();
} }
@ -829,7 +836,7 @@ pandora.ui.infoView = function(data) {
'&nbsp;(<a href="/imdbId=' + data.imdbId + '">' '&nbsp;(<a href="/imdbId=' + data.imdbId + '">'
+ result.data.items + ' ' + result.data.items + ' '
+ pandora.site.itemName.plural.toLowerCase() + pandora.site.itemName.plural.toLowerCase()
+ ' with the same id</a>)' + '</a> with the same IMDb ID</a>)'
); );
} }
}); });

View file

@ -104,7 +104,7 @@ pandora.ui.metadataDialog = function(data) {
{}, {},
Ox.Button({ Ox.Button({
id: 'cancel', id: 'cancel',
title: 'Don\'t Update Metadata' title: 'Don\'t Update'
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
@ -246,10 +246,10 @@ pandora.ui.metadataDialog = function(data) {
} }
keys.forEach(function(key, index) { keys.forEach(function(key, index) {
var isEqual = Ox.isEqual(data[key], imdb[key]) || ( var isEqual = Ox.isEqual(data[key], imdb[key]) || (
Ox.isEmpty(data[key]) && Ox.isUndefined(imdb[key]) isEmpty(data[key]) && isEmpty(imdb[key])
), ),
checked = isEqual ? [true, true] checked = isEqual ? [true, true]
: Ox.isEmpty(data[key]) && !Ox.isUndefined(imdb[key]) ? [false, true] : isEmpty(data[key]) && !isEmpty(imdb[key]) ? [false, true]
: [true, false]; : [true, false];
if (index > 0) { if (index > 0) {
$('<div>') $('<div>')
@ -319,6 +319,10 @@ pandora.ui.metadataDialog = function(data) {
}); });
} }
function isEmpty(value) {
return Ox.isEmpty(value) || Ox.isUndefined(value);
}
function selectAll(i) { function selectAll(i) {
keys.forEach(function(key) { keys.forEach(function(key) {
var $checkbox = $input[key][1].options('inputs')[0]; var $checkbox = $input[key][1].options('inputs')[0];