r107432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107431‎ | r107432 | r107433 >
Date:21:40, 27 December 2011
Author:rmoen
Status:ok
Tags:
Comment:
made click functions dryer by moving declaration into markItem method. follow up r107095
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
@@ -48,7 +48,8 @@
4949
5050 $.ajax({
5151 type: 'get',
52 - url: mw.util.wikiScript('api') + '?' + Math.random(Date.now), // added randomness to prevent ie7 cache
 52+ url: mw.util.wikiScript('api'),
 53+ cache: false,
5354 data: request,
5455 success: function( data ) {
5556
@@ -71,8 +72,9 @@
7273 /*
7374 * API call to mark or unmark an item as helpful.
7475 */
75 - markItem: function( $item, action ) {
76 - var props = mah.getItemProperties( $item ),
 76+ markItem: function( $clicked, action ) {
 77+ var $item = $clicked.parent().parent(),
 78+ props = mah.getItemProperties( $item ),
7779 clientData = $.client.profile(),
7880 request;
7981 props.mahaction = action;
@@ -104,18 +106,16 @@
105107 * Click Event for marking an item as helpful.
106108 */
107109 $( '.markashelpful-mark' ).live( 'click', function() {
108 - var $item = $( this ).parent().parent();
109 - mah.markItem( $item, 'mark' );
 110+ mah.markItem( $(this), 'mark' );
110111 } );
111112
112113 /*
113114 * Click Event for removing helpful status from an item.
114115 */
115116 $( '.markashelpful-undo' ).live( 'click', function() {
116 - var $item = $( this ).parent().parent();
117 - mah.markItem( $item, 'unmark' );
 117+ mah.markItem( $(this), 'unmark' );
118118 } );
119119
120120 // Initialize MarkAsHelpful
121121 $( mah.init );
122 -} ) ( jQuery );
 122+} ) ( jQuery );
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107095Make $item vars local and put .init() call in document readycatrope19:27, 22 December 2011

Status & tagging log