move utility functions from pandora.js into utils.js; clear request cache on signin/signout so that favorite lists actually update

This commit is contained in:
rolux 2011-10-22 10:18:57 +00:00
parent 19d390e561
commit 3b18cf25cb
2 changed files with 83 additions and 75 deletions

View file

@ -63,8 +63,14 @@ Ox.load({
body: $('body'), body: $('body'),
document: $(document), document: $(document),
window: $(window) window: $(window)
.resize(resizeWindow) .bind({
.unload(unloadWindow) resize: function() {
pandora.resizeWindow();
},
unload: function() {
pandora.unloadWindow();
}
})
}, },
site: data.site, site: data.site,
user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user
@ -168,75 +174,4 @@ Ox.load({
}); });
} }
function resizeWindow() {
pandora.resizeFolders();
pandora.$ui.leftPanel.size(2, pandora.getInfoHeight());
pandora.$ui.info.resizeInfo();
if (!pandora.user.ui.item) {
pandora.resizeGroups(pandora.$ui.rightPanel.width());
if (pandora.user.ui.listView == 'clips') {
var clipsItems = pandora.getClipsItems();
previousClipsItems = pandora.getClipsItems(pandora.$ui.list.options('width'));
pandora.$ui.list.options({
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
});
if (clipsItems != previousClipsItems) {
Ox.Request.clearCache(); // fixme
pandora.$ui.list.reloadList(true);
}
} else if (pandora.user.ui.listView == 'timelines') {
pandora.$ui.list.options({
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
});
} else if (pandora.user.ui.listView == 'map') {
pandora.$ui.map.resizeMap();
} else if (pandora.user.ui.listView == 'calendar') {
pandora.$ui.calendar.resizeCalendar();
} else {
pandora.$ui.list.size();
}
} else {
//Ox.print('pandora.$ui.window.resize');
pandora.$ui.browser.scrollToSelection();
if (pandora.user.ui.itemView == 'info') {
pandora.$ui.info.resize();
} else if (pandora.user.ui.itemView == 'clips') {
pandora.$ui.clips.size();
} else if (pandora.user.ui.itemView == 'video') {
pandora.$ui.player.options({
// fixme: duplicated
height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
});
} else if (pandora.user.ui.itemView == 'timeline') {
pandora.$ui.editor.options({
// fixme: duplicated
height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
});
} else if (pandora.user.ui.itemView == 'map') {
pandora.$ui.map.resizeMap();
} else if (pandora.user.ui.itemView == 'calendar') {
pandora.$ui.calendar.resizeCalendar();
}
}
}
function unloadWindow() {
// fixme: ajax request has to have async set to false for this to work
pandora.user.ui.section == 'items'
&& pandora.user.ui.item
&& ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1
&& pandora.UI.set(
'videoPosition.' + pandora.user.ui.item,
pandora.$ui[
pandora.user.ui.itemView == 'video' ? 'player' : 'editor'
].options('position')
);
}
}); });

View file

@ -674,7 +674,8 @@ pandora.signin = function(data) {
pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find); pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find);
pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find); pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find);
Ox.Theme(pandora.user.ui.theme); Ox.Theme(pandora.user.ui.theme);
pandora.UI.set({find: pandora.user.ui.find}) pandora.UI.set({find: pandora.user.ui.find});
Ox.Request.clearCache();
pandora.$ui.appPanel.reload(); pandora.$ui.appPanel.reload();
}; };
@ -684,7 +685,8 @@ pandora.signout = function(data) {
pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find); pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find);
pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find); pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find);
Ox.Theme(pandora.site.user.ui.theme); Ox.Theme(pandora.site.user.ui.theme);
pandora.UI.set({find: pandora.user.ui.find}) pandora.UI.set({find: pandora.user.ui.find});
Ox.Request.clearCache();
pandora.$ui.appPanel.reload(); pandora.$ui.appPanel.reload();
}; };
@ -755,6 +757,64 @@ pandora.resizeFolders = function() {
}); });
}; };
pandora.resizeWindow = function() {
pandora.resizeFolders();
pandora.$ui.leftPanel.size(2, pandora.getInfoHeight());
pandora.$ui.info.resizeInfo();
if (!pandora.user.ui.item) {
pandora.resizeGroups(pandora.$ui.rightPanel.width());
if (pandora.user.ui.listView == 'clips') {
var clipsItems = pandora.getClipsItems();
previousClipsItems = pandora.getClipsItems(pandora.$ui.list.options('width'));
pandora.$ui.list.options({
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
});
if (clipsItems != previousClipsItems) {
Ox.Request.clearCache(); // fixme
pandora.$ui.list.reloadList(true);
}
} else if (pandora.user.ui.listView == 'timelines') {
pandora.$ui.list.options({
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
});
} else if (pandora.user.ui.listView == 'map') {
pandora.$ui.map.resizeMap();
} else if (pandora.user.ui.listView == 'calendar') {
pandora.$ui.calendar.resizeCalendar();
} else {
pandora.$ui.list.size();
}
} else {
//Ox.print('pandora.$ui.window.resize');
pandora.$ui.browser.scrollToSelection();
if (pandora.user.ui.itemView == 'info') {
pandora.$ui.info.resize();
} else if (pandora.user.ui.itemView == 'clips') {
pandora.$ui.clips.size();
} else if (pandora.user.ui.itemView == 'video') {
pandora.$ui.player.options({
// fixme: duplicated
height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
});
} else if (pandora.user.ui.itemView == 'timeline') {
pandora.$ui.editor.options({
// fixme: duplicated
height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
});
} else if (pandora.user.ui.itemView == 'map') {
pandora.$ui.map.resizeMap();
} else if (pandora.user.ui.itemView == 'calendar') {
pandora.$ui.calendar.resizeCalendar();
}
}
};
pandora.selectList = function() { pandora.selectList = function() {
if (pandora.user.ui._list) { if (pandora.user.ui._list) {
pandora.api.findLists({ pandora.api.findLists({
@ -779,6 +839,19 @@ pandora.selectList = function() {
} }
}; };
pandora.unloadWindow = function() {
// fixme: ajax request has to have async set to false for this to work
pandora.user.ui.section == 'items'
&& pandora.user.ui.item
&& ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1
&& pandora.UI.set(
'videoPosition.' + pandora.user.ui.item,
pandora.$ui[
pandora.user.ui.itemView == 'video' ? 'player' : 'editor'
].options('position')
);
};
(function() { (function() {
// Note: getFindState has to run after getListsState and getGroupsState // Note: getFindState has to run after getListsState and getGroupsState