r90397 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90396‎ | r90397 | r90398 >
Date:16:32, 19 June 2011
Author:ashley
Status:deferred
Tags:
Comment:
MobileFrontend: stylize application.js, add some missing semicolons and trim trailing whitespace
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/application.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/application.js
@@ -1,80 +1,79 @@
2 -/* Super gross hack implemented where MOST of the JS is repeated in lib/native_app_hack.rb
 2+/* Super gross hack implemented where MOST of the JS is repeated in lib/native_app_hack.rb
33 If you make significant changes here, make sure to update that version too!*/
44
5 -$(document).ready(function(){
6 - $("#logo").click(function() {
7 - $("#nav").toggle();
8 - })
 5+$( document ).ready( function() {
 6+ $( '#logo' ).click( function() {
 7+ $( '#nav' ).toggle();
 8+ });
99
10 - $("h2.section_heading").click(function() {
11 - var section_idx = parseInt($(this).get(0).id.replace( /section_(\d+)/, "$1" ));
12 - wm_toggle_section( section_idx );
13 - })
 10+ $( 'h2.section_heading' ).click( function() {
 11+ var section_idx = parseInt( $( this ).get( 0 ).id.replace( /section_(\d+)/, '$1' ) );
 12+ wm_toggle_section( section_idx );
 13+ });
1414
15 - $("a").click(function() {
16 - var link = $(this).get(0)
17 - if( link.hash.indexOf("#") == 0 ) {
18 - wm_reveal_for_hash( link.hash )
19 - }
20 - })
 15+ $( 'a' ).click( function() {
 16+ var link = $( this ).get( 0 );
 17+ if( link.hash.indexOf( '#' ) == 0 ) {
 18+ wm_reveal_for_hash( link.hash );
 19+ }
 20+ });
2121
22 - if( document.location.hash.indexOf("#") == 0 ) {
23 - wm_reveal_for_hash( document.location.hash )
24 - }
25 -
26 - updateOrientation();
27 -
28 - decode = $("#searchField");
29 - decode.val(unescape(decode.val()));
30 - decode = $("title");
31 - decode.html(unescape(decode.html()));
 22+ if( document.location.hash.indexOf( '#' ) == 0 ) {
 23+ wm_reveal_for_hash( document.location.hash );
 24+ }
3225
 26+ updateOrientation();
 27+
 28+ decode = $( '#searchField' );
 29+ decode.val( unescape( decode.val() ) );
 30+ decode = $( 'title' );
 31+ decode.html( unescape( decode.html() ) );
3332 });
3433
35 -/* updateOrientation checks the current orientation, sets the body's class attribute to portrait, landscapeLeft, or landscapeRight,
36 - and displays a descriptive message on "Handling iPhone or iPod touch Orientation Events". */
37 -function updateOrientation()
38 -{
39 - switch(window.orientation)
40 - {
41 - case 0:
42 - document.body.setAttribute("class","portrait");
43 - break;
44 - case 90:
45 - case -90:
46 - document.body.setAttribute("class","landscape");
 34+/**
 35+ * updateOrientation checks the current orientation, sets the body's class
 36+ * attribute to portrait, landscapeLeft, or landscapeRight,
 37+ * and displays a descriptive message on "Handling iPhone or iPod touch Orientation Events".
 38+ */
 39+function updateOrientation() {
 40+ switch( window.orientation ) {
 41+ case 0:
 42+ document.body.setAttribute( 'class', 'portrait' );
 43+ break;
 44+ case 90:
 45+ case -90:
 46+ document.body.setAttribute( 'class', 'landscape' );
4747 }
4848 }
4949
5050 // Point to the updateOrientation function when iPhone switches between portrait and landscape modes.
5151 window.onorientationchange = updateOrientation;
5252
53 -
5453 function wm_reveal_for_hash( hash ) {
55 - var targetel = $(hash)
56 - if(targetel) {
57 - var parentdiv = targetel.parents("div.content_block")
58 - if(parentdiv.length > 0 && ! parentdiv.is(':visible')) {
59 - var section_idx = parseInt(parentdiv.get(0).id.replace( /content_(\d+)/, "$1" ));
60 - wm_toggle_section( section_idx )
61 - }
62 - }
 54+ var targetel = $( hash );
 55+ if( targetel ) {
 56+ var parentdiv = targetel.parents( 'div.content_block' );
 57+ if( parentdiv.length > 0 && ! parentdiv.is( ':visible' ) ) {
 58+ var section_idx = parseInt( parentdiv.get( 0 ).id.replace( /content_(\d+)/, '$1' ) );
 59+ wm_toggle_section( section_idx );
 60+ }
 61+ }
6362 }
6463
6564 function wm_toggle_section( section_id ) {
66 - $("h2#section_" + section_id).children("button.show").toggle();
67 - $("h2#section_" + section_id).children("button.hide").toggle();
 65+ $( 'h2#section_' + section_id ).children( 'button.show' ).toggle();
 66+ $( 'h2#section_' + section_id ).children( 'button.hide' ).toggle();
6867
69 - $("div#content_" + section_id).toggle()
70 - $("div#anchor_" + section_id).toggle()
 68+ $( 'div#content_' + section_id ).toggle();
 69+ $( 'div#anchor_' + section_id ).toggle();
7170 }
7271
7372 var wm_clearText = function() {
74 - document.getElementById("searchField").value = "";
75 - $("#searchField").val("").focus();
 73+ document.getElementById( 'searchField' ).value = '';
 74+ $( '#searchField' ).val( '' ).focus();
7675 }
7776
7877 // If we are on iPhone, scroll down and hide URL bar
79 -if(navigator.userAgent.indexOf("iPhone") > 0) {
80 - window.scrollTo(0, 1);
 78+if( navigator.userAgent.indexOf( 'iPhone' ) > 0 ) {
 79+ window.scrollTo( 0, 1 );
8180 }

Status & tagging log