update filter select css

This commit is contained in:
rolux 2012-12-10 19:13:23 +01:00
parent b34104a6c4
commit 30850ccd81

View file

@ -160,72 +160,78 @@ pandora.ui.filter = function(id) {
filters[i].sort = [{key: data.key, operator: data.operator}];
pandora.UI.set({filters: filters});
}
});
Ox.Select({
items: Ox.clone(pandora.site.filters),
max: 1,
min: 1,
type: 'image',
value: id
})
.css(Ox.UI.SCROLLBAR_SIZE == 16 ? {
right: 0,
width: '14px'
} : {
right: '-1px',
width: '8px',
})
.bindEvent('change', function(data) {
var filters = Ox.clone(pandora.user.ui.filters),
find,
id_ = data.value,
i_ = Ox.getIndexById(pandora.user.ui.filters, id_);
if (i_ == -1) {
// new filter was not part of old filter set
if (pandora.user.ui._filterState[i].selected.length) {
// if filter with selection gets replaced, update find
find = Ox.clone(pandora.user.ui.find, true);
find.conditions.splice(pandora.user.ui._filterState[i].index, 1);
}),
$select = Ox.Select({
items: Ox.clone(pandora.site.filters),
max: 1,
min: 1,
type: 'image',
value: id
})
.css(Ox.UI.SCROLLBAR_SIZE == 16 ? {
right: 0,
width: '14px'
} : {
right: '-1px',
width: '8px',
})
.bindEvent('change', function(data) {
var filters = Ox.clone(pandora.user.ui.filters),
find,
id_ = data.value,
i_ = Ox.getIndexById(pandora.user.ui.filters, id_);
if (i_ == -1) {
// new filter was not part of old filter set
if (pandora.user.ui._filterState[i].selected.length) {
// if filter with selection gets replaced, update find
find = Ox.clone(pandora.user.ui.find, true);
find.conditions.splice(pandora.user.ui._filterState[i].index, 1);
}
filters[i] = makeFilter(id_);
pandora.UI.set(Ox.extend({
filters: filters
}, find ? {
find: find
} : {}));
replaceFilter(i, id_);
// fixme: there is an obscure special case not yet covered:
// switching to a new filter may change find from advanced to not advanced
// if part of the existing query works as a filter selection in the new filter
} else {
// swap two existing filters
var filterData = Ox.clone(pandora.user.ui._filterState[i]);
pandora.user.ui._filterState[i] = pandora.user.ui._filterState[i_];
pandora.user.ui._filterState[i_] = filterData;
filters[i] = makeFilter(id_, pandora.user.ui.filters[i_].sort);
filters[i_] = makeFilter(id, pandora.user.ui.filters[i].sort);
pandora.UI.set({filters: filters});
replaceFilter(i, id_);
replaceFilter(i_, id);
}
filters[i] = makeFilter(id_);
pandora.UI.set(Ox.extend({
filters: filters
}, find ? {
find: find
} : {}));
replaceFilter(i, id_);
// fixme: there is an obscure special case not yet covered:
// switching to a new filter may change find from advanced to not advanced
// if part of the existing query works as a filter selection in the new filter
} else {
// swap two existing filters
var filterData = Ox.clone(pandora.user.ui._filterState[i]);
pandora.user.ui._filterState[i] = pandora.user.ui._filterState[i_];
pandora.user.ui._filterState[i_] = filterData;
filters[i] = makeFilter(id_, pandora.user.ui.filters[i_].sort);
filters[i_] = makeFilter(id, pandora.user.ui.filters[i].sort);
pandora.UI.set({filters: filters});
replaceFilter(i, id_);
replaceFilter(i_, id);
}
function makeFilter(id, sort) {
// makes user.ui._filterState object from site.filters object
var filter = Ox.getObjectById(pandora.site.filters, id);
return {
id: filter.id,
sort: sort || [{key: filter.type == 'integer' ? 'name' : 'items', operator: '-'}]
};
}
function replaceFilter(i, id, find) {
// if find is passed, selected items will be derived from it // FIXME: ???
var isOuter = i % 4 == 0;
pandora.$ui[isOuter ? 'browser' : 'filtersInnerPanel'].replaceElement(
isOuter ? i / 2 : i - 1,
pandora.$ui.filters[i] = pandora.ui.filter(id)
);
}
})
.appendTo(that.$bar.$element);
function makeFilter(id, sort) {
// makes user.ui._filterState object from site.filters object
var filter = Ox.getObjectById(pandora.site.filters, id);
return {
id: filter.id,
sort: sort || [{key: filter.type == 'integer' ? 'name' : 'items', operator: '-'}]
};
}
function replaceFilter(i, id, find) {
// if find is passed, selected items will be derived from it // FIXME: ???
var isOuter = i % 4 == 0;
pandora.$ui[isOuter ? 'browser' : 'filtersInnerPanel'].replaceElement(
isOuter ? i / 2 : i - 1,
pandora.$ui.filters[i] = pandora.ui.filter(id)
);
}
})
.appendTo(that.$bar.$element);
Ox.UI.SCROLLBAR_SIZE < 16 && $($select.find('input')[0]).css({
marginRight: '-3px',
marginTop: '1px',
width: '8px',
height: '8px'
});
return that;
};