mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Rewrite listButtonTool list and unlist methods.
Need to rewrite updateState method and polish unlist. Change-Id: Ia18e038b4941a32f176747e00ed1881887cb1a8d
This commit is contained in:
parent
9f1885bc4b
commit
846d027ff7
|
@ -19,13 +19,73 @@
|
|||
/* Methods */
|
||||
|
||||
ve.ui.ListButtonTool.prototype.list = function( nodes, style ) {
|
||||
var surface = this.toolbar.surfaceView,
|
||||
model = surface.getModel(),
|
||||
doc = model.getDocument(),
|
||||
selection = model.getSelection(),
|
||||
siblings = doc.selectNodes( selection, 'siblings'),
|
||||
outerRange = null,
|
||||
tx;
|
||||
|
||||
if ( siblings.length > 1 ){
|
||||
outerRange = new ve.Range(
|
||||
siblings[0].nodeOuterRange.from,
|
||||
siblings[siblings.length-1].nodeOuterRange.to
|
||||
);
|
||||
} else {
|
||||
outerRange = ( siblings[0].node['parent'].getOuterRange() );
|
||||
}
|
||||
|
||||
tx = ve.dm.Transaction.newFromWrap(
|
||||
doc,
|
||||
outerRange,
|
||||
[],
|
||||
[ { 'type': 'list', 'attributes': { 'style': style } } ],
|
||||
[],
|
||||
[ { 'type': 'listItem' } ]
|
||||
);
|
||||
model.transact ( tx );
|
||||
return ;
|
||||
|
||||
siblings = doc.selectNodes(selection, 'siblings');
|
||||
outerRange = new ve.Range(
|
||||
siblings[0].nodeOuterRange.from,
|
||||
siblings[siblings.length-1].nodeOuterRange.to
|
||||
);
|
||||
model.setSelection( outerRange );
|
||||
surface.showSelection( model.getSelection() );
|
||||
};
|
||||
|
||||
ve.ui.ListButtonTool.prototype.unlist = function( nodes ) {
|
||||
ve.ui.ListButtonTool.prototype.unlist = function( node ){
|
||||
var surface = this.toolbar.surfaceView,
|
||||
model = surface.getModel(),
|
||||
doc = model.getDocument(),
|
||||
selection = model.getSelection(),
|
||||
siblings = doc.selectNodes( selection, 'siblings'),
|
||||
outerRange = null,
|
||||
tx;
|
||||
|
||||
if ( siblings.length > 1 ){
|
||||
outerRange = new ve.Range(
|
||||
siblings[0].nodeOuterRange.from,
|
||||
siblings[siblings.length-1].nodeOuterRange.to
|
||||
);
|
||||
} else {
|
||||
outerRange = ( siblings[0].node['parent'].getOuterRange() );
|
||||
}
|
||||
|
||||
tx = ve.dm.Transaction.newFromWrap(
|
||||
doc,
|
||||
outerRange,
|
||||
[ { 'type': 'list' } ],
|
||||
[],
|
||||
[ { 'type': 'listItem' } ],
|
||||
[]
|
||||
);
|
||||
|
||||
model.transact ( tx );
|
||||
|
||||
};
|
||||
|
||||
ve.ui.ListButtonTool.prototype.onClick = function() {
|
||||
this.toolbar.surfaceView.model.breakpoint();
|
||||
if ( !this.$.hasClass( 'es-toolbarButtonTool-down' ) ) {
|
||||
|
|
Loading…
Reference in a new issue