forked from 0x2620/oxjs
add tooltip option to Ox.Element
This commit is contained in:
parent
1d13caaf88
commit
2842ec8d09
4 changed files with 54 additions and 66 deletions
|
|
@ -9,7 +9,9 @@ Ox.Element <function:Ox.JQueryElement> Basic UI element object
|
|||
options <object> the options of the element
|
||||
# Properties
|
||||
element <string> tagname or CSS selector
|
||||
tooltip <object> tooltip (not implemented)
|
||||
tooltip <string|function> tooltip title or function that returns one
|
||||
(e) -> <string> tooltip title
|
||||
e <object> mouse event
|
||||
options <string> tagname or CSS selector
|
||||
self <object> shared private variable
|
||||
# Events -------------------------------------------------------------------
|
||||
|
|
@ -48,13 +50,6 @@ Ox.Element <function:Ox.JQueryElement> Basic UI element object
|
|||
|
||||
Ox.Element = function() {
|
||||
|
||||
/*
|
||||
tooltip option can be any of the following:
|
||||
string
|
||||
function(e), returns string
|
||||
{mousemove: true, title: function(e)}
|
||||
*/
|
||||
|
||||
return function(options, self) {
|
||||
|
||||
/*
|
||||
|
|
@ -87,14 +82,26 @@ Ox.Element = function() {
|
|||
)
|
||||
.mousedown(mousedown);
|
||||
|
||||
/*
|
||||
self.options.tooltip && that.bind(Ox.extend({
|
||||
mouseenter: mouseenter,
|
||||
mouseleave: mouseleave
|
||||
}, self.options.tooltip.mousemove ? {
|
||||
mousemove: mousemove
|
||||
} : {}));
|
||||
*/
|
||||
if (self.options.tooltip) {
|
||||
if (Ox.isString(self.options.tooltip)) {
|
||||
that.$tooltip = Ox.Tooltip({
|
||||
title: self.options.tooltip,
|
||||
});
|
||||
that.bind({
|
||||
mouseenter: mouseenter
|
||||
});
|
||||
} else {
|
||||
that.$tooltip = Ox.Tooltip({
|
||||
animate: false
|
||||
});
|
||||
that.bind({
|
||||
mousemove: mousemove
|
||||
});
|
||||
}
|
||||
that.bind({
|
||||
mouseleave: mouseleave
|
||||
});
|
||||
}
|
||||
|
||||
function bind(action, event, fn) {
|
||||
self.$eventHandler[action]('ox_' + event, function(event, data) {
|
||||
|
|
@ -186,25 +193,20 @@ Ox.Element = function() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function mouseenter(e) {
|
||||
self.$tooltip = new Ox.Tooltip({
|
||||
title: Ox.isString(self.options.tooltip) ?
|
||||
self.options.tooltip : Ox.isFunction(self.options.tooltip) ?
|
||||
self.options.tooltip(e) : self.options.tooltip.title(e)
|
||||
}).show();
|
||||
that.$tooltip.show(e);
|
||||
}
|
||||
|
||||
function mouseleave(e) {
|
||||
self.$tooltip.hide();
|
||||
that.$tooltip.hide();
|
||||
}
|
||||
|
||||
function mousemove(e) {
|
||||
self.$tooltip.options({
|
||||
title: self.options.tooltip.title(e)
|
||||
});
|
||||
Ox.print('mousemove!!')
|
||||
that.$tooltip.options({
|
||||
title: self.options.tooltip(e)
|
||||
}).show(e);
|
||||
}
|
||||
*/
|
||||
|
||||
self.setOption = function() {
|
||||
// self.setOptions(key, value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue