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