jenkins-bot has submitted this change and it was merged.
Change subject: MWLinkNodeInspector: Provide an open button here too
......................................................................
MWLinkNodeInspector: Provide an open button here too
Also add validation now that we need it for the open button.
Bug: 71904
Change-Id: I50515671bb3ff08da8dc6c247c9959c27957c867
---
M modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js
1 file changed, 32 insertions(+), 1 deletion(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js
b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js
index 5f49df5..18ede2d 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js
@@ -37,6 +37,10 @@
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,13 +56,40 @@
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
*/
ve.ui.MWLinkNodeInspector.prototype.getActionProcess = function ( action ) {
--
To view, visit https://gerrit.wikimedia.org/r/168007
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I50515671bb3ff08da8dc6c247c9959c27957c867
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits