r101237 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101236‎ | r101237 | r101238 >
Date:00:29, 29 October 2011
Author:preilly
Status:ok
Tags:
Comment:
fix events for iphone
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/opensearch.js (modified) (history)

Diff [purge]

Index: trunk/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

Follow-up revisions

RevisionCommit summaryAuthorDate
r101238mft r101237preilly00:30, 29 October 2011

Status & tagging log