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-06-30 16:17:10 +00:00
|
|
|
var isVideoView = [
|
2012-04-17 08:03:11 +00:00
|
|
|
'timeline', 'player', 'editor'
|
2012-06-30 16:17:10 +00:00
|
|
|
].indexOf(pandora.user.ui.itemView) > -1,
|
|
|
|
item = pandora.user.ui.item,
|
2012-07-01 11:40:54 +00:00
|
|
|
that = Ox.Element(),
|
|
|
|
videopointsEvent = 'pandora_videopoints.' + item.toLowerCase();
|
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 ? [
|
2013-07-09 22:49:01 +00:00
|
|
|
'cuts', 'director', 'duration', 'durations', 'editable', 'layers',
|
2013-06-29 10:03:29 +00:00
|
|
|
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
|
2012-04-17 07:06:19 +00:00
|
|
|
'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
|
|
|
|
2012-06-30 16:17:10 +00:00
|
|
|
if (pandora.user.ui.item != item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
2013-08-03 17:17:20 +00:00
|
|
|
var documentTitle = pandora.getDocumentTitle(result.data);
|
2011-11-09 22:32:54 +00:00
|
|
|
document.title = pandora.getPageTitle(document.location.pathname) || documentTitle;
|
2011-09-17 07:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-10-30 21:05:57 +00:00
|
|
|
pandora.$ui.itemTitle
|
2013-08-03 17:38:33 +00:00
|
|
|
.options({title: '<b>' + pandora.getItemTitle(result.data) + '</b>'})
|
2011-10-30 21:05:57 +00:00
|
|
|
.show();
|
|
|
|
|
2012-04-17 12:03:16 +00:00
|
|
|
// fixme: layers have value, subtitles has text?
|
|
|
|
isVideoView && 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 08:03:11 +00:00
|
|
|
'clips', 'timeline', 'player', 'editor', 'map', 'calendar'
|
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(
|
2013-05-09 10:13:58 +00:00
|
|
|
Ox._('Sorry, <i>{0}</i>'
|
|
|
|
+ ' currently doesn\'t have '
|
2012-09-08 12:09:48 +00:00
|
|
|
+ (['a', 'e', 'i', 'o'].indexOf(
|
2012-09-08 12:07:11 +00:00
|
|
|
pandora.user.ui.itemView.slice(0, 1)
|
2012-09-08 12:09:48 +00:00
|
|
|
) > -1 ? 'an': 'a') + ' '
|
2013-05-09 10:13:58 +00:00
|
|
|
+'{1} view.', [result.data.title, Ox._(pandora.user.ui.itemView)])
|
2011-08-24 22:15:50 +00:00
|
|
|
)
|
|
|
|
);
|
2014-04-11 18:32:17 +00:00
|
|
|
pandora.updateStatus(pandora.user.ui.item);
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'info') {
|
2012-04-24 08:21:54 +00:00
|
|
|
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.$ui.item = pandora.ui.infoView(result.data)
|
|
|
|
.bindEvent({
|
|
|
|
resize: function() {
|
2013-10-22 13:57:35 +00:00
|
|
|
pandora.$ui.item.resizeElement && pandora.$ui.item.resizeElement();
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2012-04-24 08:21:54 +00:00
|
|
|
})
|
|
|
|
);
|
2014-04-11 18:32:17 +00:00
|
|
|
!result.data.rendered && pandora.updateStatus(pandora.user.ui.item);
|
2013-05-27 12:29:43 +00:00
|
|
|
|
|
|
|
} else if (pandora.user.ui.itemView == 'documents') {
|
|
|
|
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2014-04-17 19:32:30 +00:00
|
|
|
pandora.$ui.documents = pandora.ui.documentsPanel({
|
|
|
|
editable: result.data.editable,
|
|
|
|
isItemView: true
|
|
|
|
})
|
2013-05-27 12:29:43 +00:00
|
|
|
);
|
2011-05-25 19:42:45 +00:00
|
|
|
|
2013-03-02 06:39:28 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'player') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-09-30 10:33:45 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2013-03-02 06:39:28 +00:00
|
|
|
pandora.$ui.player = pandora.ui.player(result.data)
|
2011-09-30 10:33:45 +00:00
|
|
|
);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2013-03-02 06:39:28 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'editor') {
|
2012-04-17 08:03:11 +00:00
|
|
|
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2013-03-02 06:39:28 +00:00
|
|
|
pandora.$ui.editor = pandora.ui.editor(result.data)
|
2012-04-17 08:03:11 +00:00
|
|
|
);
|
|
|
|
|
2013-03-02 06:39:28 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'timeline') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2012-04-17 06:31:44 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2013-03-02 06:39:28 +00:00
|
|
|
pandora.$ui.timeline = pandora.ui.timeline(result.data)
|
2012-04-17 06:31:44 +00:00
|
|
|
);
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2013-03-02 06:39:28 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'clips') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-10-30 09:49:12 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2013-03-02 06:39:28 +00:00
|
|
|
pandora.ui.clipsView(result.data.videoRatio)
|
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
|
|
|
|
2012-04-24 08:21:54 +00:00
|
|
|
pandora.$ui.item = Ox.TreeList({
|
2011-09-28 17:32:03 +00:00
|
|
|
data: result.data,
|
|
|
|
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
|
2012-04-24 08:21:54 +00:00
|
|
|
});
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
Ox.Container().append(pandora.$ui.item)
|
|
|
|
);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2013-05-27 10:13:59 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'media') {
|
2012-02-17 16:13:48 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2014-02-13 11:54:30 +00:00
|
|
|
pandora.$ui.item = pandora.ui.mediaView(result.data)
|
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,
|
2013-05-27 10:13:59 +00:00
|
|
|
pandora.$ui.item = pandora.ui.PostersView().bindEvent({
|
2011-06-07 03:17:36 +00:00
|
|
|
resize: function() {
|
2013-10-22 13:57:35 +00:00
|
|
|
pandora.$ui.item.resizeElement();
|
2011-06-07 03:17:36 +00:00
|
|
|
}
|
|
|
|
})
|
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(
|
2012-07-01 11:40:54 +00:00
|
|
|
videopointsEvent,
|
|
|
|
function(data, event, element) {
|
2012-04-17 07:06:19 +00:00
|
|
|
var options = {};
|
2014-02-18 08:44:30 +00:00
|
|
|
if (pandora.user.ui.item && event == videopointsEvent) {
|
2012-07-01 11:40:54 +00:00
|
|
|
//Ox.print('DATA.VALUE', JSON.stringify(data.value));
|
|
|
|
if (data && data.value && 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-04-17 07:06:19 +00:00
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|