r107095 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107094‎ | r107095 | r107096 >
Date:19:27, 22 December 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Make $item vars local and put .init() call in document ready
Modified paths:
  • /trunk/extensions/MarkAsHelpful/modules/ext.markAsHelpful/ext.markAsHelpful.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MarkAsHelpful/modules/ext.markAsHelpful/ext.markAsHelpful.js
@@ -108,7 +108,7 @@
109109 * Click Event for marking an item as helpful.
110110 */
111111 $( '.markashelpful-mark' ).live( 'click', function() {
112 - $item = $( this ).parent().parent();
 112+ var $item = $( this ).parent().parent();
113113 mah.markItem( $item, 'mark' );
114114 } );
115115
@@ -116,7 +116,7 @@
117117 * Click Event for removing helpful status from an item.
118118 */
119119 $( '.markashelpful-undo' ).live( 'click', function() {
120 - $item = $( this ).parent().parent();
 120+ var $item = $( this ).parent().parent();
121121 mah.markItem( $item, 'unmark' );
122122 } );
123123
@@ -136,5 +136,5 @@
137137 };
138138
139139 // Initialize MarkAsHelpful
140 - mah.init();
141 -} ) ( jQuery );
\ No newline at end of file
 140+ $( mah.init );
 141+} ) ( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r107432made click functions dryer by moving declaration into markItem method. follo...rmoen21:40, 27 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   08:46, 23 December 2011

JavaScript doesn't have block scope, the variable should be declared only once.

Status & tagging log