r101238 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101237‎ | r101238 | r101239 >
Date:00:30, 29 October 2011
Author:preilly
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/MobileFrontend/javascripts/opensearch.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/MobileFrontend/javascripts/opensearch.js
@@ -18,26 +18,43 @@
1919 results.style.display = 'none';
2020 }
2121
22 -document.onmousedown = function() {
 22+document.body.onmousedown = function() {
2323 whichElement(event);
2424 }
2525 results.onmousedown = function() {
2626 whichElement(event);
2727 }
2828
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 ) {
3139 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" ) {
3457 } 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();
4259 }
4360 }
4461

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101237fix events for iphonepreilly00:29, 29 October 2011

Status & tagging log