mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Use ve.dm.MetaList without explicitly requiring metadata index
For future compatibility with Ib5174b0dcba1c24f44d889e08140bee31a064011 . Change-Id: I15f252ce5d36bc0c38c5f5035e5176bf5e6d96e5
This commit is contained in:
parent
d5c92ebb9e
commit
c7b76329ad
|
@ -107,16 +107,16 @@ ve.ui.MWCategoriesPage.prototype.onDefaultSortChange = function ( value ) {
|
|||
* or undefined to go at the end
|
||||
*/
|
||||
ve.ui.MWCategoriesPage.prototype.onNewCategory = function ( item, beforeMetaItem ) {
|
||||
var args = [ this.getCategoryItemForInsertion( item ) ];
|
||||
|
||||
// Insert new metaList item
|
||||
if ( beforeMetaItem ) {
|
||||
this.insertMetaListItem(
|
||||
this.getCategoryItemForInsertion( item ),
|
||||
beforeMetaItem.getOffset(),
|
||||
beforeMetaItem.getIndex()
|
||||
);
|
||||
} else {
|
||||
this.insertMetaListItem( this.getCategoryItemForInsertion( item ) );
|
||||
args.push( beforeMetaItem.getOffset() );
|
||||
if ( beforeMetaItem.getIndex ) {
|
||||
args.push( beforeMetaItem.getIndex() );
|
||||
}
|
||||
}
|
||||
this.metaList.insertMeta.apply( this.metaList, args );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -135,11 +135,14 @@ ve.ui.MWCategoriesPage.prototype.onUpdateSortKey = function ( item ) {
|
|||
* @param {ve.dm.MetaItem} metaItem
|
||||
*/
|
||||
ve.ui.MWCategoriesPage.prototype.onMetaListInsert = function ( metaItem ) {
|
||||
var index;
|
||||
|
||||
// Responsible for adding UI components
|
||||
if ( metaItem.element.type === 'mwCategory' ) {
|
||||
index = this.metaList.getItemsInGroup( 'mwCategory' ).indexOf( metaItem );
|
||||
this.categoryWidget.addItems(
|
||||
[ this.getCategoryItemFromMetaListItem( metaItem ) ],
|
||||
this.metaList.findItem( metaItem.getOffset(), metaItem.getIndex(), 'mwCategory' )
|
||||
index
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -221,17 +224,6 @@ ve.ui.MWCategoriesPage.prototype.getCategoryItemForInsertion = function ( item,
|
|||
return newData;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts a meta list item
|
||||
*
|
||||
* @param {Object} metaBase meta list insert object
|
||||
* @param {number} [offset] Offset of the meta items within the document
|
||||
* @param {number} [index] Index of the meta item within the group of meta items at this offset
|
||||
*/
|
||||
ve.ui.MWCategoriesPage.prototype.insertMetaListItem = function ( metaBase, offset, index ) {
|
||||
this.metaList.insertMeta( metaBase, offset, index );
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup categories page.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue