From d5d44df053f53f46cf641d1a60c3d82cb047e5a2 Mon Sep 17 00:00:00 2001 From: Rob Moen Date: Fri, 21 Sep 2012 16:45:57 -0700 Subject: [PATCH] Regression fix, clearing only link annotations when creating link. Clearing only existing selected links when: 1) Creating a link 2) Pressing clear button Change-Id: I4b1bcd9a3ac177b2f9b4af2d562d4c4fec09d5c5 --- .../ve/ui/inspectors/ve.ui.LinkInspector.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js index d67c8b5216..6ddbbdf230 100644 --- a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js +++ b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js @@ -41,13 +41,12 @@ ve.ui.LinkInspector = function VeUiLinkInspector( toolbar, context ) { if ( $( this ).hasClass( 've-ui-inspector-button-disabled' ) ) { return; } - var i, arr, + var i, surfaceModel = inspector.context.getSurfaceView().getModel(), annotations = inspector.getAllLinkAnnotationsFromSelection(); // Clear all link annotations. - arr = annotations.get(); - for ( i = 0; i < arr.length; i++ ) { - surfaceModel.annotate( 'clear', arr[i] ); + for ( i = 0; i < annotations.length; i++ ) { + surfaceModel.annotate( 'clear', annotations[i] ); } inspector.$locationInput.val( '' ); inspector.context.closeInspector(); @@ -90,7 +89,8 @@ ve.ui.LinkInspector.prototype.getAllLinkAnnotationsFromSelection = function () { documentModel = surfaceModel.getDocument(); return documentModel .getAnnotationsFromRange( surfaceModel.getSelection() ) - .getAnnotationsOfType( /^link\// ); + .getAnnotationsOfType( /^link\// ) + .get(); }; ve.ui.LinkInspector.prototype.getFirstLinkAnnotation = function ( annotations ) { @@ -181,17 +181,16 @@ ve.ui.LinkInspector.prototype.onOpen = function () { ve.ui.LinkInspector.prototype.onClose = function ( accept ) { var surfaceView = this.context.getSurfaceView(), surfaceModel = surfaceView.getModel(), - annotations = this.getAllLinkAnnotationsFromSelection(), + linkAnnotations = this.getAllLinkAnnotationsFromSelection(), target = this.$locationInput.val(), - i, arr; + i; if ( accept ) { if ( !target ) { return; } // Clear link annotation if it exists - arr = annotations.get(); - for ( i = 0; i < arr.length; i++ ) { - surfaceModel.annotate( 'clear', arr[i] ); + for ( i = 0; i < linkAnnotations.length; i++ ) { + surfaceModel.annotate( 'clear', linkAnnotations[i] ); } surfaceModel.annotate( 'set', ve.ui.LinkInspector.getAnnotationForTarget( target ) );