2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2012-02-03 09:15:38 +00:00
|
|
|
'use strict';
|
2011-10-03 13:23:11 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.item = function() {
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2012-02-17 08:57:21 +00:00
|
|
|
var that = Ox.Element(),
|
2012-04-17 07:06:19 +00:00
|
|
|
isVideoView = ['player', 'editor'].indexOf(pandora.user.ui.itemView) > -1;
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-08-06 13:34:56 +00:00
|
|
|
pandora.api.get({
|
|
|
|
id: pandora.user.ui.item,
|
2012-04-17 07:06:19 +00:00
|
|
|
keys: isVideoView ? [
|
|
|
|
'cuts', 'director', 'duration', 'layers',
|
|
|
|
'parts', 'posterFrame', 'rendered', 'rightslevel',
|
|
|
|
'size', 'title', 'videoRatio', 'year'
|
|
|
|
] : []
|
2011-10-30 21:05:57 +00:00
|
|
|
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {
|
2011-09-17 07:07:59 +00:00
|
|
|
|
|
|
|
if (result.status.code == 200) {
|
2011-11-09 22:32:54 +00:00
|
|
|
// we want to cache the title in any way, so that after closing
|
|
|
|
// a dialog and getting to this item, the title is correct
|
|
|
|
var documentTitle = pandora.getDocumentTitle(result.data.title);
|
|
|
|
document.title = pandora.getPageTitle(document.location.pathname) || documentTitle;
|
2011-09-17 07:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 04:11:25 +00:00
|
|
|
/*if (result.status.code != 200) {
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
Ox.Element()
|
|
|
|
.css({marginTop: '32px', fontSize: '12px', textAlign: 'center'})
|
|
|
|
.html(
|
|
|
|
'Sorry, we can\'t find the '
|
|
|
|
+ pandora.site.itemName.singular.toLowerCase()
|
|
|
|
+ ' you\'re looking for.'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}*/
|
|
|
|
|
2011-10-30 21:05:57 +00:00
|
|
|
pandora.$ui.itemTitle
|
|
|
|
.options({
|
|
|
|
title: '<b>' + result.data.title
|
2011-12-30 08:00:38 +00:00
|
|
|
+ (Ox.len(result.data.director)
|
2011-12-27 13:52:16 +00:00
|
|
|
? ' (' + result.data.director.join(', ') + ')'
|
|
|
|
: '')
|
2011-10-30 21:05:57 +00:00
|
|
|
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
|
2012-04-17 07:06:19 +00:00
|
|
|
if (isVideoView) {
|
2011-10-23 02:29:20 +00:00
|
|
|
// fixme: layers have value, subtitles has text?
|
2012-04-17 06:31:44 +00:00
|
|
|
Ox.extend(result.data, pandora.getVideoOptions(result.data));
|
2011-10-22 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 04:11:25 +00:00
|
|
|
if (!result.data.rendered && [
|
2012-04-17 07:06:19 +00:00
|
|
|
'clips', 'map', 'player', 'editor'
|
2011-10-22 21:03:28 +00:00
|
|
|
].indexOf(pandora.user.ui.itemView) > -1) {
|
2011-06-27 13:39:35 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-08-24 22:15:50 +00:00
|
|
|
Ox.Element()
|
|
|
|
.css({marginTop: '32px', fontSize: '12px', textAlign: 'center'})
|
|
|
|
.html(
|
2011-10-23 02:29:20 +00:00
|
|
|
'Sorry, <i>' + result.data.title
|
2011-08-24 22:15:50 +00:00
|
|
|
+ '</i> currently doesn\'t have a '
|
|
|
|
+ pandora.user.ui.itemView + ' view.'
|
|
|
|
)
|
|
|
|
);
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'info') {
|
2012-03-21 03:09:24 +00:00
|
|
|
|
2011-08-05 18:26:27 +00:00
|
|
|
if (pandora.user.level == 'admin' && false) {
|
2011-05-25 19:42:45 +00:00
|
|
|
var $form,
|
2011-06-19 17:49:25 +00:00
|
|
|
$edit = Ox.Element()
|
|
|
|
.append($form = Ox.FormElementGroup({
|
2011-06-27 13:39:35 +00:00
|
|
|
elements: Ox.map(pandora.site.sortKeys, function(key) {
|
2011-06-19 17:49:25 +00:00
|
|
|
return Ox.Input({
|
2011-05-25 19:42:45 +00:00
|
|
|
id: key.id,
|
|
|
|
label: key.title,
|
|
|
|
labelWidth: 100,
|
2011-05-26 07:34:52 +00:00
|
|
|
value: result.data[key.id],
|
2011-05-25 19:42:45 +00:00
|
|
|
type: 'text',
|
2011-10-29 17:46:46 +00:00
|
|
|
width: 500
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
}),
|
|
|
|
separators: [
|
|
|
|
{title: '', width: 0}
|
|
|
|
]
|
|
|
|
}))
|
2011-06-19 17:49:25 +00:00
|
|
|
.append(Ox.Button({
|
2011-05-25 19:42:45 +00:00
|
|
|
title: 'Save',
|
|
|
|
type: 'text'
|
|
|
|
}).bindEvent({
|
2011-09-17 17:40:15 +00:00
|
|
|
click: function(data) {
|
|
|
|
// fixme: cleanup
|
2011-05-25 19:42:45 +00:00
|
|
|
var values = $form.value();
|
|
|
|
var changed = {};
|
2011-06-06 15:48:11 +00:00
|
|
|
Ox.map(pandora.site.itemKeys, function(key, i) {
|
2011-05-26 07:34:52 +00:00
|
|
|
if(values[i] && values[i] != ''+result.data[key.id]) {
|
|
|
|
if(Ox.isArray(key.type) && key.type[0] == 'string') {
|
2011-05-25 19:42:45 +00:00
|
|
|
changed[key.id] = values[i].split(', ');
|
2011-05-26 07:34:52 +00:00
|
|
|
} else {
|
2011-05-25 19:42:45 +00:00
|
|
|
changed[key.id] = values[i];
|
2011-05-26 07:34:52 +00:00
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if(changed) {
|
2011-10-22 22:12:56 +00:00
|
|
|
pandora.api.edit(Ox.extend(changed, {id: pandora.user.ui.item}), function(result) {
|
2011-05-25 19:42:45 +00:00
|
|
|
//fixme just reload parts that need reloading
|
|
|
|
window.location.reload();
|
2011-10-29 17:46:46 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = $edit);
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
2011-08-05 18:26:27 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.$ui.item = pandora.ui.infoView(result.data)
|
|
|
|
.bindEvent({
|
|
|
|
resize: function() {
|
|
|
|
pandora.$ui.item.resize();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
|
2011-09-23 10:44:54 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'clips') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-09-30 10:33:45 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-10-30 15:36:14 +00:00
|
|
|
pandora.ui.clipsView(result.data.videoRatio)
|
2011-09-30 10:33:45 +00:00
|
|
|
);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2012-04-17 07:06:19 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'player') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2012-04-17 06:31:44 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.$ui.player = pandora.ui.player(result.data)
|
|
|
|
);
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2012-04-17 07:06:19 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'editor') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-10-30 09:49:12 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2012-04-17 06:31:44 +00:00
|
|
|
pandora.$ui.editor = pandora.ui.editor(result.data)
|
2011-10-30 09:49:12 +00:00
|
|
|
);
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-09-23 10:44:54 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'map') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2012-04-17 06:31:44 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.ui.navigationView('map', result.data.videoRatio)
|
|
|
|
);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
|
|
|
} else if (pandora.user.ui.itemView == 'calendar') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2012-04-17 06:31:44 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.ui.navigationView('calendar', result.data.videoRatio)
|
|
|
|
);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-09-28 17:32:03 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'data') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-09-28 17:32:03 +00:00
|
|
|
var stats = Ox.Container();
|
|
|
|
Ox.TreeList({
|
|
|
|
data: result.data,
|
|
|
|
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
|
|
|
|
}).appendTo(stats);
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1, stats);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'files') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-10-15 15:21:41 +00:00
|
|
|
pandora.$ui.item = pandora.ui.filesView({
|
2011-05-26 07:34:52 +00:00
|
|
|
id: result.data.id
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
);
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-06-06 18:40:24 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'frames' || pandora.user.ui.itemView == 'posters') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-06-06 18:40:24 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-06-07 03:17:36 +00:00
|
|
|
pandora.$ui.item = pandora.ui.mediaView().bindEvent({
|
|
|
|
resize: function() {
|
|
|
|
pandora.$ui.item.resize();
|
|
|
|
}
|
|
|
|
})
|
2011-06-06 18:40:24 +00:00
|
|
|
);
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2012-04-17 07:06:19 +00:00
|
|
|
if (isVideoView && result.data.rendered) {
|
2012-02-17 16:13:48 +00:00
|
|
|
// handle links in annotations
|
2012-04-17 07:06:19 +00:00
|
|
|
pandora.$ui[pandora.user.ui.itemView].bindEvent(
|
|
|
|
'pandora_videopoints.' + pandora.user.ui.item.toLowerCase(),
|
|
|
|
function(data) {
|
|
|
|
//Ox.print('DATA.VALUE', JSON.stringify(data.value));
|
|
|
|
var options = {};
|
|
|
|
if (data.value.annotation) {
|
|
|
|
options.selected = pandora.user.ui.item + '/' + data.value.annotation;
|
|
|
|
} else {
|
|
|
|
// if annotation got set to something other than '',
|
|
|
|
// points and position will be set in consequence,
|
|
|
|
// so lets try to keep events from looping
|
|
|
|
['annotation', 'in', 'out', 'position'].forEach(function(key) {
|
|
|
|
if (!Ox.isUndefined(data.value[key])) {
|
|
|
|
options[key == 'annotation' ? 'selected' : key] = data.value[key];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
pandora.$ui[pandora.user.ui.itemView].options(options);
|
2012-02-17 16:13:48 +00:00
|
|
|
}
|
2012-04-17 07:06:19 +00:00
|
|
|
);
|
2012-02-17 16:13:48 +00:00
|
|
|
}
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
|
|
|
|