add span type number, pass state.type to getSpan
This commit is contained in:
parent
b180735d8d
commit
fbf02bc0b2
1 changed files with 13 additions and 4 deletions
|
@ -16,7 +16,7 @@ Ox.URL <f> URL controller
|
|||
callback <f> callback function
|
||||
id <s> Matching item id, or empty
|
||||
getSpan <f> Tests if a string matches a span
|
||||
(item, view, string, callback) -> <u> undefined
|
||||
(type, item, view, string, callback) -> <u> undefined
|
||||
item <s> The item id, or empty
|
||||
view <s> The view, or empty
|
||||
string <s> The string to be tested
|
||||
|
@ -56,7 +56,7 @@ Ox.URL <f> URL controller
|
|||
getItem: function(type, str, callback) {
|
||||
callback(/^\d+$/.test(str) ? str : '');
|
||||
},
|
||||
getSpan: function(item, view, str, callback) {
|
||||
getSpan: function(type, item, view, str, callback) {
|
||||
if (!item && (!view || view == 'map')) {
|
||||
callback(str.replace(/^@/, ''), 'map');
|
||||
} else {
|
||||
|
@ -473,6 +473,7 @@ Ox.URL = function(options) {
|
|||
return Ox.isNumber(point) ? (
|
||||
spanType == 'date' ? constructDate(point)
|
||||
: spanType == 'duration' ? constructDuration(point)
|
||||
: spanType == 'number' ? point
|
||||
: constructLocation(point)
|
||||
) : point;
|
||||
}).join(',');
|
||||
|
@ -544,6 +545,7 @@ Ox.URL = function(options) {
|
|||
var canBeDate = types.indexOf('date') > -1,
|
||||
canBeDuration = types.indexOf('duration') > -1,
|
||||
canBeLocation = types.indexOf('location') > -1,
|
||||
canBeNumber = types.indexOf('number') > -1,
|
||||
length = str.split(',').length;
|
||||
return canBeDate && /\d-/.test(str) ? 'date'
|
||||
: canBeDuration && /:/.test(str) ? 'duration'
|
||||
|
@ -551,7 +553,9 @@ Ox.URL = function(options) {
|
|||
// leaves us with [-]D[.D][,[-]D[.D]]
|
||||
: canBeDuration ? 'duration'
|
||||
: canBeDate && !/\./.test(str) ? 'date'
|
||||
: canBeLocation && length == 2 ? 'location' : ':'
|
||||
: canBeLocation && length == 2 ? 'location'
|
||||
: canBeNumber && /\d-/.test(str) ? 'number'
|
||||
: ':'
|
||||
}
|
||||
|
||||
function parseCondition(str) {
|
||||
|
@ -611,6 +615,10 @@ Ox.URL = function(options) {
|
|||
return Ox.parseDuration(str);
|
||||
}
|
||||
|
||||
function parseNumber(str) {
|
||||
return parseFloat(str);
|
||||
}
|
||||
|
||||
function parseFind(str) {
|
||||
str = (str || '').replace(/%7C/g, '|');
|
||||
var conditions, counter = 0,
|
||||
|
@ -698,6 +706,7 @@ Ox.URL = function(options) {
|
|||
return split.map(
|
||||
type == 'date' ? parseDate
|
||||
: type == 'duration' ? parseDuration
|
||||
: type == 'number' ? parseNumber
|
||||
: parseLocation
|
||||
);
|
||||
}
|
||||
|
@ -796,7 +805,7 @@ Ox.URL = function(options) {
|
|||
}
|
||||
if (!state.span && /^[A-Z@]/.test(parts[0])) {
|
||||
// test for span id or name
|
||||
self.options.getSpan(state.item, state.view, decodeValue(parts[0]), function(span, view) {
|
||||
self.options.getSpan(state.type, state.item, state.view, decodeValue(parts[0]), function(span, view) {
|
||||
Ox.Log('Core', 'span/view', span, view)
|
||||
if (span) {
|
||||
if (!state.view) {
|
||||
|
|
Loading…
Reference in a new issue