r92311 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92310‎ | r92311 | r92312 >
Date:21:42, 15 July 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 28574) ProofreadPage toolbar additions now compatible with WikiEditor toolbar

Took mybugs' script fragment at https://bugzilla.wikimedia.org/attachment.cgi?id=8778&action=edit and merged it into ProofreadPage proper; now building the classic toolbar buttons from the array of data that we're making for WikiEditor so we don't have to define them twice. :)
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.i18n.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php
@@ -66,6 +66,14 @@
6767 'proofreadpage_source' => 'Source',
6868 'proofreadpage_source_message' => 'Scanned edition used to establish this text',
6969 'right-pagequality' => 'Modify page quality flag',
 70+ 'proofreadpage-section-tools' => 'Proofread tools',
 71+ 'proofreadpage-group-zoom' => 'Zoom',
 72+ 'proofreadpage-group-other' => 'Other',
 73+ 'proofreadpage-button-toggle-visibility-label' => 'Show/hide this page\'s header and footer',
 74+ 'proofreadpage-button-zoom-out-label' => 'Zoom out',
 75+ 'proofreadpage-button-reset-zoom-label' => 'Reset zoom',
 76+ 'proofreadpage-button-zoom-in-label' => 'Zoom in',
 77+ 'proofreadpage-button-toggle-layout-label' => 'Vertical/horizontal layout'
7078 );
7179
7280 /** Message documentation (Message documentation)
Index: trunk/extensions/ProofreadPage/proofread.js
@@ -767,76 +767,128 @@
768768
769769 // add buttons
770770 if( proofreadPageIsEdit ) {
771 - var toolbar = document.getElementById( 'toolbar' );
 771+ var tools = {
 772+ 'section': 'proofreadpage-tools',
 773+ 'groups': {
 774+ 'zoom': {
 775+ 'label': mw.msg( 'proofreadpage-group-zoom' ),
 776+ 'tools': {
 777+ 'zoom-in': {
 778+ label: mw.msg( 'proofreadpage-button-zoom-in-label' ),
 779+ type: 'button',
 780+ icon: mw.config.get( 'wgScriptPath' ) + '/extensions/ProofreadPage/Button_zoom_in.png',
 781+ action: {
 782+ type: 'callback',
 783+ execute: function() {
 784+ xx=0;
 785+ yy=0;
 786+ pr_zoom(2);
 787+ }
 788+ }
 789+ },
 790+ 'zoom-out': {
 791+ label: mw.msg( 'proofreadpage-button-zoom-out-label' ),
 792+ type: 'button',
 793+ icon: mw.config.get( 'wgScriptPath' ) + '/extensions/ProofreadPage/Button_zoom_out.png',
 794+ action: {
 795+ type: 'callback',
 796+ execute: function() {
 797+ xx=0;
 798+ yy=0;
 799+ pr_zoom(-2);
 800+ }
 801+ }
 802+ },
 803+ 'reset-zoom': {
 804+ label: mw.msg( 'proofreadpage-button-reset-zoom-label' ),
 805+ type: 'button',
 806+ icon: mw.config.get( 'wgScriptPath' ) + '/extensions/ProofreadPage/Button_examine.png',
 807+ action: {
 808+ type: 'callback',
 809+ execute: function() {
 810+ pr_zoom(0);
 811+ }
 812+ }
 813+ }
 814+ }
 815+ },
 816+ 'other': {
 817+ 'label': mw.msg( 'proofreadpage-group-other' ),
 818+ 'tools': {
 819+ 'toggle-visibility': {
 820+ label: mw.msg( 'proofreadpage-button-toggle-visibility-label' ),
 821+ type: 'button',
 822+ icon: mw.config.get( 'wgScriptPath' ) + '/extensions/ProofreadPage/button_category_plus.png',
 823+ action: {
 824+ type: 'callback',
 825+ execute: function() {
 826+ pr_toggle_visibility();
 827+ }
 828+ }
 829+ },
 830+ 'toggle-layout': {
 831+ label: mw.msg( 'proofreadpage-button-toggle-layout-label' ),
 832+ type: 'button',
 833+ icon: mw.config.get( 'wgScriptPath' ) + '/extensions/ProofreadPage/Button_multicol.png',
 834+ action: {
 835+ type: 'callback',
 836+ execute: function() {
 837+ pr_toggle_layout();
 838+ }
 839+ }
 840+ }
 841+ }
 842+ }
 843+ }
 844+ };
772845
773 - var image = document.createElement( 'img' );
774 - image.width = 23;
775 - image.height = 22;
776 - image.className = 'mw-toolbar-editbutton';
777 - image.src = wgScriptPath + '/extensions/ProofreadPage/button_category_plus.png';
778 - image.border = 0;
779 - image.alt = mediaWiki.msg( 'proofreadpage_toggleheaders' );
780 - image.title = mediaWiki.msg( 'proofreadpage_toggleheaders' );
781 - image.style.cursor = 'pointer';
782 - image.onclick = pr_toggle_visibility;
 846+ var $edit = $( '#wpTextbox1' );
 847+ if( typeof $edit.wikiEditor == 'function' ) {
 848+ console.log('hey hey');
 849+ setTimeout(function() {
 850+ $edit.wikiEditor( 'addToToolbar', {
 851+ 'sections': {
 852+ 'proofreadpage-tools': {
 853+ 'type': 'toolbar',
 854+ 'label': mw.msg( 'proofreadpage-section-tools' )
 855+ }
 856+ }
 857+ } )
 858+ .wikiEditor( 'addToToolbar', tools);
 859+ }, 500);
 860+ } else {
 861+ var toolbar = document.getElementById( 'toolbar' );
783862
784 - var image3 = document.createElement( 'img' );
785 - image3.width = 23;
786 - image3.height = 22;
787 - image3.border = 0;
788 - image3.className = 'mw-toolbar-proofread';
789 - image3.style.cursor = 'pointer';
790 - image3.alt = '-';
791 - image3.title = 'zoom out';
792 - image3.src = wgScriptPath + '/extensions/ProofreadPage/Button_zoom_out.png';
793 - image3.onclick = new Function( 'xx=0;yy=0;pr_zoom(-2);' );
 863+ pr_rect = document.createElement( 'div' );
 864+ pr_container_parent.appendChild( pr_rect );
794865
795 - var image4 = document.createElement( 'img' );
796 - image4.width = 23;
797 - image4.height = 22;
798 - image4.border = 0;
799 - image4.className = 'mw-toolbar-proofread';
800 - image4.style.cursor = 'pointer';
801 - image4.alt = '-';
802 - image4.title = 'reset zoom';
803 - image4.src = wgScriptPath + '/extensions/ProofreadPage/Button_examine.png';
804 - image4.onclick = new Function("pr_zoom(0);");
 866+ if( ( !toolbar ) || ( self.wgWikiEditorPreferences && self.wgWikiEditorPreferences['toolbar'] ) ) {
 867+ toolbar = document.createElement( 'div' );
 868+ toolbar.style.cssText = 'position:absolute;';
 869+ pr_container_parent.appendChild( toolbar );
 870+ }
805871
806 - var image2 = document.createElement( 'img' );
807 - image2.width = 23;
808 - image2.height = 22;
809 - image2.border = 0;
810 - image2.className = 'mw-toolbar-proofread';
811 - image2.style.cursor = 'pointer';
812 - image2.alt = '+';
813 - image2.title = 'zoom in';
814 - image2.src = wgScriptPath + '/extensions/ProofreadPage/Button_zoom_in.png';
815 - image2.onclick = new Function( 'xx=0;yy=0;pr_zoom(2);' );
816 -
817 - var image1 = document.createElement( 'img' );
818 - image1.width = 23;
819 - image1.height = 22;
820 - image1.className = 'mw-toolbar-editbutton';
821 - image1.src = wgScriptPath + '/extensions/ProofreadPage/Button_multicol.png';
822 - image1.border = 0;
823 - image1.alt = ' ';
824 - image1.title = 'vertical/horizontal layout';
825 - image1.style.cursor = 'pointer';
826 - image1.onclick = pr_toggle_layout;
827 -
828 - pr_rect = document.createElement( 'div' );
829 - pr_container_parent.appendChild( pr_rect );
830 -
831 - if( ( !toolbar ) || ( self.wgWikiEditorPreferences && self.wgWikiEditorPreferences['toolbar'] ) ) {
832 - toolbar = document.createElement( 'div' );
833 - toolbar.style.cssText = 'position:absolute;';
834 - pr_container_parent.appendChild( toolbar );
 872+ var bits = [
 873+ tools.groups.other.tools['toggle-visibility'],
 874+ tools.groups.zoom.tools['zoom-out'],
 875+ tools.groups.zoom.tools['reset-zoom'],
 876+ tools.groups.zoom.tools['zoom-in'],
 877+ tools.groups.other.tools['toggle-layout']
 878+ ];
 879+ $.each(bits, function(i, button) {
 880+ var image = document.createElement( 'img' );
 881+ image.width = 23;
 882+ image.height = 22;
 883+ image.className = 'mw-toolbar-editbutton';
 884+ image.src = button.icon;
 885+ image.border = 0;
 886+ image.alt = button.label;
 887+ image.title = button.label;
 888+ image.style.cursor = 'pointer';
 889+ image.onclick = button.action.execute;
 890+ toolbar.appendChild( image );
 891+ });
835892 }
836 - toolbar.appendChild( image );
837 - toolbar.appendChild( image3 );
838 - toolbar.appendChild( image4 );
839 - toolbar.appendChild( image2 );
840 - toolbar.appendChild( image1 );
841893 }
842894 }
843895
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -78,6 +78,14 @@
7979 'proofreadpage_quality2_category',
8080 'proofreadpage_quality3_category',
8181 'proofreadpage_quality4_category',
 82+ 'proofreadpage-section-tools',
 83+ 'proofreadpage-group-zoom',
 84+ 'proofreadpage-group-other',
 85+ 'proofreadpage-button-toggle-visibility-label',
 86+ 'proofreadpage-button-zoom-out-label',
 87+ 'proofreadpage-button-reset-zoom-label',
 88+ 'proofreadpage-button-zoom-in-label',
 89+ 'proofreadpage-button-toggle-layout-label',
8290 )
8391 ),
8492 'ext.proofreadpage.article' => $prpResourceTemplate + array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r92314Followup to r92311: fix ProofreadPath to use wgExtensionAssetsPath; removed a...brion21:46, 15 July 2011
r92319MFT r92311, r92314: fix ProofreadPage toolbar with WikiEditor. Bug 28574.brion22:01, 15 July 2011
r92321MFT r92311, r92314: fix ProofreadPage toolbar with WikiEditor. Bug 28574.brion22:03, 15 July 2011
r92323MFT r92311, r92314: fix ProofreadPage toolbar with WikiEditor. Bug 28574.brion22:06, 15 July 2011

Comments

#Comment by He7d3r (talk | contribs)   22:15, 15 July 2011

Is it intentional the change of the alt attributes of 'reset zoom', 'zoom out', 'zoom in' and 'vertical/horizontal layout'?

BTW: this seems to solve also

  • Bug 29867 - Make the title and alt attributtes of toolbar buttons localizable
#Comment by Brion VIBBER (talk | contribs)   22:17, 15 July 2011

I was too lazy to give them separate alt texts in the refactored version, but we could add such if desirable. I figured making them localizable was the more useful thing, and took the versions provided in the partial patch as acceptable.

Status & tagging log