From 82f1fc8b9a759e4192f9bcdb122c2cf89c5a8480 Mon Sep 17 00:00:00 2001 From: Rolux Date: Wed, 30 Jun 2010 23:41:27 +0200 Subject: [PATCH] more list --- build/js/ox.ui.js | 15 +++++++++------ demos/test/list.js | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index f0116af..bc1a267 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -532,6 +532,8 @@ requires Ox.Request = function() { + // chained requests, make cancelable: id = 4.7.9 + var cache = {}, pending = {}, requests = {}, @@ -2477,7 +2479,7 @@ requires if (!Ox.isUndefined(self.$items[pos])) { self.$items[pos].addClass("OxSelected"); } - Ox.Event.trigger("select_" + self.options.id, { + that.triggerEvent("select", { ids: $.map(self.selected, function(v, i) { return self.ids[v]; }) @@ -2487,6 +2489,7 @@ requires function clear() { $.each(self.requests, function(i, v) { + Ox.print("Ox.Request.cancel", v); Ox.Request.cancel(v); }); $.extend(self, { @@ -2524,7 +2527,7 @@ requires if (!Ox.isUndefined(self.$items[pos])) { self.$items[pos].removeClass("OxSelected"); } - Ox.Event.trigger("select_" + self.options.id, { + that.triggerEvent("select", { ids: $.map(self.selected, function(v, i) { return self.ids[v]; }) @@ -2548,9 +2551,9 @@ requires } function getPage() { - return self.options.orientation == "vertical" - ? Math.floor(that.scrollTop() / self.pageHeight) - : Math.floor(that.scrollLeft() / self.pageWidth); + return self.options.orientation == "horizontal" + ? Math.floor(that.scrollLeft() / self.pageWidth) + : Math.floor(that.scrollTop() / self.pageHeight); } function getPositions() { @@ -2855,7 +2858,7 @@ requires key: key, operator: operator } - // fixme: trigger sort event here + that.triggerEvent("sort", self.options.sort[0]); updateSort(); } } diff --git a/demos/test/list.js b/demos/test/list.js index 4693919..94d8dd0 100644 --- a/demos/test/list.js +++ b/demos/test/list.js @@ -3,8 +3,8 @@ $(function() { var $body = $("body"), $document = $(document), app = new Ox.App({ - requestURL: "http://blackbook.local:8000/api/" - // requestURL: "http://lion.oil21.org:8000/api/" + // requestURL: "http://blackbook.local:8000/api/" + requestURL: "http://lion.oil21.org:8000/api/" }), $menu = new Ox.MainMenu({ menus: [ @@ -24,6 +24,9 @@ $(function() { { checked: false, group: "sort_movies", id: "director", title: "Director" }, { checked: false, group: "sort_movies", id: "country", title: "Country" }, { checked: true, group: "sort_movies", id: "year", title: "Year" }, + { checked: false, group: "sort_movies", id: "runtime", title: "Runtime" }, + { checked: false, group: "sort_movies", id: "language", title: "Language" }, + { checked: false, group: "sort_movies", id: "genre", title: "Genre" }, ] }, { id: "order_movies", title: "Order Movies", items: [ { checked: false, group: "order_movies", id: "ascending", title: "Ascending"}, @@ -72,7 +75,7 @@ $(function() { title: v.title, unique: true, visible: true, - width: size - 50 - ($.browser.mozilla ? 16 : 12) + width: size - 60 - ($.browser.mozilla ? 16 : 12) }, { align: "right", @@ -80,7 +83,7 @@ $(function() { operator: "-", title: "Items", visible: true, - width: 50 + width: 60 } ], id: "group_" + v.id, @@ -109,6 +112,7 @@ $(function() { }); elements.push({ element: $group[i], + resizable: true, size: size }); }); @@ -270,10 +274,9 @@ $(function() { }).appendTo($body); $.each(groups, function(i, group) { Ox.Event.bind(null, "select_group_" + group.id, function(event, data) { - Ox.print("OK") $list.options({ request: function(options) { - app.request("find", $.extend(options, { + return app.request("find", $.extend(options, { query: { conditions: $.map(data.ids, function(v, j) { return { @@ -292,7 +295,7 @@ $(function() { $group[i_].options({ request: function(options) { delete options.keys; - app.request("find", $.extend(options, { + return app.request("find", $.extend(options, { group: group_.id, query: { conditions: $.map(data.ids, function(v, j) { @@ -311,4 +314,10 @@ $(function() { }); }); }); + Ox.Event.bind(null, "change_sort_movies", function(event, data) { + + }); + Ox.Event.bind(null, "sort_list", function(event, data) { + + }); });