update Ox.URL options if defaults for views, sortKeys change

This commit is contained in:
j 2013-10-07 19:24:29 +00:00
parent 2f7ce45233
commit 2eb48fff09

View file

@ -254,10 +254,9 @@ pandora.URL = (function() {
} }
that.init = function() { function getOptions () {
var itemsSection = pandora.site.itemsSection, var itemsSection = pandora.site.itemsSection,
findKeys, sortKeys = {}, spanType = {}, views = {}; sortKeys = {}, views = {};
views[itemsSection] = { views[itemsSection] = {
// listView is the default view // listView is the default view
@ -313,6 +312,37 @@ pandora.URL = (function() {
} }
}); });
// Edits
views['edits'] = {
list: [],
item: ['edit']
};
sortKeys['edits'] = {
list: {},
item: {}
};
// Texts
views['texts'] = {
list: [],
item: ['text']
};
sortKeys['texts'] = {
list: {},
item: {}
};
return {
views: views,
sortKeys: sortKeys
};
}
that.init = function() {
var itemsSection = pandora.site.itemsSection,
findKeys, spanType = {};
spanType[itemsSection] = { spanType[itemsSection] = {
list: { list: {
map: 'location', map: 'location',
@ -326,38 +356,19 @@ pandora.URL = (function() {
calendar: 'date' calendar: 'date'
} }
}; };
// Edits
views['edits'] = {
list: [],
item: ['edit']
};
spanType['edits'] = { spanType['edits'] = {
list: [], list: [],
item: {edit: 'duration'} item: {edit: 'duration'}
}; };
sortKeys['edits'] = {
list: {},
item: {}
};
// Texts
views['texts'] = {
list: [],
item: ['text']
};
spanType['texts'] = { spanType['texts'] = {
list: [], list: [],
item: {text: 'number'} item: {text: 'number'}
}; };
sortKeys['texts'] = {
list: {},
item: {}
};
findKeys = [{id: 'list', type: 'string'}].concat(pandora.site.itemKeys); findKeys = [{id: 'list', type: 'string'}].concat(pandora.site.itemKeys);
self.URL = Ox.URL({ self.URL = Ox.URL(Ox.extend({
findKeys: findKeys, findKeys: findKeys,
getHash: pandora.getHash, getHash: pandora.getHash,
getItem: pandora.getItem, getItem: pandora.getItem,
@ -370,11 +381,9 @@ pandora.URL = (function() {
}), }),
['preferences', 'signup', 'signin', 'signout'] ['preferences', 'signup', 'signin', 'signout']
), ),
sortKeys: sortKeys,
spanType: spanType, spanType: spanType,
types: [pandora.site.itemName.plural.toLowerCase(), 'edits', 'texts'], types: [pandora.site.itemName.plural.toLowerCase(), 'edits', 'texts'],
views: views }, getOptions()));
});
window.addEventListener('hashchange', function() { window.addEventListener('hashchange', function() {
Ox.Request.cancel(); Ox.Request.cancel();
@ -482,6 +491,12 @@ pandora.URL = (function() {
keys = !pandora.user.ui.item keys = !pandora.user.ui.item
? ['listView', 'listSort', 'find'] ? ['listView', 'listSort', 'find']
: ['item', 'itemView', 'itemSort']; : ['item', 'itemView', 'itemSort'];
} else {
if (keys.some(function(key) {
return Ox.contains(['itemSort', 'itemView', 'listSort', 'listView'], key);
})) {
self.URL.options(getOptions());
}
} }
if (self.isPopState) { if (self.isPopState) {
self.isPopState = false; self.isPopState = false;