Index: trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.css |
— | — | @@ -381,4 +381,8 @@ |
382 | 382 | |
383 | 383 | #mw-fr-diff-headeritems { |
384 | 384 | 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 @@ |
9 | 9 | /* Dropdown collapse timer */ |
10 | 10 | 'boxCollapseTimer': null, |
11 | 11 | |
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 */ |
18 | 18 | this.hideBoxDetails(); /* hide the initially displayed ratings */ |
19 | 19 | } |
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(); |
28 | 25 | } |
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(); |
37 | 31 | } |
| 32 | + // Enables changing of save button when "review this" checkbox changes */ |
| 33 | + $('#wpReviewEdit').click( FlaggedRevs.updateSaveButton ); |
38 | 34 | }, |
39 | 35 | |
40 | 36 | /* Expands flag info box details */ |
41 | 37 | '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'); |
46 | 39 | }, |
47 | 40 | |
48 | 41 | /* Collapses flag info box details */ |
49 | 42 | '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'); |
54 | 44 | }, |
55 | 45 | |
56 | 46 | /* Toggles flag info box details for (+/-) control */ |
57 | 47 | '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 | + } |
61 | 60 | } |
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 | | - } |
75 | 61 | }, |
76 | 62 | |
77 | 63 | /* Expands flag info box details on mouseOver */ |
— | — | @@ -87,7 +73,7 @@ |
88 | 74 | } |
89 | 75 | }, |
90 | 76 | |
91 | | - /* Checks is mouseOut event is for a child of parentId */ |
| 77 | + /* Checks if mouseOut event is for a child of parentId */ |
92 | 78 | 'isMouseOutBubble': function( event, parentId ) { |
93 | 79 | var toNode = null; |
94 | 80 | if ( event.relatedTarget !== undefined ) { |
— | — | @@ -109,88 +95,64 @@ |
110 | 96 | |
111 | 97 | /* Toggles diffs */ |
112 | 98 | '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 | + } |
116 | 109 | } |
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 | | - } |
130 | 110 | }, |
131 | 111 | |
132 | 112 | /* Toggles log excerpts */ |
133 | 113 | '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 | + } |
137 | 124 | } |
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 | | - } |
151 | 125 | }, |
152 | 126 | |
153 | 127 | /* Toggles log excerpts */ |
154 | 128 | '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 | + } |
158 | 139 | } |
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 | | - } |
170 | 140 | }, |
171 | 141 | |
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 | | - |
180 | 142 | /* Update save button when "review this" checkbox changes */ |
181 | 143 | '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 ) { |
185 | 147 | // 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') + ']' ); |
190 | 152 | // Submit for review |
191 | 153 | } 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') + ']' ); |
195 | 157 | } |
196 | 158 | } |
197 | 159 | mw.util.updateTooltipAccessKeys( [ save ] ); // update accesskey in save.title |
— | — | @@ -198,5 +160,4 @@ |
199 | 161 | }; |
200 | 162 | |
201 | 163 | // Perform some onload (which is when this script is included) events: |
202 | | -FlaggedRevs.enableShowhide(); |
203 | | -FlaggedRevs.setCheckTrigger(); |
| 164 | +FlaggedRevs.init(); |