From 57342999c464fd53ee9dce01f4537d41258089c6 Mon Sep 17 00:00:00 2001 From: Rolux Date: Tue, 29 Jun 2010 18:28:22 +0200 Subject: [PATCH] more list --- build/js/ox.ui.js | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 924799b..712e7c8 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -2767,14 +2767,13 @@ requires }) .html(v.title) .click(function() { - that.sort(v.id, self.options.sort[0].key == v.id ? - (self.options.sort[0].operator == "+" ? "-" : "+") : v.operator); + clickColumn(v) }) .appendTo(that.$head.$content.$element); $order = $("
") .addClass("OxOrder") .html(oxui.symbols["triangle_" + ( - self.options.sort[0].operator == "+" ? "up" : "down" + v.operator == "+" ? "up" : "down" )]) .click(function() { $(this).prev().trigger("click") @@ -2847,6 +2846,13 @@ requires } + function clickColumn(data) { + var isSelected = self.options.sort[0].key == data.id; + that.sort( + data.id, isSelected ? (self.options.sort[0].operator == "+" ? "-" : "+") : data.operator + ); + } + function constructItem(data, pos) { var $item = $("
") .addClass("OxItem") @@ -2911,9 +2917,9 @@ requires } function toggleOrder(pos) { - self.options.columns[pos].operator = self.options.columns[pos].operator == "+" ? "-" : "+"; + Ox.print("toggleOrder", pos, self.options.sort[0].operator) that.$titles[pos].next().html(oxui.symbols[ - "triangle" + self.options.columns[pos].operator == "+" ? "up" : "down" + "triangle_" + (self.options.sort[0].operator == "+" ? "up" : "down") ]); } @@ -2925,28 +2931,29 @@ requires 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() + pos == self.selectedColumn ? -16 : 16 + that.$titles[pos].width() + (that.$titles[pos].hasClass("OxSelected") ? -16 : 16) ) + "px" }); - */ } that.sort = function(key, operator) { - if (key != self.options.sort.key || operator != self.options.sort.operator) { - self.options.sort = [ - { - key: key, - operator: operator - } - ]; + var isSelected = key == self.options.sort[0].key; + self.options.sort = [ + { + key: key, + operator: operator + } + ]; + if (isSelected) { + toggleOrder(self.selectedColumn); + } else { toggleSelected(self.selectedColumn); self.selectedColumn = getColumnById(key); toggleSelected(self.selectedColumn); - 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); }; return that;