more fixes (list)
This commit is contained in:
parent
782b795a36
commit
b3ea88fc27
2 changed files with 53 additions and 25 deletions
|
@ -2724,6 +2724,7 @@ requires
|
||||||
that = new Ox.Element({}, self)
|
that = new Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
columns: [],
|
columns: [],
|
||||||
|
columnWidth: [40, 800],
|
||||||
request: function() {}, // {sort, range, keys, callback}
|
request: function() {}, // {sort, range, keys, callback}
|
||||||
sort: []
|
sort: []
|
||||||
})
|
})
|
||||||
|
@ -2736,7 +2737,7 @@ requires
|
||||||
page: 0,
|
page: 0,
|
||||||
pageLength: 100,
|
pageLength: 100,
|
||||||
scrollLeft: 0,
|
scrollLeft: 0,
|
||||||
selectedColumn: getColumnById(self.options.sort[0].key),
|
selectedColumn: getColumnIndexById(self.options.sort[0].key),
|
||||||
visibleColumns: $.map(self.options.columns, function(v, i) {
|
visibleColumns: $.map(self.options.columns, function(v, i) {
|
||||||
return v.visible ? v : null;
|
return v.visible ? v : null;
|
||||||
})
|
})
|
||||||
|
@ -2767,7 +2768,7 @@ requires
|
||||||
})
|
})
|
||||||
.html(v.title)
|
.html(v.title)
|
||||||
.click(function() {
|
.click(function() {
|
||||||
clickColumn(v)
|
clickColumn(v.id)
|
||||||
})
|
})
|
||||||
.appendTo(that.$head.$content.$element);
|
.appendTo(that.$head.$content.$element);
|
||||||
$order = $("<div>")
|
$order = $("<div>")
|
||||||
|
@ -2786,8 +2787,12 @@ requires
|
||||||
initialX = e.clientX;
|
initialX = e.clientX;
|
||||||
$window.mousemove(function(e) {
|
$window.mousemove(function(e) {
|
||||||
var x = e.clientX,
|
var x = e.clientX,
|
||||||
width = Ox.limit(initialWidth - initialX + x, 40, 512);
|
width = Ox.limit(
|
||||||
resizeColumn(i, width);
|
initialWidth - initialX + x,
|
||||||
|
self.options.columnWidth[0],
|
||||||
|
self.options.columnWidth[1]
|
||||||
|
);
|
||||||
|
resizeColumn(v.id, width);
|
||||||
});
|
});
|
||||||
$window.mouseup(function() {
|
$window.mouseup(function() {
|
||||||
$window.unbind("mousemove");
|
$window.unbind("mousemove");
|
||||||
|
@ -2795,7 +2800,7 @@ requires
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.dblclick(function() {
|
.dblclick(function() {
|
||||||
resizeColumn(i, v.width);
|
resizeColumn(v.id, v.width);
|
||||||
})
|
})
|
||||||
.appendTo(that.$head.$content.$element);
|
.appendTo(that.$head.$content.$element);
|
||||||
$left = $("<div>").addClass("OxLeft").appendTo($resize);
|
$left = $("<div>").addClass("OxLeft").appendTo($resize);
|
||||||
|
@ -2805,8 +2810,8 @@ requires
|
||||||
that.$head.$content.css({
|
that.$head.$content.css({
|
||||||
width: (Ox.sum(self.columnWidths) + 2) + "px"
|
width: (Ox.sum(self.columnWidths) + 2) + "px"
|
||||||
});
|
});
|
||||||
toggleSelected(self.selectedColumn);
|
toggleSelected(self.options.columns[self.selectedColumn].id);
|
||||||
that.$titles[self.selectedColumn].css({
|
that.$titles[getColumnPositionById(self.options.columns[self.selectedColumn].id)].css({
|
||||||
width: (self.options.columns[self.selectedColumn].width - 25) + "px"
|
width: (self.options.columns[self.selectedColumn].width - 25) + "px"
|
||||||
});
|
});
|
||||||
that.$select = $("<div>")
|
that.$select = $("<div>")
|
||||||
|
@ -2846,10 +2851,13 @@ requires
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickColumn(data) {
|
function clickColumn(id) {
|
||||||
var isSelected = self.options.sort[0].key == data.id;
|
var i = getColumnIndexById(id),
|
||||||
|
isSelected = self.options.sort[0].key == self.options.columns[i].id;
|
||||||
that.sort(
|
that.sort(
|
||||||
data.id, isSelected ? (self.options.sort[0].operator == "+" ? "-" : "+") : data.operator
|
self.options.columns[i].id, isSelected ?
|
||||||
|
(self.options.sort[0].operator == "+" ? "-" : "+") :
|
||||||
|
self.options.columns[i].operator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2873,7 +2881,7 @@ requires
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColumnById(id) {
|
function getColumnIndexById(id) {
|
||||||
var pos = -1;
|
var pos = -1;
|
||||||
$.each(self.options.columns, function(i, v) {
|
$.each(self.options.columns, function(i, v) {
|
||||||
if (v.id == id) {
|
if (v.id == id) {
|
||||||
|
@ -2884,6 +2892,17 @@ requires
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getColumnPositionById(id) {
|
||||||
|
var pos = -1;
|
||||||
|
$.each(self.visibleColumns, function(i, v) {
|
||||||
|
if (v.id == id) {
|
||||||
|
pos = i;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
function moveColumn(id) {
|
function moveColumn(id) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2892,13 +2911,15 @@ requires
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resizeColumn(pos, width) {
|
function resizeColumn(id, width) {
|
||||||
|
var i = getColumnIndexById(id),
|
||||||
|
pos = getColumnPositionById(id);
|
||||||
self.columnWidths[pos] = width;
|
self.columnWidths[pos] = width;
|
||||||
that.$head.$content.css({
|
that.$head.$content.css({
|
||||||
width: (Ox.sum(self.columnWidths) + 2) + "px"
|
width: (Ox.sum(self.columnWidths) + 2) + "px"
|
||||||
});
|
});
|
||||||
that.$titles[pos].css({
|
that.$titles[pos].css({
|
||||||
width: (width - 9 - (pos == self.selectedColumn ? 16 : 0)) + "px"
|
width: (width - 9 - (i == self.selectedColumn ? 16 : 0)) + "px"
|
||||||
});
|
});
|
||||||
that.$body.$content.find(".OxItem").css({ // fixme: can we avoid this lookup?
|
that.$body.$content.find(".OxItem").css({ // fixme: can we avoid this lookup?
|
||||||
width: Ox.sum(self.columnWidths) + "px"
|
width: Ox.sum(self.columnWidths) + "px"
|
||||||
|
@ -2906,18 +2927,15 @@ requires
|
||||||
that.$body.$content.css({
|
that.$body.$content.css({
|
||||||
width: Math.max(Ox.sum(self.columnWidths), that.$element.width() - 12) + "px" // fixme: check if scrollbar visible, and listen to resize/toggle event
|
width: Math.max(Ox.sum(self.columnWidths), that.$element.width() - 12) + "px" // fixme: check if scrollbar visible, and listen to resize/toggle event
|
||||||
});
|
});
|
||||||
$(".OxColumn" + Ox.toTitleCase(self.options.columns[pos].id)).css({
|
$(".OxColumn" + Ox.toTitleCase(self.options.columns[i].id)).css({
|
||||||
width: (width - 9) + "px"
|
width: (width - 9) + "px"
|
||||||
});
|
});
|
||||||
that.$body.clearCache();
|
that.$body.clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectColumn(pos) {
|
function toggleSelected(id) {
|
||||||
that.sort(args.columns[pos].id, args.columns[pos].operator);
|
var pos = getColumnPositionById(id);
|
||||||
}
|
updateOrder(id);
|
||||||
|
|
||||||
function toggleSelected(pos) {
|
|
||||||
updateOrder(pos);
|
|
||||||
pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass("OxSelected");
|
pos > 0 && that.$titles[pos].prev().children().eq(2).toggleClass("OxSelected");
|
||||||
that.$titles[pos].toggleClass("OxSelected");
|
that.$titles[pos].toggleClass("OxSelected");
|
||||||
that.$titles[pos].next().toggleClass("OxSelected");
|
that.$titles[pos].next().toggleClass("OxSelected");
|
||||||
|
@ -2929,7 +2947,9 @@ requires
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOrder(pos) {
|
function updateOrder(id) {
|
||||||
|
var pos = getColumnPositionById(id);
|
||||||
|
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")
|
||||||
]);
|
]);
|
||||||
|
@ -2944,11 +2964,11 @@ requires
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
updateOrder(self.selectedColumn);
|
updateOrder(self.options.columns[self.selectedColumn].id);
|
||||||
} else {
|
} else {
|
||||||
toggleSelected(self.selectedColumn);
|
toggleSelected(self.options.columns[self.selectedColumn].id);
|
||||||
self.selectedColumn = getColumnById(key);
|
self.selectedColumn = getColumnIndexById(key);
|
||||||
toggleSelected(self.selectedColumn);
|
toggleSelected(self.options.columns[self.selectedColumn].id);
|
||||||
}
|
}
|
||||||
that.$body.sort(self.options.sort[0].key, self.options.sort[0].operator);
|
that.$body.sort(self.options.sort[0].key, self.options.sort[0].operator);
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,14 @@ $(function() {
|
||||||
}),
|
}),
|
||||||
$list = new Ox.TextList({
|
$list = new Ox.TextList({
|
||||||
columns: [
|
columns: [
|
||||||
|
{
|
||||||
|
align: "left",
|
||||||
|
id: "id",
|
||||||
|
operator: "+",
|
||||||
|
title: "ID",
|
||||||
|
visible: false,
|
||||||
|
width: 80
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align: "left",
|
align: "left",
|
||||||
id: "title",
|
id: "title",
|
||||||
|
|
Loading…
Reference in a new issue