Skip to content

Instantly share code, notes, and snippets.

@trevorparscal
Created January 17, 2014 23:09
Show Gist options
  • Save trevorparscal/8483397 to your computer and use it in GitHub Desktop.
Save trevorparscal/8483397 to your computer and use it in GitHub Desktop.
/**
* @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