jenkins-bot has submitted this change and it was merged.
Change subject: AnnotationContextItem: refactor applying a change to the
annotation
......................................................................
AnnotationContextItem: refactor applying a change to the annotation
Allows for easier extension of the context item, since lots of possible
actions boil down to "do X to the related annotation".
Change-Id: Ia868ffc44096ec808c7443c40784eee8783fcbbb
---
M src/ui/contextitems/ve.ui.AnnotationContextItem.js
1 file changed, 12 insertions(+), 1 deletion(-)
Approvals:
Divec: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/ui/contextitems/ve.ui.AnnotationContextItem.js
b/src/ui/contextitems/ve.ui.AnnotationContextItem.js
index ff8c75e..1734750 100644
--- a/src/ui/contextitems/ve.ui.AnnotationContextItem.js
+++ b/src/ui/contextitems/ve.ui.AnnotationContextItem.js
@@ -70,6 +70,17 @@
* @protected
*/
ve.ui.AnnotationContextItem.prototype.onClearButtonClick = function () {
+ this.applyToAnnotations( function ( fragment, annotation ) {
+ fragment.annotateContent( 'clear', annotation );
+ } );
+};
+
+/**
+ * Apply a callback to every modelClass annotation in the current fragment
+ *
+ * @param {Function} callback Callback, will be passed fragment and annotation
+ */
+ve.ui.AnnotationContextItem.prototype.applyToAnnotations = function ( callback
) {
var i, len,
modelClasses = this.constructor.static.modelClasses,
fragment = this.getFragment(),
@@ -89,6 +100,6 @@
} ).get();
}
for ( i = 0, len = annotations.length; i < len; i++ ) {
- fragment.expandLinearSelection( 'annotation', annotations[ i ]
).annotateContent( 'clear', annotations[ i ] );
+ callback( fragment.expandLinearSelection( 'annotation',
annotations[ i ] ), annotations[ i ] );
}
};
--
To view, visit https://gerrit.wikimedia.org/r/276517
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia868ffc44096ec808c7443c40784eee8783fcbbb
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits