mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
db9f941fa6
Objectives: * Rename this.$ to this.$element * Rename this.$$ to this.$ * Get rid of the need to use this.frame.$$ * Rename OO.ui.Element.get$$ to OO.ui.Element.getJQuery Changes: (using Sublime Text regex patterns) * Replace "get$$" with "getJQuery" * Replace "\.(\$)([^\$a-zA-Z])" with ".$element$2" * Replace "\.(\$\$)" with ".$" * Replace "'$$'" with "'$'" * Set this.$ to null in constructor of OO.ui.Window * Set this.$ to this.frame.$ in initialize method of OO.ui.Window * Replace "\.(frame.\$)([^\$a-zA-Z])" with ".\$$2" Bonus: * Use this.$() in a bunch of places where $() was erroneously used Change-Id: If3d870124ab8d10f8223532cda95c2b2b075db94
83 lines
2 KiB
JavaScript
83 lines
2 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable ListItemNode class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/*global mw */
|
|
|
|
/**
|
|
* ContentEditable image caption item node.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.BranchNode
|
|
* @constructor
|
|
* @param {ve.dm.MWImageCaptionNode} model Model to observe
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ce.MWImageCaptionNode = function VeCeMWImageCaptionNode( model, config ) {
|
|
// Parent constructor
|
|
ve.ce.BranchNode.call( this, model, config );
|
|
|
|
// DOM changes
|
|
this.$element.addClass( 'thumbcaption' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ce.MWImageCaptionNode, ve.ce.BranchNode );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ce.MWImageCaptionNode.static.name = 'mwImageCaption';
|
|
|
|
ve.ce.MWImageCaptionNode.static.tagName = 'div';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* TODO: Magnify should appear/disappear based on the changes/updates to the parent (switching to
|
|
* and from thumb or frame).
|
|
*/
|
|
ve.ce.MWImageCaptionNode.prototype.onSplice = function () {
|
|
var parentType = this.model.getParent().getAttribute( 'type' );
|
|
|
|
if ( parentType === 'thumb' ) {
|
|
if ( this.$magnify ) {
|
|
this.$magnify.detach();
|
|
} else {
|
|
this.buildMagnify();
|
|
}
|
|
}
|
|
|
|
// Parent method
|
|
ve.ce.BranchNode.prototype.onSplice.apply( this, arguments );
|
|
|
|
if ( parentType === 'thumb' ) {
|
|
this.$magnify.prependTo( this.$element );
|
|
}
|
|
};
|
|
|
|
/** */
|
|
ve.ce.MWImageCaptionNode.prototype.buildMagnify = function () {
|
|
this.$magnify = this.$( '<div>' )
|
|
.addClass( 'magnify' );
|
|
this.$a = this.$( '<a>' )
|
|
.addClass( 'internal' )
|
|
// It's inside a protected node, so user can't see href/title anyways.
|
|
//.attr( 'href', '/wiki/File:Wiki.png' )
|
|
//.attr( 'title', 'Enlarge' )
|
|
.appendTo( this.$magnify );
|
|
this.$img = this.$( '<img>' )
|
|
.attr( 'src', mw.config.get( 'wgVisualEditor' ).magnifyClipIconURL )
|
|
.attr( 'width', 15 )
|
|
.attr( 'height', 11 )
|
|
//.attr( 'alt', '' )
|
|
.appendTo( this.$a );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWImageCaptionNode );
|