Ox.URL: add 'getHash' option
This commit is contained in:
parent
1c3af5e352
commit
61cb8b8dcc
1 changed files with 13 additions and 4 deletions
|
@ -7,6 +7,8 @@ Ox.URL <f> URL controller
|
||||||
findKeys <[o]> Find keys
|
findKeys <[o]> Find keys
|
||||||
id <s> Find key id
|
id <s> Find key id
|
||||||
type <s> Value type (like "string" or "integer")
|
type <s> Value type (like "string" or "integer")
|
||||||
|
getHash <f> Takes a state object and normalizes its "hash" property
|
||||||
|
(o) -> <o> State object
|
||||||
getItem <f> Tests if a string matches an item
|
getItem <f> Tests if a string matches an item
|
||||||
(string, callback) -> <u> undefined
|
(string, callback) -> <u> undefined
|
||||||
string <s> The string to be tested
|
string <s> The string to be tested
|
||||||
|
@ -372,6 +374,7 @@ Ox.URL = function(options) {
|
||||||
// fixme: find keys are also per type/list|item/view
|
// fixme: find keys are also per type/list|item/view
|
||||||
// since one can search for layer properties in some item views
|
// since one can search for layer properties in some item views
|
||||||
findKeys: [],
|
findKeys: [],
|
||||||
|
getHash: null,
|
||||||
getItem: null,
|
getItem: null,
|
||||||
getSpan: null,
|
getSpan: null,
|
||||||
pages: [],
|
pages: [],
|
||||||
|
@ -705,11 +708,11 @@ Ox.URL = function(options) {
|
||||||
state = split.length ? {hash: parseHash(split.join('#'))} : {};
|
state = split.length ? {hash: parseHash(split.join('#'))} : {};
|
||||||
if (parts[0] == '') {
|
if (parts[0] == '') {
|
||||||
// empty URL
|
// empty URL
|
||||||
callback(state);
|
getHash();
|
||||||
} else if (self.options.pages.indexOf(parts[0]) > -1) {
|
} else if (self.options.pages.indexOf(parts[0]) > -1) {
|
||||||
// page
|
// page
|
||||||
state.page = parts[0];
|
state.page = parts[0];
|
||||||
callback(state);
|
getHash();
|
||||||
} else {
|
} else {
|
||||||
if (self.options.types.indexOf(parts[0]) > -1) {
|
if (self.options.types.indexOf(parts[0]) > -1) {
|
||||||
// type
|
// type
|
||||||
|
@ -741,7 +744,7 @@ Ox.URL = function(options) {
|
||||||
state.item = '';
|
state.item = '';
|
||||||
// set to default view
|
// set to default view
|
||||||
state.view = self.options.views[state.type].list[0];
|
state.view = self.options.views[state.type].list[0];
|
||||||
callback(state);
|
getHash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function parseBeyondItem() {
|
function parseBeyondItem() {
|
||||||
|
@ -812,7 +815,7 @@ Ox.URL = function(options) {
|
||||||
// set to default item view
|
// set to default item view
|
||||||
state.view = self.options.views[state.type].item[0];
|
state.view = self.options.views[state.type].item[0];
|
||||||
}
|
}
|
||||||
callback(state);
|
getHash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function parseBeyondSpan() {
|
function parseBeyondSpan() {
|
||||||
|
@ -858,6 +861,12 @@ Ox.URL = function(options) {
|
||||||
// find
|
// find
|
||||||
state.find = parseFind(parts.join('/'));
|
state.find = parseFind(parts.join('/'));
|
||||||
}
|
}
|
||||||
|
getHash();
|
||||||
|
}
|
||||||
|
function getHash(callback) {
|
||||||
|
if (self.options.getHash) {
|
||||||
|
state = self.options.getHash(state);
|
||||||
|
}
|
||||||
callback(state);
|
callback(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue