misc fixes

This commit is contained in:
rlx 2011-09-20 00:11:16 +00:00
commit b881f74c7e
3 changed files with 18 additions and 9 deletions

View file

@ -66,7 +66,11 @@ Ox.Filter = function(options, self) {
{id: '<', title: 'is less than'}, {id: '<', title: 'is less than'},
{id: '>', title: 'is greater than'}, {id: '>', title: 'is greater than'},
{id: '-', title: 'is between'}, {id: '-', title: 'is between'},
{id: '!-', title: 'is not between'} {id: '!-', title: 'is not between'}/*,
{id: '^', title: 'starts with'},
{id: '!^', title: 'does not start with'},
{id: '$', title: 'ends with'},
{id: '!$', title: 'does not end with'}*/
], ],
string: [ string: [
{id: '=', title: 'is'}, {id: '=', title: 'is'},
@ -356,9 +360,9 @@ Ox.Filter = function(options, self) {
: [self.options.query.conditions[pos].conditions[subpos]], : [self.options.query.conditions[pos].conditions[subpos]],
isUseless = false; isUseless = false;
Ox.forEach(conditions, function(condition) { Ox.forEach(conditions, function(condition) {
isUseless = Ox.getObjectById( isUseless = ['string', 'text'].indexOf(
self.options.findKeys, condition.key Ox.getObjectById(self.options.findKeys, condition.key).type
).type == 'text' ) > -1
&& condition.operator == (self.options.query.operator == '&' ? '' : '!') && condition.operator == (self.options.query.operator == '&' ? '' : '!')
&& condition.value == '' && condition.value == ''
return isUseless; return isUseless;

View file

@ -196,7 +196,7 @@ Ox.Select = function(options, self) {
that.selectItem = function(id) { that.selectItem = function(id) {
//Ox.print('selectItem', id, Ox.getObjectById(self.options.items, id).title) //Ox.print('selectItem', id, Ox.getObjectById(self.options.items, id).title)
self.options.type == 'text' && self.$title.html( self.options.type == 'text' && self.$title.html(
Ox.getObjectById(self.options.items, id).title[0] // fixme: title should not have become an array Ox.getObjectById(self.options.items, id).title
); );
self.$menu.checkItem(id); self.$menu.checkItem(id);
self.checked = self.optionGroup.checked(); self.checked = self.optionGroup.checked();

View file

@ -434,12 +434,12 @@ Ox.clone <f> Returns a (shallow or deep) copy of an object or array
@*/ @*/
Ox.clone = function(col, deep) { Ox.clone = function(col, deep) {
var ret; // fixme: is there any use case for shallow copy?
var ret = Ox.isArray(col) ? [] : {};
if (deep) { if (deep) {
ret = Ox.isArray(col) ? [] : {};
Ox.forEach(col, function(val, key) { Ox.forEach(col, function(val, key) {
ret[key] = ['array', 'object'].indexOf(Ox.typeOf(val)) > -1 ret[key] = ['array', 'object'].indexOf(Ox.typeOf(val)) > -1
? Ox.clone(val) : val; ? Ox.clone(val, true) : val;
}); });
} else { } else {
ret = Ox.isArray(col) ? col.slice() : Ox.extend({}, col); ret = Ox.isArray(col) ? col.slice() : Ox.extend({}, col);
@ -700,6 +700,7 @@ Ox.isEmpty <f> Returns true if a collection is empty
true true
@*/ @*/
Ox.isEmpty = function(val) { Ox.isEmpty = function(val) {
// fixme: what about deep isEmpty?
return Ox.len(val) == 0; return Ox.len(val) == 0;
}; };
@ -4233,11 +4234,15 @@ Ox.serialize <f> Parses an object into query parameters
'a=1&b=2&c=3' 'a=1&b=2&c=3'
> Ox.serialize({a: 1, b: 2.3, c: [4, 5]}) > Ox.serialize({a: 1, b: 2.3, c: [4, 5]})
'a=1&b=2.3&c=4,5' 'a=1&b=2.3&c=4,5'
> Ox.serialize({string: 'foo', empty: {}, null: null, undefined: void 0})
'string=bar'
@*/ @*/
Ox.serialize = function(obj) { Ox.serialize = function(obj) {
var arr = []; var arr = [];
Ox.forEach(obj, function(val, key) { Ox.forEach(obj, function(val, key) {
if (!Ox.isEmpty(val) && !Ox.isNull(val) && !Ox.isUndefined(val)) {
arr.push(key + '=' + val); arr.push(key + '=' + val);
}
}); });
return arr.join('&'); return arr.join('&');
}; };