mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
Add dummy mouse/click handlers on bind elements so that they remain clickable on Opera Mini.
This commit is contained in:
parent
aa58b2a7e6
commit
d62864b7de
1 changed files with 16 additions and 2 deletions
|
|
@ -306,14 +306,18 @@ function hasVirtualBindings($ele)
|
|||
return false;
|
||||
}
|
||||
|
||||
function dummyMouseHandler(){}
|
||||
|
||||
function getSpecialEventObject(eventType)
|
||||
{
|
||||
var realType = eventType.substr(1);
|
||||
return {
|
||||
setup: function(data, namespace) {
|
||||
// If this is the first virtual mouse binding for this element,
|
||||
// add a bindings object to its data.
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
if (!hasVirtualBindings($this)){
|
||||
$this.data(dataPropertyName, {});
|
||||
}
|
||||
|
|
@ -329,9 +333,15 @@ function getSpecialEventObject(eventType)
|
|||
|
||||
activeDocHandlers[eventType] = (activeDocHandlers[eventType] || 0) + 1;
|
||||
if (activeDocHandlers[eventType] == 1){
|
||||
$document.bind(eventType.substr(1), mouseEventCallback);
|
||||
$document.bind(realType, mouseEventCallback);
|
||||
}
|
||||
|
||||
// Some browsers, like Opera Mini, won't dispatch mouse/click events
|
||||
// for elements unless they actually have handlers registered on them.
|
||||
// To get around this, we register dummy handlers on the elements.
|
||||
|
||||
$this.bind(realType, dummyMouseHandler);
|
||||
|
||||
// For now, if event capture is not supported, we rely on mouse handlers.
|
||||
if (eventCaptureSupported){
|
||||
// If this is the first virtual mouse binding for the document,
|
||||
|
|
@ -350,7 +360,7 @@ function getSpecialEventObject(eventType)
|
|||
|
||||
--activeDocHandlers[eventType];
|
||||
if (!activeDocHandlers[eventType]){
|
||||
$document.unbind(eventType.substr(1), mouseEventCallback);
|
||||
$document.unbind(realType, mouseEventCallback);
|
||||
}
|
||||
|
||||
if (eventCaptureSupported){
|
||||
|
|
@ -367,6 +377,10 @@ function getSpecialEventObject(eventType)
|
|||
bindings = $this.data(dataPropertyName);
|
||||
bindings[eventType] = false;
|
||||
|
||||
// Unregister the dummy event handler.
|
||||
|
||||
$this.unbind(realType, dummyMouseHandler);
|
||||
|
||||
// If this is the last virtual mouse binding on the
|
||||
// element, remove the binding data from the element.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue