From f6c45c98bd03deca7bc8a626fe5f80fd0bca8bd8 Mon Sep 17 00:00:00 2001 From: Rolux Date: Sat, 20 Feb 2010 15:26:33 +0530 Subject: [PATCH] fixing defaults/options for enhanced widgets --- build/js/ox.ui.js | 56 +++++++++++++++++++++++++++++++++++++++---- demos/test/index.html | 24 +++++++++++++++++++ 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 091bf0c..45bde76 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -871,6 +871,7 @@ requires that.defaults({foo: x}) sets self.defaults */ self.defaults = defaults; + delete self.options; // fixme: hackish fix for that = OxFoo({}, self).defaults({...}).options({...}) return that; }; that.gainFocus = function() { @@ -907,11 +908,11 @@ requires // options (str, val) or options({str: val, ...}) // translate (str, val) to ({str: val}) args = Ox.makeObject.apply(that, arguments); - // if options have not been set, extend defaults, - // otherwise, extend options /* options = self.options; */ + // if options have not been set, extend defaults, + // otherwise, extend options self.options = $.extend(self.options || self.defaults, args); $.each(args, function(key, value) { self.onChange(key, value); @@ -1322,7 +1323,8 @@ requires that.remove(); that.$layer.remove(); callback(); - }) + }); + return that; } that.disable = function() { @@ -1335,7 +1337,9 @@ requires } that.open = function() { + Ox.print("opening...") that.$layer.appendTo($body); + Ox.print("opening...") that.css({ opacity: 0 }).appendTo(that.$layer).animate({ @@ -1358,11 +1362,52 @@ requires var self = self || {}, that = new Ox.Element("div", self) - .defaults() - .options(); + .defaults({ + items: [] + }) + .options(options || {}); // fixme: the || {} can be done once, in the options function + + $.each(self.options.items, function(i, item) { + + }); + + that.values = function() { + var values = {}; + if (arguments.length == 0) { + $.each(self.options.items, function(i, item) { + values[item.id] = item.val(); + }); + return values; + } else { + $.each(arguments[0], function(key, value) { + + }); + return that; + } + }; + + return that; }; + Ox.FormItem = function(options, self) { + + var self = self || {}, + that = new Ox.Element("", self) + .defaults({ + error: "", + regexp: / /, + size: "medium", + type: "text" + }) + .options(options || {}); + + that.$input = new OxInput(); + + return that; + + } + /* ---------------------------------------------------------------------------- Ox.Button @@ -2225,6 +2270,7 @@ requires that.bindEvent("hide_" + that.menus[position].options("id"), onHideMenu); }); + Ox.print(self.options) if (self.options.extras.length) { that.extras = $("
") .addClass("OxExtras") diff --git a/demos/test/index.html b/demos/test/index.html index bef1056..8decaf2 100644 --- a/demos/test/index.html +++ b/demos/test/index.html @@ -127,6 +127,15 @@ { id: "contact", title: "Contact"} ] }, + { + id: "user", + title: "User", + items: [ + { disabled: true, id: "user", title: "User: not logged in"}, + {}, + { id: "login", title: "Login" } + ] + }, { id: "file", title: "File", @@ -183,6 +192,21 @@ loadingIcon.stop(); }, 5000); }); + + var loginDialog = new Ox.Dialog({ + buttons: [ + { value: "Register", click: function() { loginDialog.close(); } }, + { value: "Reset Password", click: function() { loginDialog.close(); } }, + { value: "Cancel", click: function() { loginDialog.close(); } }, + { value: "Login", click: function() { loginDialog.close(); } } + ], + title: "Login" + }); + + Ox.Event.bind(null, "click_login", function() { + loginDialog.open(); + }); + var bottomPanel = Ox.Bar({size: "small"}) .css({ zIndex: 2,