Index: trunk/extensions/CodeReview/modules/ext.codereview.overview.js |
— | — | @@ -1,31 +1,36 @@ |
2 | | -/* Scap roadmap viewer, version [0.0.7] |
3 | | - * Originally from: http://www.mediawiki.org/wiki/User:Splarka/scapmap.js |
| 2 | +/** |
| 3 | + * Revision overview widget for the MediaWiki CodeReview extension |
| 4 | + * Based on http://www.mediawiki.org/wiki/User:Splarka/scapmap.js |
4 | 5 | * |
| 6 | + * Adds an "Overview" portlet link on pages with a revision table on SpecialCode. |
| 7 | + * When triggered the overview slides out with boxes, each representing a revision. |
| 8 | + * The boxes links take you to that relevant row in the table, and a backlink is created |
| 9 | + * in the id column. |
5 | 10 | * |
6 | | - * Loads on, for example: http://www.mediawiki.org/wiki/Special:Code/MediaWiki |
7 | | - * Click [overview] to generate map. |
8 | | - * Text in the "path" input box is stripped from the path line in the summary. |
9 | | - * Clicking a colored box takes you to that relevant line, and a backlink is created in the id column on focus. |
10 | | - * Hovering over a colored box pops up a little info packet box. |
| 11 | + * Hovering over a colored box shows a tooltip containg info from the table row. |
11 | 12 | */ |
12 | 13 | jQuery( function( $ ) { |
13 | | - // check if we're on a page with a useful list of revisions |
14 | | - if( $( '#path' ).size() && $('table.TablePager').size() ) { |
15 | | - var portlet = $( '#p-namespaces' ).size() ? 'p-namespaces' : 'p-cactions'; |
16 | | - mw.util.addPortletLink( |
17 | | - portlet, |
18 | | - '#', |
19 | | - mw.msg( 'codereview-overview-title' ), |
20 | | - 'ca-scapmap', |
21 | | - mw.msg( 'codereview-overview-desc' ) |
22 | | - ); |
| 14 | + |
| 15 | + // Return early if this page doesn't qualify |
| 16 | + if ( !$( '#path' ).length || !$( 'table.TablePager' ).length ) { |
| 17 | + return; |
23 | 18 | } |
24 | 19 | |
25 | | - $('#ca-scapmap').click( function () { |
| 20 | + var portletLink = mw.util.addPortletLink( |
| 21 | + $( '#p-namespaces' ).length ? 'p-namespaces' : 'p-cactions', |
| 22 | + '#', |
| 23 | + mw.msg( 'codereview-overview-title' ), |
| 24 | + 'ca-scapmap', |
| 25 | + mw.msg( 'codereview-overview-desc' ) |
| 26 | + ), |
| 27 | + // Cache since we'll be using this a few times |
| 28 | + $portletLink = $( portletLink ); |
| 29 | + |
| 30 | + $portletLink.click( function() { |
26 | 31 | var $tr = $('table.TablePager tr'); |
27 | | - if( $tr.size() < 2 ){ |
| 32 | + if ( $tr.length < 2 ){ |
28 | 33 | return; |
29 | | - } else if( $('#overviewmap').size() ) { |
| 34 | + } else if ( $('#overviewmap').length ) { |
30 | 35 | // We've already created it; maybe they just want to toggle it on and off |
31 | 36 | $('#overviewmap').slideToggle(); |
32 | 37 | return; |
— | — | @@ -42,13 +47,13 @@ |
43 | 48 | var status = false; |
44 | 49 | |
45 | 50 | var trc = $(this).attr( 'class' ); |
46 | | - if( !trc || !trc.length ) { |
| 51 | + if ( !trc || !trc.length ) { |
47 | 52 | return; |
48 | 53 | } else { |
49 | 54 | trc = trc.split( ' ' ); |
50 | 55 | } |
51 | | - for( var j = 0; j < trc.length; j++ ) { |
52 | | - if( trc[j].substring( 0, 21 ) == 'mw-codereview-status-' ) { |
| 56 | + for ( var j = 0; j < trc.length; j++ ) { |
| 57 | + if ( trc[j].substring( 0, 21 ) == 'mw-codereview-status-' ) { |
53 | 58 | status = trc[j].substring( 21 ); |
54 | 59 | } |
55 | 60 | } |
— | — | @@ -56,7 +61,7 @@ |
57 | 62 | |
58 | 63 | var statusname = $td.filter( '.TablePager_col_cr_status' ).text(); |
59 | 64 | |
60 | | - if( !statusname || !status ) { |
| 65 | + if ( !statusname || !status ) { |
61 | 66 | return; |
62 | 67 | } |
63 | 68 | |
— | — | @@ -70,12 +75,12 @@ |
71 | 76 | }; |
72 | 77 | |
73 | 78 | var path = $td.filter( '.TablePager_col_cr_path' ).text(); |
74 | | - if( path && path.indexOf( vpath ) == 0 && path != vpath && vpath != '' ) { |
| 79 | + if ( path && path.indexOf( vpath ) == 0 && path != vpath && vpath != '' ) { |
75 | 80 | path = '\u2026' + path.substring( vpath.length ); |
76 | 81 | } |
77 | 82 | overviewPopupData[i]['path'] = path; |
78 | 83 | |
79 | | - if( !totals[statusname] ) { |
| 84 | + if ( !totals[statusname] ) { |
80 | 85 | totals[statusname] = 0; |
81 | 86 | } |
82 | 87 | totals[statusname]++; |
— | — | @@ -90,24 +95,24 @@ |
91 | 96 | }); |
92 | 97 | |
93 | 98 | var sumtext = []; |
94 | | - for( var i in totals ) { |
95 | | - if( typeof i != 'string' || typeof totals[i] != 'number' ) { |
| 99 | + for ( var i in totals ) { |
| 100 | + if ( typeof i != 'string' || typeof totals[i] != 'number' ) { |
96 | 101 | continue; |
97 | 102 | } |
98 | 103 | sumtext.push( i + ': ' + totals[i] ); |
99 | 104 | } |
100 | 105 | sumtext.sort(); |
101 | 106 | var $summary = $( '<div class="summary">' ) |
102 | | - .text( 'Total revisions: ' + ( $tr.size() - 1 ) + '. [' + sumtext.join(', ') + ']' ); |
| 107 | + .text( 'Total revisions: ' + ( $tr.length - 1 ) + '. [' + sumtext.join(', ') + ']' ); |
103 | 108 | |
104 | 109 | $( '#overviewmap' ) |
105 | 110 | .append( $summary ) |
106 | | - .css( 'max-width', Math.floor( Math.sqrt( $tr.size() ) ) * 30 ) |
| 111 | + .css( 'max-width', Math.floor( Math.sqrt( $tr.length ) ) * 30 ) |
107 | 112 | .slideDown(); |
108 | 113 | |
109 | 114 | // Add the hover popup |
110 | 115 | $( '#overviewmap > a' ) |
111 | | - .mouseenter( function () { |
| 116 | + .mouseenter( function() { |
112 | 117 | |
113 | 118 | var $el = $( this ); |
114 | 119 | if ( $el.data('overviewPopup') ) { |
Index: trunk/extensions/MobileFrontend/views/layout/application.html.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -global $wgExtensionAssetsPath, $wgAppleTouchIcon; |
| 3 | +global $wgScriptPath, $wgExtensionAssetsPath, $wgAppleTouchIcon; |
4 | 4 | |
5 | 5 | $dir = self::$dir; |
6 | 6 | $code = self::$code; |
— | — | @@ -12,19 +12,31 @@ |
13 | 13 | |
14 | 14 | $cssFileName = ( isset( self::$device['css_file_name'] ) ) ? self::$device['css_file_name'] : 'default'; |
15 | 15 | |
| 16 | +if ( @$_GET['patch'] == '1' ) { |
| 17 | + |
| 18 | + $script = ''; |
| 19 | + |
| 20 | + |
| 21 | +} else { |
| 22 | + |
| 23 | + $script = '<script type="text/javascript" language="javascript" src="'.$wgExtensionAssetsPath.'/MobileFrontend/javascripts/application.js"></script>'; |
| 24 | + |
| 25 | +} |
| 26 | + |
| 27 | + |
16 | 28 | $applicationHtml = <<<EOT |
17 | 29 | <!DOCTYPE html PUBLIC |
18 | 30 | "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" |
19 | 31 | "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"> |
20 | | -<html lang='{$code}' dir='{$dir}' xml:lang='{$code}' xmlns='http://www.w3.org/1999/xhtml'> |
| 32 | +<html lang="{$code}" dir="{$dir}" xml:lang="{$code}" xmlns="http://www.w3.org/1999/xhtml"> |
21 | 33 | <head> |
22 | 34 | <title>{$htmlTitle}</title> |
23 | 35 | <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> |
24 | | - <link href='{$wgExtensionAssetsPath}/MobileFrontend/stylesheets/{$cssFileName}.css' media='all' rel='Stylesheet' type='text/css' /> |
| 36 | + <link href="{$wgExtensionAssetsPath}/MobileFrontend/stylesheets/{$cssFileName}.css" media="all" rel="Stylesheet" type="text/css" /> |
25 | 37 | <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> |
26 | | - <meta name = "viewport" content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> |
| 38 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> |
27 | 39 | ${appleTouchIconTag} |
28 | | - <script type='text/javascript'> |
| 40 | + <script type="text/javascript"> |
29 | 41 | //<![CDATA[ |
30 | 42 | var title = "{$htmlTitle}"; |
31 | 43 | function shouldCache() { |
— | — | @@ -32,12 +44,12 @@ |
33 | 45 | } |
34 | 46 | //]]> |
35 | 47 | </script> |
36 | | - <script type="text/javascript" language="javascript" src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/jquery.js"></script> |
37 | | - <script type="text/javascript" language="javascript" src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/application.js"></script> |
| 48 | + <script type="text/javascript" language="javascript" src="{$wgScriptPath}/resources/jquery/jquery.js"></script> |
| 49 | + {$script} |
38 | 50 | </head> |
39 | 51 | <body> |
40 | 52 | {$searchWebkitHtml} |
41 | | - <div class='show' id='content_wrapper'> |
| 53 | + <div class="show" id="content_wrapper"> |
42 | 54 | {$contentHtml} |
43 | 55 | </div> |
44 | 56 | {$footerHtml} |