mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
1fd7e85846
Objective: * Allow inserting images from local wiki and commons Changes: ve.init.mw.ViewPageTarget.js * Add media insert button to toolbar ve.init.mw.Platform.js * Add getMediaSources method - defaults to local wiki and commons ve.ui.MWMediaInsertDialog.js * New dialog for inserting media * Uses a media select widget and inserts block images ve.ui.Dialog.css * Added styling for media select widget in media insert dialog ve.ui.Widget.css * Added styles for media select widget and media select item widget ve.ui.MWMediaInsertButtonTool.js * New tool for inserting media ve.ui.MediaSelectItemWidget.js * New item widget for media select widgets ve.ui.MediaSelectWidget.js * New widget for searching for and selecting media items ve.ui.TextInputWidget.js * Added isPending method VisualEditor.i18n.php * New messages for media insert dialog VisualEditor.php * Added links to new files and messages PhantomJS-- Change-Id: Ia803ff3ef518782ce76802d2dab7559686a1bb0a
102 lines
2.2 KiB
JavaScript
102 lines
2.2 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface TextInputWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.TextInputWidget object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.InputWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Config options
|
|
* @cfg {string} [placeholder] Placeholder text
|
|
* @cfg {string} [icon] Symbolic name of icon
|
|
*/
|
|
ve.ui.TextInputWidget = function VeUiTextInputWidget( config ) {
|
|
// Parent constructor
|
|
ve.ui.InputWidget.call( this, config );
|
|
|
|
// Properties
|
|
this.pending = 0;
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-textInputWidget' );
|
|
if ( config.icon ) {
|
|
this.$.addClass( 've-ui-textInputWidget-decorated' );
|
|
this.$.append(
|
|
$( '<span>' )
|
|
.addClass( 've-ui-textInputWidget-icon ve-ui-icon-' + config.icon )
|
|
.mousedown( ve.bind( function () {
|
|
this.$input.focus();
|
|
return false;
|
|
}, this ) )
|
|
);
|
|
}
|
|
if ( config.placeholder ) {
|
|
this.$input.attr( 'placeholder', config.placeholder );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.TextInputWidget, ve.ui.InputWidget );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Get input element.
|
|
*
|
|
* @method
|
|
* @param {Object} [config] Config options
|
|
* @return {jQuery} Input element
|
|
*/
|
|
ve.ui.TextInputWidget.prototype.getInputElement = function ( config ) {
|
|
return config.multiline ? this.$$( '<textarea>' ) : this.$$( '<input>' ).attr( 'type', 'text' );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Checks if input is pending.
|
|
*
|
|
* @method
|
|
* @returns {boolean} Input is pending
|
|
*/
|
|
ve.ui.TextInputWidget.prototype.isPending = function () {
|
|
return !!this.pending;
|
|
};
|
|
|
|
/**
|
|
* Increases the pending stack.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.TextInputWidget.prototype.pushPending = function () {
|
|
this.pending++;
|
|
this.$.addClass( 've-ui-textInputWidget-pending' );
|
|
this.$input.addClass( 've-ui-texture-pending' );
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Reduces the pending stack.
|
|
*
|
|
* Clamped at zero.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.TextInputWidget.prototype.popPending = function () {
|
|
this.pending = Math.max( 0, this.pending - 1 );
|
|
if ( !this.pending ) {
|
|
this.$.removeClass( 've-ui-textInputWidget-pending' );
|
|
this.$input.removeClass( 've-ui-texture-pending' );
|
|
}
|
|
return this;
|
|
};
|