mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Initiali implementation of number and bullet buttons for lists.
This commit is contained in:
parent
31585463ed
commit
a9a53a00a8
|
@ -106,6 +106,7 @@ $wgResourceModules += array(
|
|||
'es/tools/es.AnnotationButtonTool.js',
|
||||
'es/tools/es.ClearButtonTool.js',
|
||||
'es/tools/es.HistoryButtonTool.js',
|
||||
'es/tools/es.ListButtonTool.js',
|
||||
'es/tools/es.DropdownTool.js',
|
||||
'es/tools/es.FormatDropdownTool.js'
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
<script src="../modules/es/tools/es.AnnotationButtonTool.js"></script>
|
||||
<script src="../modules/es/tools/es.ClearButtonTool.js"></script>
|
||||
<script src="../modules/es/tools/es.HistoryButtonTool.js"></script>
|
||||
<script src="../modules/es/tools/es.ListButtonTool.js"></script>
|
||||
<script src="../modules/es/tools/es.DropdownTool.js"></script>
|
||||
<script src="../modules/es/tools/es.FormatDropdownTool.js"></script>
|
||||
|
||||
|
|
|
@ -73,10 +73,17 @@
|
|||
.es-toolbarButtonTool-clear:before {
|
||||
background-image: url(../images/clear.png);
|
||||
}
|
||||
.es-toolbarButtonTool-number:before {
|
||||
background-image: url(../images/number.png);
|
||||
}
|
||||
.es-toolbarButtonTool-bullet:before {
|
||||
background-image: url(../images/bullet.png);
|
||||
}
|
||||
.es-toolbarButtonTool-disabled.es-toolbarButtonTool-clear:before {
|
||||
-moz-opacity: 0.25;
|
||||
filter:alpha(opacity=25);
|
||||
opacity: 0.25;
|
||||
}
|
||||
.es-toolbarButtonTool-clear:before {
|
||||
background-image: url(../images/clear.png);
|
||||
}
|
||||
|
|
41
modules/es/tools/es.ListButtonTool.js
Normal file
41
modules/es/tools/es.ListButtonTool.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
es.ListButtonTool = function( toolbar, name, data ) {
|
||||
es.ButtonTool.call( this, toolbar, name );
|
||||
this.data = data;
|
||||
};
|
||||
|
||||
es.ListButtonTool.prototype.onClick = function() {
|
||||
};
|
||||
|
||||
es.ListButtonTool.prototype.updateState = function( annotations, nodes ) {
|
||||
function areSameTypeAndStyle( nodes, style ) {
|
||||
for( var i = 0; i < nodes.length; i++ ) {
|
||||
parent = nodes[i].getParent();
|
||||
if ( parent.getElementType() !== 'listItem' ) {
|
||||
return false;
|
||||
}
|
||||
styles = parent.getElementAttribute( 'styles' );
|
||||
if ( styles[ styles.length - 1] !== style ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( areSameTypeAndStyle( nodes, this.name ) ) {
|
||||
this.$.addClass( 'es-toolbarButtonTool-down' );
|
||||
} else {
|
||||
this.$.removeClass( 'es-toolbarButtonTool-down' );
|
||||
}
|
||||
};
|
||||
|
||||
es.Tool.tools.number = {
|
||||
constructor: es.ListButtonTool,
|
||||
name: 'number'
|
||||
};
|
||||
|
||||
es.Tool.tools.bullet = {
|
||||
constructor: es.ListButtonTool,
|
||||
name: 'bullet'
|
||||
};
|
||||
|
||||
es.extendClass( es.ListButtonTool, es.ButtonTool );
|
|
@ -49,7 +49,8 @@ es.ToolbarView = function( $container, surfaceView, config ) {
|
|||
|
||||
this.config = config || [
|
||||
{ 'name': 'textStyle', 'items' : [ 'bold', 'italic', 'link', 'clear', 'format' ] },
|
||||
{ 'name': 'history', 'items' : [ 'undo', 'redo' ] }
|
||||
{ 'name': 'history', 'items' : [ 'undo', 'redo' ] },
|
||||
{ 'name': 'list', 'items' : [ 'number', 'bullet' ] }
|
||||
];
|
||||
this.setup();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue