1
0
Fork 0
forked from 0x2620/oxjs

form elements rewrite, part 1

This commit is contained in:
rlx 2011-12-21 13:42:47 +00:00
commit 7f83cd3141
30 changed files with 1061 additions and 958 deletions

View file

@ -328,16 +328,23 @@ Ox.Element = function(options, self) {
};
/*@
defaults <function> Sets the default options for an element object
defaults <function> Gets or sets the default options for an element object
({key: value, ...}) -> <obj> This element object
key <str> The name of the default option
value <val> The value of the default option
@*/
that.defaults = function(defaults) {
// sets the default options
self.defaults = defaults;
self.options = defaults;
return that;
that.defaults = function() {
var ret;
if (arguments.length == 0) {
ret = self.defaults;
} else if (Ox.isString(arguments[0])) {
ret = self.defaults[arguments[0]];
} else {
self.defaults = arguments[0];
self.options = Ox.clone(self.defaults);
ret = that;
}
return ret;
};
/*@
@ -386,14 +393,6 @@ Ox.Element = function(options, self) {
return Ox.getset(self.options, arguments, self.setOption, that);
};
that.setElement = function($element) {
//$element[0].className = that.$element[0].className;
$element.addClass('OxElement').data({oxid: that.id});
that.$element.replaceWith($element);
that.$element = $element;
that[0] = that.$element[0];
};
/*@
removeElement <function> Removes an element object and its event handler
() -> <obj> This element
@ -413,6 +412,22 @@ Ox.Element = function(options, self) {
return that;
};
that.setElement = function($element) {
//$element[0].className = that.$element[0].className;
$element.addClass('OxElement').data({oxid: that.id});
that.$element.replaceWith($element);
that.$element = $element;
that[0] = that.$element[0];
};
that.toggleOption = function() {
var options = {};
Ox.toArray(arguments[0]).forEach(function(key) {
options[key] == !self.options[key];
});
that.options(options);
};
/*@
triggerEvent <function> Triggers an event
(event) -> <object> This element object