Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Change button events to delegation instead of bind for extra buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Sep 27, 2011
1 parent 8623b09 commit e0b43fd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
17 changes: 11 additions & 6 deletions dist/jquery.qtip.basic.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Tue Sep 20 17:01:42 2011 +0100
* Date: Tue Sep 20 22:20:54 2011 +0100
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -249,13 +249,9 @@ function QTip(target, options, id, attr)
// Create button and setup attributes
elements.button.appendTo(elements.titlebar)
.attr('role', 'button')
.hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); })
.click(function(event) {
if(!tooltip.hasClass(disabled)) { self.hide(event); }
return FALSE;
})
.bind('mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
});

// Redraw the tooltip when we're done
Expand All @@ -280,11 +276,20 @@ function QTip(target, options, id, attr)
'aria-atomic': TRUE
})
)
.insertBefore(elements.content);
.insertBefore(elements.content)

// Button-specific events
.delegate('.ui-state-default', 'mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
})
.delegate('.ui-state-default', 'mouseover mouseout', function(event){
$(this).toggleClass('ui-state-hover', event.type === 'mouseover');
});

// Create button if enabled
if(options.content.title.button) { createButton(); }


// Redraw the tooltip dimensions if it's rendered
else if(self.rendered){ self.redraw(); }
}
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.qtip.css
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Tue Sep 20 17:01:42 2011 +0100
* Date: Tue Sep 20 22:20:54 2011 +0100
*/

/* Core qTip styles */
Expand Down
17 changes: 11 additions & 6 deletions dist/jquery.qtip.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Tue Sep 20 17:01:42 2011 +0100
* Date: Tue Sep 20 22:20:54 2011 +0100
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -249,13 +249,9 @@ function QTip(target, options, id, attr)
// Create button and setup attributes
elements.button.appendTo(elements.titlebar)
.attr('role', 'button')
.hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); })
.click(function(event) {
if(!tooltip.hasClass(disabled)) { self.hide(event); }
return FALSE;
})
.bind('mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
});

// Redraw the tooltip when we're done
Expand All @@ -280,11 +276,20 @@ function QTip(target, options, id, attr)
'aria-atomic': TRUE
})
)
.insertBefore(elements.content);
.insertBefore(elements.content)

// Button-specific events
.delegate('.ui-state-default', 'mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
})
.delegate('.ui-state-default', 'mouseover mouseout', function(event){
$(this).toggleClass('ui-state-hover', event.type === 'mouseover');
});

// Create button if enabled
if(options.content.title.button) { createButton(); }


// Redraw the tooltip dimensions if it's rendered
else if(self.rendered){ self.redraw(); }
}
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions src/core.js
Expand Up @@ -186,13 +186,9 @@ function QTip(target, options, id, attr)
// Create button and setup attributes
elements.button.appendTo(elements.titlebar)
.attr('role', 'button')
.hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); })
.click(function(event) {
if(!tooltip.hasClass(disabled)) { self.hide(event); }
return FALSE;
})
.bind('mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
});

// Redraw the tooltip when we're done
Expand All @@ -217,11 +213,20 @@ function QTip(target, options, id, attr)
'aria-atomic': TRUE
})
)
.insertBefore(elements.content);
.insertBefore(elements.content)

// Button-specific events
.delegate('.ui-state-default', 'mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
})
.delegate('.ui-state-default', 'mouseover mouseout', function(event){
$(this).toggleClass('ui-state-hover', event.type === 'mouseover');
});

// Create button if enabled
if(options.content.title.button) { createButton(); }


// Redraw the tooltip dimensions if it's rendered
else if(self.rendered){ self.redraw(); }
}
Expand Down

0 comments on commit e0b43fd

Please sign in to comment.