mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 10:48:42 +00:00
Merge "Use iconWhenInvisible for alien extension nodes"
This commit is contained in:
commit
fe19bfb0af
|
@ -1669,8 +1669,7 @@
|
|||
"modules/ve-mw/ui/contextitems/ve.ui.MWAlienExtensionContextItem.js"
|
||||
],
|
||||
"styles": [
|
||||
"modules/ve-mw/ui/styles/inspectors/ve.ui.MWAlienExtensionInspector.css",
|
||||
"modules/ve-mw/ce/styles/nodes/ve.ce.MWAlienExtensionNode.css"
|
||||
"modules/ve-mw/ui/styles/inspectors/ve.ui.MWAlienExtensionInspector.css"
|
||||
],
|
||||
"dependencies": [
|
||||
"ext.visualEditor.mwcore"
|
||||
|
|
|
@ -10,60 +10,24 @@
|
|||
*
|
||||
* @class
|
||||
* @abstract
|
||||
* @mixins OO.ui.mixin.IconElement
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ce.MWAlienExtensionNode = function VeCeMWAlienExtensionNode( config ) {
|
||||
// Mixin constructors
|
||||
OO.ui.mixin.IconElement.call( this, config );
|
||||
|
||||
// Events
|
||||
this.connect( this, { setup: 'onAlienSetup' } );
|
||||
ve.ce.MWAlienExtensionNode = function VeCeMWAlienExtensionNode() {
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.initClass( ve.ce.MWAlienExtensionNode );
|
||||
|
||||
OO.mixinClass( ve.ce.MWAlienExtensionNode, OO.ui.mixin.IconElement );
|
||||
|
||||
/* Static members */
|
||||
|
||||
ve.ce.MWAlienExtensionNode.static.primaryCommandName = 'alienExtension';
|
||||
|
||||
ve.ce.MWAlienExtensionNode.static.iconWhenInvisible = 'alienextension';
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* Handle setup events
|
||||
*/
|
||||
ve.ce.MWAlienExtensionNode.prototype.onAlienSetup = function () {
|
||||
if ( !this.isVisible() ) {
|
||||
this.setIcon( 'alienextension' );
|
||||
this.$element.first().prepend( this.$icon );
|
||||
} else {
|
||||
this.setIcon( null );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc ve.ce.MWExtensionNode
|
||||
*/
|
||||
ve.ce.MWAlienExtensionNode.prototype.render = function ( generatedContents ) {
|
||||
// Since render is triggered before onSetup, we need to make sure that the
|
||||
// icon is detached only when it is defined and is not null
|
||||
if ( this.$icon ) {
|
||||
this.$icon.detach();
|
||||
}
|
||||
// Call parent mixin
|
||||
ve.ce.GeneratedContentNode.prototype.render.call( this, generatedContents );
|
||||
|
||||
// Since render replaces this.$element with a new node, we need to make sure
|
||||
// our iconElement is defined again to be this.$element
|
||||
this.$element.addClass( 've-ce-mwAlienExtensionNode' );
|
||||
};
|
||||
|
||||
/* Static methods */
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/*!
|
||||
* VisualEditor ContentEditable MediaWiki MWAlienExtensionNode styles.
|
||||
*
|
||||
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
.ve-ce-mwAlienExtensionNode.oo-ui-iconElement {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
padding: 0.2em;
|
||||
margin: -0.25em 0.15em 0 0.15em;
|
||||
}
|
||||
|
||||
.ve-ce-mwAlienExtensionNode.oo-ui-iconElement .oo-ui-iconElement-icon {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: 24px 24px;
|
||||
opacity: 0.5;
|
||||
}
|
Loading…
Reference in a new issue