diff --git a/source/Ox.UI/js/Core/URL.js b/source/Ox.UI/js/Core/URL.js index 16646974..5ea55679 100644 --- a/source/Ox.UI/js/Core/URL.js +++ b/source/Ox.UI/js/Core/URL.js @@ -25,9 +25,15 @@ Ox.URL URL controller state State object string The string to be tested callback callback function + getSort Tests if a sort object is valid (for the current item) + May modify the state's sort properties + (state, value, callback) -> undefined + state State object + value The value to be tested + callback Callback function getSpan Tests if a value matches a span May modify the state's view and span properties - (state, string, callback) -> undefined + (state, value, callback) -> undefined state State object value <[n]|s> The value to be tested callback 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(); + } + } else { + if (!state.view) { + // set to default list or item view + state.view = self.options.views[state.type][ + !state.item ? 'list' : 'item' + ][0]; + } + getHash(); } - // span + } + 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][