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,
|
2016-10-03 10:45:52 +00:00
|
|
|
keys: isVideoView ? Ox.unique(pandora.VIDEO_OPTIONS_KEYS.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
|
|
|
|
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
|
2016-10-04 22:00:03 +00:00
|
|
|
var documentTitle = pandora.getWindowTitle(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
|
2014-11-21 14:26:50 +00:00
|
|
|
.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
|
|
|
|
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) {
|
2016-11-30 10:07:09 +00:00
|
|
|
var html = Ox._('Sorry, <i>{0}</i>'
|
|
|
|
+ ' currently doesn\'t have '
|
|
|
|
+ (['a', 'e', 'i', 'o'].indexOf(
|
|
|
|
pandora.user.ui.itemView.slice(0, 1)
|
|
|
|
) > -1 ? 'an': 'a') + ' '
|
|
|
|
+'{1} view.', [result.data.title, Ox._(pandora.user.ui.itemView)]);
|
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'})
|
2016-11-30 10:07:09 +00:00
|
|
|
.html(html)
|
2011-08-24 22:15:50 +00:00
|
|
|
);
|
2016-11-30 10:07:09 +00:00
|
|
|
pandora.site.itemViews.filter(function(view) {
|
|
|
|
return view.id == 'documents';
|
|
|
|
}).length && pandora.api.get({
|
|
|
|
id: pandora.user.ui.item,
|
|
|
|
keys: ['numberofdocuments']
|
|
|
|
}, function(result) {
|
|
|
|
if (result.data.numberofdocuments) {
|
|
|
|
var $text = Ox.Element()
|
|
|
|
.css({marginTop: '32px', fontSize: '12px', textAlign: 'center'})
|
|
|
|
.html(
|
|
|
|
html
|
|
|
|
+ '<br>'
|
2017-01-25 20:47:47 +00:00
|
|
|
+ Ox._('There {0} <a href="{1}">{2}</a>', [
|
|
|
|
(result.data.numberofdocuments == 1 ? 'is' : 'are'),
|
2016-11-30 10:07:09 +00:00
|
|
|
'/' + pandora.user.ui.item + '/documents',
|
|
|
|
Ox.formatCount(result.data.numberofdocuments, 'document')
|
|
|
|
])
|
|
|
|
)
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1, $text);
|
|
|
|
pandora.createLinks($text);
|
|
|
|
}
|
|
|
|
});
|
2015-02-04 08:29:08 +00:00
|
|
|
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() {
|
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
|
|
|
})
|
|
|
|
);
|
2015-02-04 08:29:08 +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,
|
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,
|
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)
|
|
|
|
);
|
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
|
|
|
};
|
|
|
|
|