Ox.URL: correctly handle number spans

This commit is contained in:
rlx 2013-03-04 11:19:09 +00:00
parent 0989a41c8e
commit 4f9192f140

View file

@ -40,10 +40,10 @@ Ox.URL <f> URL controller
typeA <o> Span types for this type
list <o> Span types for list views for this type
viewA <s> Span type for this view
Can be "date", "duration" or "location"
Can be "date", "duration", "location" or "number"
item <o> Span types for item views for this type
viewA <s> Span type for this view
Can be "date", "duration" or "location"
Can be "date", "duration", "location" or "number"
types <[s]> List of types
views <o> List and item views for all types
typeA <o> Views for type "typeA"
@ -504,8 +504,8 @@ Ox.URL = function(options) {
return Ox.isNumber(point) ? (
spanType == 'date' ? constructDate(point)
: spanType == 'duration' ? constructDuration(point)
: spanType == 'number' ? point
: constructLocation(point)
: spanType == 'location' ? constructLocation(point)
: point
) : point;
}).join(',');
}
@ -586,8 +586,8 @@ Ox.URL = function(options) {
: canBeDuration ? 'duration'
: canBeDate && !/\./.test(str) ? 'date'
: canBeLocation && length == 2 ? 'location'
: canBeNumber && /\d-/.test(str) ? 'number'
: ':'
: canBeNumber && /^\d+$/.test(str) ? 'number'
: '';
}
function parseCondition(str) {
@ -647,10 +647,6 @@ 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,
@ -716,6 +712,10 @@ Ox.URL = function(options) {
});
}
function parseNumber(str) {
return parseInt(str);
}
function parseSort(str, state) {
return str.split(',').map(function(str) {
var hasOperator = /^[\+-]/.test(str);
@ -738,8 +738,8 @@ Ox.URL = function(options) {
return split.map(
type == 'date' ? parseDate
: type == 'duration' ? parseDuration
: type == 'number' ? parseNumber
: parseLocation
: type == 'location' ? parseLocation
: parseNumber
);
}
@ -813,7 +813,7 @@ Ox.URL = function(options) {
spanType = state.view
? spanTypes[state.view]
: getSpanType(parts[0], Ox.unique(Ox.values(spanTypes)));
Ox.Log('Core', 'SPAN TYPE', spanType)
Ox.Log('URL', 'SPAN TYPE', spanType)
if (spanType) {
span = parseSpan(parts[0], spanType);
if (span) {