Index: trunk/extensions/MobileFrontend/javascripts/opensearch.js |
— | — | @@ -18,26 +18,43 @@ |
19 | 19 | results.style.display = 'none'; |
20 | 20 | } |
21 | 21 | |
22 | | -document.onmousedown = function() { |
| 22 | +document.body.onmousedown = function() { |
23 | 23 | whichElement(event); |
24 | 24 | } |
25 | 25 | results.onmousedown = function() { |
26 | 26 | whichElement(event); |
27 | 27 | } |
28 | 28 | |
29 | | -function whichElement(e) { |
30 | | - if (!e) { |
| 29 | +document.body.ontouchstart = function() { |
| 30 | + whichElement(event); |
| 31 | +} |
| 32 | +results.ontouchstart = function() { |
| 33 | + whichElement(event); |
| 34 | +} |
| 35 | + |
| 36 | +function whichElement( e ) { |
| 37 | + var targ; |
| 38 | + if ( !e ) { |
31 | 39 | var e = window.event; |
32 | | - e.target = e.srcElement; |
33 | | - e.cancelBubble = true; |
| 40 | + } |
| 41 | + if ( e.target ) { |
| 42 | + targ = e.target; |
| 43 | + } else if ( e.srcElement ) { |
| 44 | + targ = e.srcElement; |
| 45 | + } |
| 46 | + |
| 47 | + if ( targ.nodeType == 3 ) { |
| 48 | + targ = targ.parentNode; |
| 49 | + } |
| 50 | + |
| 51 | + e.cancelBubble = true; |
| 52 | + e.stopPropagation(); |
| 53 | + |
| 54 | + if ( targ.className == "suggestion-result" || |
| 55 | + targ.className == "search-result-item" || |
| 56 | + targ.className == "sq-val-update" ) { |
34 | 57 | } else { |
35 | | - e.stopPropagation(); |
36 | | - if (e.target.className == "suggestion-result" || |
37 | | - e.target.className == "search-result-item" || |
38 | | - e.target.className == "sq-val-update" ) { |
39 | | - } else { |
40 | | - hideResults(); |
41 | | - } |
| 58 | + hideResults(); |
42 | 59 | } |
43 | 60 | } |
44 | 61 | |