trigger change event in filter

This commit is contained in:
rlx 2011-09-19 13:17:35 +00:00
parent d50e37588b
commit 211884740d
3 changed files with 41 additions and 20 deletions

View file

@ -275,6 +275,7 @@ Ox.Filter = function(options, self) {
self.options.query.conditions[pos].conditions.splice(subpos, 0, condition); self.options.query.conditions[pos].conditions.splice(subpos, 0, condition);
} }
renderConditions(); renderConditions();
triggerChangeEvent();
} }
function changeConditionKey(pos, subpos, key) { function changeConditionKey(pos, subpos, key) {
@ -295,6 +296,7 @@ Ox.Filter = function(options, self) {
renderConditions(); renderConditions();
//self.$conditions[pos].replaceElement(1, constructConditionOperator(pos, oldOperator)); //self.$conditions[pos].replaceElement(1, constructConditionOperator(pos, oldOperator));
} }
triggerChangeEvent();
} }
function changeConditionOperator(pos, subpos, operator) { function changeConditionOperator(pos, subpos, operator) {
@ -312,6 +314,15 @@ Ox.Filter = function(options, self) {
condition.value = condition.value[0] condition.value = condition.value[0]
renderConditions(); renderConditions();
} }
triggerChangeEvent();
}
function changeConditionValue(pos, subpos, value) {
var condition = subpos == -1
? self.options.query.conditions[pos]
: self.options.query.conditions[pos].conditions[subpos];
condition.value = value;
triggerChangeEvent();
} }
function changeOperator(data) { function changeOperator(data) {
@ -324,6 +335,7 @@ Ox.Filter = function(options, self) {
} }
}); });
changeGroupOperator && renderConditions(); changeGroupOperator && renderConditions();
triggerChangeEvent();
} }
function getConditionType(type) { function getConditionType(type) {
@ -343,6 +355,7 @@ Ox.Filter = function(options, self) {
self.options.query.conditions[pos].conditions.splice(subpos, 1); self.options.query.conditions[pos].conditions.splice(subpos, 1);
} }
renderConditions(); renderConditions();
triggerChangeEvent();
} }
function renderButtons(pos, subpos) { function renderButtons(pos, subpos) {
@ -435,10 +448,10 @@ Ox.Filter = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
Ox.print('changeKey', data) var $element = data._element.parent();
changeConditionKey( changeConditionKey(
data._element.parent().data('position'), $element.data('position'),
data._element.parent().data('subposition'), $element.data('subposition'),
data.selected[0].id data.selected[0].id
); );
} }
@ -462,9 +475,10 @@ Ox.Filter = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
var $element = data._element.parent();
changeConditionOperator( changeConditionOperator(
data._element.parent().data('position'), $element.data('position'),
data._element.parent().data('subposition'), $element.data('subposition'),
data.selected[0].id data.selected[0].id
); );
} }
@ -485,14 +499,12 @@ Ox.Filter = function(options, self) {
}) })
).bindEvent({ ).bindEvent({
change: function(data) { change: function(data) {
var $element = data._element.parent(), var $element = data._element.parent();
pos = $element.data('position'), changeConditionValue(
subpos = $element.data('subposition'); $element.data('position'),
if (subpos == -1) { $element.data('subposition'),
self.options.query.conditions[pos].value = data.value; data.value
} else { );
self.options.query.conditions[pos].conditions[subpos].value = data.value;
}
} }
}); });
} }
@ -645,6 +657,12 @@ Ox.Filter = function(options, self) {
return $input; return $input;
} }
function triggerChangeEvent() {
that.triggerEvent('change', {
query: self.options.query
});
}
return that; return that;
}; };

View file

@ -150,7 +150,7 @@ Ox.Range = function(options, self) {
function clickTrack(data) { function clickTrack(data) {
// fixme: thumb ends up a bit too far on the right // fixme: thumb ends up a bit too far on the right
var isThumb = $(edatatarget).hasClass('OxThumb'); var isThumb = $(data.target).hasClass('OxThumb');
self.drag = { self.drag = {
left: self.$track.offset().left, left: self.$track.offset().left,
offset: isThumb ? data.clientX - self.$thumb.offset().left - 8 /*self.thumbSize / 2*/ : 0 offset: isThumb ? data.clientX - self.$thumb.offset().left - 8 /*self.thumbSize / 2*/ : 0

View file

@ -237,18 +237,21 @@ Ox.Dialog = function(options, self) {
function drag(event) { function drag(event) {
Ox.print(document.body.scrollTop, '...') Ox.print(document.body.scrollTop, '...')
var left = Ox.limit( var left, top;
if (!$(event.target).is('.OxButton')) {
left = Ox.limit(
self.drag.left - self.drag.x + event.clientX, self.drag.left - self.drag.x + event.clientX,
self.minLeft, self.maxLeft self.minLeft, self.maxLeft
), );
top = Ox.limit( top = Ox.limit(
self.drag.top - self.drag.y + event.clientY, self.drag.top - self.drag.y + event.clientY,
self.minTop, self.maxTop self.minTop, self.maxTop
); );
setCSS({ setCSS({
left: left, left: left,
top: top top: top
}); });
}
} }
function dragend() { function dragend() {