jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/328696 )
Change subject: Add button to select and copy share/embed text to clipboard
......................................................................
Add button to select and copy share/embed text to clipboard
Clipboard icon adapted from modules/tools/images/pasting.svg from the
ContentTranslation extension.
Also adjusts some margins to better separate embed code box from embed
options
Bug: T77295
Change-Id: Ic7a11eab6ecc767ad4d80b94a7b62578d535d047
---
M extension.json
M i18n/en.json
M i18n/qqq.json
A resources/mmv/ui/img/pasting-hover.svg
A resources/mmv/ui/img/pasting.svg
M resources/mmv/ui/mmv.ui.reuse.dialog.less
M resources/mmv/ui/mmv.ui.reuse.embed.js
M resources/mmv/ui/mmv.ui.reuse.embed.less
M resources/mmv/ui/mmv.ui.reuse.share.js
M resources/mmv/ui/mmv.ui.reuse.share.less
10 files changed, 224 insertions(+), 2 deletions(-)
Approvals:
Gergő Tisza: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index 0beefd2..cc0f826 100644
--- a/extension.json
+++ b/extension.json
@@ -278,6 +278,7 @@
"mmv/ui/mmv.ui.reuse.shareembed.less"
],
"dependencies": [
+ "jquery.tipsy",
"oojs",
"oojs-ui",
"mediawiki.user",
@@ -290,6 +291,8 @@
"multimediaviewer-link-to-file",
"multimediaviewer-link-to-page",
"multimediaviewer-reuse-loading-placeholder",
+ "multimediaviewer-reuse-copy-share",
+ "multimediaviewer-reuse-copy-embed",
"multimediaviewer-embed-tab",
"multimediaviewer-embed-html",
"multimediaviewer-embed-wt",
diff --git a/i18n/en.json b/i18n/en.json
index e7d7ac5..f6c6f03 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -76,6 +76,8 @@
"multimediaviewer-geolocation": "Location: $1",
"multimediaviewer-reuse-link": "Share or embed this file",
"multimediaviewer-reuse-loading-placeholder": "Loading…",
+ "multimediaviewer-reuse-copy-share": "Select and copy (if supported)
the link for sharing this file",
+ "multimediaviewer-reuse-copy-embed": "Select and copy (if supported)
the code for embedding this file",
"multimediaviewer-share-tab": "Share",
"multimediaviewer-embed-tab": "Embed",
"multimediaviewer-download-link": "Download this file",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 20a3b4c..7c9f3a9 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -85,6 +85,8 @@
"multimediaviewer-geolocation": "Message for displaying a location.
Parameters:\n* $1 - a location which is formatted by
{{msg-mw|Multimediaviewer-geoloc-coords}}\n{{Identical|Location}}",
"multimediaviewer-reuse-link": "Text of the link on the metadata panel
which opens the reuse panel",
"multimediaviewer-reuse-loading-placeholder": "Text that appears in all
reuse text boxes as a placeholder while the data loads.\n{{Identical|Loading}}",
+ "multimediaviewer-reuse-copy-share": "Text of the tooltip for the
button to select and copy the sharing link (if supported by the browser) in the
reuse panel, that is displayed when hovered over.",
+ "multimediaviewer-reuse-copy-embed": "Text of the tooltip for the
button to select and copy the embedding code (if supported by the browser) in
the reuse panel, that is displayed when hovered over.",
"multimediaviewer-share-tab": "Tab title text for the file reuse panel
- used for the section with shareable URLs.\n{{Identical|Share}}",
"multimediaviewer-embed-tab": "Tab title text for the file reuse panel
- used for the section with embeddable HTML and wikitext.",
"multimediaviewer-download-link": "Tooltip text for file download
dialog open button.\n{{Identical|Download}}",
diff --git a/resources/mmv/ui/img/pasting-hover.svg
b/resources/mmv/ui/img/pasting-hover.svg
new file mode 100644
index 0000000..059d3cd
--- /dev/null
+++ b/resources/mmv/ui/img/pasting-hover.svg
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="18.244141"
+ height="22.457031"
+ viewBox="0 0 18.244141 22.457031"
+ id="Layer_1"
+ xml:space="preserve"
+ sodipodi:docname="pasting-hover.svg"
+ inkscape:version="0.92pre3 r"><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="1012"
+ id="namedview9"
+ showgrid="false"
+ showguides="false"
+ inkscape:guide-bbox="true"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true"
+ inkscape:object-paths="false"
+ inkscape:snap-center="true"
+ inkscape:zoom="11.313709"
+ inkscape:cx="22.688172"
+ inkscape:cy="23.452284"
+ inkscape:window-x="0"
+ inkscape:window-y="32"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="Layer_1"
+ inkscape:snap-smooth-nodes="true"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" /><metadata
+ id="metadata1113"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage"
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs1111" /><g
+ transform="matrix(1.4181234,0,0,1.4181234,-793.35706,-221.27829)"
+ id="g317"
+ style="fill:#3366bb;fill-opacity:1"><path
+
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#3366bb;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.80299997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 2.7734375 1.9355469 C 1.2094812 2.236981 0 3.6118835 0 5.2558594 L
0 19.054688 C 0 20.914868 1.5402096 22.457031 3.4003906 22.457031 L 14.84375
22.457031 C 16.703945 22.457031 18.244141 20.914868 18.244141 19.054688 L
18.244141 5.2558594 C 18.244141 3.6118835 17.034668 2.236981 15.470703
1.9355469 C 15.599513 2.2668096 15.677734 2.6218425 15.677734 2.9941406 L
15.677734 3.1699219 C 15.677734 3.7614633 15.493769 4.3149859 15.1875 4.7832031
C 15.336398 4.8859833 15.441406 5.0413526 15.441406 5.2558594 L 15.441406
19.054688 C 15.441406 19.410494 15.199571 19.652344 14.84375 19.652344 L
3.4003906 19.652344 C 3.0445836 19.652344 2.8027344 19.410494 2.8027344
19.054688 L 2.8027344 5.2558594 C 2.8027344 5.0413526 2.9077445 4.8859831
3.0566406 4.7832031 C 2.7500427 4.3150348 2.5664062 3.7623232 2.5664062
3.1699219 L 2.5664062 2.9941406 C 2.5664062 2.6219843 2.6449195 2.2664332
2.7734375 1.9355469 z "
+ transform="matrix(0.70515725,0,0,0.70515725,559.44148,156.03599)"
+ id="rect3680" /><path
+
style="fill:#3366bb;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.80299997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 29.324219,-6.5390625 c -0.831,0 -1.5,0.669 -1.5,1.5 v 0.00391 h
-1.039063 c -0.824906,0 -1.490234,0.6653284 -1.490234,1.4902343 v 0.1757813 c
0,0.8249059 0.665328,1.4882812 1.490234,1.4882812 h 2.539063 2.054687 2.539063
c 0.824906,0 1.488281,-0.6633753 1.488281,-1.4882812 v -0.1757813 c
0,-0.8249059 -0.663375,-1.4902343 -1.488281,-1.4902343 h -1.039063 v -0.00391 c
0,-0.831 -0.669,-1.5 -1.5,-1.5 z"
+ transform="matrix(0.70515725,0,0,0.70515725,544.47204,160.64706)"
+ id="rect4501"
+ inkscape:connector-curvature="0" /></g></svg>
\ No newline at end of file
diff --git a/resources/mmv/ui/img/pasting.svg b/resources/mmv/ui/img/pasting.svg
new file mode 100644
index 0000000..4d21242
--- /dev/null
+++ b/resources/mmv/ui/img/pasting.svg
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="18.244141"
+ height="22.457031"
+ viewBox="0 0 18.244141 22.457031"
+ id="Layer_1"
+ xml:space="preserve"
+ sodipodi:docname="pasting.svg"
+ inkscape:version="0.92pre3 r"><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="1012"
+ id="namedview9"
+ showgrid="false"
+ showguides="false"
+ inkscape:guide-bbox="true"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true"
+ inkscape:object-paths="false"
+ inkscape:snap-center="true"
+ inkscape:zoom="11.313709"
+ inkscape:cx="22.688172"
+ inkscape:cy="23.452284"
+ inkscape:window-x="0"
+ inkscape:window-y="32"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="Layer_1"
+ inkscape:snap-smooth-nodes="true"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" /><metadata
+ id="metadata1113"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage"
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs1111" /><g
+ transform="matrix(1.4181234,0,0,1.4181234,-793.35706,-221.27829)"
+ id="g317"><path
+
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#bbbbbb;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.80299997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 2.7734375 1.9355469 C 1.2094812 2.236981 0 3.6118835 0 5.2558594 L
0 19.054688 C 0 20.914868 1.5402096 22.457031 3.4003906 22.457031 L 14.84375
22.457031 C 16.703945 22.457031 18.244141 20.914868 18.244141 19.054688 L
18.244141 5.2558594 C 18.244141 3.6118835 17.034668 2.236981 15.470703
1.9355469 C 15.599513 2.2668096 15.677734 2.6218425 15.677734 2.9941406 L
15.677734 3.1699219 C 15.677734 3.7614633 15.493769 4.3149859 15.1875 4.7832031
C 15.336398 4.8859833 15.441406 5.0413526 15.441406 5.2558594 L 15.441406
19.054688 C 15.441406 19.410494 15.199571 19.652344 14.84375 19.652344 L
3.4003906 19.652344 C 3.0445836 19.652344 2.8027344 19.410494 2.8027344
19.054688 L 2.8027344 5.2558594 C 2.8027344 5.0413526 2.9077445 4.8859831
3.0566406 4.7832031 C 2.7500427 4.3150348 2.5664062 3.7623232 2.5664062
3.1699219 L 2.5664062 2.9941406 C 2.5664062 2.6219843 2.6449195 2.2664332
2.7734375 1.9355469 z "
+ transform="matrix(0.70515725,0,0,0.70515725,559.44148,156.03599)"
+ id="rect3680" /><path
+
style="fill:#bbbbbb;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.80299997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 29.324219,-6.5390625 c -0.831,0 -1.5,0.669 -1.5,1.5 v 0.00391 h
-1.039063 c -0.824906,0 -1.490234,0.6653284 -1.490234,1.4902343 v 0.1757813 c
0,0.8249059 0.665328,1.4882812 1.490234,1.4882812 h 2.539063 2.054687 2.539063
c 0.824906,0 1.488281,-0.6633753 1.488281,-1.4882812 v -0.1757813 c
0,-0.8249059 -0.663375,-1.4902343 -1.488281,-1.4902343 h -1.039063 v -0.00391 c
0,-0.831 -0.669,-1.5 -1.5,-1.5 z"
+ transform="matrix(0.70515725,0,0,0.70515725,544.47204,160.64706)"
+ id="rect4501"
+ inkscape:connector-curvature="0" /></g></svg>
\ No newline at end of file
diff --git a/resources/mmv/ui/mmv.ui.reuse.dialog.less
b/resources/mmv/ui/mmv.ui.reuse.dialog.less
index 1521406..1791aeb 100644
--- a/resources/mmv/ui/mmv.ui.reuse.dialog.less
+++ b/resources/mmv/ui/mmv.ui.reuse.dialog.less
@@ -54,6 +54,20 @@
&.active {
display: block;
}
+
+ .mw-mmv-reuse-copy {
+ /* @embed */
+ background-image: url( img/pasting.svg );
+ background-size: contain;
+ background-position: right center;
+ background-repeat: no-repeat;
+
+ &:hover {
+ /* @embed */
+ background-image: url( img/pasting-hover.svg );
+ text-decoration: none;
+ }
+ }
}
.mw-mmv-dialog-down-arrow {
diff --git a/resources/mmv/ui/mmv.ui.reuse.embed.js
b/resources/mmv/ui/mmv.ui.reuse.embed.js
index 0aeacec..dc080ac 100644
--- a/resources/mmv/ui/mmv.ui.reuse.embed.js
+++ b/resources/mmv/ui/mmv.ui.reuse.embed.js
@@ -143,10 +143,34 @@
mw.mmv.actionLogger.log( 'embed-wikitext-copied' );
} );
+ this.$copyButton = $( '<a>' )
+ .addClass( 'mw-mmv-reuse-copy' )
+ .click( function () {
+ // Select the text, and then try to copy the
text.
+ // If the copy fails or is not supported,
continue as if nothing had happened.
+ $( this ).parent().find( '.active > textarea'
).select();
+ try {
+ if ( document.queryCommandSupported &&
+ document.queryCommandSupported(
'copy' ) ) {
+ document.execCommand( 'copy' );
+ }
+ } catch ( e ) {
+ // queryCommandSupported in Firefox
pre-41 can throw errors when used with
+ // clipboard commands. We catch and
ignore these and other copy-command-related
+ // errors here.
+ }
+ } )
+ .prop( 'title', mw.msg(
'multimediaviewer-reuse-copy-embed' ) )
+ .tipsy( {
+ delayIn: mw.config.get( 'wgMultimediaViewer'
).tooltipDelay,
+ gravity: this.correctEW( 'se' )
+ } );
+
$( '<p>' )
.append(
this.embedTextHtml.$element,
- this.embedTextWikitext.$element
+ this.embedTextWikitext.$element,
+ this.$copyButton
)
.appendTo( $container );
};
diff --git a/resources/mmv/ui/mmv.ui.reuse.embed.less
b/resources/mmv/ui/mmv.ui.reuse.embed.less
index 5910644..5c89523 100644
--- a/resources/mmv/ui/mmv.ui.reuse.embed.less
+++ b/resources/mmv/ui/mmv.ui.reuse.embed.less
@@ -26,13 +26,21 @@
padding: 20px 27px;
.mw-mmv-embed-explanation {
- margin: 0 0 10px 0;
+ margin: 10px 0 20px 0;
padding: 0;
}
p,
textarea {
margin: 0;
+ }
+
+ .mw-mmv-reuse-copy {
+ float: right;
+ width: 1em;
+ height: 1em;
+ margin: 10px 0.5em 20px 0;
+ padding: 0 0 0 5px;
}
}
@@ -49,6 +57,7 @@
.mw-mmv-embed-size {
display: none;
+ margin: 10px 0 0 0;
&.active {
display: block;
diff --git a/resources/mmv/ui/mmv.ui.reuse.share.js
b/resources/mmv/ui/mmv.ui.reuse.share.js
index 340f358..2a3dac4 100644
--- a/resources/mmv/ui/mmv.ui.reuse.share.js
+++ b/resources/mmv/ui/mmv.ui.reuse.share.js
@@ -40,6 +40,8 @@
SP = Share.prototype;
SP.init = function () {
+ var pane = this;
+
this.$pane.addClass( 'mw-mmv-share-pane' )
.appendTo( this.$container );
@@ -65,6 +67,30 @@
mw.mmv.actionLogger.log( 'share-page' );
} );
+ this.$copyButton = $( '<a>' )
+ .addClass( 'mw-mmv-reuse-copy' )
+ .click( function () {
+ // Select the text, and then try to copy the
text.
+ // If the copy fails or is not supported,
continue as if nothing had happened.
+ pane.pageInput.$input.select();
+ try {
+ if ( document.queryCommandSupported &&
+ document.queryCommandSupported(
'copy' ) ) {
+ document.execCommand( 'copy' );
+ }
+ } catch ( e ) {
+ // queryCommandSupported in Firefox
pre-41 can throw errors when used with
+ // clipboard commands. We catch and
ignore these and other copy-command-related
+ // errors here.
+ }
+ } )
+ .prop( 'title', mw.msg(
'multimediaviewer-reuse-copy-share' ) )
+ .tipsy( {
+ delayIn: mw.config.get( 'wgMultimediaViewer'
).tooltipDelay,
+ gravity: this.correctEW( 'se' )
+ } )
+ .appendTo( this.$pane );
+
this.pageInput.$element.appendTo( this.$pane );
this.$explanation = $( '<div>' )
diff --git a/resources/mmv/ui/mmv.ui.reuse.share.less
b/resources/mmv/ui/mmv.ui.reuse.share.less
index 6ef629e..1e2cbc8 100644
--- a/resources/mmv/ui/mmv.ui.reuse.share.less
+++ b/resources/mmv/ui/mmv.ui.reuse.share.less
@@ -14,6 +14,19 @@
text-shadow: none;
}
}
+
+ .mw-mmv-reuse-copy {
+ // style rules based on .mw-mmv-share-page-link
+ float: right;
+ width: 1.5em;
+ height: 1.5em;
+
+ // position approximately to the middle - probably fragile but
couldn't find a better way as
+ // the height of OOJS-UI input widget has both em and px parts
and not possible to calculate
+ // exactly
+ margin: 8px 0.5em 8px 0;
+ padding: 0 0 0 5px;
+ }
}
.mw-mmv-share-page-link {
--
To view, visit https://gerrit.wikimedia.org/r/328696
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7a11eab6ecc767ad4d80b94a7b62578d535d047
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Sn1per <[email protected]>
Gerrit-Reviewer: Fomafix <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: JadeMaveric <[email protected]>
Gerrit-Reviewer: Sn1per <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits