pandora/static/js/embedPanel.js

78 lines
2.6 KiB
JavaScript
Raw Normal View History

2013-02-21 10:48:56 +00:00
'use strict';
2013-03-09 03:49:15 +00:00
// FIXME: rename to embedView
2013-03-01 11:24:33 +00:00
2013-02-18 10:17:19 +00:00
pandora.ui.embedPanel = function() {
2013-02-20 04:39:12 +00:00
2013-03-01 11:24:33 +00:00
var that,
2013-02-20 08:58:15 +00:00
ui = pandora.user.ui,
2013-03-01 11:24:33 +00:00
view = !ui.item ? ui.listView : ui.itemView;
2014-02-14 16:49:42 +00:00
if (!ui.page) {
if (ui.section == 'items') {
if (!ui.item) {
if (view == 'grid') {
that = pandora.ui.embedGrid();
} else if (view == 'clip') {
that = pandora.ui.embedError(true);
} else if (Ox.contains(['map', 'calendar'], view)) {
that = pandora.ui.embedNavigation(view);
}
} else {
if (view == 'info') {
that = pandora.ui.embedInfo();
} else if (Ox.contains(['player', 'editor'], view)) {
that = pandora.ui.embedPlayer();
} else if (view == 'timeline') {
that = pandora.ui.embedTimeline();
} else if (view == 'clips') {
that = pandora.ui.embedError(true);
} else if (Ox.contains(['map', 'calendar'], view)) {
that = pandora.ui.embedNavigation(view);
}
2013-02-20 12:38:51 +00:00
}
2014-02-14 16:49:42 +00:00
} else if (ui.section == 'edits') {
// FIXME: this is non-standard, see above!
that = pandora.ui.editPanel(true);
2013-02-20 12:38:51 +00:00
} else {
2014-02-14 16:49:42 +00:00
that = pandora.ui.embedError(true)
2013-02-20 10:07:58 +00:00
}
2014-02-14 16:49:42 +00:00
} else if (ui.page == 'documents' && ui.document) {
that = pandora.ui.embedError(true);
2013-02-20 10:07:58 +00:00
}
2013-03-01 11:24:33 +00:00
if (!that) {
that = pandora.ui.embedError();
2013-02-20 08:58:15 +00:00
}
2013-02-18 10:17:19 +00:00
that.display = function() {
// fixme: move animation into Ox.App
var animate = $('.OxScreen').length == 0;
Ox.Log('', 'ANIMATE?', animate)
animate && pandora.$ui.body.css({opacity: 0});
that.appendTo(pandora.$ui.body);
animate && pandora.$ui.body.animate({opacity: 1}, 1000);
return that;
};
2013-02-20 04:39:12 +00:00
2014-02-14 16:49:42 +00:00
// only add reloadPanel if not defined by embed element
that.reloadPanel = that.reloadPanel || function(data) {
if (Ox.isUndefined(data) || data.value != data.previousValue) {
pandora.$ui.embedPanel.replaceWith(pandora.$ui.embedPanel = pandora.ui.embedPanel());
2013-08-10 10:57:24 +00:00
return pandora.$ui.embedPanel;
}
2013-03-01 11:24:33 +00:00
return that;
};
that.bindEvent({
2014-02-04 06:55:06 +00:00
pandora_find: that.reloadPanel,
pandora_item: that.reloadPanel,
pandora_itemview: that.reloadPanel,
2014-02-04 06:55:06 +00:00
pandora_listview: that.reloadPanel,
pandora_videopoints: that.reloadPanel,
pandora_hash: that.reloadPanel
2013-02-20 12:38:51 +00:00
});
2013-02-18 10:17:19 +00:00
return that;
2013-02-20 04:39:12 +00:00
2013-02-20 10:46:24 +00:00
};