pandora/static/js/item.js

174 lines
6.7 KiB
JavaScript
Raw Normal View History

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-05-25 19:42:45 +00:00
pandora.ui.item = function() {
2011-09-17 07:07:59 +00:00
var isVideoView = [
2012-04-17 08:03:11 +00:00
'timeline', 'player', 'editor'
].indexOf(pandora.user.ui.itemView) > -1,
item = pandora.user.ui.item,
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,
keys: isVideoView ? [
'audioTracks',
'cuts', 'duration', 'durations', 'editable', 'layers',
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
'streams', 'size', 'videoRatio',
].concat(pandora.site.itemTitleKeys) : []
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 (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
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
.options({title: '<b>' + pandora.getItemTitle(result.data, true) + '</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
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,
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)])
)
);
result.data.parts > 0 && 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() {
pandora.$ui.item.resizeElement && pandora.$ui.item.resizeElement();
2011-05-25 19:42:45 +00:00
}
2012-04-24 08:21:54 +00:00
})
);
!result.data.rendered && result.data.parts > 0 && 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,
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') {
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
);
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-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') {
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
);
} else if (pandora.user.ui.itemView == 'map') {
2012-04-17 06:31:44 +00:00
pandora.$ui.contentPanel.replaceElement(1,
pandora.ui.navigationView('map', result.data.videoRatio)
);
} else if (pandora.user.ui.itemView == 'calendar') {
2012-04-17 06:31:44 +00:00
pandora.$ui.contentPanel.replaceElement(1,
pandora.ui.navigationView('calendar', result.data.videoRatio)
);
2011-09-28 17:32:03 +00:00
} else if (pandora.user.ui.itemView == 'data') {
2012-04-24 08:21:54 +00:00
pandora.$ui.item = Ox.TreeList({
2011-09-28 17:32:03 +00:00
data: result.data,
2014-09-26 12:12:25 +00:00
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)
);
} else if (pandora.user.ui.itemView == 'media') {
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') {
2011-06-06 18:40:24 +00:00
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.item = pandora.ui.PostersView().bindEvent({
2011-06-07 03:17:36 +00:00
resize: function() {
pandora.$ui.item.resizeElement();
2011-06-07 03:17:36 +00:00
}
})
2011-06-06 18:40:24 +00:00
);
2011-05-25 19:42:45 +00:00
}
if (isVideoView && result.data.rendered) {
// handle links in annotations
pandora.$ui[pandora.user.ui.itemView].bindEvent(
videopointsEvent,
function(data, event, element) {
var options = {};
if (pandora.user.ui.item && event == videopointsEvent) {
//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);
}
}
);
}
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
};