r102670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102669‎ | r102670 | r102671 >
Date:17:40, 10 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
got rid of inline js and made use of jQuery
Modified paths:
  • /trunk/extensions/Nuke/Nuke.php (modified) (history)
  • /trunk/extensions/Nuke/Nuke_body.php (modified) (history)
  • /trunk/extensions/Nuke/ext.nuke.js (added) (history)

Diff [purge]

Index: trunk/extensions/Nuke/Nuke_body.php
@@ -123,19 +123,7 @@
124124
125125 $nuke = $this->getTitle();
126126
127 - $script = <<<JAVASCRIPT
128 -<script type="text/javascript">
129 -function selectPages( bool ) {
130 - var inputs = document.getElementsByTagName("input");
131 - for (i = 0; i < inputs.length; i++) {
132 - if (inputs[i].type == "checkbox") {
133 - inputs[i].checked = bool;
134 - }
135 - }
136 -}
137 -</script>
138 -JAVASCRIPT;
139 - $out->addScript( $script );
 127+ $out->addModules( 'ext.nuke' );
140128
141129 $out->addHTML(
142130 Xml::openElement( 'form', array(
@@ -154,9 +142,9 @@
155143
156144 // Select: All, None
157145 $links = array();
158 - $links[] = '<a href="#" onclick="selectPages( true ); return false;">' .
 146+ $links[] = '<a href="#" id="toggleall">' .
159147 wfMsg( 'powersearch-toggleall' ) . '</a>';
160 - $links[] = '<a href="#" onclick="selectPages( false ); return false;">' .
 148+ $links[] = '<a href="#" id="togglenone">' .
161149 wfMsg( 'powersearch-togglenone' ) . '</a>';
162150 $out->addHTML(
163151 Xml::tags( 'p',
@@ -174,6 +162,7 @@
175163
176164 foreach( $pages as $info ) {
177165 list( $title, $edits, $userName ) = $info;
 166+
178167 $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
179168 $thumb = $image && $image->exists() ? $image->transform( array( 'width' => 120, 'height' => 120 ), 0 ) : false;
180169
Index: trunk/extensions/Nuke/Nuke.php
@@ -4,7 +4,7 @@
55 die( 'Not an entry point.' );
66 }
77
8 -define( 'Nuke_VERSION', '1.1.1' );
 8+define( 'Nuke_VERSION', '1.1.2' );
99
1010 $dir = dirname(__FILE__) . '/';
1111
@@ -26,3 +26,19 @@
2727 $wgAutoloadClasses['SpecialNuke'] = $dir . 'Nuke_body.php';
2828 $wgSpecialPages['Nuke'] = 'SpecialNuke';
2929 $wgSpecialPageGroups['Nuke'] = 'pagetools';
 30+
 31+// Resource loader modules
 32+$moduleTemplate = array(
 33+ 'localBasePath' => dirname( __FILE__ ) . '/',
 34+ 'remoteExtPath' => 'Nuke/'
 35+);
 36+
 37+$wgResourceModules['ext.nuke'] = $moduleTemplate + array(
 38+ 'scripts' => array(
 39+ 'ext.nuke.js'
 40+ ),
 41+ 'messages' => array(
 42+ )
 43+);
 44+
 45+unset( $moduleTemplate );
Index: trunk/extensions/Nuke/ext.nuke.js
@@ -0,0 +1,18 @@
 2+/**
 3+ * JavasSript for the Nuke MediaWiki extension.
 4+ * @see https://www.mediawiki.org/wiki/Extension:Nuke
 5+ *
 6+ * @licence GNU GPL v2 or later
 7+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 8+ */
 9+
 10+(function( $, mw ) { $( document ).ready( function() {
 11+
 12+ function selectPages( check ) {
 13+ $( 'input[type=checkbox]' ).prop( 'checked', check )
 14+ }
 15+
 16+ $( '#toggleall' ).click( function(){ selectPages( true ); } );
 17+ $( '#togglenone' ).click( function(){ selectPages( false ); } );
 18+
 19+} ); })( window.jQuery, window.mediaWiki );
\ No newline at end of file

Status & tagging log