From 3c65d830f2857b5f1a2996d315361d1f9f93c7b0 Mon Sep 17 00:00:00 2001 From: Steven Zhang Date: Sat, 10 Aug 2013 11:27:01 +0800 Subject: [PATCH] Create an underline tool Bug: 51609 Change-Id: I65246d7eeb154950c35a1cb70909a113080c2323 --- VisualEditor.i18n.php | 3 ++ VisualEditor.php | 2 + .../init/targets/ve.init.mw.ViewPageTarget.js | 2 +- modules/ve/init/ve.init.Target.js | 3 +- .../buttons/ve.ui.UnderlineButtonTool.js | 43 +++++++++++++++++++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 modules/ve/ui/tools/buttons/ve.ui.UnderlineButtonTool.js diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php index b992b1e715..2571126507 100644 --- a/VisualEditor.i18n.php +++ b/VisualEditor.i18n.php @@ -34,6 +34,7 @@ $messages['en'] = array( 'visualeditor-annotationbutton-link-tooltip' => 'Link', 'visualeditor-annotationbutton-language-tooltip' => 'Language', 'visualeditor-annotationbutton-strikethrough-tooltip' => 'Strikethrough', + 'visualeditor-annotationbutton-underline-tooltip' => 'Underline', 'visualeditor-beta-label' => 'beta', 'visualeditor-beta-warning' => 'VisualEditor is in \'beta\'. You may encounter software issues, and you may not be able to edit parts of the page. Click "{{int:visualeditor-ca-editsource}}" to switch to wikitext mode – unsaved changes will be lost.', 'visualeditor-beta-appendix' => 'beta', @@ -252,6 +253,8 @@ See also: {{Identical|Language}}', 'visualeditor-annotationbutton-strikethrough-tooltip' => 'Tooltip text for strikethrough button. {{Identical|Strikethrough}}', + 'visualeditor-annotationbutton-underline-tooltip' => 'Tooltip text for underline button. +{{Identical|Underline}}', 'visualeditor-beta-label' => 'Text of tool in the toolbar that highlights that VisualEditor is still in beta. {{Identical|Beta}}', 'visualeditor-beta-warning' => "Note shown when user clicks on 'beta' label in VisualEditor, warning users that the software may have issues", diff --git a/VisualEditor.php b/VisualEditor.php index b06747211b..0039227bce 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -732,6 +732,7 @@ $wgResourceModules += array( 've/ui/widgets/ve.ui.LanguageInputWidget.js', 've/ui/tools/buttons/ve.ui.CodeButtonTool.js', 've/ui/tools/buttons/ve.ui.StrikethroughButtonTool.js', + 've/ui/tools/buttons/ve.ui.UnderlineButtonTool.js', ), 'dependencies' => array( 'ext.visualEditor.core', @@ -744,6 +745,7 @@ $wgResourceModules += array( 'visualeditor-mwmathinspector-title', 'visualeditor-annotationbutton-language-tooltip', 'visualeditor-annotationbutton-strikethrough-tooltip', + 'visualeditor-annotationbutton-underline-tooltip', ), ), diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 16b7d418cb..d073cd7376 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -170,7 +170,7 @@ ve.init.mw.ViewPageTarget.compatibility = { ve.init.mw.ViewPageTarget.static.toolbarTools = [ { 'items': [ 'undo', 'redo' ] }, { 'items': [ 'mwFormat' ] }, - { 'items': [ 'bold', 'italic', 'mwLink', 'language', 'code', 'strikethrough', 'clear' ] }, + { 'items': [ 'bold', 'italic', 'strikethrough', 'underline', 'mwLink', 'language', 'code', 'clear' ] }, { 'items': [ 'number', 'bullet', 'outdent', 'indent' ] }, { 'items': [ 'mwMediaInsert', 'mwReference', 'mwReferenceList', 'mwTransclusion', 'mwMath', 'mwHiero' ] } ]; diff --git a/modules/ve/init/ve.init.Target.js b/modules/ve/init/ve.init.Target.js index 28c246df2d..7cc8a8445b 100644 --- a/modules/ve/init/ve.init.Target.js +++ b/modules/ve/init/ve.init.Target.js @@ -32,7 +32,7 @@ ve.mixinClass( ve.init.Target, ve.EventEmitter ); ve.init.Target.static.toolbarTools = [ { 'items': ['undo', 'redo'] }, { 'items': ['format'] }, - { 'items': ['bold', 'italic', 'link', 'code', 'language', 'strikethrough', 'clear'] }, + { 'items': ['bold', 'italic', 'link', 'code', 'language', 'underline', 'strikethrough', 'clear'] }, { 'items': ['number', 'bullet', 'outdent', 'indent'] } ]; @@ -43,6 +43,7 @@ ve.init.Target.static.surfaceCommands = [ //'language', 'undo', 'redo', + //'underline', //'strikethrough', 'indent', 'outdent' diff --git a/modules/ve/ui/tools/buttons/ve.ui.UnderlineButtonTool.js b/modules/ve/ui/tools/buttons/ve.ui.UnderlineButtonTool.js new file mode 100644 index 0000000000..ea0a5456fb --- /dev/null +++ b/modules/ve/ui/tools/buttons/ve.ui.UnderlineButtonTool.js @@ -0,0 +1,43 @@ +/*! + * VisualEditor UserInterface UnderlineButtonTool class. + * + * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * UserInterface underline button tool. + * + * @class + * @extends ve.ui.AnnotationButtonTool + * @constructor + * @param {ve.ui.SurfaceToolbar} toolbar + * @param {Object} [config] Config options + */ +ve.ui.UnderlineButtonTool = function VeUiUnderlineButtonTool( toolbar, config ) { + // Parent constructor + ve.ui.AnnotationButtonTool.call( this, toolbar, config ); +}; + +/* Inheritance */ + +ve.inheritClass( ve.ui.UnderlineButtonTool, ve.ui.AnnotationButtonTool ); + +/* Static Properties */ + +ve.ui.UnderlineButtonTool.static.name = 'underline'; + +ve.ui.UnderlineButtonTool.static.icon = { + 'default': 'underline-a', + 'en': 'underline-u' +}; + +ve.ui.UnderlineButtonTool.static.titleMessage = 'visualeditor-annotationbutton-underline-tooltip'; + +ve.ui.UnderlineButtonTool.static.annotation = { 'name': 'textStyle/underline' }; + +/* Registration */ + +ve.ui.toolFactory.register( 'underline', ve.ui.UnderlineButtonTool ); + +ve.ui.commandRegistry.register( 'underline', 'annotation', 'toggle', 'textStyle/underline' );