Merge "MWLinkNodeInspector: Provide an open button here too"

This commit is contained in:
jenkins-bot 2014-10-22 03:04:15 +00:00 committed by Gerrit Code Review
commit 5a3c2a9f4c

View file

@ -36,6 +36,10 @@ ve.ui.MWLinkNodeInspector.static.removable = false;
ve.ui.MWLinkNodeInspector.static.modelClasses = [ ve.dm.MWNumberedExternalLinkNode ];
ve.ui.MWLinkNodeInspector.static.actions = ve.ui.MWLinkNodeInspector.super.static.actions.concat( [
{
action: 'open',
label: OO.ui.deferMsg( 'visualeditor-linkinspector-open' )
},
{
action: 'convert',
label: OO.ui.deferMsg( 'visualeditor-linknodeinspector-add-label' )
@ -52,12 +56,39 @@ ve.ui.MWLinkNodeInspector.prototype.initialize = function () {
ve.ui.MWLinkNodeInspector.super.prototype.initialize.call( this );
// Properties
this.targetInput = new OO.ui.TextInputWidget( { $: this.$ } );
this.targetInput = new OO.ui.TextInputWidget( {
$: this.$,
validate: ve.init.platform.getExternalLinkUrlProtocolsRegExp()
} );
// Events
this.targetInput.connect( this, { change: 'onTargetInputChange' } );
// Initialization
this.form.$element.append( this.targetInput.$element );
};
/**
* Handle target input change events.
*
* Updates the open button's hyperlink location.
*
* @param {string} value New target input value
*/
ve.ui.MWLinkNodeInspector.prototype.onTargetInputChange = function () {
var href = this.targetInput.getValue(),
inspector = this;
this.targetInput.isValid().done( function ( valid ) {
inspector.actions.forEach( { actions: 'open' }, function ( action ) {
action.setHref( href ).setTarget( '_blank' ).setDisabled( !valid );
// HACK: Chrome renders a dark outline around the action when it's a link, but causing it to
// re-render makes it magically go away; this is incredibly evil and needs further
// investigation
action.$element.hide().fadeIn( 0 );
} );
} );
};
/**
* @inheritdoc
*/