Index: trunk/extensions/MobileFrontend/javascripts/opensearch.js |
— | — | @@ -1,3 +1,5 @@ |
| 2 | +MobileFrontend.opensearch = function() { |
| 3 | + |
2 | 4 | var apiUrl = '/api.php'; |
3 | 5 | |
4 | 6 | if ( scriptPath ) { |
— | — | @@ -15,23 +17,10 @@ |
16 | 18 | var sb = document.getElementById( 'searchbox' ); |
17 | 19 | |
18 | 20 | function hideResults() { |
| 21 | + var results = document.getElementById( 'results' ); |
19 | 22 | results.style.display = 'none'; |
20 | 23 | } |
21 | 24 | |
22 | | -document.body.onmousedown = function( event ) { |
23 | | - whichElement(event); |
24 | | -} |
25 | | -results.onmousedown = function( event ) { |
26 | | - whichElement(event); |
27 | | -} |
28 | | - |
29 | | -document.body.ontouchstart = function( event ) { |
30 | | - whichElement(event); |
31 | | -} |
32 | | -results.ontouchstart = function( event ) { |
33 | | - whichElement(event); |
34 | | -} |
35 | | - |
36 | 25 | function whichElement( e ) { |
37 | 26 | var targ; |
38 | 27 | if ( !e ) { |
— | — | @@ -137,6 +126,7 @@ |
138 | 127 | } |
139 | 128 | |
140 | 129 | function sqValUpdate( sqValue ) { |
| 130 | + var search = document.getElementById( 'search' ); |
141 | 131 | if ( search ) { |
142 | 132 | search.value = sqValue + ' '; |
143 | 133 | search.focus(); |
— | — | @@ -145,6 +135,7 @@ |
146 | 136 | } |
147 | 137 | |
148 | 138 | function writeResults( sections ) { |
| 139 | + var results = document.getElementById( 'results' ); |
149 | 140 | results.style.display = 'block'; |
150 | 141 | if ( !sections || sections.length < 1 ) { |
151 | 142 | results.innerHTML = "No results"; |
— | — | @@ -178,4 +169,29 @@ |
179 | 170 | suggestions.appendChild( suggestionsResult ); |
180 | 171 | } |
181 | 172 | } |
182 | | -} |
\ No newline at end of file |
| 173 | +} |
| 174 | + |
| 175 | +function init() { |
| 176 | + var results = document.getElementById( 'results' ); |
| 177 | + results.onmousedown = function( event ) { |
| 178 | + whichElement( event ); |
| 179 | + }; |
| 180 | + document.body.onmousedown = function( event ) { |
| 181 | + whichElement( event ); |
| 182 | + }; |
| 183 | + document.body.ontouchstart = function( event ) { |
| 184 | + whichElement( event ); |
| 185 | + }; |
| 186 | + results.ontouchstart = function( event ) { |
| 187 | + whichElement( event ); |
| 188 | + }; |
| 189 | +} |
| 190 | +init(); |
| 191 | + |
| 192 | +return { |
| 193 | + init: init, |
| 194 | + writeResults: writeResults, |
| 195 | + createObjectArray: createObjectArray |
| 196 | +}; |
| 197 | + |
| 198 | +}(); |
Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js |
— | — | @@ -1,3 +1,5 @@ |
| 2 | +MobileFrontend.opensearch = function() { |
| 3 | + |
2 | 4 | var apiUrl = '/api.php'; |
3 | 5 | |
4 | 6 | if ( scriptPath ) { |
— | — | @@ -109,18 +111,18 @@ |
110 | 112 | pE.style.display = 'none'; |
111 | 113 | } |
112 | 114 | |
113 | | - var removeResults = document.getElementById( 'remove-results' ); |
114 | | - if ( !removeResults ) { |
| 115 | + var removeResultsEl = document.getElementById( 'remove-results' ); |
| 116 | + if ( !removeResultsEl ) { |
115 | 117 | rrd = document.createElement( 'a' ); |
116 | | - rrd.setAttribute( 'href', '#' ); |
| 118 | + rrd.setAttribute( 'href', '#' ); |
117 | 119 | rrd.setAttribute( 'id', 'remove-results' ); |
118 | | - rrd.setAttribute( 'onclick', 'removeResults();' ); |
| 120 | + rrd.addEventListener( 'click', removeResults ); |
119 | 121 | rrdD = document.createElement( 'div' ); |
120 | 122 | rrdD.setAttribute( 'id', 'left-arrow' ); |
121 | 123 | rrd.appendChild( rrdD ); |
122 | 124 | sq.insertBefore( rrd, sq.firstChild ); |
123 | 125 | } else { |
124 | | - removeResults.style.display = 'block'; |
| 126 | + removeResultsEl.style.display = 'block'; |
125 | 127 | } |
126 | 128 | focused = true; |
127 | 129 | } |
— | — | @@ -176,20 +178,6 @@ |
177 | 179 | } |
178 | 180 | } |
179 | 181 | |
180 | | -document.body.onmousedown = function( event ) { |
181 | | - whichElement(event); |
182 | | -} |
183 | | -results.onmousedown = function( event ) { |
184 | | - whichElement(event); |
185 | | -} |
186 | | - |
187 | | -document.body.ontouchstart = function( event ) { |
188 | | - whichElement(event); |
189 | | -} |
190 | | -results.ontouchstart = function( event ) { |
191 | | - whichElement(event); |
192 | | -} |
193 | | - |
194 | 182 | function whichElement( e ) { |
195 | 183 | var targ; |
196 | 184 | if ( !e ) { |
— | — | @@ -309,6 +297,7 @@ |
310 | 298 | } |
311 | 299 | |
312 | 300 | function sqValUpdate( sqValue ) { |
| 301 | + var search = document.getElementById( 'search' ); |
313 | 302 | if ( search ) { |
314 | 303 | search.value = sqValue + ' '; |
315 | 304 | search.focus(); |
— | — | @@ -325,6 +314,7 @@ |
326 | 315 | } |
327 | 316 | |
328 | 317 | function writeResults( sections ) { |
| 318 | + var results = document.getElementById( 'results' ); |
329 | 319 | var term = htmlEntities( document.getElementById( 'search' ).value ); |
330 | 320 | results.style.display = 'block'; |
331 | 321 | if ( search ) { |
— | — | @@ -368,4 +358,30 @@ |
369 | 359 | '<strong>$1</strong>' ); |
370 | 360 | } |
371 | 361 | } |
372 | | -} |
\ No newline at end of file |
| 362 | +} |
| 363 | + |
| 364 | +function init() { |
| 365 | + var results = document.getElementById( 'results' ); |
| 366 | + results.onmousedown = function( event ) { |
| 367 | + whichElement( event ); |
| 368 | + }; |
| 369 | + document.body.onmousedown = function( event ) { |
| 370 | + whichElement( event ); |
| 371 | + }; |
| 372 | + document.body.ontouchstart = function( event ) { |
| 373 | + whichElement( event ); |
| 374 | + }; |
| 375 | + results.ontouchstart = function( event ) { |
| 376 | + whichElement( event ); |
| 377 | + }; |
| 378 | +} |
| 379 | +init(); |
| 380 | + |
| 381 | +return { |
| 382 | + init: init, |
| 383 | + writeResults: writeResults, |
| 384 | + createObjectArray: createObjectArray, |
| 385 | + removeResults: removeResults |
| 386 | +}; |
| 387 | + |
| 388 | +}(); |