Created
January 17, 2014 23:09
-
-
Save trevorparscal/8483397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @inheritdoc | |
*/ | |
ve.ui.LinkInspector.prototype.setup = function ( data ) { | |
var focusedNode = this.surface.getView().getFocusedNode(); | |
if ( | |
focusedNode && | |
ve.isInstanceOfAny( focusedNode.getModel(), this.constructor.static.modelClasses ) | |
) { | |
this.linkNode = focusedNode.getModel(); | |
// Call grandparent method, skipping AnnotationInspector | |
ve.ui.Inspector.prototype.setup.call( this, data ); | |
} else { | |
this.linkNode = null; | |
// Parent method | |
ve.ui.AnnotationInspector.prototype.setup.call( this, data ); | |
} | |
// Disable surface until animation is complete; will be reenabled in ready() | |
this.surface.disable(); | |
}; | |
/** | |
* @inheritdoc | |
*/ | |
ve.ui.LinkInspector.prototype.ready = function () { | |
var href; | |
// Parent method | |
ve.ui.AnnotationInspector.prototype.ready.call( this ); | |
// Note: Focus input prior to setting target annotation | |
this.targetInput.$input.focus(); | |
if ( this.linkNode ) { | |
href = this.linkNode.getAttribute( 'href' ); | |
if ( typeof href === 'string' && href.length ) { | |
this.targetInput.setValue( href ); | |
} | |
} else { | |
this.targetInput.setAnnotation( this.initialAnnotation ); | |
} | |
this.targetInput.$input.select(); | |
this.surface.enable(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment