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
|
state <o> State object
|
||||||
string <s> The string to be tested
|
string <s> The string to be tested
|
||||||
callback <f> callback function
|
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
|
getSpan <f> Tests if a value matches a span
|
||||||
May modify the state's view and span properties
|
May modify the state's view and span properties
|
||||||
(state, string, callback) -> <u> undefined
|
(state, value, callback) -> <u> undefined
|
||||||
state <o> State object
|
state <o> State object
|
||||||
value <[n]|s> The value to be tested
|
value <[n]|s> The value to be tested
|
||||||
callback <f> Callback function
|
callback <f> Callback function
|
||||||
|
@ -410,6 +416,7 @@ Ox.URL = function(options) {
|
||||||
getHash: null,
|
getHash: null,
|
||||||
getItem: null,
|
getItem: null,
|
||||||
getPart: null,
|
getPart: null,
|
||||||
|
getSort: null,
|
||||||
getSpan: null,
|
getSpan: null,
|
||||||
pages: [],
|
pages: [],
|
||||||
spanType: {},
|
spanType: {},
|
||||||
|
@ -818,14 +825,14 @@ Ox.URL = function(options) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
state.item = '';
|
state.item = '';
|
||||||
// set to default view
|
// set to default list view
|
||||||
state.view = self.options.views[state.type].list[0];
|
state.view = self.options.views[state.type].list[0];
|
||||||
getHash();
|
getHash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function parseBeyondItem() {
|
function parseBeyondItem() {
|
||||||
Ox.Log('Core', 'pBI', state, parts.join('/'));
|
Ox.Log('Core', 'pBI', state, parts.join('/'));
|
||||||
var sortKeyIds, sortParts, span, spanType, spanTypes;
|
var sortKeyIds, sortParts;
|
||||||
if (
|
if (
|
||||||
parts.length && state.item
|
parts.length && state.item
|
||||||
&& self.options.views[state.type].item.indexOf(parts[0]) > -1
|
&& 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) {
|
} else if (state.item && self.options.views[state.type].item.length == 1) {
|
||||||
state.view = self.options.views[state.type].item[0];
|
state.view = self.options.views[state.type].item[0];
|
||||||
}
|
}
|
||||||
// sort
|
|
||||||
if (parts.length) {
|
if (parts.length) {
|
||||||
sortParts = parts[0].split(',');
|
sortParts = parts[0].split(',');
|
||||||
sortKeyIds = Ox.map(self.options.sortKeys[state.type][
|
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) {
|
if (parts.length) {
|
||||||
spanTypes = self.options.spanType[state.type][
|
spanTypes = self.options.spanType[state.type][
|
||||||
!state.item ? 'list' : 'item'
|
!state.item ? 'list' : 'item'
|
||||||
|
@ -922,14 +945,16 @@ Ox.URL = function(options) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!state.view) {
|
if (!state.view) {
|
||||||
// set to default item view
|
// set to default list or item view
|
||||||
state.view = self.options.views[state.type].item[0];
|
state.view = self.options.views[state.type][
|
||||||
|
!state.item ? 'list' : 'item'
|
||||||
|
][0];
|
||||||
}
|
}
|
||||||
getHash();
|
getHash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function parseBeyondSpan() {
|
function parseBeyondSpan() {
|
||||||
Ox.Log('Core', 'pBS', state, parts)
|
Ox.Log('Core', 'pBSp', state, parts.join('/'))
|
||||||
if (!state.view) {
|
if (!state.view) {
|
||||||
// set to default list or item view
|
// set to default list or item view
|
||||||
state.view = self.options.views[state.type][
|
state.view = self.options.views[state.type][
|
||||||
|
|
Loading…
Reference in a new issue