make menu and list talk to each other
This commit is contained in:
parent
cca5b99fed
commit
5a655b3e20
1 changed files with 88 additions and 27 deletions
|
@ -142,7 +142,7 @@ requires
|
||||||
requestURL: oxui.requestURL
|
requestURL: oxui.requestURL
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
self.change = function() {
|
self.change = function(key, value) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1897,7 +1897,9 @@ requires
|
||||||
})
|
})
|
||||||
.click(select)
|
.click(select)
|
||||||
.appendTo(that);
|
.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({
|
self.selectMenu = new Ox.Menu({
|
||||||
element: that,
|
element: that,
|
||||||
id: self.selectId,
|
id: self.selectId,
|
||||||
|
@ -2134,6 +2136,11 @@ requires
|
||||||
} : that.$input.val());
|
} : 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) {
|
that.height = function(value) {
|
||||||
var stop = 8 / value;
|
var stop = 8 / value;
|
||||||
if (self.options.type == "textarea") {
|
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) {
|
that.width = function(val) {
|
||||||
// fixme: silly hack, and won't work for css()
|
// fixme: silly hack, and won't work for css()
|
||||||
that.$element.width(val + 16);
|
that.$element.width(val + 16);
|
||||||
|
@ -3301,7 +3315,7 @@ requires
|
||||||
$order = $("<div>")
|
$order = $("<div>")
|
||||||
.addClass("OxOrder")
|
.addClass("OxOrder")
|
||||||
.html(oxui.symbols["triangle_" + (
|
.html(oxui.symbols["triangle_" + (
|
||||||
v.operator == "+" ? "up" : "down"
|
v.operator === "" ? "up" : "down"
|
||||||
)])
|
)])
|
||||||
.click(function() {
|
.click(function() {
|
||||||
$(this).prev().trigger("click")
|
$(this).prev().trigger("click")
|
||||||
|
@ -3388,7 +3402,7 @@ requires
|
||||||
isSelected = self.options.sort[0].key == self.options.columns[i].id;
|
isSelected = self.options.sort[0].key == self.options.columns[i].id;
|
||||||
that.sort(
|
that.sort(
|
||||||
self.options.columns[i].id, isSelected ?
|
self.options.columns[i].id, isSelected ?
|
||||||
(self.options.sort[0].operator == "+" ? "-" : "+") :
|
(self.options.sort[0].operator === "" ? "-" : "") :
|
||||||
self.options.columns[i].operator
|
self.options.columns[i].operator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3544,23 +3558,25 @@ requires
|
||||||
|
|
||||||
function toggleSelected(id) {
|
function toggleSelected(id) {
|
||||||
var pos = getColumnPositionById(id);
|
var pos = getColumnPositionById(id);
|
||||||
updateOrder(id);
|
if (pos > -1) {
|
||||||
pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass("OxSelected");
|
updateOrder(id);
|
||||||
that.$titles[pos].toggleClass("OxSelected");
|
pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass("OxSelected");
|
||||||
that.$titles[pos].next().toggleClass("OxSelected");
|
that.$titles[pos].toggleClass("OxSelected");
|
||||||
that.$titles[pos].next().next().children().eq(0).toggleClass("OxSelected");
|
that.$titles[pos].next().toggleClass("OxSelected");
|
||||||
that.$titles[pos].css({
|
that.$titles[pos].next().next().children().eq(0).toggleClass("OxSelected");
|
||||||
width: (
|
that.$titles[pos].css({
|
||||||
that.$titles[pos].width() + (that.$titles[pos].hasClass("OxSelected") ? -16 : 16)
|
width: (
|
||||||
) + "px"
|
that.$titles[pos].width() + (that.$titles[pos].hasClass("OxSelected") ? -16 : 16)
|
||||||
});
|
) + "px"
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOrder(id) {
|
function updateOrder(id) {
|
||||||
var pos = getColumnPositionById(id);
|
var pos = getColumnPositionById(id);
|
||||||
Ox.print(id, pos)
|
Ox.print(id, pos)
|
||||||
that.$titles[pos].next().html(oxui.symbols[
|
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) {
|
function mousemove(event) {
|
||||||
var $target = $(event.target),
|
var $target = $(event.target),
|
||||||
focused,
|
focused,
|
||||||
|
@ -3713,6 +3740,12 @@ requires
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.checkItem = function(id) {
|
||||||
|
that.getItem(id).options({
|
||||||
|
checked: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
that.disableItem = function(id) {
|
that.disableItem = function(id) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -3722,11 +3755,16 @@ requires
|
||||||
};
|
};
|
||||||
|
|
||||||
that.getItem = function(id) {
|
that.getItem = function(id) {
|
||||||
var item;
|
var ids = id.split("_"),
|
||||||
$.each(that.menus, function(i, menu) {
|
item;
|
||||||
item = menu.getItem(id);
|
if (ids.length == 1) {
|
||||||
return !item;
|
$.each(that.menus, function(i, menu) {
|
||||||
});
|
item = menu.getItem(id);
|
||||||
|
return !item;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
item = getMenuById(ids.shift()).getItem(ids.join("_"));
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3746,6 +3784,10 @@ requires
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.uncheckItem = function(id) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -3765,6 +3807,8 @@ requires
|
||||||
side open to "bottom" or "right"
|
side open to "bottom" or "right"
|
||||||
size "large", "medium" or "small"
|
size "large", "medium" or "small"
|
||||||
|
|
||||||
|
methods:
|
||||||
|
|
||||||
events:
|
events:
|
||||||
change_groupId {id, value} checked item of a group has changed
|
change_groupId {id, value} checked item of a group has changed
|
||||||
click_itemId item not belonging to a group was clicked
|
click_itemId item not belonging to a group was clicked
|
||||||
|
@ -4211,14 +4255,31 @@ requires
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.getItem = function(id) {
|
that.checkItem = function(id) {
|
||||||
var item;
|
that.getItem(id).options({
|
||||||
$.each(this.items, function(i, v) {
|
checked: true
|
||||||
if (v.options("id") == id) {
|
|
||||||
item = v;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue