From a6078fa905c043dbce4b11a1b669ecf7e5169369 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 28 Feb 2013 11:53:19 +0000 Subject: [PATCH] update indiancinema info view, id dialog and metadata dialog --- static/js/pandora/idDialog.js | 89 +++++++++++++++++----- static/js/pandora/infoView.indiancinema.js | 9 ++- static/js/pandora/metadataDialog.js | 10 ++- 3 files changed, 83 insertions(+), 25 deletions(-) diff --git a/static/js/pandora/idDialog.js b/static/js/pandora/idDialog.js index 02aa2b57..f5ea8a42 100644 --- a/static/js/pandora/idDialog.js +++ b/static/js/pandora/idDialog.js @@ -25,6 +25,8 @@ pandora.ui.idDialog = function(data) { }) ), + $content, + $input = [], $checkboxGroup, that = Ox.Dialog({ @@ -43,7 +45,7 @@ pandora.ui.idDialog = function(data) { {}, Ox.Button({ id: 'cancel', - title: 'Don\'t Update IMDb ID' + title: 'Don\'t Update' }) .bindEvent({ click: function() { @@ -87,12 +89,13 @@ pandora.ui.idDialog = function(data) { } }); pandora.api.getIds(get, function(result) { - var checkboxes = [], - $content = Ox.Element() - .css({padding: '13px', overflowY: 'auto'}); + var checkboxes = []; + $content = Ox.Element() + .css({padding: '13px', overflowY: 'auto'}); if (result.data.items) { ['title', 'director', 'year'].forEach(function(key) { - Ox.Input({ + $input.push( + Ox.Input({ label: Ox.toTitleCase(key), labelWidth: 128, value: key == 'director' @@ -110,14 +113,23 @@ pandora.ui.idDialog = function(data) { getIds(); } }) - .appendTo($content); + .appendTo($content) + ); }); $('
') .css({width: '1px', height: '8px'}) .appendTo($content); if (!data.imdbId) { 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 : Ox.noop )({id: data.imdbId}, function(result_) { - result_ && Ox.print(result_, '...', result_ && result_.data.items) if (result_ && result_.data.items) { checkboxes.push( - {id: data.imdbId, title: getTitle(result_.data.items[0])} + { + id: data.imdbId, + title: getTitle(result_.data.items[0]) + } ) } checkboxes = checkboxes.concat( result.data.items.map(function(item) { - return {id: item.id, title: getTitle(item)}; + return { + id: item.id, + title: getTitle(item) + }; }) ); $checkboxGroup = Ox.CheckboxGroup({ @@ -148,6 +165,7 @@ pandora.ui.idDialog = function(data) { change: updateButton }) .appendTo($content); + var elements = $checkboxGroup.find('.OxCheckbox:not(.OxButton)'); checkboxes.forEach(function(checkbox, index) { if (checkbox.id != 'none') { Ox.Button({ @@ -156,9 +174,8 @@ pandora.ui.idDialog = function(data) { type: 'image' }) .css({ - position: 'absolute', - top: 96 + index * 24 + 'px', - right: 16 + Ox.UI.SCROLLBAR_SIZE + 'px' + float: 'right', + marginTop: '-18px' }) .bindEvent({ click: function() { @@ -168,9 +185,9 @@ pandora.ui.idDialog = function(data) { ), '_blank'); } }) - .appendTo($content); + .appendTo(elements[index]) } - }) + }); that.options({content: $content}); 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([ - data.imdbId || data.id, - data.title + (data.originalTitle ? ' (' + data.originalTitle + ')' : ''), - data.director ? data.director.join(', ') : '', - data.year + item.id, + item.title + (item.originalTitle ? ' (' + item.originalTitle + ')' : ''), + item.director ? item.director.join(', ') : '', + item.year ]).join(' — '); } - function setSize() { + function highlightTitle(value) { + return '' + value + ''; + } + + function isEmpty(value) { + return Ox.isEmpty(value) || Ox.isUndefined(value); + } + + function setSize(data) { dialogHeight = data.height; dialogWidth = data.width; formWidth = getFormWidth(); + $input.forEach(function($element) { + $element.options({width: formWidth}); + }); $checkboxGroup.options({width: formWidth}); } diff --git a/static/js/pandora/infoView.indiancinema.js b/static/js/pandora/infoView.indiancinema.js index ce9b92b3..180ed5fd 100644 --- a/static/js/pandora/infoView.indiancinema.js +++ b/static/js/pandora/infoView.indiancinema.js @@ -283,6 +283,11 @@ pandora.ui.infoView = function(data) { title: 'Update Metadata...' }, {}, + { + id: 'upload', + title: 'Upload Video...' + }, + {}, { id: 'delete', title: 'Delete ' + pandora.site.itemName.singular + '...', @@ -299,6 +304,8 @@ pandora.ui.infoView = function(data) { pandora.$ui.idDialog = pandora.ui.idDialog(data).open(); } else if (data_.id == 'metadata') { 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') { pandora.$ui.deleteItemDialog = pandora.ui.deleteItemDialog(data).open(); } @@ -829,7 +836,7 @@ pandora.ui.infoView = function(data) { ' (' + result.data.items + ' ' + pandora.site.itemName.plural.toLowerCase() - + ' with the same id)' + + ' with the same IMDb ID)' ); } }); diff --git a/static/js/pandora/metadataDialog.js b/static/js/pandora/metadataDialog.js index 3aef0c0c..e8962f1e 100644 --- a/static/js/pandora/metadataDialog.js +++ b/static/js/pandora/metadataDialog.js @@ -104,7 +104,7 @@ pandora.ui.metadataDialog = function(data) { {}, Ox.Button({ id: 'cancel', - title: 'Don\'t Update Metadata' + title: 'Don\'t Update' }) .bindEvent({ click: function() { @@ -246,10 +246,10 @@ pandora.ui.metadataDialog = function(data) { } keys.forEach(function(key, index) { 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] - : Ox.isEmpty(data[key]) && !Ox.isUndefined(imdb[key]) ? [false, true] + : isEmpty(data[key]) && !isEmpty(imdb[key]) ? [false, true] : [true, false]; if (index > 0) { $('
') @@ -319,6 +319,10 @@ pandora.ui.metadataDialog = function(data) { }); } + function isEmpty(value) { + return Ox.isEmpty(value) || Ox.isUndefined(value); + } + function selectAll(i) { keys.forEach(function(key) { var $checkbox = $input[key][1].options('inputs')[0];