r98078 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98077‎ | r98078 | r98079 >
Date:19:22, 25 September 2011
Author:aaron
Status:ok
Tags:
Comment:
* Made flaggedrevs.js use jquery
* Make sure pending change diffs in UI boxes have a white background
Modified paths:
  • /trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.css (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.js (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.css
@@ -381,4 +381,8 @@
382382
383383 #mw-fr-diff-headeritems {
384384 direction: ltr;
385 -}
\ No newline at end of file
 385+}
 386+
 387+#mw-fr-stablediff {
 388+ background-color: white;
 389+}
Index: trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.js
@@ -8,69 +8,55 @@
99 /* Dropdown collapse timer */
1010 'boxCollapseTimer': null,
1111
12 - /* Enables rating/diff clutter via show/hide */
13 - 'enableShowhide': function() {
14 - // Rating detail box
15 - var toggle = document.getElementById('mw-fr-revisiontoggle');
16 - if ( toggle ) {
17 - toggle.style.display = 'inline'; /* show toggle control */
 12+ /* Startup function */
 13+ 'init': function() {
 14+ // Enables rating detail box
 15+ var toggle = $('#mw-fr-revisiontoggle');
 16+ if ( toggle.length ) {
 17+ toggle.css('display','inline'); /* show toggle control */
1818 this.hideBoxDetails(); /* hide the initially displayed ratings */
1919 }
20 - // Diff detail box
21 - toggle = document.getElementById('mw-fr-difftoggle');
22 - if ( toggle ) {
23 - toggle.style.display = 'inline'; /* show toggle control */
24 - var diff = document.getElementById('mw-fr-stablediff');
25 - if ( diff ) {
26 - diff.style.display = 'none';
27 - }
 20+ // Enables diff detail box
 21+ toggle = $('#mw-fr-difftoggle');
 22+ if ( toggle.length ) {
 23+ toggle.css('display','inline'); /* show toggle control */
 24+ $('#mw-fr-stablediff').hide();
2825 }
29 - // Log detail box
30 - toggle = document.getElementById('mw-fr-logtoggle');
31 - if ( toggle ) {
32 - toggle.style.display = 'inline'; /* show toggle control */
33 - var log = document.getElementById('mw-fr-logexcerpt');
34 - if ( log ) {
35 - log.style.display = 'none';
36 - }
 26+ // Enables log detail box
 27+ toggle = $('#mw-fr-logtoggle');
 28+ if ( toggle.length ) {
 29+ toggle.css('display','inline'); /* show toggle control */
 30+ $('#mw-fr-logexcerpt').hide();
3731 }
 32+ // Enables changing of save button when "review this" checkbox changes */
 33+ $('#wpReviewEdit').click( FlaggedRevs.updateSaveButton );
3834 },
3935
4036 /* Expands flag info box details */
4137 'showBoxDetails': function() {
42 - var ratings = document.getElementById('mw-fr-revisiondetails');
43 - if ( ratings ) {
44 - ratings.style.display = 'block';
45 - }
 38+ $('#mw-fr-revisiondetails').css('display','block');
4639 },
4740
4841 /* Collapses flag info box details */
4942 'hideBoxDetails': function( event ) {
50 - var ratings = document.getElementById('mw-fr-revisiondetails');
51 - if ( ratings ) {
52 - ratings.style.display = 'none';
53 - }
 43+ $('#mw-fr-revisiondetails').css('display','none');
5444 },
5545
5646 /* Toggles flag info box details for (+/-) control */
5747 'toggleBoxDetails': function() {
58 - var toggle = document.getElementById('mw-fr-revisiontoggle');
59 - if ( !toggle ) {
60 - return;
 48+ var toggle = $('#mw-fr-revisiontoggle');
 49+ var ratings = $('#mw-fr-revisiondetails');
 50+ if ( toggle.length && ratings.length ) {
 51+ // Collapsed -> expand
 52+ if ( ratings.css('display') == 'none' ) {
 53+ this.showBoxDetails();
 54+ toggle.text( mw.msg('revreview-toggle-hide') );
 55+ // Expanded -> collapse
 56+ } else {
 57+ this.hideBoxDetails();
 58+ toggle.text( mw.msg('revreview-toggle-show') );
 59+ }
6160 }
62 - var ratings = document.getElementById('mw-fr-revisiondetails');
63 - if ( !ratings ) {
64 - return;
65 - }
66 - // Collapsed -> expand
67 - if ( ratings.style.display == 'none' ) {
68 - this.showBoxDetails();
69 - toggle.innerHTML = mw.msg('revreview-toggle-hide');
70 - // Expanded -> collapse
71 - } else {
72 - this.hideBoxDetails();
73 - toggle.innerHTML = mw.msg('revreview-toggle-show');
74 - }
7561 },
7662
7763 /* Expands flag info box details on mouseOver */
@@ -87,7 +73,7 @@
8874 }
8975 },
9076
91 - /* Checks is mouseOut event is for a child of parentId */
 77+ /* Checks if mouseOut event is for a child of parentId */
9278 'isMouseOutBubble': function( event, parentId ) {
9379 var toNode = null;
9480 if ( event.relatedTarget !== undefined ) {
@@ -109,88 +95,64 @@
11096
11197 /* Toggles diffs */
11298 'toggleDiff': function() {
113 - var diff = document.getElementById('mw-fr-stablediff');
114 - if ( !diff ) {
115 - return;
 99+ var diff = $('#mw-fr-stablediff');
 100+ var toggle = $('#mw-fr-difftoggle');
 101+ if ( diff.length && toggle.length ) {
 102+ if ( diff.css('display') == 'none' ) {
 103+ diff.show( 'slow' );
 104+ toggle.children('a').text( mw.msg('revreview-diff-toggle-hide') );
 105+ } else {
 106+ diff.hide( 'slow' );
 107+ toggle.children('a').text( mw.msg('revreview-diff-toggle-show') );
 108+ }
116109 }
117 - var toggle = document.getElementById('mw-fr-difftoggle');
118 - if ( !toggle ) {
119 - return;
120 - }
121 - if ( diff.style.display == 'none' ) {
122 - diff.style.display = 'block';
123 - toggle.getElementsByTagName('a')[0].innerHTML =
124 - mw.msg('revreview-diff-toggle-hide');
125 - } else {
126 - diff.style.display = 'none';
127 - toggle.getElementsByTagName('a')[0].innerHTML =
128 - mw.msg('revreview-diff-toggle-show');
129 - }
130110 },
131111
132112 /* Toggles log excerpts */
133113 'toggleLog': function() {
134 - var log = document.getElementById('mw-fr-logexcerpt');
135 - if ( !log ) {
136 - return;
 114+ var log = $('#mw-fr-logexcerpt');
 115+ var toggle = $('#mw-fr-logtoggle');
 116+ if ( log.length && toggle.length ) {
 117+ if ( log.css('display') == 'none' ) {
 118+ log.show();
 119+ toggle.children('a').text( mw.msg('revreview-log-toggle-hide') );
 120+ } else {
 121+ log.hide();
 122+ toggle.children('a').text( mw.msg('revreview-log-toggle-show') );
 123+ }
137124 }
138 - var toggle = document.getElementById('mw-fr-logtoggle');
139 - if ( !toggle ) {
140 - return;
141 - }
142 - if ( log.style.display == 'none' ) {
143 - log.style.display = 'block';
144 - toggle.getElementsByTagName('a')[0].innerHTML =
145 - mw.msg('revreview-log-toggle-hide');
146 - } else {
147 - log.style.display = 'none';
148 - toggle.getElementsByTagName('a')[0].innerHTML =
149 - mw.msg('revreview-log-toggle-show');
150 - }
151125 },
152126
153127 /* Toggles log excerpts */
154128 'toggleLogDetails': function() {
155 - var log = document.getElementById('mw-fr-logexcerpt');
156 - if ( !log ) {
157 - return;
 129+ var log = $('#mw-fr-logexcerpt');
 130+ var toggle = $('#mw-fr-logtoggle');
 131+ if ( log.length && toggle.length ) {
 132+ if ( log.css('display') == 'none' ) {
 133+ log.show();
 134+ toggle.children('a').text( mw.msg('revreview-log-details-hide') );
 135+ } else {
 136+ log.hide();
 137+ toggle.children('a').text( mw.msg('revreview-log-details-show') );
 138+ }
158139 }
159 - var toggle = document.getElementById('mw-fr-logtoggle');
160 - if ( !toggle ) {
161 - return;
162 - }
163 - if ( log.style.display == 'none' ) {
164 - log.style.display = 'block';
165 - toggle.getElementsByTagName('a')[0].innerHTML = mw.msg('revreview-log-details-hide');
166 - } else {
167 - log.style.display = 'none';
168 - toggle.getElementsByTagName('a')[0].innerHTML = mw.msg('revreview-log-details-show');
169 - }
170140 },
171141
172 - /* Enables changing of save button when "review this" checkbox changes */
173 - 'setCheckTrigger': function() {
174 - var checkbox = document.getElementById('wpReviewEdit');
175 - if ( checkbox ) {
176 - checkbox.onclick = FlaggedRevs.updateSaveButton;
177 - }
178 - },
179 -
180142 /* Update save button when "review this" checkbox changes */
181143 'updateSaveButton': function() {
182 - var checkbox = document.getElementById('wpReviewEdit');
183 - var save = document.getElementById('wpSave');
184 - if ( checkbox && save ) {
 144+ var save = $('#wpSave');
 145+ var checkbox = $('#wpReviewEdit');
 146+ if ( save.length && checkbox.length ) {
185147 // Review pending changes
186 - if ( checkbox.checked ) {
187 - save.value = mw.msg('savearticle');
188 - save.title = mw.msg('tooltip-save') +
189 - ' [' + mw.msg('accesskey-save') + ']';
 148+ if ( checkbox.attr('checked') ) {
 149+ save.val( mw.msg('savearticle') );
 150+ save.attr( 'title',
 151+ mw.msg('tooltip-save') + ' [' + mw.msg('accesskey-save') + ']' );
190152 // Submit for review
191153 } else {
192 - save.value = mw.msg('revreview-submitedit');
193 - save.title = mw.msg('revreview-submitedit-title')
194 - + ' [' + mw.msg('accesskey-save') + ']';
 154+ save.val( mw.msg('revreview-submitedit') );
 155+ save.attr( 'title',
 156+ mw.msg('revreview-submitedit-title') + ' [' + mw.msg('accesskey-save') + ']' );
195157 }
196158 }
197159 mw.util.updateTooltipAccessKeys( [ save ] ); // update accesskey in save.title
@@ -198,5 +160,4 @@
199161 };
200162
201163 // Perform some onload (which is when this script is included) events:
202 -FlaggedRevs.enableShowhide();
203 -FlaggedRevs.setCheckTrigger();
 164+FlaggedRevs.init();

Follow-up revisions

RevisionCommit summaryAuthorDate
r98096[flaggedrevs.js]: Code cleanup...krinkle23:16, 25 September 2011

Status & tagging log