Skip to content

Commit 050d03f

Browse files
committed
- Added copy error message for un-supported browsers (like safari)
- Better spacing in-between share rows.
1 parent f4ce225 commit 050d03f

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

js/views/ShareMenu.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,21 @@ p.initialize = function (element, docsView) {
5050
this.sharePatternTxt = $.el("#sharePatternTxt", this.element);
5151
this.shareJavascriptTxt = $.el("#shareJavascriptTxt", this.element);
5252

53-
new Clipboard(".share-link-btn").on("success", this._handleCopySuccess.bind(this));
54-
new Clipboard(".share-expression-btn").on("success", this._handleCopySuccess.bind(this));
55-
new Clipboard(".share-javascript-btn").on("success", this._handleCopySuccess.bind(this));
56-
new Clipboard(".share-pattern-btn").on("success", this._handleCopySuccess.bind(this));
53+
new Clipboard(".share-link-btn")
54+
.on("success", this._handleCopySuccess.bind(this))
55+
.on("error", this._handleCopyError.bind(this));
56+
57+
new Clipboard(".share-expression-btn")
58+
.on("success", this._handleCopySuccess.bind(this))
59+
.on("error", this._handleCopyError.bind(this));
60+
61+
new Clipboard(".share-javascript-btn")
62+
.on("success", this._handleCopySuccess.bind(this))
63+
.on("error", this._handleCopyError.bind(this));
64+
65+
new Clipboard(".share-pattern-btn")
66+
.on("success", this._handleCopySuccess.bind(this))
67+
.on("error", this._handleCopyError.bind(this));
5768

5869
this._successToolTip = new Tooltip($.el(".share-link-btn"), "", {mode: "custom"});
5970

@@ -64,13 +75,25 @@ p.initialize = function (element, docsView) {
6475
}
6576
};
6677

78+
p._handleCopyError = function(event) {
79+
var copyKeyLabel = $.getCtrlKey();
80+
this.showCopyToolTip("Press " + copyKeyLabel +" + C to copy.", event, false);
81+
}
82+
6783
p._handleCopySuccess = function(event) {
84+
this.showCopyToolTip("Copied!", event);
85+
}
86+
87+
p.showCopyToolTip = function(content, event, autoHide) {
6888
var rect = event.trigger.getBoundingClientRect();
69-
this._successToolTip.show("Copied!", rect);
89+
this._successToolTip.show(content, rect);
7090
var _this = this;
71-
setTimeout(function() {
72-
_this._successToolTip.hide();
73-
}, 750);
91+
92+
if (autoHide !== false) {
93+
setTimeout(function () {
94+
_this._successToolTip.hide();
95+
}, 750);
96+
}
7497
}
7598

7699
p.handleExpressionCopied = function (event) {

scss/menus.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
}
3737
}
3838

39+
header:not(:first-child) {
40+
@include calc("padding-top", "0.375em*4");
41+
}
42+
3943
.public-wrap {
4044
padding-top: .5rem;
4145
}

0 commit comments

Comments
 (0)