From 565ff78139e4eb3760acde3a186a4e18e2f4ea60 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Thu, 2 Jun 2011 06:19:44 +0000 Subject: [PATCH] now we have a rainbow-gradient range track hidden deep within pandora --- source/Ox.UI/js/Form/Ox.Filter.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.Filter.js b/source/Ox.UI/js/Form/Ox.Filter.js index e3080291..17672d45 100644 --- a/source/Ox.UI/js/Form/Ox.Filter.js +++ b/source/Ox.UI/js/Form/Ox.Filter.js @@ -270,7 +270,7 @@ Ox.Filter = function(options, self) { function getConditionType(type) { type = Ox.isArray(type) ? type[0] : type; - if (['float', 'integer', 'year'].indexOf(type) > -1) { + if (['float', 'hue', 'integer', 'year'].indexOf(type) > -1) { type = 'number'; } return type; @@ -364,7 +364,7 @@ Ox.Filter = function(options, self) { function renderConditionKey(condition) { return Ox.Select({ - items: $.map(self.options.findKeys, function(key) { + items: self.options.findKeys.map(function(key) { return { checked: key.id == condition.key, id: key.id, @@ -388,10 +388,11 @@ Ox.Filter = function(options, self) { } function renderConditionOperator(condition) { + Ox.print('rCO', condition) return Ox.Select({ - items: $.map(self.conditionOperators[getConditionType( + items: self.conditionOperators[getConditionType( Ox.getObjectById(self.options.findKeys, condition.key).type - )], function(operator) { + )].map(function(operator) { return { checked: operator.id == condition.operator, // fixme: should be "selected", not "checked" id: operator.id, @@ -442,12 +443,30 @@ Ox.Filter = function(options, self) { var $input, findKey = Ox.getObjectById(self.options.findKeys, condition.key), isArray = Ox.isArray(condition.value), + isHue, type = findKey.type == 'integer' ? 'int' : findKey.type, formatArgs, formatType, title; if (findKey.format) { formatArgs = findKey.format.args formatType = findKey.format.type; - if (findKey.format.type == 'date') { + if (formatType == 'color') { + isHue = formatArgs[0] == 'hue'; + $input = Ox.Range({ + max: isHue ? 360 : 1, + min: 0, + size: !isArray ? 288 : 128, // fixme: should be width! + width: !isArray ? 288 : 128, // have to set this too, for formatting when tuple + step: isHue ? 1 : 0.01, + thumbSize: 48, + thumbValue: true, + trackColors: isHue ? [ + 'rgb(255, 0, 0)', 'rgb(255, 255, 0)', + 'rgb(0, 255, 0)', 'rgb(0, 255, 255)', + 'rgb(0, 0, 255)', 'rgb(255, 0, 255)', + 'rgb(255, 0, 0)' + ] : ['rgb(0, 0, 0)', 'rgb(255, 255, 255)'] + }); + } else if (formatType == 'date') { $input = Ox.DateInput(!isArray ? { //value: condition.value, width: {day: 66, month: 66, year: 140} @@ -526,7 +545,7 @@ Ox.Filter = function(options, self) { Ox.FormElementGroup({ elements: [ Ox.Select({ - items: $.map(self.operators, function(operator) { + items: self.operators.map(function(operator) { return { checked: operator.id != self.options.query.operator, id: operator.id,