jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/345272 )
Change subject: Disable VE when features are not supported
......................................................................
Disable VE when features are not supported
Also:
* fixes a pointer-events bug on maplinks
Bug: T157996
Change-Id: Iacd7f3cc8d0443e8ecf86554cca5bce38e745d7f
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/ve-maps/ve.dm.MWInlineMapsNode.js
M modules/ve-maps/ve.dm.MWMapsNode.js
M modules/ve-maps/ve.ui.MWMaps.css
A modules/ve-maps/ve.ui.MWMapsContextItem.js
M styles/link.less
8 files changed, 175 insertions(+), 4 deletions(-)
Approvals:
Esanders: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index c4946ea..cf47a6a 100644
--- a/extension.json
+++ b/extension.json
@@ -352,6 +352,7 @@
"modules/ve-maps/ve.ce.MWInlineMapsNode.js",
"modules/ve-maps/ve.dm.MWMapsNode.js",
"modules/ve-maps/ve.ce.MWMapsNode.js",
+ "modules/ve-maps/ve.ui.MWMapsContextItem.js",
"modules/ve-maps/ve.ui.MWMapsDialog.js",
"modules/ve-maps/ve.ui.MWMapsTool.js"
],
@@ -359,6 +360,8 @@
"modules/ve-maps/ve.ui.MWMaps.css"
],
"messages": [
+ "visualeditor-mwmapscontextitem-nosupport",
+ "visualeditor-mwmapscontextitem-title",
"visualeditor-mwmapsdialog-align",
"visualeditor-mwmapsdialog-geojson",
"visualeditor-mwmapsdialog-position-button",
diff --git a/i18n/en.json b/i18n/en.json
index bb11c5c..88da910 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -117,5 +117,7 @@
"visualeditor-mwmapsdialog-position-zoom": "Zoom",
"visualeditor-mwmapsdialog-reset-map": "Reset map position",
"visualeditor-mwmapsdialog-size": "Size",
- "visualeditor-mwmapsdialog-title": "Map"
+ "visualeditor-mwmapsdialog-title": "Map",
+ "visualeditor-mwmapscontextitem-nosupport": "This map contains dynamic
features, and for now can only be edited in source mode.",
+ "visualeditor-mwmapscontextitem-title": "Map"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 40251d3..a9b5d5d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -121,5 +121,7 @@
"visualeditor-mwmapsdialog-position-zoom": "Label for zoom within
current position popup\n{{Identical|Zoom}}",
"visualeditor-mwmapsdialog-reset-map": "Label for resetting the map's
position",
"visualeditor-mwmapsdialog-size": "Label for map
size\n{{Identical|Size}}",
- "visualeditor-mwmapsdialog-title": "Title of the map
dialog\n{{Identical|Map}}"
+ "visualeditor-mwmapsdialog-title": "Title of the map
dialog\n{{Identical|Map}}",
+ "visualeditor-mwmapscontextitem-nosupport": "Description that visual
editing is disabled because the map contains dynamic features not supported by
the visual editor.",
+ "visualeditor-mwmapscontextitem-title": "Title of the map context
item\n{{Identical|Map}}"
}
diff --git a/modules/ve-maps/ve.dm.MWInlineMapsNode.js
b/modules/ve-maps/ve.dm.MWInlineMapsNode.js
index b15a4d2..e968129 100644
--- a/modules/ve-maps/ve.dm.MWInlineMapsNode.js
+++ b/modules/ve-maps/ve.dm.MWInlineMapsNode.js
@@ -29,6 +29,50 @@
ve.dm.MWInlineMapsNode.static.extensionName = 'maplink';
+/* Methods */
+
+/**
+ * Don't allow maps to be edited if they contain features that are not
+ * supported not supported by the editor.
+ *
+ * @inheritdoc
+ */
+ve.dm.MWInlineMapsNode.prototype.isEditable = function () {
+ var containsDynamicFeatures = this.usesAutoPositioning() ||
this.usesExternalData();
+ return !this.usesMapData() || !containsDynamicFeatures;
+};
+
+/**
+ * Checks whether the map uses auto-positioning.
+ *
+ * @return {boolean}
+ */
+ve.dm.MWInlineMapsNode.prototype.usesAutoPositioning = function () {
+ var mwAttrs = this.getAttribute( 'mw' ).attrs;
+ return !( mwAttrs.latitude && mwAttrs.longitude && mwAttrs.zoom );
+};
+
+/**
+ * Checks whether the map uses external data.
+ *
+ * @return {boolean}
+ */
+ve.dm.MWInlineMapsNode.prototype.usesExternalData = function () {
+ var mwData = this.getAttribute( 'mw' ),
+ geoJson = mwData.body.extsrc;
+ return /ExternalData/.test( geoJson );
+};
+
+/**
+ * Checks whether the map contains any map data.
+ *
+ * @return {boolean}
+ */
+ve.dm.MWInlineMapsNode.prototype.usesMapData = function () {
+ var mwData = this.getAttribute( 'mw' );
+ return !!mwData.body.extsrc;
+};
+
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWInlineMapsNode );
diff --git a/modules/ve-maps/ve.dm.MWMapsNode.js
b/modules/ve-maps/ve.dm.MWMapsNode.js
index 8f4a754..8a24cd7 100644
--- a/modules/ve-maps/ve.dm.MWMapsNode.js
+++ b/modules/ve-maps/ve.dm.MWMapsNode.js
@@ -98,6 +98,48 @@
return this.constructor.static.createScalable(
this.getCurrentDimensions() );
};
+/**
+ * Don't allow maps to be edited if they contain features that are not
+ * supported not supported by the editor.
+ *
+ * @inheritdoc
+ */
+ve.dm.MWMapsNode.prototype.isEditable = function () {
+ var containsDynamicFeatures = this.usesAutoPositioning() ||
this.usesExternalData();
+ return !this.usesMapData() || !containsDynamicFeatures;
+};
+
+/**
+ * Checks whether the map uses auto-positioning.
+ *
+ * @return {boolean}
+ */
+ve.dm.MWMapsNode.prototype.usesAutoPositioning = function () {
+ var mwAttrs = this.getAttribute( 'mw' ).attrs;
+ return !( mwAttrs.latitude && mwAttrs.longitude && mwAttrs.zoom );
+};
+
+/**
+ * Checks whether the map uses external data.
+ *
+ * @return {boolean}
+ */
+ve.dm.MWMapsNode.prototype.usesExternalData = function () {
+ var mwData = this.getAttribute( 'mw' ),
+ geoJson = mwData.body.extsrc;
+ return /ExternalData/.test( geoJson );
+};
+
+/**
+ * Checks whether the map contains any map data.
+ *
+ * @return {boolean}
+ */
+ve.dm.MWMapsNode.prototype.usesMapData = function () {
+ var mwData = this.getAttribute( 'mw' );
+ return !!mwData.body.extsrc;
+};
+
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWMapsNode );
diff --git a/modules/ve-maps/ve.ui.MWMaps.css b/modules/ve-maps/ve.ui.MWMaps.css
index d24ad19..6b8cec7 100644
--- a/modules/ve-maps/ve.ui.MWMaps.css
+++ b/modules/ve-maps/ve.ui.MWMaps.css
@@ -44,3 +44,9 @@
.ve-ui-mwMapsDialog-position-table th {
padding: 0.5em 1em 0.5em 0;
}
+
+.ve-ui-mwMapsContextItem-nosupport {
+ color: #777;
+ font-style: italic;
+ line-height: 1.6;
+}
diff --git a/modules/ve-maps/ve.ui.MWMapsContextItem.js
b/modules/ve-maps/ve.ui.MWMapsContextItem.js
new file mode 100644
index 0000000..8d48469
--- /dev/null
+++ b/modules/ve-maps/ve.ui.MWMapsContextItem.js
@@ -0,0 +1,71 @@
+/*!
+ * VisualEditor MWMapsContextItem class.
+ *
+ * @copyright 2011-2017 VisualEditor Team and others; see
http://ve.mit-license.org
+ */
+
+/**
+ * Context item for a MWInlineMapsNode or MWMapsNode.
+ *
+ * @class
+ * @extends ve.ui.LinearContextItem
+ *
+ * @constructor
+ * @param {ve.ui.Context} context Context item is in
+ * @param {ve.dm.Model} model Model item is related to
+ * @param {Object} config Configuration options
+ */
+ve.ui.MWMapsContextItem = function VeUiMWMapsContextItem() {
+ // Parent constructor
+ ve.ui.MWMapsContextItem.super.apply( this, arguments );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.MWMapsContextItem, ve.ui.LinearContextItem );
+
+/* Static Properties */
+
+ve.ui.MWMapsContextItem.static.name = 'mwMaps';
+
+ve.ui.MWMapsContextItem.static.icon = 'map';
+
+ve.ui.MWMapsContextItem.static.label = OO.ui.deferMsg(
'visualeditor-mwmapscontextitem-title' );
+
+ve.ui.MWMapsContextItem.static.modelClasses = [ ve.dm.MWInlineMapsNode,
ve.dm.MWMapsNode ];
+
+ve.ui.MWMapsContextItem.static.commandName = 'mwMaps';
+
+/* Methods */
+
+/**
+ * Get a DOM rendering of the reference.
+ *
+ * @private
+ * @return {jQuery} DOM rendering of reference
+ */
+ve.ui.MWMapsContextItem.prototype.getRendering = function () {
+ if ( !this.model.isEditable() ) {
+ return $( '<div>' )
+ .addClass( 've-ui-mwMapsContextItem-nosupport' )
+ .text( this.getDescription() );
+ }
+};
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWMapsContextItem.prototype.getDescription = function () {
+ return this.model.isEditable() ? '' : ve.msg(
'visualeditor-mwmapscontextitem-nosupport' );
+};
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWMapsContextItem.prototype.renderBody = function () {
+ this.$body.empty().append( this.getRendering() );
+};
+
+/* Registration */
+
+ve.ui.contextItemFactory.register( ve.ui.MWMapsContextItem );
diff --git a/styles/link.less b/styles/link.less
index b1f230c..cb26ec3 100644
--- a/styles/link.less
+++ b/styles/link.less
@@ -69,8 +69,9 @@
cursor: pointer;
}
- .mw-kartographer-maplink:not( .mw-kartographer-link ),
- .mw-kartographer-map:not( .mw-kartographer-link ):not(
.mw-kartographer-interactive ) { // stylelint bug
+ /* stylelint-disable-next-line indentation */
+ .mw-kartographer-maplink:not( .mw-kartographer-link ):not(
.ve-ce-focusableNode ), /* stylelint-disable-next-line indentation */
+ .mw-kartographer-map:not( .mw-kartographer-link ):not(
.mw-kartographer-interactive ) {
pointer-events: none;
cursor: default;
}
--
To view, visit https://gerrit.wikimedia.org/r/345272
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iacd7f3cc8d0443e8ecf86554cca5bce38e745d7f
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: JGirault <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: JGirault <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits