fixing defaults/options for enhanced widgets
This commit is contained in:
parent
4f2dc7dd53
commit
ef8c8eed37
2 changed files with 75 additions and 5 deletions
|
@ -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 = $("<div>")
|
||||
.addClass("OxExtras")
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue