make menu and list talk to each other

This commit is contained in:
rolux 2010-07-07 14:36:12 +02:00
parent 35f852283d
commit a259ef8b27

View File

@ -142,7 +142,7 @@ requires
requestURL: oxui.requestURL
}, options);
self.change = function() {
self.change = function(key, value) {
};
@ -1897,7 +1897,9 @@ requires
})
.click(select)
.appendTo(that);
self.selectId = self.options.id + "_placeholder";
self.selectId = Ox.toCamelCase(
self.options.id + "_" + (self.options.label.length > 1 ? "label" : "placeholder")
);
self.selectMenu = new Ox.Menu({
element: that,
id: self.selectId,
@ -2134,6 +2136,11 @@ requires
} : that.$input.val());
}
that.changeLabel = function(id) {
that.$label.html(Ox.getObjectById(self.options.label, id).title);
self.selectMenu.checkItem(id);
};
that.height = function(value) {
var stop = 8 / value;
if (self.options.type == "textarea") {
@ -2485,6 +2492,13 @@ requires
};
that.selectItem = function(id) {
that.$button.options({
value: Ox.getObjectById(self.options.items, id).title
});
that.$menu.checkItem(id);
};
that.width = function(val) {
// fixme: silly hack, and won't work for css()
that.$element.width(val + 16);
@ -3301,7 +3315,7 @@ requires
$order = $("<div>")
.addClass("OxOrder")
.html(oxui.symbols["triangle_" + (
v.operator == "+" ? "up" : "down"
v.operator === "" ? "up" : "down"
)])
.click(function() {
$(this).prev().trigger("click")
@ -3388,7 +3402,7 @@ requires
isSelected = self.options.sort[0].key == self.options.columns[i].id;
that.sort(
self.options.columns[i].id, isSelected ?
(self.options.sort[0].operator == "+" ? "-" : "+") :
(self.options.sort[0].operator === "" ? "-" : "") :
self.options.columns[i].operator
);
}
@ -3544,23 +3558,25 @@ requires
function toggleSelected(id) {
var pos = getColumnPositionById(id);
updateOrder(id);
pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass("OxSelected");
that.$titles[pos].toggleClass("OxSelected");
that.$titles[pos].next().toggleClass("OxSelected");
that.$titles[pos].next().next().children().eq(0).toggleClass("OxSelected");
that.$titles[pos].css({
width: (
that.$titles[pos].width() + (that.$titles[pos].hasClass("OxSelected") ? -16 : 16)
) + "px"
});
if (pos > -1) {
updateOrder(id);
pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass("OxSelected");
that.$titles[pos].toggleClass("OxSelected");
that.$titles[pos].next().toggleClass("OxSelected");
that.$titles[pos].next().next().children().eq(0).toggleClass("OxSelected");
that.$titles[pos].css({
width: (
that.$titles[pos].width() + (that.$titles[pos].hasClass("OxSelected") ? -16 : 16)
) + "px"
});
}
}
function updateOrder(id) {
var pos = getColumnPositionById(id);
Ox.print(id, pos)
that.$titles[pos].next().html(oxui.symbols[
"triangle_" + (self.options.sort[0].operator == "+" ? "up" : "down")
"triangle_" + (self.options.sort[0].operator === "" ? "up" : "down")
]);
}
@ -3677,6 +3693,17 @@ requires
}
}
function getMenuById(id) {
var menu = null;
$.each(that.menus, function(i, v) {
if (v.options("id") == id) {
menu = v;
return false;
}
});
return menu;
}
function mousemove(event) {
var $target = $(event.target),
focused,
@ -3713,6 +3740,12 @@ requires
};
that.checkItem = function(id) {
that.getItem(id).options({
checked: true
});
};
that.disableItem = function(id) {
};
@ -3722,11 +3755,16 @@ requires
};
that.getItem = function(id) {
var item;
$.each(that.menus, function(i, menu) {
item = menu.getItem(id);
return !item;
});
var ids = id.split("_"),
item;
if (ids.length == 1) {
$.each(that.menus, function(i, menu) {
item = menu.getItem(id);
return !item;
});
} else {
item = getMenuById(ids.shift()).getItem(ids.join("_"));
}
return item;
};
@ -3746,6 +3784,10 @@ requires
}
};
that.uncheckItem = function(id) {
};
return that;
};
@ -3765,6 +3807,8 @@ requires
side open to "bottom" or "right"
size "large", "medium" or "small"
methods:
events:
change_groupId {id, value} checked item of a group has changed
click_itemId item not belonging to a group was clicked
@ -4211,14 +4255,31 @@ requires
};
that.getItem = function(id) {
var item;
$.each(this.items, function(i, v) {
if (v.options("id") == id) {
item = v;
return false;
}
that.checkItem = function(id) {
that.getItem(id).options({
checked: true
});
};
that.getItem = function(id) {
var ids = id.split("_"),
item;
if (ids.length == 1) {
$.each(that.items, function(i, v) {
if (v.options("id") == id) {
item = v;
return false;
}
});
if (!item) {
$.each(that.submenus, function(k, submenu) {
item = submenu.getItem(id);
return !item;
});
}
} else {
item = that.submenus[ids.shift()].getItem(ids.join("_"));
}
return item;
};