URL controller: add options.getSort (some sort keys may only be valid for some items)
This commit is contained in:
parent
89e4368a0e
commit
3cad42ca28
1 changed files with 33 additions and 8 deletions
|
@ -25,9 +25,15 @@ Ox.URL <f> URL controller
|
|||
state <o> State object
|
||||
string <s> The string to be tested
|
||||
callback <f> callback function
|
||||
getSort <f> Tests if a sort object is valid (for the current item)
|
||||
May modify the state's sort properties
|
||||
(state, value, callback) -> <u> undefined
|
||||
state <o> State object
|
||||
value <o> The value to be tested
|
||||
callback <f> Callback function
|
||||
getSpan <f> Tests if a value matches a span
|
||||
May modify the state's view and span properties
|
||||
(state, string, callback) -> <u> undefined
|
||||
(state, value, callback) -> <u> undefined
|
||||
state <o> State object
|
||||
value <[n]|s> The value to be tested
|
||||
callback <f> Callback function
|
||||
|
@ -410,6 +416,7 @@ Ox.URL = function(options) {
|
|||
getHash: null,
|
||||
getItem: null,
|
||||
getPart: null,
|
||||
getSort: null,
|
||||
getSpan: null,
|
||||
pages: [],
|
||||
spanType: {},
|
||||
|
@ -818,14 +825,14 @@ Ox.URL = function(options) {
|
|||
}
|
||||
} else {
|
||||
state.item = '';
|
||||
// set to default view
|
||||
// set to default list view
|
||||
state.view = self.options.views[state.type].list[0];
|
||||
getHash();
|
||||
}
|
||||
}
|
||||
function parseBeyondItem() {
|
||||
Ox.Log('Core', 'pBI', state, parts.join('/'));
|
||||
var sortKeyIds, sortParts, span, spanType, spanTypes;
|
||||
var sortKeyIds, sortParts;
|
||||
if (
|
||||
parts.length && state.item
|
||||
&& self.options.views[state.type].item.indexOf(parts[0]) > -1
|
||||
|
@ -836,7 +843,6 @@ Ox.URL = function(options) {
|
|||
} else if (state.item && self.options.views[state.type].item.length == 1) {
|
||||
state.view = self.options.views[state.type].item[0];
|
||||
}
|
||||
// sort
|
||||
if (parts.length) {
|
||||
sortParts = parts[0].split(',');
|
||||
sortKeyIds = Ox.map(self.options.sortKeys[state.type][
|
||||
|
@ -866,8 +872,25 @@ Ox.URL = function(options) {
|
|||
}
|
||||
}
|
||||
);
|
||||
if (state.sort) {
|
||||
// may modify state.sort
|
||||
self.options.getSort(state, state.sort, parseBeyondSort);
|
||||
} else {
|
||||
parseBeyondSort();
|
||||
}
|
||||
// span
|
||||
} else {
|
||||
if (!state.view) {
|
||||
// set to default list or item view
|
||||
state.view = self.options.views[state.type][
|
||||
!state.item ? 'list' : 'item'
|
||||
][0];
|
||||
}
|
||||
getHash();
|
||||
}
|
||||
}
|
||||
function parseBeyondSort() {
|
||||
Ox.Log('Core', 'pBSo', state, parts.join('/'))
|
||||
var span, spanType, spanTypes;
|
||||
if (parts.length) {
|
||||
spanTypes = self.options.spanType[state.type][
|
||||
!state.item ? 'list' : 'item'
|
||||
|
@ -922,14 +945,16 @@ Ox.URL = function(options) {
|
|||
}
|
||||
} else {
|
||||
if (!state.view) {
|
||||
// set to default item view
|
||||
state.view = self.options.views[state.type].item[0];
|
||||
// set to default list or item view
|
||||
state.view = self.options.views[state.type][
|
||||
!state.item ? 'list' : 'item'
|
||||
][0];
|
||||
}
|
||||
getHash();
|
||||
}
|
||||
}
|
||||
function parseBeyondSpan() {
|
||||
Ox.Log('Core', 'pBS', state, parts)
|
||||
Ox.Log('Core', 'pBSp', state, parts.join('/'))
|
||||
if (!state.view) {
|
||||
// set to default list or item view
|
||||
state.view = self.options.views[state.type][
|
||||
|
|
Loading…
Reference in a new issue