Allow initial value to be accepted in link inspector if it is the

default text.

Change-Id: Ife8e8742b57bc9ff75cf147d6abc913f2a2ada7c
This commit is contained in:
Rob Moen 2012-06-20 21:52:42 -07:00
parent 48bba8fcb8
commit 11c3e8b0fb

View file

@ -87,7 +87,7 @@ ve.ui.LinkInspector.prototype.getSelectionText = function() {
for ( var i = 0; i < max; i++ ) {
if ( ve.isArray( data[i] ) ) {
str += data[i][0];
} else if( typeof data[i] === 'string') {
} else if( typeof data[i] === 'string' ) {
str += data[i];
}
}
@ -96,21 +96,29 @@ ve.ui.LinkInspector.prototype.getSelectionText = function() {
ve.ui.LinkInspector.prototype.onOpen = function() {
var annotation = this.getAnnotationFromSelection();
var initialValue = '';
if ( annotation === null ) {
this.$locationInput.val( this.getSelectionText() );
this.$clearButton.addClass( 'es-inspector-button-disabled' );
} else if ( annotation.type === 'link/wikiLink' ) {
// Internal link
this.$locationInput.val( annotation.data.title || '' );
initialValue = annotation.data.title || '';
this.$locationInput.val( initialValue );
this.$clearButton.removeClass( 'es-inspector-button-disabled' );
} else {
// External link
this.$locationInput.val( annotation.data.href || '' );
initialValue = annotation.data.title || '';
this.$locationInput.val( initialValue );
this.$clearButton.removeClass( 'es-inspector-button-disabled' );
}
this.$acceptButton.addClass( 'es-inspector-button-disabled' );
this.initialValue = this.$locationInput.val();
this.initialValue = initialValue;
if ( this.$locationInput.val().length === 0 ) {
this.$acceptButton.addClass( 'es-inspector-button-disabled' );
} else {
this.$acceptButton.removeClass( 'es-inspector-button-disabled' );
}
var _this = this;
setTimeout( function() {
_this.$locationInput.focus().select();