Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js |
— | — | @@ -1,55 +0,0 @@ |
2 | | -module("MobileFrontend toggle.js: wm_toggle_section", { |
3 | | - setup: function() { |
4 | | - MFET.createFixtures(); |
5 | | - MFE.toggle.init(); |
6 | | - $("#section_1,#content_1,#anchor_1").addClass("openSection"); |
7 | | - }, |
8 | | - teardown: function() { |
9 | | - MFET.cleanFixtures(); |
10 | | - window.location.hash = "#"; |
11 | | - } |
12 | | -}); |
13 | | - |
14 | | -test("wm_toggle_section", function() { |
15 | | - strictEqual($("#section_1").hasClass("openSection"), true, "openSection class present"); |
16 | | - MFE.toggle.wm_toggle_section("1"); |
17 | | - strictEqual($("#content_1").hasClass("openSection"), false, "check content is closed on a toggle"); |
18 | | - strictEqual($("#anchor_1").hasClass("openSection"), false, "check anchor is closed on toggle"); |
19 | | - strictEqual($("#section_1").hasClass("openSection"), false, "check section is closed"); |
20 | | - |
21 | | - // perform second toggle |
22 | | - MFE.toggle.wm_toggle_section("1"); |
23 | | - strictEqual($("#content_1").hasClass("openSection"), true, "check content reopened"); |
24 | | - strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor reopened"); |
25 | | - strictEqual($("#section_1").hasClass("openSection"), true, "check section has reopened"); |
26 | | -}); |
27 | | - |
28 | | -test("wm_reveal_for_hash", function() { |
29 | | - MFE.toggle.wm_reveal_for_hash("#First_Section"); |
30 | | - applyCss(); |
31 | | - strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle"); |
32 | | - strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle"); |
33 | | - strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible"); |
34 | | - strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden"); |
35 | | -}); |
36 | | - |
37 | | -test("wm_reveal_for_hash", function() { |
38 | | - MFE.toggle.wm_reveal_for_hash("#First_Section_2"); |
39 | | - strictEqual($("#content_1").hasClass("openSection"), true, "check content is visible on a toggle"); |
40 | | - strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor is visible on toggle"); |
41 | | - strictEqual($("#section_1").hasClass("openSection"), true, "check section is marked as open"); |
42 | | -}); |
43 | | - |
44 | | -test("clicking hash links", function() { |
45 | | - MFET.triggerEvent($("[href=#First_Section_2]")[0], "click"); |
46 | | - strictEqual($("#content_1").hasClass("openSection"), true, "check content is visible on a toggle"); |
47 | | - strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor is visible on toggle"); |
48 | | - strictEqual($("#section_1").hasClass("openSection"), true, "check section marked as open"); |
49 | | -}); |
50 | | - |
51 | | -test("clicking a heading toggles it", function() { |
52 | | - var visibilityStart = $("#content_2").hasClass("openSection"); |
53 | | - MFET.triggerEvent($("#section_2")[0], "click"); |
54 | | - strictEqual(visibilityStart, false, "check content is hidden at start"); |
55 | | - strictEqual($("#content_2").hasClass("openSection"), true, "check content is shown on a toggle"); |
56 | | -}); |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/fixtures.js |
— | — | @@ -1,13 +1,3 @@ |
2 | | -var mwMobileFrontendConfig = { |
3 | | - messages: { |
4 | | - showText: "show", |
5 | | - hideText: "hide" |
6 | | - }, |
7 | | - settings: { |
8 | | - scriptPath: "/" |
9 | | - } |
10 | | -}; |
11 | | - |
12 | 2 | window.MobileFrontendTests = { |
13 | 3 | cleanFixtures: function() { |
14 | 4 | // note the ZeroRatedMobileAccess extension attaches a banner to the qunit test suite |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js |
— | — | @@ -1,22 +1,14 @@ |
2 | 2 | var MFE = MobileFrontend; |
3 | 3 | var MFET = window.MobileFrontendTests; |
4 | 4 | |
5 | | -module("MobileFrontend application.js: utils", { |
6 | | - setup: function() { |
7 | | - var section = '<div class="t_section_heading"></div>'; |
8 | | - $('<div id="mfetest">' + section + '<div id="t_section_1">' + section + '</div>').appendTo(document.body); |
9 | | - }, |
10 | | - teardown: function() { |
11 | | - $("#mfetest").remove(); |
12 | | - } |
13 | | -}); |
| 5 | +module("MobileFrontend application.js: utils"); |
14 | 6 | |
15 | 7 | test("Basic selector support (#id)", function() { |
16 | | - strictEqual(MFE.utils("#t_section_1").length, 1, "only one element matches this selector"); |
| 8 | + strictEqual(MFE.utils("#section_1").length, 1, "only one element matches this selector"); |
17 | 9 | }); |
18 | 10 | |
19 | 11 | test("Basic selector support (.className)", function() { |
20 | | - strictEqual(MFE.utils(".t_section_heading").length, 2, "only two elements matches this selector"); |
| 12 | + strictEqual(MFE.utils(".section_heading").length, 2, "only two elements matches this selector"); |
21 | 13 | }); |
22 | 14 | |
23 | 15 | test("Basic selector support (tag name)", function() { |
— | — | @@ -65,3 +57,61 @@ |
66 | 58 | strictEqual(visible3, false, "toggle"); |
67 | 59 | }); |
68 | 60 | |
| 61 | +module("MobileFrontend application.js: wm_toggle_section", { |
| 62 | + setup: function() { |
| 63 | + MFET.createFixtures(); |
| 64 | + MFE.init(); |
| 65 | + $("#content_1,#anchor_1,#section_1 .hide").hide(); |
| 66 | + $("#section_1 .show").show(); |
| 67 | + }, |
| 68 | + teardown: function() { |
| 69 | + MFET.cleanFixtures(); |
| 70 | + window.location.hash = "#"; |
| 71 | + } |
| 72 | +}); |
| 73 | + |
| 74 | +test("wm_toggle_section", function() { |
| 75 | + MFE.wm_toggle_section("1"); |
| 76 | + strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle"); |
| 77 | + strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle"); |
| 78 | + strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible"); |
| 79 | + strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden"); |
| 80 | + |
| 81 | + // perform second toggle |
| 82 | + MFE.wm_toggle_section("1"); |
| 83 | + strictEqual($("#content_1").is(":visible"), false, "check content is hidden on a toggle"); |
| 84 | + strictEqual($("#anchor_1").is(":visible"), false, "check anchor is hidden on toggle"); |
| 85 | + strictEqual($("#section_1 .hide").is(":visible"), false, "check hide button now hidden"); |
| 86 | + strictEqual($("#section_1 .show").is(":visible"), true, "check show button now visible"); |
| 87 | +}); |
| 88 | + |
| 89 | +test("wm_reveal_for_hash", function() { |
| 90 | + MFE.wm_reveal_for_hash("#First_Section"); |
| 91 | + strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle"); |
| 92 | + strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle"); |
| 93 | + strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible"); |
| 94 | + strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden"); |
| 95 | +}); |
| 96 | + |
| 97 | +test("wm_reveal_for_hash", function() { |
| 98 | + MFE.wm_reveal_for_hash("#First_Section_2"); |
| 99 | + strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle"); |
| 100 | + strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle"); |
| 101 | + strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible"); |
| 102 | + strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden"); |
| 103 | +}); |
| 104 | + |
| 105 | +test("clicking hash links", function() { |
| 106 | + MFET.triggerEvent($("[href=#First_Section_2]")[0], "click"); |
| 107 | + strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle"); |
| 108 | + strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle"); |
| 109 | + strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible"); |
| 110 | + strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden"); |
| 111 | +}); |
| 112 | + |
| 113 | +test("clicking a heading toggles it", function() { |
| 114 | + var visibilityStart = $("#content_1").is(":visible"); |
| 115 | + MFET.triggerEvent($("#section_1")[0], "click"); |
| 116 | + strictEqual(visibilityStart, false, "check content is hidden at start"); |
| 117 | + strictEqual($("#content_1").is(":visible"), true, "check content is hidden on a toggle"); |
| 118 | +}); |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php |
— | — | @@ -219,14 +219,15 @@ |
220 | 220 | array( false, null, array() ), |
221 | 221 | array( true, 'webkit', array() ), |
222 | 222 | array( false, 'webkit', array( 'action' => 'edit' ) ), |
223 | | - array( false, 'webkit', array( 'useformat' => 'desktop' ) ), |
| 223 | + array( false, 'webkit', array( 'mobileaction' => 'view_normal_site' ) ), |
224 | 224 | array( true, null, array( 'useformat' => 'mobile-wap' ) ), |
225 | 225 | array( false, null, array( 'useformat' => 'mobile-wap', 'action' => 'edit' ) ), |
226 | 226 | array( false, null, array( 'useformat' => 'mobile-wap', 'action' => 'history' ) ), |
227 | | - array( false, null, array( 'useformat' => 'desktop' ) ), |
| 227 | + array( false, null, array( 'useformat' => 'mobile-wap', 'mobileaction' => 'view_normal_site' ) ), |
228 | 228 | array( true, null, array( 'useformat' => 'mobile' ) ), |
229 | 229 | array( false, null, array( 'useformat' => 'mobile', 'action' => 'edit' ) ), |
230 | 230 | array( false, null, array( 'useformat' => 'mobile', 'action' => 'history' ) ), |
| 231 | + array( false, null, array( 'useformat' => 'mobile', 'mobileaction' => 'view_normal_site' ) ), |
231 | 232 | ); |
232 | 233 | } |
233 | 234 | |
— | — | @@ -301,65 +302,4 @@ |
302 | 303 | array( 'edit' ), |
303 | 304 | ); |
304 | 305 | } |
305 | | - |
306 | | - /** |
307 | | - * @dataProvider getUseFormatProvider |
308 | | - */ |
309 | | - public function testGetUseFormat( $explicit, $requestParam, $expected ) { |
310 | | - global $wgRequest, $wgExtMobileFrontend; |
311 | | - $wgRequest->setVal( 'useformat', $requestParam ); |
312 | | - $wgExtMobileFrontend->setUseFormat( $explicit ); |
313 | | - $this->assertEquals( $expected, $wgExtMobileFrontend->getUseFormat() ); |
314 | | - } |
315 | | - |
316 | | - public function getUseFormatProvider() { |
317 | | - return array( |
318 | | - array( 'mobile', null, 'mobile' ), |
319 | | - array( null, 'mobile', 'mobile' ), |
320 | | - array( null, null, '' ), |
321 | | - array( 'desktop', 'mobile', 'desktop' ), |
322 | | - ); |
323 | | - } |
324 | | - |
325 | | - public function testGetUseFormatCookieExpiry() { |
326 | | - global $wgExtMobileFrontend, $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry; |
327 | | - $getUseFormatCookieExpiry = self::getMethod( 'getUseFormatCookieExpiry' ); |
328 | | - |
329 | | - $origMFCookieExpiry = $wgMobileFrontendFormatCookieExpiry; |
330 | | - $startTime = time(); |
331 | | - $wgMobileFrontendFormatCookieExpiry = 60; |
332 | | - $mfCookieExpected = $startTime + 60; |
333 | | - $this->assertTrue( $mfCookieExpected == $getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime ) ), 'Using MobileFrontend expiry.' ); |
334 | | - |
335 | | - $wgMobileFrontendFormatCookieExpiry = null; |
336 | | - $defaultMWCookieExpected = $startTime + $wgCookieExpiration; |
337 | | - $this->assertTrue( $defaultMWCookieExpected == $getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime ) ), 'Using default MediaWiki cookie expiry.' ); |
338 | | - |
339 | | - // reset global back to original value |
340 | | - $wgMobileFrontendFormatCookieExpiry = $origMFCookieExpiry; |
341 | | - } |
342 | | - |
343 | | - /** |
344 | | - * @outputBuffering enabled |
345 | | - */ |
346 | | - /*public function testCookie() { |
347 | | - global $wgRequest; |
348 | | - $wgRequest->response()->setCookie( 'foo', 'bar' ); |
349 | | - $this->assertEquals( $wgRequest->getCookie( 'foo' ), 'bar' ); |
350 | | - setcookie( 'foobar', 'pants' ); |
351 | | - $this->asertEquals( $_COOKIE[ 'foobar' ], 'pants' ); |
352 | | - } |
353 | | - |
354 | | - /** |
355 | | - * NB this will not work as PHPUnit seems to not make it possible to set |
356 | | - * and retrieve cookies. Note above test, testCookie() - both assertions |
357 | | - * currently fail, making testing ExtMobileFrontend::checkUserFormatCookie() |
358 | | - * impossible. |
359 | | - * |
360 | | - * @outputBuffering enabled |
361 | | - */ |
362 | | - /*public function testCheckUseFormatCookie() { |
363 | | - |
364 | | - } |
365 | | - */ |
366 | 306 | } |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/library/WURFL/Handlers/Utils.php |
— | — | @@ -174,12 +174,12 @@ |
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | | - * The nth($ordinal) occurrence of $needle in $haystack or -1 if no match is found |
| 178 | + * The nth($ordinal) occurance of $needle in $haystack or -1 if no match is found |
179 | 179 | * @param string $haystack |
180 | 180 | * @param string $needle |
181 | 181 | * @param int $ordinal |
182 | 182 | * @throws InvalidArgumentException |
183 | | - * @return int Char index of occurrence |
| 183 | + * @return int Char index of occurance |
184 | 184 | */ |
185 | 185 | public static function ordinalIndexOf($haystack, $needle, $ordinal) { |
186 | 186 | if (is_null ( $haystack ) || empty ( $haystack )) { |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | | - * First occurrence of a / character |
| 210 | + * First occurance of a / character |
211 | 211 | * @param string $string Haystack |
212 | 212 | * @return int Char index |
213 | 213 | */ |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | | - * Second occurrence of a / character |
| 220 | + * Second occurance of a / character |
221 | 221 | * @param string $string Haystack |
222 | 222 | * @return int Char index |
223 | 223 | */ |
— | — | @@ -228,7 +228,7 @@ |
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
232 | | - * First occurrence of a space character |
| 232 | + * First occurance of a space character |
233 | 233 | * @param string $string Haystack |
234 | 234 | * @return int Char index |
235 | 235 | */ |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | | - * First occurrence of a ; character or length |
| 242 | + * First occurance of a ; character or length |
243 | 243 | * @param string $string Haystack |
244 | 244 | * @return int Char index |
245 | 245 | */ |
— | — | @@ -247,7 +247,7 @@ |
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
251 | | - * First occurrence of $toMatch string or length |
| 251 | + * First occurance of $toMatch string or length |
252 | 252 | * @param string $string Haystack |
253 | 253 | * @param string $toMatch Needle |
254 | 254 | * @return int Char index |
— | — | @@ -339,4 +339,4 @@ |
340 | 340 | public static function removeLocale($userAgent) { |
341 | 341 | return preg_replace ( self::LANGUAGE_PATTERN, "", $userAgent, 1 ); |
342 | 342 | } |
343 | | -} |
| 343 | +} |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | public static $searchField; |
28 | 28 | public static $disableImagesURL; |
29 | 29 | public static $enableImagesURL; |
| 30 | + public static $disableMobileSiteURL; |
30 | 31 | public static $viewNormalSiteURL; |
31 | 32 | public static $currentURL; |
32 | 33 | public static $displayNoticeId; |
— | — | @@ -43,7 +44,6 @@ |
44 | 45 | public static $logoutHtml; |
45 | 46 | public static $loginHtml; |
46 | 47 | public static $zeroRatedBanner; |
47 | | - public static $useFormatCookieName; |
48 | 48 | |
49 | 49 | protected $useFormat; |
50 | 50 | |
— | — | @@ -72,6 +72,7 @@ |
73 | 73 | 'mobile-frontend-hide-button', |
74 | 74 | 'mobile-frontend-back-to-top-of-section', |
75 | 75 | 'mobile-frontend-regular-site', |
| 76 | + 'mobile-frontend-perm-stop-redirect', |
76 | 77 | 'mobile-frontend-home-button', |
77 | 78 | 'mobile-frontend-random-button', |
78 | 79 | 'mobile-frontend-are-you-sure', |
— | — | @@ -191,7 +192,7 @@ |
192 | 193 | * @return bool |
193 | 194 | */ |
194 | 195 | public function addMobileFooter( &$obj, &$tpl ) { |
195 | | - global $wgRequest, $wgServer; |
| 196 | + global $wgRequest; |
196 | 197 | wfProfileIn( __METHOD__ ); |
197 | 198 | |
198 | 199 | $title = $obj->getTitle(); |
— | — | @@ -203,7 +204,6 @@ |
204 | 205 | $this->removeQueryStringParameter( $wgRequest->appendQuery( 'useformat=mobile' ), 'mobileaction' ) |
205 | 206 | ); |
206 | 207 | |
207 | | - $mobileViewUrl = $this->getMobileUrl( $wgServer . $mobileViewUrl ); |
208 | 208 | $tpl->set( 'mobileview', "<a href='{$mobileViewUrl}' class='noprint'>" . wfMsg( 'mobile-frontend-view' ) . "</a>" ); |
209 | 209 | $footerlinks['places'][] = 'mobileview'; |
210 | 210 | $tpl->set( 'footerlinks', $footerlinks ); |
— | — | @@ -231,7 +231,8 @@ |
232 | 232 | |
233 | 233 | self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' ); |
234 | 234 | self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' ); |
235 | | - self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'useformat=desktop' ); |
| 235 | + self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=disable_mobile_site' ); |
| 236 | + self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=view_normal_site' ); |
236 | 237 | self::$currentURL = $wgRequest->getFullRequestURL(); |
237 | 238 | self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 'mobileaction=leave_feedback' ); |
238 | 239 | |
— | — | @@ -476,6 +477,12 @@ |
477 | 478 | exit(); |
478 | 479 | } |
479 | 480 | |
| 481 | + if ( $mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML' ) { |
| 482 | + echo $this->renderDisableMobileSiteXHTML(); |
| 483 | + wfProfileOut( __METHOD__ ); |
| 484 | + exit(); |
| 485 | + } |
| 486 | + |
480 | 487 | if ( $mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML' ) { |
481 | 488 | echo $this->renderOptInMobileSiteXHTML(); |
482 | 489 | wfProfileOut( __METHOD__ ); |
— | — | @@ -709,7 +716,6 @@ |
710 | 717 | } |
711 | 718 | $wgOut->addVaryHeader( 'Cookie' ); |
712 | 719 | $wgOut->addVaryHeader( 'X-Carrier' ); |
713 | | - $wgOut->addVaryHeader( 'X-Images' ); |
714 | 720 | wfProfileOut( __METHOD__ ); |
715 | 721 | return true; |
716 | 722 | } |
— | — | @@ -851,6 +857,54 @@ |
852 | 858 | } |
853 | 859 | |
854 | 860 | /** |
| 861 | + * @return string |
| 862 | + */ |
| 863 | + private function renderDisableMobileSiteXHTML() { |
| 864 | + wfProfileIn( __METHOD__ ); |
| 865 | + if ( $this->contentFormat == 'XHTML' ) { |
| 866 | + $this->getMsg(); |
| 867 | + $areYouSure = self::$messages['mobile-frontend-are-you-sure']; |
| 868 | + $explainDisable = self::$messages['mobile-frontend-explain-disable']; |
| 869 | + $disableButton = self::$messages['mobile-frontend-disable-button']; |
| 870 | + $backButton = self::$messages['mobile-frontend-back-button']; |
| 871 | + $htmlTitle = $areYouSure; |
| 872 | + $title = $areYouSure; |
| 873 | + $searchTemplate = $this->getSearchTemplate(); |
| 874 | + $searchWebkitHtml = $searchTemplate->getHTML(); |
| 875 | + $footerTemplate = $this->getFooterTemplate(); |
| 876 | + $footerHtml = $footerTemplate->getHTML(); |
| 877 | + $disableTemplate = new DisableTemplate(); |
| 878 | + $options = array( |
| 879 | + 'currentURL' => self::$currentURL, |
| 880 | + 'mobileRedirectFormAction' => self::$mobileRedirectFormAction, |
| 881 | + 'areYouSure' => $areYouSure, |
| 882 | + 'explainDisable' => $explainDisable, |
| 883 | + 'disableButton' => $disableButton, |
| 884 | + 'backButton' => $backButton, |
| 885 | + 'htmlTitle' => $htmlTitle, |
| 886 | + 'title' => $title, |
| 887 | + ); |
| 888 | + $disableTemplate->setByArray( $options ); |
| 889 | + $disableHtml = $disableTemplate->getHTML(); |
| 890 | + |
| 891 | + $contentHtml = $disableHtml; |
| 892 | + $applicationTemplate = $this->getApplicationTemplate(); |
| 893 | + $options = array( |
| 894 | + 'htmlTitle' => $htmlTitle, |
| 895 | + 'searchWebkitHtml' => $searchWebkitHtml, |
| 896 | + 'contentHtml' => $contentHtml, |
| 897 | + 'footerHtml' => $footerHtml, |
| 898 | + ); |
| 899 | + $applicationTemplate->setByArray( $options ); |
| 900 | + $applicationHtml = $applicationTemplate->getHTML(); |
| 901 | + wfProfileOut( __METHOD__ ); |
| 902 | + return $applicationHtml; |
| 903 | + } |
| 904 | + wfProfileOut( __METHOD__ ); |
| 905 | + return ''; |
| 906 | + } |
| 907 | + |
| 908 | + /** |
855 | 909 | * @return DomElement |
856 | 910 | */ |
857 | 911 | public function renderLogin() { |
— | — | @@ -1110,6 +1164,7 @@ |
1111 | 1165 | $options = array( |
1112 | 1166 | 'messages' => self::$messages, |
1113 | 1167 | 'leaveFeedbackURL' => self::$leaveFeedbackURL, |
| 1168 | + 'disableMobileSiteURL' => self::$disableMobileSiteURL, |
1114 | 1169 | 'viewNormalSiteURL' => self::$viewNormalSiteURL, |
1115 | 1170 | 'disableImages' => self::$disableImages, |
1116 | 1171 | 'disableImagesURL' => self::$disableImagesURL, |
— | — | @@ -1165,8 +1220,6 @@ |
1166 | 1221 | 'zeroRatedBanner' => self::$zeroRatedBanner, |
1167 | 1222 | 'showText' => self::$messages[ 'mobile-frontend-show-button' ], |
1168 | 1223 | 'hideText' => self::$messages[ 'mobile-frontend-hide-button' ], |
1169 | | - 'useFormatCookieName' => self::$useFormatCookieName, |
1170 | | - 'useFormatCookieDuration' => $this->getUseFormatCookieDuration(), |
1171 | 1224 | ); |
1172 | 1225 | $applicationTemplate->setByArray( $options ); |
1173 | 1226 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1223,7 +1276,6 @@ |
1224 | 1277 | $testModules['qunit']['ext.mobilefrontend.tests'] = array( |
1225 | 1278 | 'scripts' => array( 'tests/js/fixtures.js', 'javascripts/application.js', |
1226 | 1279 | 'javascripts/opensearch.js', 'javascripts/banner.js', |
1227 | | - 'javascripts/toggle.js', 'tests/js/test_toggle.js', |
1228 | 1280 | 'tests/js/test_application.js', 'tests/js/test_opensearch.js', 'tests/js/test_banner.js' ), |
1229 | 1281 | 'dependencies' => array( ), |
1230 | 1282 | 'localBasePath' => dirname( __FILE__ ), |
— | — | @@ -1388,20 +1440,15 @@ |
1389 | 1441 | } |
1390 | 1442 | |
1391 | 1443 | protected function shouldDisplayMobileView() { |
1392 | | - // always display desktop view if it's explicitly requested |
1393 | | - $useFormat = $this->getUseFormat(); |
1394 | | - if ( $useFormat == 'desktop' ) { |
| 1444 | + if ( !$this->isMobileDevice() && !$this->isFauxMobileDevice() ) { |
1395 | 1445 | return false; |
1396 | 1446 | } |
1397 | | - |
1398 | | - if ( !$this->isMobileDevice() && !$this->isFauxMobileDevice() ) { |
1399 | | - return false; |
1400 | | - } |
1401 | 1447 | |
1402 | 1448 | $action = $this->getAction(); |
| 1449 | + $mobileAction = $this->getMobileAction(); |
1403 | 1450 | |
1404 | | - |
1405 | | - if ( $action === 'edit' || $action === 'history' ) { |
| 1451 | + if ( $action === 'edit' || $action === 'history' || |
| 1452 | + $mobileAction === 'view_normal_site' ) { |
1406 | 1453 | return false; |
1407 | 1454 | } |
1408 | 1455 | |
— | — | @@ -1449,80 +1496,33 @@ |
1450 | 1497 | } |
1451 | 1498 | |
1452 | 1499 | public function checkUseFormatCookie() { |
1453 | | - global $wgRequest, $wgCookiePrefix; |
| 1500 | + global $wgRequest; |
1454 | 1501 | |
1455 | | - if ( !isset( self::$useFormatCookieName )) { |
1456 | | - self::$useFormatCookieName = 'mf_useformat'; |
1457 | | - } |
1458 | | - |
1459 | 1502 | $useFormat = $this->getUseFormat(); |
1460 | 1503 | $useFormatFromCookie = $wgRequest->getCookie( 'mf_useformat' ); |
1461 | | - |
1462 | | - // fetch format from cookie and set it if one is not otherwise specified |
1463 | 1504 | if( !strlen( $useFormat ) && !is_null( $useFormatFromCookie ) ) { |
1464 | 1505 | $this->setUseFormat( $useFormatFromCookie ); |
1465 | 1506 | } |
1466 | 1507 | |
1467 | | - // set appropriate cookie if necessary |
1468 | | - if ( ( $useFormatFromCookie != 'mobile' && $useFormat == 'mobile' ) || |
1469 | | - ( $useFormatFromCookie != 'desktop' && $useFormat == 'desktop' ) ) { |
1470 | | - $this->setUseFormatCookie( $useFormat ); |
| 1508 | + // if we should not be displaying the mobile view, make sure cookies are unset etc. |
| 1509 | + if ( !$this->shouldDisplayMobileView() ) { |
| 1510 | + // make sure cookie is unset for appropriate mobile actions |
| 1511 | + $mobileAction = $this->getMobileAction(); |
| 1512 | + if ( in_array( $mobileAction, array( 'view_normal_site', 'disable_mobile_site' ) ) ) { |
| 1513 | + $wgRequest->response()->setCookie( 'mf_useformat', false, time() - 3600 ); |
| 1514 | + } |
| 1515 | + |
| 1516 | + // make sure useformat is unset |
| 1517 | + $this->setUseFormat( '' ); |
| 1518 | + return; |
1471 | 1519 | } |
1472 | | - } |
1473 | | - |
1474 | | - /** |
1475 | | - * Set the mf_useformat cookie |
1476 | | - * |
1477 | | - * This cookie can determine whether or not a user should see the mobile |
1478 | | - * version of pages. |
1479 | | - * |
1480 | | - * @param string The format to store in the cookie |
1481 | | - */ |
1482 | | - protected function setUseFormatCookie( $useFormat ) { |
1483 | | - global $wgRequest, $wgCookiePath, $wgCookieSecure, $wgCookieDomain; |
1484 | | - $expiry = $this->getUseFormatCookieExpiry(); |
1485 | 1520 | |
1486 | | - // use regular php setcookie() rather than WebResponse::setCookie |
1487 | | - // so we can ignore $wgCookieHttpOnly since the protection it provides |
1488 | | - // is irrelevant for this cookie. |
1489 | | - setcookie( self::$useFormatCookieName, $useFormat, $expiry, $wgCookiePath, $wgCookieDomain, $wgCookieSecure ); |
| 1521 | + // if getUseFormat and no cookie set, set the cookie |
| 1522 | + if ( is_null( $useFormatFromCookie ) && strlen( $useFormat ) ) { |
| 1523 | + $wgRequest->response()->setCookie( 'mf_useformat', $useFormat, 0 ); |
| 1524 | + } |
1490 | 1525 | } |
1491 | 1526 | |
1492 | | - /** |
1493 | | - * Get the expiration time for the mf_useformat cookie |
1494 | | - * |
1495 | | - * @param int The base time (in seconds since Epoch) from which to calculate |
1496 | | - * cookie expiration. If null, time() is used. |
1497 | | - * @return int The time (in seconds since Epoch) that the cookie should expire |
1498 | | - */ |
1499 | | - protected function getUseFormatCookieExpiry( $startTime=null ) { |
1500 | | - $cookieDuration = $this->getUseFormatCookieDuration(); |
1501 | | - if ( intval( $startTime ) === 0 ) $startTime = time(); |
1502 | | - $expiry = $startTime + $cookieDuration; |
1503 | | - return $expiry; |
1504 | | - } |
1505 | | - |
1506 | | - public function getCacheVaryCookies( $out, &$cookies ) { |
1507 | | - global $wgCookiePrefix; |
1508 | | - $cookies[] = 'mf_useformat'; |
1509 | | - return true; |
1510 | | - } |
1511 | | - |
1512 | | - /** |
1513 | | - * Determine the duration the cookie should last. |
1514 | | - * |
1515 | | - * If $wgMobileFrontendFormatcookieExpiry has a non-0 value, use that |
1516 | | - * for the duration. Otherwise, fall back to $wgCookieExpiration. |
1517 | | - * |
1518 | | - * @return int The number of seconds for which the cookie should last. |
1519 | | - */ |
1520 | | - protected function getUseFormatCookieDuration() { |
1521 | | - global $wgMobileFrontendFormatCookieExpiry, $wgCookieExpiration; |
1522 | | - $cookieDuration = ( abs( intval( $wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ? |
1523 | | - $wgMobileFrontendFormatCookieExpiry : $wgCookieExpiration; |
1524 | | - return $cookieDuration; |
1525 | | - } |
1526 | | - |
1527 | 1527 | public function getVersion() { |
1528 | 1528 | return __CLASS__ . ': $Id$'; |
1529 | 1529 | } |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/api/ApiQueryExcerpts.php |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | |
199 | 199 | public function getExamples() { |
200 | 200 | return array( |
201 | | - 'api.php?action=query&prop=excerpts&exlength=175&titles=Therion' => 'Get a 175-character excerpt', |
| 201 | + 'api.php?action=query&prop=excerpt&length=175&titles=Therion' => 'Get a 175-character excerpt', |
202 | 202 | ); |
203 | 203 | } |
204 | 204 | |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js |
— | — | @@ -1,86 +0,0 @@ |
2 | | -if( typeof jQuery !== 'undefined' ) { |
3 | | - MobileFrontend.references = (function($) { |
4 | | - var calculatePosition, hashtest, options = {}; |
5 | | - |
6 | | - hashtest = window.location.hash.substr(1).match(/refspeed:([0-9]*)/); |
7 | | - options.animationSpeed = hashtest ? parseInt( hashtest[1], 10 ) : 500; |
8 | | - hashtest = window.location.hash.substr(1).match(/refanimation:([a-z]*)/); |
9 | | - options.animation = hashtest ? hashtest[1] : null; |
10 | | - |
11 | | - function collect() { |
12 | | - var references = {}; |
13 | | - $( 'ol.references li' ).each(function(i, el) { |
14 | | - references[ $(el).attr( 'id' ) ] = { |
15 | | - html: $(el).html(), |
16 | | - label: i + 1 |
17 | | - }; |
18 | | - }); |
19 | | - return references; |
20 | | - } |
21 | | - |
22 | | - // TODO: only apply to places that need it |
23 | | - // http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html |
24 | | - // https://github.com/Modernizr/Modernizr/issues/167 |
25 | | - calculatePosition = function() { |
26 | | - var h = $( '#mf-references' ).outerHeight(); |
27 | | - $( '#mf-references' ).css( { |
28 | | - top: ( window.innerHeight + window.pageYOffset ) - h, |
29 | | - bottom: 'auto', |
30 | | - position: 'absolute' |
31 | | - } ); |
32 | | - }; |
33 | | - $( document ).scroll(calculatePosition); |
34 | | - |
35 | | - function init() { |
36 | | - $( '<div id="mf-references"><div></div></div>' ).hide().appendTo( document.body ); |
37 | | - var close = function() { |
38 | | - var top; |
39 | | - lastLink = null; |
40 | | - if( options.animation === 'none' ) { |
41 | | - $( '#mf-references' ).hide(); |
42 | | - } else if( options.animation === 'slide' ){ |
43 | | - top = window.innerHeight + window.pageYOffset; |
44 | | - $( '#mf-references' ).show().animate( { top: top }, options.animationSpeed ); |
45 | | - } else { |
46 | | - $( '#mf-references' ).fadeOut( options.animationSpeed ); |
47 | | - } |
48 | | - }, lastLink; |
49 | | - $( '<button>close</button>' ).click( close ).appendTo( '#mf-references' ); |
50 | | - $( '.mw-cite-backlink a' ).click( close ); |
51 | | - |
52 | | - var data, html, href, references = collect(); |
53 | | - $( 'sup a' ).unbind('click').click( function(ev) { |
54 | | - var top, oh; |
55 | | - href = $(this).attr( 'href' ); |
56 | | - data = href && href.charAt(0) === '#' ? |
57 | | - references[ href.substr( 1, href.length ) ] : null; |
58 | | - |
59 | | - if( !$("#mf-references").is(":visible") || lastLink !== href) { |
60 | | - lastLink = href; |
61 | | - if( data ) { |
62 | | - html = '<h3>[' + data.label + ']</h3>' + data.html; |
63 | | - } else { |
64 | | - html = $( '<a />' ).text( $(this).text() ). |
65 | | - attr( 'href', href ).appendTo('<div />').parent().html(); |
66 | | - } |
67 | | - $( '#mf-references div' ).html( html ); |
68 | | - calculatePosition(); |
69 | | - if( options.animation === 'none' ) { |
70 | | - $( '#mf-references' ).show(); |
71 | | - } else if( options.animation === 'slide' ){ |
72 | | - top = window.innerHeight + window.pageYOffset; |
73 | | - oh = $( '#mf-references' ).outerHeight(); |
74 | | - $( '#mf-references' ).show().css( { 'top': top } ). |
75 | | - animate( { top: top - oh }, options.animationSpeed ); |
76 | | - } else { |
77 | | - $( '#mf-references' ).fadeIn( options.animationSpeed ); |
78 | | - } |
79 | | - } else { |
80 | | - close(); |
81 | | - } |
82 | | - ev.preventDefault(); |
83 | | - }); |
84 | | - } |
85 | | - init(); |
86 | | - })(jQuery); |
87 | | -} |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js |
— | — | @@ -1,97 +0,0 @@ |
2 | | -/*global document, window */ |
3 | | -/*jslint sloppy: true, white:true, maxerr: 50, indent: 4, plusplus: true*/ |
4 | | -MobileFrontend.toggle = (function() { |
5 | | - var u = MobileFrontend.utils; |
6 | | - |
7 | | - function init() { |
8 | | - var i, a, heading, btns, |
9 | | - sectionHeadings = u( '.section_heading' ); |
10 | | - |
11 | | - // TODO: remove in future - currently enables toggling in Wikipedia Mobile App v < 1.1 |
12 | | - window.wm_toggle_section = wm_toggle_section; |
13 | | - btns = u( '.section_heading button' ); |
14 | | - for( i = 0; i < btns.length; i++ ) { |
15 | | - u( btns[i] ).remove(); |
16 | | - } |
17 | | - |
18 | | - function openSectionHandler() { |
19 | | - var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
20 | | - if( sectionNumber > -1 ) { |
21 | | - wm_toggle_section( sectionNumber ); |
22 | | - } |
23 | | - } |
24 | | - function createButton( visible ) { |
25 | | - var btn, label; |
26 | | - btn = document.createElement( 'button' ); |
27 | | - label = document.createTextNode( MobileFrontend.message( visible ? 'expand-section' : 'collapse-section' ) ); |
28 | | - btn.className = visible ? 'show' : 'hide'; |
29 | | - btn.appendChild( label ); |
30 | | - return btn; |
31 | | - } |
32 | | - if(!sectionHeadings) { |
33 | | - sectionHeadings = []; |
34 | | - } else { |
35 | | - u( document.body ).addClass( 'togglingEnabled' ); |
36 | | - } |
37 | | - for( i = 0; i < sectionHeadings.length; i++ ) { |
38 | | - heading = sectionHeadings[i]; |
39 | | - heading.removeAttribute( 'onclick' ); // TODO: remove any legacy onclick handlers |
40 | | - heading.insertBefore( createButton( true ), heading.firstChild ); |
41 | | - heading.insertBefore( createButton( false ), heading.firstChild ); |
42 | | - u( heading ).bind( 'click', openSectionHandler ); |
43 | | - } |
44 | | - |
45 | | - function checkHash() { |
46 | | - var hash = this.hash || document.location.hash; |
47 | | - if ( hash.indexOf( '#' ) === 0 ) { |
48 | | - wm_reveal_for_hash( hash ); |
49 | | - } |
50 | | - } |
51 | | - checkHash(); |
52 | | - for ( a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
53 | | - u( a[i] ).bind( 'click', checkHash ); |
54 | | - } |
55 | | - } |
56 | | - |
57 | | - function wm_reveal_for_hash( hash ) { |
58 | | - var targetel = document.getElementById( hash.substr(1) ), |
59 | | - p, section_idx; |
60 | | - if ( targetel ) { |
61 | | - p = targetel; |
62 | | - while ( p && !u(p).hasClass( 'content_block' ) && |
63 | | - !u(p).hasClass( 'section_heading' ) ) { |
64 | | - p = p.parentNode; |
65 | | - } |
66 | | - if ( p && p.style.display !== 'block' ) { |
67 | | - section_idx = parseInt( p.id.split( '_' )[1], 10 ); |
68 | | - wm_toggle_section( section_idx ); |
69 | | - } |
70 | | - } |
71 | | - } |
72 | | - |
73 | | - function wm_toggle_section( section_id ) { |
74 | | - var b = document.getElementById( 'section_' + section_id ), |
75 | | - bb = b.getElementsByTagName( 'button' ), i, s, e; |
76 | | - if( u(b).hasClass( 'openSection' ) ) { |
77 | | - u(b).removeClass( 'openSection' ); |
78 | | - } else { |
79 | | - u(b).addClass( 'openSection' ); |
80 | | - } |
81 | | - for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
82 | | - e = document.getElementById( d[i] + section_id ); |
83 | | - if ( e && u( e ).hasClass( 'openSection' ) ) { |
84 | | - u( e ).removeClass( 'openSection' ) |
85 | | - } else { |
86 | | - u( e ).addClass( 'openSection' ) |
87 | | - } |
88 | | - } |
89 | | - } |
90 | | - |
91 | | - init(); |
92 | | - return { |
93 | | - wm_reveal_for_hash: wm_reveal_for_hash, |
94 | | - wm_toggle_section: wm_toggle_section, |
95 | | - init: init |
96 | | - }; |
97 | | - |
98 | | -})(); |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.min.js |
— | — | @@ -1 +0,0 @@ |
2 | | -if(typeof jQuery!=="undefined"){MobileFrontend.references=(function(d){var b,f,a={};f=window.location.hash.substr(1).match(/refspeed:([0-9]*)/);a.animationSpeed=f?parseInt(f[1],10):500;f=window.location.hash.substr(1).match(/refanimation:([a-z]*)/);a.animation=f?f[1]:null;function c(){var g={};d("ol.references li").each(function(h,j){g[d(j).attr("id")]={html:d(j).html(),label:h+1}});return g}b=function(){var g=d("#mf-references").outerHeight();d("#mf-references").css({top:(window.innerHeight+window.pageYOffset)-g,bottom:"auto",position:"absolute"})};d(document).scroll(b);function e(){d('<div id="mf-references"><div></div></div>').hide().appendTo(document.body);var l=function(){var m;j=null;if(a.animation==="none"){d("#mf-references").hide()}else{if(a.animation==="slide"){m=window.innerHeight+window.pageYOffset;d("#mf-references").show().animate({top:m},a.animationSpeed)}else{d("#mf-references").fadeOut(a.animationSpeed)}}},j;d("<button>close</button>").click(l).appendTo("#mf-references");d(".mw-cite-backlink a").click(l);var k,i,g,h=c();d("sup a").unbind("click").click(function(m){var o,n;g=d(this).attr("href");k=g&&g.charAt(0)==="#"?h[g.substr(1,g.length)]:null;if(!d("#mf-references").is(":visible")||j!==g){j=g;if(k){i="<h3>["+k.label+"]</h3>"+k.html}else{i=d("<a />").text(d(this).text()).attr("href",g).appendTo("<div />").parent().html()}d("#mf-references div").html(i);b();if(a.animation==="none"){d("#mf-references").show()}else{if(a.animation==="slide"){o=window.innerHeight+window.pageYOffset;n=d("#mf-references").outerHeight();d("#mf-references").show().css({top:o}).animate({top:o-n},a.animationSpeed)}else{d("#mf-references").fadeIn(a.animationSpeed)}}}else{l()}m.preventDefault()})}e()})(jQuery)}; |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js |
— | — | @@ -1 +0,0 @@ |
2 | | -MobileFrontend.toggle=(function(){var a=MobileFrontend.utils;function c(){var l,f,n,m,h=a(".section_heading");window.wm_toggle_section=b;m=a(".section_heading button");for(l=0;l<m.length;l++){a(m[l]).remove()}function k(){var i=this.id?this.id.split("_")[1]:-1;if(i!==-1){b(i)}}function g(p){var o,i;o=document.createElement("button");i=document.createTextNode(MobileFrontend.message(p?"expand-section":"collapse-section"));o.className=p?"show":"hide";o.appendChild(i);return o}if(!h){h=[]}else{a(document.body).addClass("togglingEnabled")}for(l=0;l<h.length;l++){n=h[l];n.removeAttribute("onclick");n.insertBefore(g(true),n.firstChild);n.insertBefore(g(false),n.firstChild);a(n).bind("click",k)}function j(){var i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}j();for(f=document.getElementsByTagName("a"),l=0;l<f.length;l++){a(f[l]).bind("click",j)}}function e(i){var g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&!a(h).hasClass("content_block")&&!a(h).hasClass("section_heading")){h=h.parentNode}if(h&&!a(h).hasClass("openSection")){f=parseInt(h.id.split("_")[1],10);b(f)}}}function b(g){var f=document.getElementById("section_"+g),l=f.getElementsByTagName("button"),h,j,k;if(a(f).hasClass("openSection")){a(f).removeClass("openSection")}else{a(f).addClass("openSection")}for(h=0,d=["content_","anchor_"];h<=1;h++){k=document.getElementById(d[h]+g);if(k&&a(k).hasClass("openSection")){a(k).removeClass("openSection")}else{a(k).addClass("openSection")}}}c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c}})(); |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js |
— | — | @@ -1 +1 @@ |
2 | | -MobileFrontend.opensearch=(function(){var c="/api.php",m=-1,d=500,A=15,q,k=document.getElementById("search"),a=document.getElementById("searchbox"),r=document.getElementById("content"),o=document.getElementById("footer"),y=document.getElementById("clearsearch"),j=false,x,w,n=MobileFrontend.utils;c=MobileFrontend.setting("scriptPath")+c;function s(){results.style.display="none"}x=n('meta[name="viewport"]');if(x){x=x[0];w=x.getAttribute("content")}function h(){if(x){x.setAttribute("content","minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0");n(document.body).bind("gesturestart",function(){x.setAttribute("content",w)})}}h();k.onfocus=function(){var u,B;a=document.getElementById("searchbox");header=document.getElementById("header");r=document.getElementById("content");o=document.getElementById("footer");h();if(!j){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("remove-results");if(!u){u=document.createElement("a");u.setAttribute("href","#");u.setAttribute("id","remove-results");n(u).bind("click",z);B=document.createElement("div");B.setAttribute("id","left-arrow");u.appendChild(B);header.insertBefore(u,header.firstChild)}j=true}};function z(){MobileFrontend.utils(document.body).removeClass("full-screen-search");if(j){j=false}if(y){y.style.display="none"}}function b(B){var u;if(!B){B=window.event}if(B.target){u=B.target}else{if(B.srcElement){u=B.srcElement}}if(u.nodeType===3){u=u.parentNode}B.cancelBubble=true;B.stopPropagation();if(u.className==="suggestion-result"||u.className==="search-result-item"||u.className==="suggestions-result"||u.className==="sq-val-update"||u.id==="results"||u.id==="search"||u.id==="searchbox"||u.id==="sq"||u.id==="placeholder"||u.id==="clearsearch"||u.tagName==="BODY"){if(u.id==="clearsearch"&&results){results.innerHTML=""}}else{s()}}var l=function(u){u.preventDefault();clearTimeout(m);q=k.value;if(q.length<1){results.innerHTML=""}else{q=encodeURIComponent(q);m=setTimeout(function(){i(q)},d)}};n(k).bind("keyup",l);n(document.getElementById("searchForm")).bind("submit",l);n(k).bind("blur",l);function i(u){url=c+"?action=opensearch&limit="+A+"&namespace=0&format=xml&search="+u;n.ajax({url:url,success:function(B){if(n(document.body).hasClass("full-screen-search")){p(g(B))}}})}function g(E){var F=[],B,C,D,u=E.getElementsByTagName("Item");for(B=0;B<u.length;B++){C=u[B];D={label:C.getElementsByTagName("Text")[0].textContent,value:C.getElementsByTagName("Url")[0].textContent};F.push(D)}return F}function e(C){var B=document.createTextNode(C),u=document.createElement("div");u.appendChild(B);return u.innerHTML}function v(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function p(J){var D=document.getElementById("results"),F,E,C=e(document.getElementById("search").value),I,B,u,G,H;D.style.display="block";if(k){k.focus()}if(!J||J.length<1){D.innerHTML='<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>'}else{if(D.firstChild){D.removeChild(D.firstChild)}F=document.createElement("ul");F.className="suggestions-results";D.appendChild(F);for(E=0;E<J.length;E++){I=J[E];u=document.createElement("li");u.setAttribute("title",I.label);u.className="suggestions-result";G=document.createElement("a");G.setAttribute("href",I.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));G.className="search-result-item";H=document.createTextNode(I.label);G.appendChild(H);u.appendChild(G);F.appendChild(u);B=v(C);G.innerHTML=G.innerHTML.replace(new RegExp("("+B+")","ig"),"<strong>$1</strong>")}}}function f(){var E=document.getElementById("clearsearch"),u=document.getElementById("search");function C(){if(E){if(u.value.length>0){E.style.display="block"}else{E.style.display="none"}}}function B(F){u.value="";E.style.display="none";F.preventDefault()}function D(){u.select()}n(E).bind("mousedown",B);n(u).bind("keyup",C);n(u).bind("click",D)}function t(){var u=document.getElementById("results");u.onmousedown=b;document.body.onmousedown=b;document.body.ontouchstart=b;u.ontouchstart=b}t();f();return{init:t,initClearSearch:f,writeResults:p,createObjectArray:g,removeResults:z}}()); |
\ No newline at end of file |
| 2 | +MobileFrontend.opensearch=(function(){var c="/api.php",p=-1,f=500,E=15,v,w=document.getElementById("results"),o=document.getElementById("search"),z=document.getElementById("sq"),a=document.getElementById("searchbox"),e=document.getElementById("logo"),g=document.getElementById("goButton"),y=document.getElementById("content"),s=document.getElementById("footer"),F=document.getElementById("zero-rated-banner")||document.getElementById("zero-rated-banner-red"),C=document.getElementById("clearsearch"),n=false,q={},r=MobileFrontend.utils;if(scriptPath){c=scriptPath+c}function x(){w.style.display="none"}function k(){if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)){var u=r('meta[name="viewport"]');if(u){u=u[0];u.content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0";r(document.body).bind("gesturestart",function(){u.content="width=device-width, initial-scale=1.0"})}}}k();o.onfocus=function(){var u,J,K,G,H,I;a=document.getElementById("searchbox");z=document.getElementById("sq");y=document.getElementById("content");s=document.getElementById("footer");k();if(!n){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("placeholder");if(!u){J=document.createElement("span");K=document.createTextNode(placeholder);J.setAttribute("id","placeholder");J.appendChild(K);a.insertBefore(J,a.firstChild)}u=document.getElementById("placeholder");if(u){u.style.display="block"}if(u&&o.value!==""){u.style.display="none"}I=document.getElementById("remove-results");if(!I){G=document.createElement("a");G.setAttribute("href","#");G.setAttribute("id","remove-results");r(G).bind("click",D);H=document.createElement("div");H.setAttribute("id","left-arrow");G.appendChild(H);z.insertBefore(G,z.firstChild)}n=true}};function D(){MobileFrontend.utils(document.body).removeClass("full-screen-search");var G,u=document.getElementById("placeholder");if(u){u.style.display="none"}if(n){n=false}if(C){C.style.display="none"}}function b(G){var u;if(!G){G=window.event}if(G.target){u=G.target}else{if(G.srcElement){u=G.srcElement}}if(u.nodeType===3){u=u.parentNode}G.cancelBubble=true;G.stopPropagation();if(u.className==="suggestion-result"||u.className==="search-result-item"||u.className==="suggestions-result"||u.className==="sq-val-update"||u.id==="results"||u.id==="search"||u.id==="searchbox"||u.id==="sq"||u.id==="placeholder"||u.id==="clearsearch"||u.tagName==="BODY"){if(u.id==="clearsearch"&&w){w.innerHTML=""}}else{x()}}window.onload=function(){r(o).bind("keyup",function(){clearTimeout(p);v=this.value;if(v.length<1){w.innerHTML=""}else{v=encodeURIComponent(v);p=setTimeout(function(){m(v)},f)}})};function m(u){url=c+"?action=opensearch&limit="+E+"&namespace=0&format=xml&search="+u;r.ajax({url:url,success:function(G){t(j(G))}})}function j(J){var K=[],G,H,I,u=J.getElementsByTagName("Item");for(G=0;G<u.length;G++){H=u[G];I={label:H.getElementsByTagName("Text")[0].textContent,value:H.getElementsByTagName("Url")[0].textContent};K.push(I)}return K}function l(G){var u=document.getElementById("search");if(u){u.value=G+" ";u.focus();m(u.value)}}function h(H){var G=document.createTextNode(H);var u=document.createElement("div");u.appendChild(G);return u.innerHTML}function B(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function t(P){var J=document.getElementById("results"),L,K,I=h(document.getElementById("search").value),H,O,G,u,M,N;J.style.display="block";if(o){o.focus()}if(!P||P.length<1){J.innerHTML='<div class="suggestions-results" title="No Results">No Results</div>'}else{if(J.firstChild){J.removeChild(J.firstChild)}L=document.createElement("div");L.className="suggestions-results";J.appendChild(L);H=function(){var Q=this.parentNode.getAttribute("title");l(Q)};for(K=0;K<P.length;K++){O=P[K];u=document.createElement("div");M=document.createElement("a");u.setAttribute("title",O.label);u.className="suggestions-result";N=document.createTextNode("+");M.appendChild(N);M.className="sq-val-update";r(M).bind("click",H);u.appendChild(M);M=document.createElement("a");M.setAttribute("href",O.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));M.className="search-result-item";N=document.createTextNode(O.label);M.appendChild(N);u.appendChild(M);L.appendChild(u);G=B(I);M.innerHTML=M.innerHTML.replace(new RegExp("("+G+")","ig"),"<strong>$1</strong>")}}}function d(){var u=document.getElementById("placeholder");if(u){u.style.display="none"}}function i(){var K=document.getElementById("clearsearch"),G=document.getElementById("search"),u=document.getElementById("results");function I(){if(K){if(G.value.length>0){K.style.display="block"}else{K.style.display="none"}}}function H(L){G.value="";K.style.display="none";if(L){L.preventDefault()}}function J(){G.select()}r(K).bind("mousedown",H);r(G).bind("keyup",I);r(G).bind("keydown",d);r(G).bind("click",J)}function A(){var u=document.getElementById("results");u.onmousedown=b;document.body.onmousedown=b;document.body.ontouchstart=b;u.ontouchstart=b;o.onpaste=d}A();i();return{init:A,initClearSearch:i,writeResults:t,createObjectArray:j,removeResults:D}}()); |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js |
— | — | @@ -1 +1 @@ |
2 | | -MobileFrontend=(function(){var a;function b(){var e;a(document.body).addClass("jsEnabled");e=document.getElementById("languageselection");function c(){var g;if(e){g=e.options[e.selectedIndex].value;if(g){location.href=g}}}a(e).bind("change",c);function d(){var g=document.getElementById("nav").style;g.display=g.display==="block"?"none":"block"}a(document.getElementById("logo")).bind("click",d);function f(){var h=MobileFrontend.setting("useFormatCookieName");var g=MobileFrontend.setting("useFormatCookieDuration");g=g/(24*60*60);MobileFrontend.banner.writeCookie(h,"desktop",g)}a(document.getElementById("mf-display-toggle")).bind("click",f);window.scrollTo(0,1)}a=typeof jQuery!=="undefined"?jQuery:function(e){if(typeof(e)==="string"){if(document.querySelectorAll){return[].slice.call(document.querySelectorAll(e))}}else{if(!e){e=document.createElement("div")}}function d(i){var j=e.className.split(" ");return j.indexOf(i)>-1}function f(i){var j=e.className,k=j.split(" ");k.push(i);e.className=k.join(" ")}function g(j){var l=e.className,m=l.split(" "),n=[],k;for(k=0;k<m.length;k++){if(m[k]!==j){n.push(m[k])}}e.className=n.join(" ")}function h(j,i){e.addEventListener(j,i,false)}function c(){e.parentNode.removeChild(e)}return{addClass:f,bind:h,hasClass:d,remove:c,removeClass:g}};a.ajax=a.ajax||function(e){var c,d;if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new ActiveXObject("Microsoft.XMLHTTP")}if(c.overrideMimeType){c.overrideMimeType("text/xml")}c.onreadystatechange=function(){if(c.readyState===4&&c.status===200){e.success(c.responseXML)}};c.open("GET",e.url,true);c.send()};b();return{init:b,message:function(c){return mwMobileFrontendConfig.messages[c]||""},setting:function(c){return mwMobileFrontendConfig.settings[c]||""},utils:a}}()); |
\ No newline at end of file |
| 2 | +MobileFrontend=(function(){var a;function c(){var j,k,f,o,r,h,n=a(".section_heading");a(document.body).addClass("jsEnabled");window.wm_toggle_section=b;var h=a(".section_heading button");for(j=0;j<h.length;j++){a(h[j]).remove()}function m(){var i=this.id?this.id.split("_")[1]:-1;if(i>-1){b(i)}}function p(t){var s,i;s=document.createElement("button");i=document.createTextNode(t?showText:hideText);s.className=t?"show":"hide";s.appendChild(i);s.style.display=t?"inline-block":"none";return s}if(!n){n=[]}else{a(document.body).addClass("togglingEnabled")}for(j=0;j<n.length;j++){r=n[j];r.removeAttribute("onclick");r.insertBefore(p(true),r.firstChild);r.insertBefore(p(false),r.firstChild);a(r).bind("click",m)}k=document.getElementById("results");f=document.getElementById("languageselection");function g(){var i;if(f){i=f.options[f.selectedIndex].value;if(i){location.href=i}}}a(f).bind("change",g);function l(){var i=document.getElementById("nav").style;i.display=i.display==="block"?"none":"block"}a(document.getElementById("logo")).bind("click",l);function q(){var i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}q();for(o=document.getElementsByTagName("a"),j=0;j<o.length;j++){a(o[j]).bind("click",q)}window.scrollTo(0,1)}function e(i){var g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&h.className!=="content_block"&&h.className!=="section_heading"){h=h.parentNode}if(h&&h.style.display!=="block"){f=parseInt(h.id.split("_")[1],10);b(f)}}}function b(g){var f=document.getElementById("section_"+g),l=f.getElementsByTagName("button"),h,j,k;for(h=0;h<=1;h++){j=l[h].style;j.display=j.display==="none"||(h&&!j.display)?"inline-block":"none"}for(h=0,d=["content_","anchor_"];h<=1;h++){k=document.getElementById(d[h]+g);if(k){k.style.display=k.style.display==="block"?"none":"block"}}}a=typeof jQuery!=="undefined"?jQuery:function(g){if(typeof(g)==="string"){if(document.querySelectorAll){return[].slice.call(document.querySelectorAll(g))}}function h(k){var l=g.className,m=l.split(" ");m.push(k);g.className=m.join(" ")}function i(k){var m=g.className,n=m.split(" "),o=[],l;for(l=0;l<n.length;l++){if(n[l]!==k){o.push(n[l])}}g.className=o.join(" ")}function j(l,k){g.addEventListener(l,k,false)}function f(){g.parentNode.removeChild(g)}return{addClass:h,bind:j,remove:f,removeClass:i}};a.ajax=a.ajax||function(h){var f,g;if(window.XMLHttpRequest){f=new XMLHttpRequest()}else{f=new ActiveXObject("Microsoft.XMLHTTP")}if(f.overrideMimeType){f.overrideMimeType("text/xml")}f.onreadystatechange=function(){if(f.readyState===4&&f.status===200){h.success(f.responseXML)}};f.open("GET",h.url,true);f.send()};c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c,utils:a}}()); |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.js |
— | — | @@ -8,7 +8,9 @@ |
9 | 9 | sb = document.getElementById( 'searchbox' ), |
10 | 10 | u = MobileFrontend.utils; |
11 | 11 | |
12 | | - apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl; |
| 12 | + if ( scriptPath ) { |
| 13 | + apiUrl = scriptPath + apiUrl; |
| 14 | + } |
13 | 15 | |
14 | 16 | function hideResults() { |
15 | 17 | var results = document.getElementById( 'results' ); |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.min.js |
— | — | @@ -1 +1 @@ |
2 | | -MobileFrontend.opensearch=(function(){var l="/api.php",c=-1,f=500,g=5,h=document.getElementById("results"),p=document.getElementById("search"),k=document.getElementById("searchbox"),m=MobileFrontend.utils;l=MobileFrontend.setting("scriptPath")+l;function b(){var q=document.getElementById("results");q.style.display="none"}function e(r){var q;if(!r){r=window.event}if(r.target){q=r.target}else{if(r.srcElement){q=r.srcElement}}if(q.nodeType===3){q=q.parentNode}r.cancelBubble=true;r.stopPropagation();if(!(q.className==="suggestion-result"||q.className==="search-result-item"||q.className==="suggestions-result"||q.className==="sq-val-update")){b()}}window.onload=function(){m(p).bind("keyup",function(){clearTimeout(c);var q=this.value;if(q.length<1){h.innerHTML=""}else{c=setTimeout(function(){o(q)},f)}})};function o(q){q=encodeURIComponent(q);url=l+"?action=opensearch&limit="+g+"&namespace=0&format=xml&search="+q;m.ajax({url:url,success:function(r){j(i(r))}})}function i(u){var v=[],r,s,t,q=u.getElementsByTagName("Item");for(r=0;r<q.length;r++){s=q[r];t={label:s.getElementsByTagName("Text")[0].textContent,value:s.getElementsByTagName("Url")[0].textContent};v.push(t)}return v}function d(r){var q=document.getElementById("search");if(q){q.value=r+" ";q.focus();o(q.value)}}function j(B){var t=document.getElementById("results"),w,u,s,A,q,y,z,r=document.getElementById("sq"),v=document.getElementById("header");t.style.display="block";var x=r.offsetParent.offsetTop+r.offsetHeight+r.offsetTop-1+v.offsetTop;t.style.top=x+"px";if(!B||B.length<1){t.innerHTML='<div class="suggestions-results"><div class="suggestions-result">No results</div></div>'}else{if(t.firstChild){t.removeChild(t.firstChild)}w=document.createElement("div");w.className="suggestions-results";t.appendChild(w);s=function(){var C=this.parentNode.getAttribute("title");d(C)};for(u=0;u<B.length;u++){A=B[u];q=document.createElement("div");y=document.createElement("a");q.setAttribute("title",A.label);q.className="suggestions-result";z=document.createTextNode("+");y.appendChild(z);y.className="sq-val-update";m(y).bind("click",s);q.appendChild(y);y=document.createElement("a");y.setAttribute("href",A.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));y.className="search-result-item";z=document.createTextNode(A.label);y.appendChild(z);q.appendChild(y);w.appendChild(q)}}}function a(){var v=document.getElementById("clearsearch"),r=document.getElementById("search"),q=document.getElementById("results");function t(){if(v){if(r.value.length>0){v.style.display="block"}else{v.style.display="none";if(q){q.style.display="none"}}}}function s(w){r.value="";v.style.display="none";if(q){q.style.display="none"}if(w){w.preventDefault()}}function u(){r.select()}m(v).bind("mousedown",s);m(r).bind("keyup",t);m(r).bind("click",u)}function n(){var q=document.getElementById("results");q.onmousedown=e;document.body.onmousedown=e;document.body.ontouchstart=e;q.ontouchstart=e}n();a();return{init:n,initClearSearch:a,writeResults:j,createObjectArray:i}}()); |
\ No newline at end of file |
| 2 | +MobileFrontend.opensearch=(function(){var l="/api.php",c=-1,f=500,g=5,h=document.getElementById("results"),p=document.getElementById("search"),k=document.getElementById("searchbox"),m=MobileFrontend.utils;if(scriptPath){l=scriptPath+l}function b(){var q=document.getElementById("results");q.style.display="none"}function e(r){var q;if(!r){r=window.event}if(r.target){q=r.target}else{if(r.srcElement){q=r.srcElement}}if(q.nodeType===3){q=q.parentNode}r.cancelBubble=true;r.stopPropagation();if(!(q.className==="suggestion-result"||q.className==="search-result-item"||q.className==="suggestions-result"||q.className==="sq-val-update")){b()}}window.onload=function(){m(p).bind("keyup",function(){clearTimeout(c);var q=this.value;if(q.length<1){h.innerHTML=""}else{c=setTimeout(function(){o(q)},f)}})};function o(q){q=encodeURIComponent(q);url=l+"?action=opensearch&limit="+g+"&namespace=0&format=xml&search="+q;m.ajax({url:url,success:function(r){j(i(r))}})}function i(u){var v=[],r,s,t,q=u.getElementsByTagName("Item");for(r=0;r<q.length;r++){s=q[r];t={label:s.getElementsByTagName("Text")[0].textContent,value:s.getElementsByTagName("Url")[0].textContent};v.push(t)}return v}function d(r){var q=document.getElementById("search");if(q){q.value=r+" ";q.focus();o(q.value)}}function j(B){var t=document.getElementById("results"),w,u,s,A,q,y,z,r=document.getElementById("sq"),v=document.getElementById("header");t.style.display="block";var x=r.offsetParent.offsetTop+r.offsetHeight+r.offsetTop-1+v.offsetTop;t.style.top=x+"px";if(!B||B.length<1){t.innerHTML='<div class="suggestions-results"><div class="suggestions-result">No results</div></div>'}else{if(t.firstChild){t.removeChild(t.firstChild)}w=document.createElement("div");w.className="suggestions-results";t.appendChild(w);s=function(){var C=this.parentNode.getAttribute("title");d(C)};for(u=0;u<B.length;u++){A=B[u];q=document.createElement("div");y=document.createElement("a");q.setAttribute("title",A.label);q.className="suggestions-result";z=document.createTextNode("+");y.appendChild(z);y.className="sq-val-update";m(y).bind("click",s);q.appendChild(y);y=document.createElement("a");y.setAttribute("href",A.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));y.className="search-result-item";z=document.createTextNode(A.label);y.appendChild(z);q.appendChild(y);w.appendChild(q)}}}function a(){var v=document.getElementById("clearsearch"),r=document.getElementById("search"),q=document.getElementById("results");function t(){if(v){if(r.value.length>0){v.style.display="block"}else{v.style.display="none";if(q){q.style.display="none"}}}}function s(w){r.value="";v.style.display="none";if(q){q.style.display="none"}if(w){w.preventDefault()}}function u(){r.select()}m(v).bind("mousedown",s);m(r).bind("keyup",t);m(r).bind("click",u)}function n(){var q=document.getElementById("results");q.onmousedown=e;document.body.onmousedown=e;document.body.ontouchstart=e;q.ontouchstart=e}n();a();return{init:n,initClearSearch:a,writeResults:j,createObjectArray:i}}()); |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_application.js |
— | — | @@ -0,0 +1,183 @@ |
| 2 | +/*global document, window */ |
| 3 | +/*jslint sloppy: true, white:true, maxerr: 50, indent: 4, plusplus: true*/ |
| 4 | +/* |
| 5 | +TODO: getElementsByClassName not supported by IE < 9 |
| 6 | +TODO: addEventListener not supported by IE < 9 |
| 7 | +*/ |
| 8 | +MobileFrontend = (function() { |
| 9 | + var utilities; |
| 10 | + |
| 11 | + function init() { |
| 12 | + var i, search, clearSearch, results, languageSelection, a, heading, btns, |
| 13 | + sectionHeadings = utilities( '.section_heading' ); |
| 14 | + utilities( document.body ).addClass( 'jsEnabled' ); |
| 15 | + |
| 16 | + // TODO: remove in future - currently enables toggling in Wikipedia Mobile App v < 1.1 |
| 17 | + window.wm_toggle_section = wm_toggle_section; |
| 18 | + var btns = utilities( '.section_heading button' ); |
| 19 | + for( i = 0; i < btns.length; i++ ) { |
| 20 | + utilities( btns[i] ).remove(); |
| 21 | + } |
| 22 | + |
| 23 | + function openSectionHandler() { |
| 24 | + var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
| 25 | + if( sectionNumber > -1 ) { |
| 26 | + wm_toggle_section( sectionNumber ); |
| 27 | + } |
| 28 | + } |
| 29 | + function createButton( visible ) { |
| 30 | + var btn, label; |
| 31 | + btn = document.createElement( 'button' ); |
| 32 | + label = document.createTextNode( visible ? showText : hideText ); |
| 33 | + btn.className = visible ? 'show' : 'hide'; |
| 34 | + btn.appendChild( label ); |
| 35 | + btn.style.display = visible ? 'inline-block' : 'none'; |
| 36 | + return btn; |
| 37 | + } |
| 38 | + if(!sectionHeadings) { |
| 39 | + sectionHeadings = []; |
| 40 | + } else { |
| 41 | + utilities( document.body ).addClass( 'togglingEnabled' ); |
| 42 | + } |
| 43 | + for( i = 0; i < sectionHeadings.length; i++ ) { |
| 44 | + heading = sectionHeadings[i]; |
| 45 | + heading.removeAttribute( 'onclick' ); // TODO: remove any legacy onclick handlers |
| 46 | + heading.insertBefore( createButton( true ), heading.firstChild ); |
| 47 | + heading.insertBefore( createButton( false ), heading.firstChild ); |
| 48 | + utilities( heading ).bind( 'click', openSectionHandler ); |
| 49 | + } |
| 50 | + results = document.getElementById( 'results' ); |
| 51 | + languageSelection = document.getElementById( 'languageselection' ); |
| 52 | + |
| 53 | + function navigateToLanguageSelection() { |
| 54 | + var url; |
| 55 | + if ( languageSelection ) { |
| 56 | + url = languageSelection.options[languageSelection.selectedIndex].value; |
| 57 | + if ( url ) { |
| 58 | + location.href = url; |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + utilities( languageSelection ).bind( 'change', navigateToLanguageSelection ); |
| 63 | + |
| 64 | + function logoClick() { |
| 65 | + var n = document.getElementById( 'nav' ).style; |
| 66 | + n.display = n.display === 'block' ? 'none' : 'block'; |
| 67 | + } |
| 68 | + utilities( document.getElementById( 'logo' ) ).bind( 'click', logoClick ); |
| 69 | + |
| 70 | + function checkHash() { |
| 71 | + var hash = this.hash || document.location.hash; |
| 72 | + if ( hash.indexOf( '#' ) === 0 ) { |
| 73 | + wm_reveal_for_hash( hash ); |
| 74 | + } |
| 75 | + } |
| 76 | + checkHash(); |
| 77 | + for ( a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
| 78 | + utilities( a[i] ).bind( 'click', checkHash ); |
| 79 | + } |
| 80 | + |
| 81 | + // Try to scroll and hide URL bar |
| 82 | + window.scrollTo( 0, 1 ); |
| 83 | + } |
| 84 | + |
| 85 | + function wm_reveal_for_hash( hash ) { |
| 86 | + var targetel = document.getElementById( hash.substr(1) ), |
| 87 | + p, section_idx; |
| 88 | + if ( targetel ) { |
| 89 | + p = targetel; |
| 90 | + while ( p && p.className !== 'content_block' && |
| 91 | + p.className !== 'section_heading' ) { |
| 92 | + p = p.parentNode; |
| 93 | + } |
| 94 | + if ( p && p.style.display !== 'block' ) { |
| 95 | + section_idx = parseInt( p.id.split( '_' )[1], 10 ); |
| 96 | + wm_toggle_section( section_idx ); |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + function wm_toggle_section( section_id ) { |
| 102 | + var b = document.getElementById( 'section_' + section_id ), |
| 103 | + bb = b.getElementsByTagName( 'button' ), i, s, e; |
| 104 | + for ( i = 0; i <= 1; i++ ) { |
| 105 | + s = bb[i].style; |
| 106 | + s.display = s.display === 'none' || ( i && !s.display ) ? 'inline-block' : 'none'; |
| 107 | + } |
| 108 | + for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
| 109 | + e = document.getElementById( d[i] + section_id ); |
| 110 | + if ( e ) { |
| 111 | + e.style.display = e.style.display === 'block' ? 'none' : 'block'; |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + utilities = typeof jQuery !== 'undefined' ? jQuery : function( el ) { |
| 117 | + if( typeof(el) === 'string' ) { |
| 118 | + if( document.querySelectorAll ) { |
| 119 | + return [].slice.call( document.querySelectorAll( el ) ); |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + function addClass( name ) { |
| 124 | + var className = el.className, |
| 125 | + classNames = className.split( ' ' ); |
| 126 | + classNames.push(name); // TODO: only push if unique |
| 127 | + el.className = classNames.join( ' ' ); |
| 128 | + } |
| 129 | + |
| 130 | + function removeClass( name ) { |
| 131 | + var className = el.className, |
| 132 | + classNames = className.split( ' ' ), |
| 133 | + newClasses = [], i; |
| 134 | + for( i = 0; i < classNames.length; i++ ) { |
| 135 | + if( classNames[i] !== name ) { |
| 136 | + newClasses.push( classNames[i] ); |
| 137 | + } |
| 138 | + } |
| 139 | + el.className = newClasses.join( ' ' ); |
| 140 | + } |
| 141 | + |
| 142 | + function bind( type, handler ) { |
| 143 | + el.addEventListener( type, handler, false ); |
| 144 | + } |
| 145 | + |
| 146 | + function remove() { |
| 147 | + el.parentNode.removeChild(el); |
| 148 | + } |
| 149 | + |
| 150 | + return { |
| 151 | + addClass: addClass, |
| 152 | + bind: bind, |
| 153 | + remove: remove, |
| 154 | + removeClass: removeClass |
| 155 | + }; |
| 156 | + } |
| 157 | + utilities.ajax = utilities.ajax || function( options ) { |
| 158 | + var xmlHttp, url; |
| 159 | + if ( window.XMLHttpRequest ) { |
| 160 | + xmlHttp = new XMLHttpRequest(); |
| 161 | + } else { |
| 162 | + xmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP' ); |
| 163 | + } |
| 164 | + if( xmlHttp.overrideMimeType ) { // non standard |
| 165 | + xmlHttp.overrideMimeType( 'text/xml' ); |
| 166 | + } |
| 167 | + xmlHttp.onreadystatechange = function() { |
| 168 | + if ( xmlHttp.readyState === 4 && xmlHttp.status === 200 ) { |
| 169 | + options.success( xmlHttp.responseXML ); |
| 170 | + } |
| 171 | + }; |
| 172 | + xmlHttp.open( 'GET', options.url, true ); |
| 173 | + xmlHttp.send(); |
| 174 | + }; |
| 175 | + |
| 176 | + init(); |
| 177 | + return { |
| 178 | + wm_reveal_for_hash: wm_reveal_for_hash, |
| 179 | + wm_toggle_section: wm_toggle_section, |
| 180 | + init: init, |
| 181 | + utils: utilities |
| 182 | + }; |
| 183 | + |
| 184 | +}()); |
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_application.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 185 | + native |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js |
— | — | @@ -3,42 +3,47 @@ |
4 | 4 | MobileFrontend.opensearch = (function() { |
5 | 5 | var apiUrl = '/api.php', timer = -1, typingDelay = 500, |
6 | 6 | numResults = 15, term, |
| 7 | + results = document.getElementById( 'results' ), |
7 | 8 | search = document.getElementById( 'search' ), |
| 9 | + sq = document.getElementById( 'sq' ), |
8 | 10 | sb = document.getElementById( 'searchbox' ), |
| 11 | + logo = document.getElementById( 'logo' ), |
| 12 | + goButton = document.getElementById( 'goButton' ), |
9 | 13 | content = document.getElementById( 'content' ), |
10 | 14 | footer = document.getElementById( 'footer' ), |
| 15 | + zeroRatedBanner = document.getElementById( 'zero-rated-banner' ) || |
| 16 | + document.getElementById( 'zero-rated-banner-red' ), |
11 | 17 | clearSearch = document.getElementById( 'clearsearch' ), |
12 | | - focused = false, |
13 | | - viewportmeta, originalViewport, |
| 18 | + focused = false, ol = {}, |
14 | 19 | u = MobileFrontend.utils; |
15 | 20 | |
16 | | - apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl; |
| 21 | + if ( scriptPath ) { |
| 22 | + apiUrl = scriptPath + apiUrl; |
| 23 | + } |
17 | 24 | |
18 | 25 | function hideResults() { |
19 | 26 | results.style.display = 'none'; |
20 | 27 | } |
21 | | - |
22 | | - viewportmeta = u( 'meta[name="viewport"]' ) |
23 | | - if ( viewportmeta ) { |
24 | | - viewportmeta = viewportmeta[0]; |
25 | | - originalViewport = viewportmeta.getAttribute( 'content' ); |
26 | | - } |
27 | | - // prevent auto-zoom in on clicking search for certain browsers e.g. palm pre and ipad |
28 | 28 | function resetViewPort() { |
29 | | - if ( viewportmeta ) { |
30 | | - viewportmeta.setAttribute( 'content', 'minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0'); |
31 | | - u( document.body ).bind( 'gesturestart', function () { |
32 | | - viewportmeta.setAttribute( 'content', originalViewport ); |
33 | | - } ); |
| 29 | + if ( navigator.userAgent.match( /iPhone/i ) || navigator.userAgent.match( /iPad/i ) ) { |
| 30 | + var viewportmeta = u( 'meta[name="viewport"]' ); |
| 31 | + if ( viewportmeta ) { |
| 32 | + viewportmeta = viewportmeta[0]; |
| 33 | + viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0'; |
| 34 | + u( document.body ).bind( 'gesturestart', function () { |
| 35 | + viewportmeta.content = 'width=device-width, initial-scale=1.0'; |
| 36 | + } ); |
| 37 | + } |
34 | 38 | } |
35 | 39 | } |
36 | 40 | |
37 | 41 | resetViewPort(); |
38 | 42 | |
39 | 43 | search.onfocus = function() { |
40 | | - var rrd, rrdD; |
| 44 | + var pE, pT, pTT, rrd, rrdD, |
| 45 | + removeResultsEl; |
41 | 46 | sb = document.getElementById( 'searchbox' ); |
42 | | - header = document.getElementById( 'header' ); |
| 47 | + sq = document.getElementById( 'sq' ); |
43 | 48 | content = document.getElementById( 'content' ); |
44 | 49 | footer = document.getElementById( 'footer' ); |
45 | 50 | resetViewPort(); |
— | — | @@ -46,8 +51,25 @@ |
47 | 52 | if ( !focused ) { |
48 | 53 | MobileFrontend.utils( document.body ).addClass( 'full-screen-search' ); |
49 | 54 | |
50 | | - rrd = document.getElementById( 'remove-results' ); |
51 | | - if ( !rrd ) { |
| 55 | + pE = document.getElementById( 'placeholder' ); |
| 56 | + if ( !pE ) { |
| 57 | + pT = document.createElement( 'span' ); |
| 58 | + pTT = document.createTextNode(placeholder); |
| 59 | + pT.setAttribute( 'id', 'placeholder' ); |
| 60 | + pT.appendChild(pTT); |
| 61 | + sb.insertBefore( pT, sb.firstChild ); |
| 62 | + } |
| 63 | + pE = document.getElementById( 'placeholder' ); |
| 64 | + if ( pE ) { |
| 65 | + pE.style.display = 'block'; |
| 66 | + } |
| 67 | + |
| 68 | + if ( pE && search.value !== '' ) { |
| 69 | + pE.style.display = 'none'; |
| 70 | + } |
| 71 | + |
| 72 | + removeResultsEl = document.getElementById( 'remove-results' ); |
| 73 | + if ( !removeResultsEl ) { |
52 | 74 | rrd = document.createElement( 'a' ); |
53 | 75 | rrd.setAttribute( 'href', '#' ); |
54 | 76 | rrd.setAttribute( 'id', 'remove-results' ); |
— | — | @@ -55,7 +77,7 @@ |
56 | 78 | rrdD = document.createElement( 'div' ); |
57 | 79 | rrdD.setAttribute( 'id', 'left-arrow' ); |
58 | 80 | rrd.appendChild( rrdD ); |
59 | | - header.insertBefore( rrd, header.firstChild ); |
| 81 | + sq.insertBefore( rrd, sq.firstChild ); |
60 | 82 | } |
61 | 83 | focused = true; |
62 | 84 | } |
— | — | @@ -63,7 +85,12 @@ |
64 | 86 | |
65 | 87 | function removeResults() { |
66 | 88 | MobileFrontend.utils( document.body ).removeClass( 'full-screen-search' ); |
| 89 | + var removeResultsEl, pE = document.getElementById( 'placeholder' ); |
67 | 90 | |
| 91 | + if ( pE ) { |
| 92 | + pE.style.display = 'none'; |
| 93 | + } |
| 94 | + |
68 | 95 | if ( focused ) { |
69 | 96 | focused = false; |
70 | 97 | } |
— | — | @@ -111,14 +138,14 @@ |
112 | 139 | window.onload = function () { |
113 | 140 | u( search ).bind( 'keyup', |
114 | 141 | function() { |
115 | | - clearTimeout( timer ); |
116 | | - term = search.value; |
117 | | - if ( term.length < 1 ) { |
118 | | - results.innerHTML = ''; |
119 | | - } else { |
120 | | - term = encodeURIComponent( term ); |
121 | | - timer = setTimeout( function () { searchApi( term ); }, typingDelay ); |
122 | | - } |
| 142 | + clearTimeout( timer ); |
| 143 | + term = this.value; |
| 144 | + if ( term.length < 1 ) { |
| 145 | + results.innerHTML = ''; |
| 146 | + } else { |
| 147 | + term = encodeURIComponent( term ); |
| 148 | + timer = setTimeout( function () { searchApi( term ); }, typingDelay ); |
| 149 | + } |
123 | 150 | } ); |
124 | 151 | }; |
125 | 152 | |
— | — | @@ -145,9 +172,18 @@ |
146 | 173 | return sections; |
147 | 174 | } |
148 | 175 | |
| 176 | + function sqValUpdate( sqValue ) { |
| 177 | + var search = document.getElementById( 'search' ); |
| 178 | + if ( search ) { |
| 179 | + search.value = sqValue + ' '; |
| 180 | + search.focus(); |
| 181 | + searchApi( search.value ); |
| 182 | + } |
| 183 | + } |
| 184 | + |
149 | 185 | function htmlEntities( str ) { |
150 | | - var text = document.createTextNode( str ), |
151 | | - el = document.createElement( 'div' ); |
| 186 | + var text = document.createTextNode( str ); |
| 187 | + var el = document.createElement( 'div' ); |
152 | 188 | el.appendChild( text ); |
153 | 189 | return el.innerHTML; |
154 | 190 | } |
— | — | @@ -159,27 +195,37 @@ |
160 | 196 | function writeResults( sections ) { |
161 | 197 | var results = document.getElementById( 'results' ), suggestions, i, |
162 | 198 | term = htmlEntities( document.getElementById( 'search' ).value ), |
163 | | - section, escapedTerm, suggestionsResult, link, label; |
| 199 | + suggestionListener, section, escapedTerm, suggestionsResult, link, label; |
164 | 200 | |
165 | 201 | results.style.display = 'block'; |
166 | 202 | if ( search ) { |
167 | 203 | search.focus(); |
168 | 204 | } |
169 | 205 | if ( !sections || sections.length < 1 ) { |
170 | | - results.innerHTML = '<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>'; |
| 206 | + results.innerHTML = "<div class=\"suggestions-results\" title=\"No Results\">No Results</div>"; |
171 | 207 | } else { |
172 | 208 | if( results.firstChild ) { |
173 | 209 | results.removeChild( results.firstChild ); |
174 | 210 | } |
175 | | - suggestions = document.createElement( 'ul' ); |
| 211 | + suggestions = document.createElement( 'div' ); |
176 | 212 | suggestions.className = 'suggestions-results'; |
177 | 213 | results.appendChild( suggestions ); |
| 214 | + suggestionListener = function() { |
| 215 | + var title = this.parentNode.getAttribute( 'title' ); |
| 216 | + sqValUpdate( title ); |
| 217 | + }; |
178 | 218 | |
179 | 219 | for ( i = 0; i < sections.length; i++ ) { |
180 | 220 | section = sections[i]; |
181 | | - suggestionsResult = document.createElement( 'li' ); |
| 221 | + suggestionsResult = document.createElement( 'div' ); |
| 222 | + link = document.createElement( 'a' ); |
182 | 223 | suggestionsResult.setAttribute( 'title', section.label ); |
183 | 224 | suggestionsResult.className = 'suggestions-result'; |
| 225 | + label = document.createTextNode( '+' ); |
| 226 | + link.appendChild(label); |
| 227 | + link.className = 'sq-val-update'; |
| 228 | + u( link ).bind( 'click', suggestionListener ); |
| 229 | + suggestionsResult.appendChild( link ); |
184 | 230 | |
185 | 231 | link = document.createElement( 'a' ); |
186 | 232 | link.setAttribute( 'href', section.value.replace( /^(?:\/\/|[^\/]+)*\//, '/' ) ); |
— | — | @@ -198,9 +244,17 @@ |
199 | 245 | } |
200 | 246 | } |
201 | 247 | |
| 248 | + function handleDefaultText() { |
| 249 | + var pE = document.getElementById( 'placeholder' ); |
| 250 | + if ( pE ) { |
| 251 | + pE.style.display = 'none'; |
| 252 | + } |
| 253 | + } |
| 254 | + |
202 | 255 | function initClearSearch() { |
203 | 256 | var clearSearch = document.getElementById( 'clearsearch' ), |
204 | | - search = document.getElementById( 'search' ); |
| 257 | + search = document.getElementById( 'search' ), |
| 258 | + results = document.getElementById( 'results' ); |
205 | 259 | function handleClearSearchLink() { |
206 | 260 | if ( clearSearch ) { |
207 | 261 | if ( search.value.length > 0 ) { |
— | — | @@ -224,6 +278,7 @@ |
225 | 279 | } |
226 | 280 | u( clearSearch ).bind( 'mousedown', clearSearchBox ); |
227 | 281 | u( search ).bind( 'keyup', handleClearSearchLink ); |
| 282 | + u( search ).bind( 'keydown', handleDefaultText ); |
228 | 283 | u( search ).bind( 'click', onFocusHandler ); |
229 | 284 | } |
230 | 285 | |
— | — | @@ -233,6 +288,7 @@ |
234 | 289 | document.body.onmousedown = whichElement; |
235 | 290 | document.body.ontouchstart = whichElement; |
236 | 291 | results.ontouchstart = whichElement; |
| 292 | + search.onpaste = handleDefaultText; |
237 | 293 | } |
238 | 294 | init(); |
239 | 295 | initClearSearch(); |
— | — | @@ -245,4 +301,4 @@ |
246 | 302 | removeResults: removeResults |
247 | 303 | }; |
248 | 304 | |
249 | | -}()); |
| 305 | +}()); |
\ No newline at end of file |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -4,9 +4,45 @@ |
5 | 5 | var utilities; |
6 | 6 | |
7 | 7 | function init() { |
8 | | - var languageSelection; |
| 8 | + var i, results, languageSelection, a, heading, btns, |
| 9 | + sectionHeadings = utilities( '.section_heading' ); |
9 | 10 | utilities( document.body ).addClass( 'jsEnabled' ); |
10 | 11 | |
| 12 | + // TODO: remove in future - currently enables toggling in Wikipedia Mobile App v < 1.1 |
| 13 | + window.wm_toggle_section = wm_toggle_section; |
| 14 | + var btns = utilities( '.section_heading button' ); |
| 15 | + for( i = 0; i < btns.length; i++ ) { |
| 16 | + utilities( btns[i] ).remove(); |
| 17 | + } |
| 18 | + |
| 19 | + function openSectionHandler() { |
| 20 | + var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
| 21 | + if( sectionNumber > -1 ) { |
| 22 | + wm_toggle_section( sectionNumber ); |
| 23 | + } |
| 24 | + } |
| 25 | + function createButton( visible ) { |
| 26 | + var btn, label; |
| 27 | + btn = document.createElement( 'button' ); |
| 28 | + label = document.createTextNode( visible ? showText : hideText ); |
| 29 | + btn.className = visible ? 'show' : 'hide'; |
| 30 | + btn.appendChild( label ); |
| 31 | + btn.style.display = visible ? 'inline-block' : 'none'; |
| 32 | + return btn; |
| 33 | + } |
| 34 | + if(!sectionHeadings) { |
| 35 | + sectionHeadings = []; |
| 36 | + } else { |
| 37 | + utilities( document.body ).addClass( 'togglingEnabled' ); |
| 38 | + } |
| 39 | + for( i = 0; i < sectionHeadings.length; i++ ) { |
| 40 | + heading = sectionHeadings[i]; |
| 41 | + heading.removeAttribute( 'onclick' ); // TODO: remove any legacy onclick handlers |
| 42 | + heading.insertBefore( createButton( true ), heading.firstChild ); |
| 43 | + heading.insertBefore( createButton( false ), heading.firstChild ); |
| 44 | + utilities( heading ).bind( 'click', openSectionHandler ); |
| 45 | + } |
| 46 | + results = document.getElementById( 'results' ); |
11 | 47 | languageSelection = document.getElementById( 'languageselection' ); |
12 | 48 | |
13 | 49 | function navigateToLanguageSelection() { |
— | — | @@ -26,33 +62,58 @@ |
27 | 63 | } |
28 | 64 | utilities( document.getElementById( 'logo' ) ).bind( 'click', logoClick ); |
29 | 65 | |
30 | | - function desktopViewClick() { |
31 | | - var cookieName = MobileFrontend.setting( 'useFormatCookieName' ); |
32 | | - var cookieDuration = MobileFrontend.setting( 'useFormatCookieDuration' ); |
33 | | - // convert from seconds to days |
34 | | - cookieDuration = cookieDuration / ( 24 * 60 * 60 ); |
35 | | - MobileFrontend.banner.writeCookie( cookieName, 'desktop', cookieDuration ); |
| 66 | + function checkHash() { |
| 67 | + var hash = this.hash || document.location.hash; |
| 68 | + if ( hash.indexOf( '#' ) === 0 ) { |
| 69 | + wm_reveal_for_hash( hash ); |
| 70 | + } |
36 | 71 | } |
37 | | - utilities( document.getElementById( 'mf-display-toggle' ) ).bind( 'click', desktopViewClick ); |
| 72 | + checkHash(); |
| 73 | + for ( a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
| 74 | + utilities( a[i] ).bind( 'click', checkHash ); |
| 75 | + } |
38 | 76 | |
39 | 77 | // Try to scroll and hide URL bar |
40 | 78 | window.scrollTo( 0, 1 ); |
41 | 79 | } |
42 | 80 | |
| 81 | + function wm_reveal_for_hash( hash ) { |
| 82 | + var targetel = document.getElementById( hash.substr(1) ), |
| 83 | + p, section_idx; |
| 84 | + if ( targetel ) { |
| 85 | + p = targetel; |
| 86 | + while ( p && p.className !== 'content_block' && |
| 87 | + p.className !== 'section_heading' ) { |
| 88 | + p = p.parentNode; |
| 89 | + } |
| 90 | + if ( p && p.style.display !== 'block' ) { |
| 91 | + section_idx = parseInt( p.id.split( '_' )[1], 10 ); |
| 92 | + wm_toggle_section( section_idx ); |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + function wm_toggle_section( section_id ) { |
| 98 | + var b = document.getElementById( 'section_' + section_id ), |
| 99 | + bb = b.getElementsByTagName( 'button' ), i, s, e; |
| 100 | + for ( i = 0; i <= 1; i++ ) { |
| 101 | + s = bb[i].style; |
| 102 | + s.display = s.display === 'none' || ( i && !s.display ) ? 'inline-block' : 'none'; |
| 103 | + } |
| 104 | + for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
| 105 | + e = document.getElementById( d[i] + section_id ); |
| 106 | + if ( e ) { |
| 107 | + e.style.display = e.style.display === 'block' ? 'none' : 'block'; |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + |
43 | 112 | utilities = typeof jQuery !== 'undefined' ? jQuery : function( el ) { |
44 | 113 | if( typeof(el) === 'string' ) { |
45 | 114 | if( document.querySelectorAll ) { |
46 | 115 | return [].slice.call( document.querySelectorAll( el ) ); |
47 | 116 | } |
48 | | - } else if( !el ) { |
49 | | - el = document.createElement( 'div' ); |
50 | 117 | } |
51 | | - |
52 | | - function hasClass( name ) { |
53 | | - var classNames = el.className.split( ' ' ); |
54 | | - return classNames.indexOf( name ) > -1; |
55 | | - } |
56 | | - |
57 | 118 | function addClass( name ) { |
58 | 119 | var className = el.className, |
59 | 120 | classNames = className.split( ' ' ); |
— | — | @@ -83,7 +144,6 @@ |
84 | 145 | return { |
85 | 146 | addClass: addClass, |
86 | 147 | bind: bind, |
87 | | - hasClass: hasClass, |
88 | 148 | remove: remove, |
89 | 149 | removeClass: removeClass |
90 | 150 | }; |
— | — | @@ -109,13 +169,9 @@ |
110 | 170 | |
111 | 171 | init(); |
112 | 172 | return { |
| 173 | + wm_reveal_for_hash: wm_reveal_for_hash, |
| 174 | + wm_toggle_section: wm_toggle_section, |
113 | 175 | init: init, |
114 | | - message: function( name ) { |
115 | | - return mwMobileFrontendConfig.messages[name] || ''; |
116 | | - }, |
117 | | - setting: function( name ) { |
118 | | - return mwMobileFrontendConfig.settings[name] || ''; |
119 | | - }, |
120 | 176 | utils: utilities |
121 | 177 | }; |
122 | 178 | |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php |
— | — | @@ -26,7 +26,8 @@ |
27 | 27 | 'mobile-frontend-hide-button' => 'Hide', |
28 | 28 | 'mobile-frontend-disable-button' => 'Disable', |
29 | 29 | 'mobile-frontend-back-button' => 'Back', |
30 | | - 'mobile-frontend-regular-site' => 'Desktop view', |
| 30 | + 'mobile-frontend-regular-site' => 'View this page on regular {{SITENAME}}', |
| 31 | + 'mobile-frontend-perm-stop-redirect' => 'Permanently disable mobile site', |
31 | 32 | 'mobile-frontend-error-page-title' => 'We have a problem!', |
32 | 33 | 'mobile-frontend-error-page-text' => '{{SITENAME}} mobile is still under active development and we are working hard to fix all of our internal errors. We have been notified about this error and will be fixing it soon. Please check back!', |
33 | 34 | 'mobile-frontend-are-you-sure' => 'Are you sure?', |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css |
— | — | @@ -182,7 +182,6 @@ |
183 | 183 | |
184 | 184 | html[dir="rtl"] #results { |
185 | 185 | left: 41px; |
186 | | - right: 53px; |
187 | 186 | } |
188 | 187 | |
189 | 188 | .search_bar .search { |
— | — | @@ -333,30 +332,20 @@ |
334 | 333 | margin: 0px; |
335 | 334 | } |
336 | 335 | |
337 | | -button.show, |
338 | | -button.hide { /* for non-js browsers */ |
| 336 | +button.show { |
339 | 337 | display: none; |
340 | 338 | } |
341 | 339 | |
342 | | -.togglingEnabled button.hide, |
343 | | -.togglingEnabled .openSection button.show { |
344 | | - display: none; |
345 | | -} |
346 | | - |
347 | | -.togglingEnabled .openSection button.hide, |
348 | 340 | .togglingEnabled button.show { |
349 | 341 | display: inline-block; |
350 | 342 | } |
351 | 343 | |
352 | 344 | .togglingEnabled .content_block, |
353 | | -.togglingEnabled .section_anchors { |
| 345 | +.togglingEnabled .section_anchors, |
| 346 | +button.section_heading.hide { |
354 | 347 | display: none; |
355 | 348 | } |
356 | 349 | |
357 | | -.togglingEnabled .openSection { |
358 | | - display: block; |
359 | | -} |
360 | | - |
361 | 350 | .mwm-notice { |
362 | 351 | padding: 5px; |
363 | 352 | background: #dddddd; |
— | — | @@ -537,7 +526,6 @@ |
538 | 527 | -moz-border-radius: 5px; |
539 | 528 | background: #f9f9f9; |
540 | 529 | margin-bottom: 10px; |
541 | | - text-align: center; |
542 | 530 | } |
543 | 531 | |
544 | 532 | .thumb .thumbinner[style] { |
— | — | @@ -587,7 +575,6 @@ |
588 | 576 | #footer { |
589 | 577 | margin: 0 8px; |
590 | 578 | clear: both; |
591 | | - font-size: 0.8em; |
592 | 579 | } |
593 | 580 | |
594 | 581 | #logo { |
— | — | @@ -638,7 +625,7 @@ |
639 | 626 | height: 25px; |
640 | 627 | width: 27px; |
641 | 628 | padding-bottom: 0; |
642 | | - text-indent: -999px; |
| 629 | + text-indent: 999px; |
643 | 630 | } |
644 | 631 | |
645 | 632 | html[dir="rtl"] .goButton { |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/close-button-beta.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | html, |
3 | | -body { |
4 | | - margin: 0; |
5 | | - padding: 0; |
6 | | - height: 100%; |
| 3 | +body { |
| 4 | + margin: 0; |
| 5 | + padding: 0; |
| 6 | + height: 100%; |
7 | 7 | } |
8 | 8 | |
9 | 9 | html { |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | } |
12 | 12 | |
13 | 13 | body { |
14 | | - font-size: 1em; |
| 14 | + font-size: 0.8em; |
15 | 15 | line-height: 1; |
16 | 16 | color: black; |
17 | 17 | background: white; |
— | — | @@ -19,21 +19,24 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | .clearlink { |
23 | | - top: 9px; |
24 | | - right: -18px; |
25 | | - width: 18px; |
26 | | - height: 20px; |
27 | | - background: url(images/close-button-beta.png) no-repeat scroll 0 0 transparent; |
28 | | - margin: 0; |
29 | | - display: block; |
30 | | - background-position: right center; |
31 | | - background-size: auto 12px; |
| 23 | + background: url(images/close-button.png?v=1) no-repeat scroll 0 0 transparent; |
| 24 | + background-position: center center; |
32 | 25 | cursor: pointer; |
| 26 | + zoom: 1; |
33 | 27 | position: absolute; |
| 28 | + right: 0.25em; |
| 29 | + top: 10%; |
| 30 | + margin: 1px; |
| 31 | + height: 42px; |
| 32 | + width: 42px; |
| 33 | + margin-top: -6px; |
| 34 | + z-index: 99; |
| 35 | + border: 0px solid; |
| 36 | + display: none; |
34 | 37 | } |
35 | 38 | |
36 | 39 | html[dir="rtl"] .clearlink { |
37 | | - left: 0; |
| 40 | + left: 0.25em; |
38 | 41 | right: auto; |
39 | 42 | } |
40 | 43 | |
— | — | @@ -103,16 +106,38 @@ |
104 | 107 | text-align: center; |
105 | 108 | } |
106 | 109 | |
| 110 | +.suggestions-results { |
| 111 | + font-size: 1.4em; |
| 112 | + cursor: pointer; |
| 113 | + margin: 0; |
| 114 | + padding: 0; |
| 115 | +} |
| 116 | + |
| 117 | +.suggestions-results hr { |
| 118 | + margin: 0; |
| 119 | +} |
| 120 | + |
| 121 | +.suggestions-result { |
| 122 | + color: black; |
| 123 | + margin: 0; |
| 124 | + line-height: 2.6em; |
| 125 | + padding: 0.01em 0.25em; |
| 126 | + postion: relative; |
| 127 | + border-bottom: solid 1px #999999; |
| 128 | +} |
| 129 | + |
107 | 130 | .suggestions-result a { |
108 | 131 | text-decoration: none; |
109 | 132 | color: #666; |
110 | 133 | } |
111 | | - |
| 134 | +.suggestions-result a:link { |
| 135 | + text-decoration: none; |
| 136 | + color:#666; |
| 137 | +} |
112 | 138 | .suggestions-result a:visited { |
113 | 139 | text-decoration: none; |
114 | 140 | color:#666; |
115 | 141 | } |
116 | | - |
117 | 142 | .suggestions-result a:hover { |
118 | 143 | text-decoration: none; |
119 | 144 | color:#666; |
— | — | @@ -121,13 +146,36 @@ |
122 | 147 | text-decoration: none; |
123 | 148 | color:#666; |
124 | 149 | } |
125 | | - |
126 | 150 | .suggestions-result:hover { |
127 | 151 | background-color: #ACD1E9; |
128 | 152 | } |
| 153 | +a.sq-val-update { |
| 154 | + font-size: 1.3em; |
| 155 | + display: block; |
| 156 | + font-weight: normal; |
| 157 | + text-decoration: none; |
| 158 | + color: #666; |
| 159 | + position: absolute; |
| 160 | + right: 0; |
| 161 | + width: 1.5em; |
| 162 | + text-align: center; |
| 163 | +} |
| 164 | +a.sq-val-update:link { |
| 165 | + text-decoration: none; |
| 166 | +} |
| 167 | +a.sq-val-update:visited { |
| 168 | + text-decoration: none; |
| 169 | +} |
| 170 | +a.sq-val-update:hover { |
| 171 | + text-decoration: none; |
| 172 | +} |
| 173 | +a.sq-val-update:active { |
| 174 | + text-decoration: none; |
| 175 | +} |
129 | 176 | |
130 | 177 | a.search-result-item { |
131 | 178 | display: block; |
| 179 | + margin-right: 2em; |
132 | 180 | } |
133 | 181 | |
134 | 182 | /* TODO: support browsers which do not support data uris */ |
— | — | @@ -136,7 +184,18 @@ |
137 | 185 | padding-right: 13px; |
138 | 186 | } |
139 | 187 | |
| 188 | +#results { |
| 189 | + display: none; |
| 190 | + background-color: #ffffff; |
| 191 | + border-top: none; |
| 192 | + z-index: 2; |
| 193 | + position: absolute; |
| 194 | + left: 53px; |
| 195 | + top: 35px; |
| 196 | +} |
| 197 | + |
140 | 198 | .search_bar .search { |
| 199 | + width: 90%; |
141 | 200 | -webkit-appearance: none; |
142 | 201 | border-top-width: 0px; |
143 | 202 | border-right-width: 0px; |
— | — | @@ -146,10 +205,6 @@ |
147 | 206 | outline-width: initial; |
148 | 207 | outline-color: initial; |
149 | 208 | padding: 0; |
150 | | - font-size: 1.2em; |
151 | | - padding-right: 16px; |
152 | | - width: 100%; |
153 | | - vertical-align: middle; /* don't use line height here as placeholder on ripple positions incorrectly */ |
154 | 209 | } |
155 | 210 | |
156 | 211 | #search::-webkit-search-cancel-button { |
— | — | @@ -283,54 +338,20 @@ |
284 | 339 | margin: 0px; |
285 | 340 | } |
286 | 341 | |
287 | | -.section_heading { |
288 | | - cursor: pointer; |
289 | | -} |
290 | | - |
291 | | -button.show, |
292 | | -button.hide { /* for non-js browsers */ |
| 342 | +button.show { |
293 | 343 | display: none; |
294 | 344 | } |
295 | 345 | |
296 | | -.togglingEnabled button.hide, |
297 | | -.togglingEnabled .openSection button.show { |
298 | | - display: none; |
299 | | -} |
300 | | - |
301 | | -.togglingEnabled .openSection button.hide, |
302 | 346 | .togglingEnabled button.show { |
303 | 347 | display: inline-block; |
304 | 348 | } |
305 | 349 | |
306 | | -.openSection button.hide, |
307 | | -.openSection button.show { |
308 | | - opacity: 1; |
309 | | -} |
310 | | - |
311 | | -.togglingEnabled .section_anchors { |
| 350 | +.togglingEnabled .content_block, |
| 351 | +.togglingEnabled .section_anchors, |
| 352 | +button.section_heading.hide { |
312 | 353 | display: none; |
313 | 354 | } |
314 | 355 | |
315 | | -.togglingEnabled .content_block { |
316 | | - max-height: 0; |
317 | | - position: relative; |
318 | | - overflow: hidden; |
319 | | - -webkit-transition: max-height 0.2s ease-in; |
320 | | - -moz-transition: max-height 0.2s ease-in; |
321 | | - -o-transition: max-height 0.2s ease-in; |
322 | | - transition: max-height 0.2s ease-in; |
323 | | -} |
324 | | - |
325 | | -.togglingEnabled .openSection.section_anchors { |
326 | | - display: block; |
327 | | -} |
328 | | - |
329 | | -.togglingEnabled .openSection.content_block { |
330 | | - max-height: 9999px; /* large number as height: auto is not effected by transitions */ |
331 | | - -webkit-transition: max-height 0.7s ease-in; |
332 | | - transition: max-height 0.7s ease-in; |
333 | | -} |
334 | | - |
335 | 356 | .mwm-notice { |
336 | 357 | padding: 5px; |
337 | 358 | background: #dddddd; |
— | — | @@ -497,7 +518,6 @@ |
498 | 519 | -moz-border-radius: 5px; |
499 | 520 | background: #f9f9f9; |
500 | 521 | margin-bottom: 10px; |
501 | | - text-align: center; |
502 | 522 | } |
503 | 523 | |
504 | 524 | .thumb .thumbinner[style] { |
— | — | @@ -535,14 +555,13 @@ |
536 | 556 | } |
537 | 557 | |
538 | 558 | #header { |
539 | | - margin: 0; |
| 559 | + margin: 8px 8px 0 8px; |
540 | 560 | position: relative; |
541 | | - border-bottom: solid 1px #CCC; |
542 | 561 | } |
543 | 562 | |
544 | 563 | #content_wrapper { |
545 | 564 | clear: both; |
546 | | - margin: 22px 22px; |
| 565 | + margin: 0 8px; |
547 | 566 | } |
548 | 567 | |
549 | 568 | #footer { |
— | — | @@ -552,60 +571,51 @@ |
553 | 572 | |
554 | 573 | #logo { |
555 | 574 | position: absolute; |
556 | | - height: 22px; |
557 | | - cursor: pointer; |
558 | | - left: 22px; |
559 | | - top: 9px; |
560 | | - width: 35px; |
| 575 | + top: 4px; |
| 576 | + left: 5px; |
561 | 577 | } |
562 | 578 | |
563 | | -html[dir="rtl"] #searchbox { |
564 | | - padding: 0px 54px 0px 20px; |
565 | | -} |
566 | | - |
567 | 579 | #zero-language-search.search_bar, |
568 | 580 | #searchbox { |
569 | 581 | width: auto; |
570 | 582 | position: relative; |
571 | | - padding: 0px 40px 0px 73px; /* right = width of #logo (35px) + 22px + 16px |
572 | | - left = width of close button + 22px */ |
| 583 | + padding: 8px 32px 8px 44px; |
| 584 | + border: 1px solid #cccccc; |
573 | 585 | -webkit-border-radius: 2px; |
574 | 586 | -moz-border-radius: 2px; |
575 | | - -webkit-tap-highlight-color: rgba(255, 255, 255, 0); |
576 | 587 | } |
577 | 588 | |
578 | | -.full-screen-search #searchbox { |
579 | | - padding: 0px 40px 0px 54px; /* right = width of #logo (18px) + 22px + 16px */ |
580 | | -} |
581 | | - |
582 | 589 | #zero-language-search.search_bar { |
583 | 590 | padding: 8px 32px 8px 0px; |
584 | 591 | } |
585 | 592 | |
586 | | -html[dir="rtl"] #remove-results, |
587 | | -html[dir="rtl"] #logo { |
588 | | - right: 18px; |
589 | | - left: auto; |
| 593 | +#searchbox #form { |
| 594 | + padding-right: 34px; |
| 595 | + width: 100%; |
| 596 | + margin-bottom: 0; |
590 | 597 | } |
591 | 598 | |
| 599 | +html[dir="rtl"] #logo, |
592 | 600 | .goButton { |
593 | 601 | position: absolute; |
594 | | - right: -18px; |
| 602 | + right: 2px; |
595 | 603 | left: auto; |
596 | | - top: 0px; |
| 604 | +} |
| 605 | + |
| 606 | +.goButton { |
| 607 | + top: 2px; |
597 | 608 | border: 0; |
598 | | - background: url(images/s.gif) no-repeat center left; |
| 609 | + background: url(images/s.gif) no-repeat top left; |
599 | 610 | background-size: 27px 25px; |
600 | | - height: 40px; |
| 611 | + height: 25px; |
601 | 612 | width: 27px; |
602 | 613 | padding-bottom: 0; |
603 | | - text-indent: -999px; |
604 | | - cursor: pointer; |
| 614 | + text-indent: 999px; |
605 | 615 | } |
606 | 616 | |
607 | 617 | html[dir="rtl"] .goButton { |
608 | 618 | right: auto; |
609 | | - left: 0; |
| 619 | + left: 2px; |
610 | 620 | } |
611 | 621 | |
612 | 622 | #searchbox a, |
— | — | @@ -714,67 +724,44 @@ |
715 | 725 | full screen search css |
716 | 726 | */ |
717 | 727 | .full-screen-search #header { |
718 | | - -webkit-box-shadow: 3px 1px 8px #333; |
719 | | - -moz-box-shadow: 3px 1px 8px #333; |
720 | | - -o-box-shadow: 3px 1px 8px #333; |
721 | | - box-shadow: 3px 1px 8px #333; |
722 | | - z-index: 2; |
723 | 728 | margin: 0; |
724 | | - background-color: white; |
725 | 729 | } |
726 | 730 | |
727 | | -#results, |
728 | | -#content_wrapper { |
729 | | - transition: all 0.3s ease-in-out; |
730 | | - -webkit-transition: all 0.3s ease-in-out; |
731 | | - -moz-transition: all 0.3s ease-in-out; |
732 | | - -o-transition: all 0.3s ease-in-out; |
733 | | -} |
734 | | - |
735 | | -#content_wrapper, |
736 | | -.full-screen-search #results { |
737 | | - opacity: 1; |
738 | | - height: auto; |
739 | | -} |
740 | | - |
741 | | -#results, |
742 | | -.full-screen-search #content_wrapper { |
743 | | - height: 0; |
744 | | - overflow: hidden; |
745 | | - opacity: 0; |
746 | | -} |
747 | | - |
| 731 | +.full-screen-search #content, |
748 | 732 | .full-screen-search #footer, |
749 | 733 | .full-screen-search #zero-rated-banner-red, |
750 | 734 | .full-screen-search #zero-rated-banner { |
751 | 735 | display: none; |
752 | 736 | } |
753 | 737 | |
754 | | -#search::-webkit-search-decoration { |
755 | | - display: none; |
| 738 | +.full-screen-search #search { |
| 739 | + height: 30px; /* height of #sq - 2px border */ |
| 740 | + font-size: 1.2em; |
756 | 741 | } |
757 | 742 | |
758 | | -#header, |
759 | | -#search, |
760 | | -#sq, |
761 | | -#header form, |
762 | | -#searchbox { |
763 | | - position: relative; |
764 | | - right: 0; |
765 | | - top: 0; |
766 | | - left: 0; |
767 | | - height: 40px; |
| 743 | +html[dir="rtl"] .full-screen-search #sq { |
| 744 | + padding-left: 0; |
| 745 | + padding-right: 44px; |
768 | 746 | } |
769 | 747 | |
770 | | -#searchbox { |
771 | | - margin: 0; |
772 | | -} |
773 | | - |
774 | 748 | .full-screen-search #sq { |
| 749 | + position: relative; |
| 750 | + padding-left: 44px; |
775 | 751 | margin-right: 0; |
776 | 752 | font-size: 16px; |
| 753 | + border: none; |
| 754 | + background-color: transparent; |
777 | 755 | } |
778 | 756 | |
| 757 | +.full-screen-search #searchbox { |
| 758 | + position: absolute; |
| 759 | + width: 100%; |
| 760 | + padding: 0; |
| 761 | + top: 0; |
| 762 | + left: 0; |
| 763 | + border: none; |
| 764 | +} |
| 765 | + |
779 | 766 | .full-screen-search #logo, |
780 | 767 | .full-screen-search .goButton { |
781 | 768 | display: none; |
— | — | @@ -783,32 +770,26 @@ |
784 | 771 | .full-screen-search #results { |
785 | 772 | left: 0px; |
786 | 773 | width: 100% !important; |
787 | | - max-height: 99999px; |
788 | | - border: none; |
789 | | - z-index: 1; |
| 774 | + min-height: 100%; |
| 775 | + border-bottom: none; |
| 776 | + border-left: none; |
| 777 | + border-right: none; |
| 778 | + border-top: 1px solid #A6A6A6; |
790 | 779 | background-color: #E6E6E6; |
791 | | - position: relative; |
792 | | - opacity: 1; |
| 780 | + display: block; |
793 | 781 | } |
794 | 782 | |
795 | 783 | .full-screen-search .suggestions-results { |
| 784 | + line-height: 2.6em; |
796 | 785 | padding: 0; |
797 | 786 | position: relative; |
798 | | - padding-bottom: 20px; |
| 787 | + border-bottom: solid 1px #999; |
799 | 788 | font-size: 1.4em; |
800 | | - cursor: pointer; |
801 | | - margin: 0; |
802 | | - background-color: white; |
803 | 789 | } |
804 | 790 | |
805 | 791 | .full-screen-search .suggestions-result { |
806 | | - color: #666; |
| 792 | + line-height: 2.6em; |
807 | 793 | border: none; |
808 | | - position: relative; |
809 | | - border-bottom: solid 1px #999999; |
810 | | - border-bottom: solid 1px #eee; |
811 | | - padding: 12px 56px; |
812 | | - font-size: 0.9em; |
813 | 794 | } |
814 | 795 | |
815 | 796 | .full-screen-search .suggestions-result a:visited { |
— | — | @@ -818,16 +799,16 @@ |
819 | 800 | #remove-results { |
820 | 801 | display: none; |
821 | 802 | position: absolute; |
822 | | - width: 18px; |
| 803 | + width: 40px; |
823 | 804 | height: 40px; |
824 | 805 | text-align: center; |
825 | 806 | line-height: 40px; |
826 | | - background: url(images/arrow-left-beta.png) no-repeat scroll 0 0 transparent; |
827 | | - background-position: left center; |
828 | | - background-size: auto 18px; |
| 807 | + background: url(images/arrow-left.png) no-repeat scroll 0 0 transparent; |
| 808 | + background-position: center center; |
829 | 809 | cursor: pointer; |
830 | | - left: 24px; |
831 | | - top: 6px; /* (#header height - background height) / 2 */ |
| 810 | + zoom: 1; |
| 811 | + left: -3px; |
| 812 | + top: 3px; |
832 | 813 | margin: 1px; |
833 | 814 | margin-top: -6px; |
834 | 815 | z-index: 99; |
— | — | @@ -836,57 +817,37 @@ |
837 | 818 | overflow: hidden; |
838 | 819 | } |
839 | 820 | |
840 | | -.full-screen-search #remove-results { |
841 | | - display: block; |
| 821 | +html[dir="rtl"] #remove-results { |
| 822 | + right: 0px; |
| 823 | + left: auto; |
842 | 824 | } |
843 | 825 | |
844 | | -.full-screen-search #nav { |
845 | | - display: none !important; |
| 826 | +.full-screen-search #results { |
| 827 | + display: block !important; |
846 | 828 | } |
847 | 829 | |
848 | | -#mf-references { |
849 | | - -webkit-transition: bottom 0.1s ease-in-out; |
850 | | - -moz-transition: bottom 0.1s ease-in-out; |
851 | | - -o-transition: bottom 0.1s ease-in-out; |
852 | | - transition: bottom 0.1s ease-in-out; |
853 | | - position: fixed; |
854 | | - bottom: 0; |
855 | | - left: 0; |
856 | | - right: 0; |
857 | | - background-color: #E4E4E4; |
858 | | - padding: 22px; |
859 | | - -webkit-box-shadow: 0px -20px 10px -16px #aaa; |
860 | | - -moz-box-shadow: 0px -20px 10px -16px #aaa; |
861 | | - -o-box-shadow: 0px -20px 10px -16px #aaa; |
862 | | - box-shadow: 0px -20px 10px -16px #aaa; |
863 | | - word-break: break-word; |
864 | | - line-height: 1.4em; |
865 | | - font-size: 0.8em; |
| 830 | +.full-screen-search #remove-results { |
| 831 | + display: block; |
866 | 832 | } |
867 | 833 | |
868 | | -#mf-references button { |
869 | | - top: 22px; |
870 | | - right: 22px; /* padding of #content_wrapper */ |
871 | | - width: 16px; |
872 | | - height: 12px; |
873 | | - background: url(images/close-button-beta.png) no-repeat scroll 0 0 transparent; |
874 | | - margin: 0; |
875 | | - background-position: right center; |
876 | | - background-size: auto 12px; |
877 | | - cursor: pointer; |
878 | | - position: absolute; |
879 | | - text-indent: -999px; |
880 | | - border: none; |
| 834 | +.full-screen-search .clearlink { |
| 835 | + background: url(images/close-button.png?v=1) no-repeat scroll 0 0 transparent; |
| 836 | + top: 0px; |
| 837 | + right: 0px; |
| 838 | + height: 42px; |
| 839 | + width: 42px; |
881 | 840 | } |
882 | 841 | |
883 | | -#mf-references h3 { |
884 | | - margin: 0; |
885 | | - padding-right: 4px; |
886 | | - line-height: 1em; |
887 | | - display: inline; |
| 842 | +.full-screen-search #nav { |
| 843 | + display: none !important; |
888 | 844 | } |
889 | 845 | |
890 | | -#mf-references a:visited, |
891 | | -#mf-references a { |
892 | | - color: #3354C0; |
| 846 | +#placeholder { |
| 847 | + position: absolute; |
| 848 | + left: 38px; |
| 849 | + z-index: 2; |
| 850 | + top: 0; |
| 851 | + color: #666; |
| 852 | + font-size: 16px; |
| 853 | + padding-top: 10px; |
893 | 854 | } |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css |
— | — | @@ -31,3 +31,5 @@ |
32 | 32 | span.idx { |
33 | 33 | display: none; |
34 | 34 | } |
| 35 | + |
| 36 | + |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile |
— | — | @@ -2,6 +2,5 @@ |
3 | 3 | java -jar yuicompressor-2.4.6.jar javascripts/application.js -o javascripts/application.min.js |
4 | 4 | java -jar yuicompressor-2.4.6.jar javascripts/banner.js -o javascripts/banner.min.js |
5 | 5 | java -jar yuicompressor-2.4.6.jar javascripts/opensearch.js -o javascripts/opensearch.min.js |
6 | | - java -jar yuicompressor-2.4.6.jar javascripts/toggle.js -o javascripts/toggle.min.js |
7 | | - java -jar yuicompressor-2.4.6.jar javascripts/references.js -o javascripts/references.min.js |
| 6 | + java -jar yuicompressor-2.4.6.jar javascripts/beta_application.js -o javascripts/beta_application.min.js |
8 | 7 | java -jar yuicompressor-2.4.6.jar javascripts/beta_opensearch.js -o javascripts/beta_opensearch.min.js |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -103,16 +103,6 @@ |
104 | 104 | $wgMobileUrlTemplate = ''; |
105 | 105 | |
106 | 106 | /** |
107 | | - * The number of seconds the 'useformat' cookie should be valid |
108 | | - * |
109 | | - * The useformat cookie gets set when a user manually elects to view |
110 | | - * either the mobile or desktop view of the site. |
111 | | - * |
112 | | - * If this value is not set, it will default to $wgCookieExpiration |
113 | | - */ |
114 | | -$wgMobileFrontendFormatCookieExpiry; |
115 | | - |
116 | | -/** |
117 | 107 | * URL for script used to disable mobile site |
118 | 108 | * (protocol, host, optional port; path portion) |
119 | 109 | * |
— | — | @@ -120,8 +110,6 @@ |
121 | 111 | */ |
122 | 112 | $wgMobileRedirectFormAction = false; |
123 | 113 | |
124 | | -$wgMobileResourceVersion; |
125 | | - |
126 | 114 | $wgExtMobileFrontend = null; |
127 | 115 | |
128 | 116 | $wgExtensionFunctions[] = 'efMobileFrontend_Setup'; |
— | — | @@ -134,7 +122,6 @@ |
135 | 123 | $wgHooks['APIGetParamDescription'][] = 'ApiParseExtender::onAPIGetParamDescription'; |
136 | 124 | $wgHooks['APIGetDescription'][] = 'ApiParseExtender::onAPIGetDescription'; |
137 | 125 | |
138 | | - |
139 | 126 | function efMobileFrontend_Setup() { |
140 | 127 | global $wgExtMobileFrontend, $wgHooks; |
141 | 128 | $wgExtMobileFrontend = new ExtMobileFrontend(); |
— | — | @@ -143,7 +130,6 @@ |
144 | 131 | $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgExtMobileFrontend, 'addMobileFooter' ); |
145 | 132 | $wgHooks['TestCanonicalRedirect'][] = array( &$wgExtMobileFrontend, 'testCanonicalRedirect' ); |
146 | 133 | $wgHooks['ResourceLoaderTestModules'][] = array( &$wgExtMobileFrontend, 'addTestModules' ); |
147 | | - $wgHooks['GetCacheVaryCookies'][] = array( &$wgExtMobileFrontend, 'getCacheVaryCookies' ); |
148 | 134 | } |
149 | 135 | |
150 | 136 | /** |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php |
— | — | @@ -9,12 +9,14 @@ |
10 | 10 | public function getHTML() { |
11 | 11 | |
12 | 12 | $regularSite = $this->data['messages']['mobile-frontend-regular-site']; |
| 13 | + $permStopRedirect = $this->data['messages']['mobile-frontend-perm-stop-redirect']; |
13 | 14 | $copyright = $this->data['messages']['mobile-frontend-copyright']; |
14 | 15 | $disableImages = $this->data['messages']['mobile-frontend-disable-images']; |
15 | 16 | $enableImages = $this->data['messages']['mobile-frontend-enable-images']; |
16 | 17 | $leaveFeedback = $this->data['messages']['mobile-frontend-leave-feedback']; |
17 | 18 | |
18 | 19 | $leaveFeedbackURL = $this->data['leaveFeedbackURL']; |
| 20 | + $disableMobileSiteURL = $this->data['disableMobileSiteURL']; |
19 | 21 | $viewNormalSiteURL = $this->data['viewNormalSiteURL']; |
20 | 22 | |
21 | 23 | if ( $this->data['disableImages'] == 0 ) { |
— | — | @@ -36,7 +38,10 @@ |
37 | 39 | <div id='footer' {$footerDisplayNone}> |
38 | 40 | <div class='nav' id='footmenu'> |
39 | 41 | <div class='mwm-notice'> |
40 | | - <a href="{$viewNormalSiteURL}" id="mf-display-toggle">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink} |
| 42 | + <a href="{$viewNormalSiteURL}">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink} |
| 43 | + <div id="perm"> |
| 44 | + <a href="{$disableMobileSiteURL}">{$permStopRedirect}</a> |
| 45 | + </div> |
41 | 46 | </div> |
42 | 47 | </div> |
43 | 48 | <div id='copyright'>{$copyright}</div> |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | class ApplicationTemplate extends MobileFrontendTemplate { |
9 | 9 | |
10 | 10 | public function getHTML() { |
11 | | - global $wgMobileResourceVersion; |
| 11 | + |
12 | 12 | if ( $this->data['wgAppleTouchIcon'] !== false ) { |
13 | 13 | $appleTouchIconTag = Html::element( 'link', array( 'rel' => 'apple-touch-icon', 'href' => $this->data['wgAppleTouchIcon'] ) ); |
14 | 14 | } else { |
— | — | @@ -34,36 +34,16 @@ |
35 | 35 | $endScriptTag = '"></script>'; |
36 | 36 | $javaScriptPath = $this->data['wgExtensionAssetsPath'] . '/MobileFrontend/javascripts/'; |
37 | 37 | |
38 | | - $jQuerySupport = $this->data['device']['supports_jquery']; |
39 | | - $jQueryScript = $jQuerySupport ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
40 | | - $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js?version=' . $wgMobileResourceVersion . $endScriptTag : ''; |
| 38 | + $jQueryScript = ( $this->data['device']['supports_jquery'] ) ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
| 39 | + $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js?version=122920111241' . $endScriptTag : ''; |
41 | 40 | |
42 | 41 | $startLinkTag = "<link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/"; |
43 | 42 | $endLinkTag = "' media='all' rel='Stylesheet' type='text/css' />"; |
44 | 43 | $filePageStyle = ( $this->data['isFilePage'] ) ? $startLinkTag . 'filepage.css' . $endLinkTag : ''; |
45 | | - $buttonHideText = Xml::escapeJsString( $this->data['hideText'] ); |
46 | | - $buttonShowText = Xml::escapeJsString( $this->data['showText'] ); |
| 44 | + $buttonHideText = htmlentities( $this->data['hideText'], ENT_QUOTES ); |
| 45 | + $buttonShowText = htmlentities( $this->data['showText'], ENT_QUOTES ); |
47 | 46 | |
48 | | - $jsconfig = array( |
49 | | - 'messages' => array( |
50 | | - 'expand-section' => $buttonShowText, |
51 | | - 'collapse-section' => $buttonHideText |
52 | | - ), |
53 | | - 'settings' => array( |
54 | | - 'scriptPath' => ( $this->data['wgScriptPath'] ), |
55 | | - 'useFormatCookieName' => ( $this->data['useFormatCookieName'] ), |
56 | | - 'useFormatCookieDuration' => ( $this->data['useFormatCookieDuration'] ), |
57 | | - ), |
58 | | - ); |
59 | | - $configuration = FormatJSON::encode( $jsconfig ); |
60 | 47 | |
61 | | - if( $this->data['isBetaGroupMember'] && $jQuerySupport ) { |
62 | | - $betajs = <<<HTML |
63 | | - {$startScriptTag}{$javaScriptPath}references.{$resourceSuffix}js?version={$wgMobileResourceVersion}{$endScriptTag} |
64 | | -HTML; |
65 | | - } else { |
66 | | - $betajs = ""; |
67 | | - } |
68 | 48 | $applicationHtml = <<<HTML |
69 | 49 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
70 | 50 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
— | — | @@ -71,14 +51,20 @@ |
72 | 52 | <head> |
73 | 53 | <title>{$this->data['htmlTitle']}</title> |
74 | 54 | <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> |
75 | | - <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$betaPrefix}common.css?version={$wgMobileResourceVersion}' media='all' rel='Stylesheet' type='text/css' /> |
76 | | - <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$cssFileName}.css?version={$wgMobileResourceVersion}' media='all' rel='Stylesheet' type='text/css' /> |
| 55 | + <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$betaPrefix}common.css?version=1331257310' media='all' rel='Stylesheet' type='text/css' /> |
| 56 | + <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$cssFileName}.css?version=1331257310' media='all' rel='Stylesheet' type='text/css' /> |
77 | 57 | {$filePageStyle} |
78 | | - <meta name="viewport" content="initial-scale=1.0"> |
| 58 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
79 | 59 | {$appleTouchIconTag} |
80 | 60 | {$jQueryScript} |
81 | | - <script type="text/javascript"> |
82 | | - var mwMobileFrontendConfig = {$configuration}; |
| 61 | + <script type='text/javascript'> |
| 62 | + //<![CDATA[ |
| 63 | + var title = "{$this->data['htmlTitle']}"; |
| 64 | + var scriptPath = "{$this->data['wgScriptPath']}"; |
| 65 | + var placeholder = "{$this->data['placeholder']}"; |
| 66 | + var showText = "{$buttonShowText}"; |
| 67 | + var hideText = "{$buttonHideText}"; |
| 68 | + //]]> |
83 | 69 | </script> |
84 | 70 | </head> |
85 | 71 | <body> |
— | — | @@ -90,11 +76,9 @@ |
91 | 77 | </div> |
92 | 78 | {$this->data['footerHtml']} |
93 | 79 | <!--[if gt IE 9]><!--> |
94 | | - {$startScriptTag}{$javaScriptPath}application.{$resourceSuffix}js?version={$wgMobileResourceVersion}{$endScriptTag} |
95 | | - {$startScriptTag}{$javaScriptPath}toggle.{$resourceSuffix}js?version={$wgMobileResourceVersion}{$endScriptTag} |
96 | | - {$startScriptTag}{$javaScriptPath}banner.{$resourceSuffix}js?version={$wgMobileResourceVersion}{$endScriptTag} |
97 | | - {$startScriptTag}{$javaScriptPath}{$betaPrefix}opensearch.{$resourceSuffix}js?version={$wgMobileResourceVersion}{$endScriptTag} |
98 | | - {$betajs} |
| 80 | + {$startScriptTag}{$javaScriptPath}{$betaPrefix}application.{$resourceSuffix}js?version=1331257310{$endScriptTag} |
| 81 | + {$startScriptTag}{$javaScriptPath}banner.{$resourceSuffix}js?version=1331257310{$endScriptTag} |
| 82 | + {$startScriptTag}{$javaScriptPath}{$betaPrefix}opensearch.{$resourceSuffix}js?version=1331250599{$endScriptTag} |
99 | 83 | {$filePageScript} |
100 | 84 | <!--[endif]--> |
101 | 85 | </body> |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/DisableTemplate.php |
— | — | @@ -8,9 +8,7 @@ |
9 | 9 | |
10 | 10 | public function getHTML() { |
11 | 11 | |
12 | | - |
13 | | - $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $this->data['currentURL'] ); |
14 | | - $currentURL = str_replace( '&useformat=mobile', '', $currentURL ); |
| 12 | + $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $this->data['currentURL'] ); // TODO: $currentURl is unused |
15 | 13 | $mobileRedirectFormAction = $this->data['mobileRedirectFormAction']; |
16 | 14 | |
17 | 15 | $disableHtml = <<<HTML |
— | — | @@ -22,7 +20,7 @@ |
23 | 21 | </p> |
24 | 22 | <div id='disableButtons'> |
25 | 23 | <form action='{$mobileRedirectFormAction}' method='get'> |
26 | | - <input name='to' type='hidden' value='{$currentURL}' /> |
| 24 | + <input name='to' type='hidden' value='{$this->data['currentURL']}' /> |
27 | 25 | <input name='expires_in_days' type='hidden' value='3650' /> |
28 | 26 | <button id='disableButton' type='submit'>{$this->data['disableButton']}</button> |
29 | 27 | </form> |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php |
— | — | @@ -8,14 +8,12 @@ |
9 | 9 | |
10 | 10 | public function getHTML() { |
11 | 11 | |
12 | | - $searchField = Xml::escapeJsString( $this->data['searchField'] ); |
| 12 | + $searchField = htmlspecialchars( $this->data['searchField'] ); |
13 | 13 | $mainPageUrl = $this->data['mainPageUrl']; |
14 | 14 | $randomPageUrl = $this->data['randomPageUrl']; |
15 | 15 | $homeButton = $this->data['messages']['mobile-frontend-home-button']; |
16 | 16 | $randomButton = $this->data['messages']['mobile-frontend-random-button']; |
17 | | - $clearText = Xml::escapeJsString( $this->data['messages']['mobile-frontend-clear-search'] ); |
18 | | - $searchValue = $this->data['messages']['mobile-frontend-search-submit']; |
19 | | - $placeholder = Xml::escapeJsString( $this->data['messages']['mobile-frontend-placeholder'] ); |
| 17 | + $clearText = htmlentities( $this->data['messages']['mobile-frontend-clear-search'], ENT_QUOTES ); |
20 | 18 | |
21 | 19 | $scriptUrl = wfScript(); |
22 | 20 | $searchBoxDisplayNone = ( $this->data['hideSearchBox'] ) ? ' style="display: none;" ' : ''; |
— | — | @@ -26,16 +24,17 @@ |
27 | 25 | |
28 | 26 | $languageSelection = $this->data['buildLanguageSelection'] . '<br/>'; |
29 | 27 | $languageSelectionText = '<b>' . $this->data['messages']['mobile-frontend-language'] . ':</b><br/>'; |
30 | | - $languageSelectionDiv = $languageSelectionText . $languageSelection; |
| 28 | + $languageSelectionDiv = '<div id="languageselectionsection">' . $languageSelectionText . $languageSelection . '</div>'; |
31 | 29 | |
32 | 30 | $searchWebkitHtml = <<<HTML |
| 31 | + {$openSearchResults} |
33 | 32 | <div id='header'> |
34 | 33 | <div id='searchbox' {$logoDisplayNone}> |
35 | 34 | <img width="35" height="22" alt='Logo' id='logo' src='{$this->data['wgMobileFrontendLogo']}' {$logoDisplayNone} /> |
36 | 35 | <form action='{$scriptUrl}' class='search_bar' method='get' {$searchBoxDisplayNone}> |
37 | 36 | <input type="hidden" value="Special:Search" name="title" /> |
38 | 37 | <div id="sq" class="divclearable"> |
39 | | - <input type="search" name="search" id="search" size="22" value="{$searchField}" autocorrect="off" autocomplete="off" autocapitalize="off" maxlength="1024" class="search" placeholder="{$placeholder}" /> |
| 38 | + <input type="search" name="search" id="search" size="22" value="{$searchField}" autocorrect="off" autocomplete="off" autocapitalize="off" maxlength="1024" class="search" /> |
40 | 39 | <div class="clearlink" id="clearsearch" title="{$clearText}"></div> |
41 | 40 | </div> |
42 | 41 | <button id='goButton' class='goButton' type='submit'></button> |
— | — | @@ -47,7 +46,6 @@ |
48 | 47 | <a href="{$randomPageUrl}" id="randomButton" class="button">{$randomButton}</a> |
49 | 48 | </div> |
50 | 49 | </div> |
51 | | - {$openSearchResults} |
52 | 50 | HTML; |
53 | 51 | return $searchWebkitHtml; |
54 | 52 | } |
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend |
___________________________________________________________________ |
Modified: svn:mergeinfo |
55 | 53 | Reverse-merged /trunk/extensions/MobileFrontend:r113463,113465-113466,113469-113472,113486,113488,113512,113553,113640,113642,113644-113645,113685,113693,113695,113714,113720-113721,113726,113730,113769-113771,113778,113807,113831-113832,113865-113866,113870-113872,113876,113880-113883,113885,113887,113897-113901,113930,113942,113971,113987,114005,114025,114100,114134,114136,114144-114145,114150,114152,114157,114177,114184,114190-114191,114193,114211-114212,114214,114220 |