Merge "Replace toolbar with OOUI/OOUI-style SVGs"

This commit is contained in:
jenkins-bot 2016-02-29 23:33:18 +00:00 committed by Gerrit Code Review
commit e10ed30111
36 changed files with 216 additions and 74 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@
node_modules/
vendor/
ace-git/
composer.lock

View file

@ -48,7 +48,7 @@
},
"jquery.codeEditor": {
"scripts": "jquery.codeEditor.js",
"styles": "jquery.codeEditor.css",
"styles": "jquery.codeEditor.less",
"dependencies": [
"jquery.wikiEditor",
"ext.codeEditor.ace",

20
images/LICENSE-MIT Normal file
View file

@ -0,0 +1,20 @@
Copyright 2011-2016 OOjs UI Team and other contributors.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

BIN
images/code-progressive.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<g id="code" fill="#347bff">
<path id="left-bracket" d="M9.665 6.32l-4.259 4.274-1.406 1.406 1.406 1.406 4.259 4.274 1.406-1.438-4.259-4.243 4.259-4.243z"/>
<use transform="matrix(-1 0 0 1 24 0)" id="right-bracket" xlink:href="#left-bracket"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 446 B

BIN
images/code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

7
images/code.svg Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<g id="code">
<path id="left-bracket" d="M9.665 6.32l-4.259 4.274-1.406 1.406 1.406 1.406 4.259 4.274 1.406-1.438-4.259-4.243 4.259-4.243z"/>
<use transform="matrix(-1 0 0 1 24 0)" id="right-bracket" xlink:href="#left-bracket"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

BIN
images/find.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

7
images/find.svg Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<g id="find">
<path id="magnifying-glass" d="M13.656 11c-1.92 0-3.5 1.548-3.5 3.47 0 1.92 1.58 3.5 3.5 3.5.75 0 1.432-.253 2-.657l.094.156 2.375 2.37c.19.19.534.15.78-.096s.315-.59.126-.78l-2.37-2.377-.185-.094a3.545 3.545 0 0 0 .655-2.03c0-1.92-1.55-3.47-3.47-3.47zm0 1.656a1.8 1.8 0 0 1 1.813 1.813 1.83 1.83 0 0 1-1.82 1.84c-1.01 0-1.844-.83-1.844-1.847s.832-1.814 1.844-1.814z"/>
<path id="text" d="M6 5v2h10V5H6zm0 3v2h11V8H6zm0 3v2h3.53a4.443 4.443 0 0 1 1.44-2H6zm0 3v2h3.53c-.177-.48-.28-.99-.28-1.53 0-.16.046-.315.063-.47H6z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 697 B

BIN
images/gotoLine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

4
images/gotoLine.svg Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<path d="M 6,4 6,5 7,5 7,8 8,8 8,4 Z m -1,5 0,1 2,0 0,1 -2,0 0,3 3,0 0,-1 -2,0 0,-1 2,0 0,-3 z m 0,6 0,1 2,0 0,1 -1,0 0,1 1,0 0,1 -2,0 0,1 3,0 0,-5 z m 8,-5.5 -4,2.5 4,2.5 0,-1.5 6,0 0,-2 -6,0 z" />
</svg>

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 259 B

4
images/indent.svg Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M10 8h9v2h-9V8zm0 3h9v2h-9v-2zm0 3h6v2h-6v-2zm11-8H3V4h18v2zm0 14H3v-2h18v2zM3 8v8l5-4-5-4z"/>
</svg>

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 244 B

4
images/outdent.svg Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M10 8h9v2h-9V8zm0 3h9v2h-9v-2zm0 3h6v2h-6v-2zm11-8H3V4h18v2zm0 14H3v-2h18v2zM3 12l5 4V8l-5 4z"/>
</svg>

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<path fill="#347bff" d="m 10.041164,6.0000146 6.958836,0 0,1.499718 -1.5,4.754e-4 0,10.500245 -1.5,0 0,-10.500245 -2.5,0 0,10.500245 -1.5,-4.76e-4 0,-6.006954 C 8.7805614,11.91291 7.6646755,11.611794 6.9954024,11.0911 6.3318007,10.565652 6,9.8674581 6,8.9963601 6,8.0970523 6.3686675,7.3727882 7.1060025,6.8236471 7.8433375,6.2745059 8.8217243,6.0000146 10.041164,6.0000146 Z" />
</svg>

After

Width:  |  Height:  |  Size: 555 B

BIN
images/pilcrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

4
images/pilcrow.svg Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<path d="m 10.041164,6.0000146 6.958836,0 0,1.499718 -1.5,4.754e-4 0,10.500245 -1.5,0 0,-10.500245 -2.5,0 0,10.500245 -1.5,-4.76e-4 0,-6.006954 C 8.7805614,11.91291 7.6646755,11.611794 6.9954024,11.0911 6.3318007,10.565652 6,9.8674581 6,8.9963601 6,8.0970523 6.3686675,7.3727882 7.1060025,6.8236471 7.8433375,6.2745059 8.8217243,6.0000146 10.041164,6.0000146 Z" />
</svg>

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<g id="wrapping" fill="#347bff">
<path d="m 4,7 0,2 13,0 c 1.125297,0 2,0.8747028 2,2 0,1.125297 -0.874703,2 -2,2 l -1,0 0,-2 -3,3 3,3 0,-2 1,0 c 2.198703,0 4,-1.801297 4,-4 0,-2.1987028 -1.801297,-4 -4,-4 z" />
<path d="m 4,15 7,0 0,2 -7,0 z" />
<path d="m 4,11 7,0 0,2 -7,0 z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 269 B

8
images/wrapping.svg Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
<g id="wrapping">
<path d="m 4,7 0,2 13,0 c 1.125297,0 2,0.8747028 2,2 0,1.125297 -0.874703,2 -2,2 l -1,0 0,-2 -3,3 3,3 0,-2 1,0 c 2.198703,0 4,-1.801297 4,-4 0,-2.1987028 -1.801297,-4 -4,-4 z" />
<path d="m 4,15 7,0 0,2 -7,0 z" />
<path d="m 4,11 7,0 0,2 -7,0 z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 461 B

View file

@ -1,55 +0,0 @@
.group-codeeditor-format,
.group-codeeditor-style,
.codeEditor-ui-toolbar .group-insert,
.codeEditor-ui-toolbar .group-format,
.codeEditor-ui-toolbar .tabs span.tab-advanced,
.codeEditor-ui-toolbar .tabs span.tab-characters,
.codeEditor-ui-toolbar .tabs span.tab-help,
.codeEditor-ui-toolbar .sections {
display: none;
}
.codeEditor-ui-toolbar .group-codeeditor-format,
.codeEditor-ui-toolbar .group-codeeditor-style {
display: block;
}
.codeEditor-status {
clear: both;
width: 100%;
background-color: #F0F0F0;
border-top: 1px solid silver;
display: table;
}
.codeEditor-status .codeEditor-status-worker-cell.ace_gutter-cell {
background-position: 0 center;
}
.codeEditor-status-worker {
padding: 0 0.3em;
user-select: none;
cursor: pointer;
display: table-cell;
*float: left;
*width: 10em;
}
.codeEditor-status-message {
border-left: 1px solid silver;
border-right: 1px solid silver;
padding: 0 0.3em;
width: 100%;
display: table-cell;
*float: left;
*width: auto;
}
.codeEditor-status-line {
padding: 0 0.3em;
text-align: right;
white-space: nowrap;
display: table-cell;
*float: right;
*width: 4em;
}

View file

@ -48,7 +48,6 @@
selectedLine = 0,
cookieEnabled,
returnFalse = function () { return false; },
extIconPath = mw.config.get( 'wgCodeEditorAssetsPath', mw.config.get( 'wgExtensionAssetsPath' ) ) + '/CodeEditor/images/',
api = new mw.Api();
// Initialize state
@ -103,14 +102,14 @@
* Internally used functions
*/
context.fn = $.extend( context.fn, {
codeEditorToolbarIcon: function () {
return extIconPath + ( context.codeEditorActive ? 'editor.png' : 'editor-off.png' );
isCodeEditorActive: function () {
return context.codeEditorActive;
},
invisibleCharsToolbarIcon: function () {
return extIconPath + ( context.showInvisibleChars ? 'markup.png' : 'markup-off.png' );
isShowInvisibleChars: function () {
return context.showInvisibleChars;
},
lineWrappingToolbarIcon: function () {
return extIconPath + ( context.lineWrappingActive ? 'wrapping.png' : 'wrapping-off.png' );
isLineWrappingActive: function () {
return context.lineWrappingActive;
},
changeCookieValue: function ( cookieName, value ) {
mw.cookie.set(
@ -202,7 +201,7 @@
codeEditor: {
labelMsg: 'codeeditor-toolbar-toggle',
type: 'button',
icon: context.fn.codeEditorToolbarIcon(),
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: toggleEditor
@ -215,7 +214,7 @@
indent: {
labelMsg: 'codeeditor-indent',
type: 'button',
icon: extIconPath + 'indent.png',
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: indent
@ -224,7 +223,7 @@
outdent: {
labelMsg: 'codeeditor-outdent',
type: 'button',
icon: extIconPath + 'outdent.png',
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: outdent
@ -238,7 +237,7 @@
invisibleChars: {
labelMsg: 'codeeditor-invisibleChars-toggle',
type: 'button',
icon: context.fn.invisibleCharsToolbarIcon(),
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: toggleInvisibleChars
@ -247,7 +246,7 @@
lineWrapping: {
labelMsg: 'codeeditor-lineWrapping-toggle',
type: 'button',
icon: context.fn.lineWrappingToolbarIcon(),
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: toggleLineWrapping
@ -256,7 +255,7 @@
gotoLine: {
labelMsg: 'codeeditor-gotoline',
type: 'button',
icon: extIconPath + 'gotoline.png',
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: gotoLine
@ -265,7 +264,7 @@
toggleSearchReplace: {
labelMsg: 'codeeditor-searchReplace-toggle',
type: 'button',
icon: extIconPath + 'search-replace.png',
offset: [ 0, 0 ],
action: {
type: 'callback',
execute: toggleSearchReplace
@ -275,6 +274,9 @@
}
}
} );
context.fn.updateCodeEditorToolbarButton();
context.fn.updateInvisibleCharsButton();
context.fn.updateLineWrappingButton();
$( '.group-codeeditor-style' ).prependTo( '.section-main' );
$( '.group-codeeditor-format' ).prependTo( '.section-main' );
$( '.group-codeeditor-main' ).prependTo( '.section-main' );
@ -282,16 +284,16 @@
updateButtonIcon: function ( targetName, iconFn ) {
var target = '.tool[rel=' + targetName + ']',
$icon = context.modules.toolbar.$toolbar.find( target );
$icon.css( 'background-image', 'url(' + iconFn() + ')' );
$icon.toggleClass( 'icon-active', iconFn() );
},
updateCodeEditorToolbarButton: function () {
context.fn.updateButtonIcon( 'codeEditor', context.fn.codeEditorToolbarIcon );
context.fn.updateButtonIcon( 'codeEditor', context.fn.isCodeEditorActive );
},
updateInvisibleCharsButton: function () {
context.fn.updateButtonIcon( 'invisibleChars', context.fn.invisibleCharsToolbarIcon );
context.fn.updateButtonIcon( 'invisibleChars', context.fn.isShowInvisibleChars );
},
updateLineWrappingButton: function () {
context.fn.updateButtonIcon( 'lineWrapping', context.fn.lineWrappingToolbarIcon );
context.fn.updateButtonIcon( 'lineWrapping', context.fn.isLineWrappingActive );
},
setCodeEditorPreference: function ( prefValue ) {
// Do not try to save options for anonymous user

View file

@ -0,0 +1,117 @@
@import "mediawiki.mixins";
.group-codeeditor-format,
.group-codeeditor-style,
.codeEditor-ui-toolbar .group-insert,
.codeEditor-ui-toolbar .group-format,
.codeEditor-ui-toolbar .tabs span.tab-advanced,
.codeEditor-ui-toolbar .tabs span.tab-characters,
.codeEditor-ui-toolbar .tabs span.tab-help,
.codeEditor-ui-toolbar .sections {
display: none;
}
.codeEditor-ui-toolbar .group-codeeditor-format,
.codeEditor-ui-toolbar .group-codeeditor-style {
display: block;
}
.group-codeeditor-main,
.group-codeeditor-format,
.group-codeeditor-style {
.tool {
opacity: 0.7;
background-position: 1px 1px!important;
&.icon-active {
opacity: 1;
}
}
}
// TODO: Use this icon from OOUI
.group-codeeditor-main .tool[rel=codeEditor] {
.background-image-svg( '../images/code.svg', '../images/code.png' );
&.icon-active {
.background-image-svg( '../images/code-progressive.svg', '../images/code-progressive.png' );
}
}
// TODO: Use this icon from OOUI
.codeEditor-ui-toolbar .tool[rel=indent] {
.background-image-svg( '../images/indent.svg', '../images/indent.png' );
}
// TODO: Use this icon from OOUI
.codeEditor-ui-toolbar .tool[rel=outdent] {
.background-image-svg( '../images/outdent.svg', '../images/outdent.png' );
}
// TODO: Upstream this icon to OOUI and use it from there
.codeEditor-ui-toolbar .tool[rel=invisibleChars] {
.background-image-svg( '../images/pilcrow.svg', '../images/pilcrow.png' );
&.icon-active {
.background-image-svg( '../images/pilcrow-progressive.svg', '../images/pilcrow-progressive.png' );
}
}
// TODO: Upstream this icon to OOUI and use it from there
.codeEditor-ui-toolbar .tool[rel=lineWrapping] {
.background-image-svg( '../images/wrapping.svg', '../images/wrapping.png' );
&.icon-active {
.background-image-svg( '../images/wrapping-progressive.svg', '../images/wrapping-progressive.png' );
}
}
// TODO: Upstream this icon to OOUI and use it from there
.codeEditor-ui-toolbar .tool[rel=gotoLine] {
.background-image-svg( '../images/gotoLine.svg', '../images/gotoLine.png' );
}
// TODO: Use this icon from OOUI
.codeEditor-ui-toolbar .tool[rel=toggleSearchReplace] {
.background-image-svg( '../images/find.svg', '../images/find.png' );
}
.wikiEditor-ui-toolbar .group-codeeditor-style {
border-right: 0;
}
.codeEditor-status {
clear: both;
width: 100%;
background-color: #F0F0F0;
border-top: 1px solid silver;
display: table;
}
.codeEditor-status .codeEditor-status-worker-cell.ace_gutter-cell {
background-position: 0 center;
}
.codeEditor-status-worker {
padding: 0 0.3em;
user-select: none;
cursor: pointer;
display: table-cell;
*float: left;
*width: 10em;
}
.codeEditor-status-message {
border-left: 1px solid silver;
border-right: 1px solid silver;
padding: 0 0.3em;
width: 100%;
display: table-cell;
*float: left;
*width: auto;
}
.codeEditor-status-line {
padding: 0 0.3em;
text-align: right;
white-space: nowrap;
display: table-cell;
*float: right;
*width: 4em;
}