pandora/static/js/mainPanel.js

143 lines
6.6 KiB
JavaScript
Raw Permalink Normal View History

2011-11-05 17:04:10 +00:00
'use strict';
2018-06-19 06:33:26 +00:00
2011-05-25 19:42:45 +00:00
pandora.ui.mainPanel = function() {
var ui = pandora.user.ui,
that = Ox.SplitPanel({
elements: [
{
collapsible: true,
collapsed: !ui.showSidebar,
element: pandora.$ui.leftPanel = pandora.ui.leftPanel(),
resizable: true,
resize: [192, 256, 320, 384],
size: ui.sidebarSize,
2014-02-14 15:23:59 +00:00
tooltip: Ox._('sidebar') + ' <span class="OxBright">'
2014-09-25 19:56:19 +00:00
+ Ox.SYMBOLS.shift + 'S</span>'
},
{
element: getRightPanel()
}
],
orientation: 'horizontal'
})
.bindEvent({
2016-10-04 22:00:03 +00:00
pandora_finddocuments: function() {
var previousUI = pandora.UI.getPrevious();
Ox.Log('FIND', 'finddocuments handled in mainPanel', previousUI.document, previousUI._collection)
2019-08-02 09:44:31 +00:00
if (!previousUI.document && ui._collection == previousUI._collection) {
pandora.$ui.list.reloadList();
// FIXME: why is this being handled _here_?
ui._documentFilterState.forEach(function(data, i) {
if (!Ox.isEqual(data.selected, previousUI._documentFilterState[i].selected)) {
pandora.$ui.documentFilters[i].options(
ui.showFilters ? {
selected: data.selected
} : {
_selected: data.selected,
selected: []
}
);
}
if (!Ox.isEqual(data.find, previousUI._documentFilterState[i].find)) {
if (!ui.showFilters) {
pandora.$ui.documentFilters[i].options({
_selected: data.selected
});
}
// we can call reloadList here, since the items function
// handles the hidden filters case without making requests
pandora.$ui.documentFilters[i].reloadList();
}
});
} else {
if (pandora.stayInItemView) {
pandora.stayInItemView = false;
} else {
that.replaceElement(1, pandora.$ui.documentPanel = pandora.ui.documentPanel());
2019-08-02 09:44:31 +00:00
}
2016-10-04 22:00:03 +00:00
}
},
pandora_document: function(data) {
if (!data.value || !data.previousValue) {
that.replaceElement(1, pandora.$ui.documentPanel = pandora.ui.documentPanel());
}
},
pandora_edit: function(data) {
that.replaceElement(1, pandora.$ui.editPanel = pandora.ui.editPanel());
},
pandora_find: function() {
var previousUI = pandora.UI.getPrevious();
Ox.Log('FIND', 'find handled in mainPanel', previousUI.item, previousUI._list)
if (!previousUI.item && ui._list == previousUI._list) {
if (['map', 'calendar'].indexOf(ui.listView) > -1) {
pandora.$ui.contentPanel.replaceElement(1,
pandora.ui.navigationView(ui.listView)
);
} else {
if (['clips', 'clip'].indexOf(ui.listView) > -1) {
pandora.$ui.list.options({find: ui.itemFind});
2012-02-01 12:01:39 +00:00
}
2023-06-27 07:15:15 +00:00
pandora.$ui.list && pandora.$ui.list.reloadList();
}
// FIXME: why is this being handled _here_?
ui._filterState.forEach(function(data, i) {
2011-11-06 08:28:10 +00:00
if (!Ox.isEqual(data.selected, previousUI._filterState[i].selected)) {
pandora.$ui.filters[i].options(
ui.showFilters ? {
selected: data.selected
} : {
_selected: data.selected,
selected: []
}
);
}
2011-11-06 08:28:10 +00:00
if (!Ox.isEqual(data.find, previousUI._filterState[i].find)) {
if (!ui.showFilters) {
pandora.$ui.filters[i].options({
_selected: data.selected
});
}
// we can call reloadList here, since the items function
// handles the hidden filters case without making requests
pandora.$ui.filters[i].reloadList();
2011-10-29 17:46:46 +00:00
}
});
} else {
if (pandora.stayInItemView) {
pandora.stayInItemView = false;
} else {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
}
2011-05-25 19:42:45 +00:00
},
2013-02-21 12:10:35 +00:00
pandora_item: function(data) {
if (!data.value || !data.previousValue) {
2013-02-16 01:20:40 +00:00
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
},
2013-02-21 12:10:35 +00:00
pandora_section: function(data) {
if (data.value != data.previousValue) {
that.replaceElement(0, pandora.$ui.leftPanel = pandora.ui.leftPanel());
that.replaceElement(1, getRightPanel());
}
},
pandora_showsidebar: function(data) {
2014-09-22 14:55:12 +00:00
data.value == that.options('elements')[0].collapsed && that.toggleElement(0);
2013-02-21 12:10:35 +00:00
},
pandora_text: function(data) {
if (data.value != data.previousValue) {
that.replaceElement(1, pandora.$ui.textPanel = pandora.ui.textPanel());
}
2011-05-25 19:42:45 +00:00
}
});
function getRightPanel() {
return ui.section == 'items' ? pandora.$ui.rightPanel = pandora.ui.rightPanel()
: ui.section == 'edits' ? pandora.$ui.editPanel = pandora.ui.editPanel()
2016-10-04 22:00:03 +00:00
: ui.section == 'documents' ? pandora.$ui.documentPanel = pandora.ui.documentPanel()
: pandora.$ui.textPanel = pandora.ui.textPanel();
}
2011-05-25 19:42:45 +00:00
return that;
};