Skip to content

Commit

Permalink
- Added copy error message for un-supported browsers (like safari)
Browse files Browse the repository at this point in the history
- Better spacing in-between share rows.
  • Loading branch information
wdamien committed Jan 20, 2016
1 parent f4ce225 commit 050d03f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
39 changes: 31 additions & 8 deletions js/views/ShareMenu.js
Expand Up @@ -50,10 +50,21 @@ p.initialize = function (element, docsView) {
this.sharePatternTxt = $.el("#sharePatternTxt", this.element);
this.shareJavascriptTxt = $.el("#shareJavascriptTxt", this.element);

new Clipboard(".share-link-btn").on("success", this._handleCopySuccess.bind(this));
new Clipboard(".share-expression-btn").on("success", this._handleCopySuccess.bind(this));
new Clipboard(".share-javascript-btn").on("success", this._handleCopySuccess.bind(this));
new Clipboard(".share-pattern-btn").on("success", this._handleCopySuccess.bind(this));
new Clipboard(".share-link-btn")
.on("success", this._handleCopySuccess.bind(this))
.on("error", this._handleCopyError.bind(this));

new Clipboard(".share-expression-btn")
.on("success", this._handleCopySuccess.bind(this))
.on("error", this._handleCopyError.bind(this));

new Clipboard(".share-javascript-btn")
.on("success", this._handleCopySuccess.bind(this))
.on("error", this._handleCopyError.bind(this));

new Clipboard(".share-pattern-btn")
.on("success", this._handleCopySuccess.bind(this))
.on("error", this._handleCopyError.bind(this));

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

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

p._handleCopyError = function(event) {
var copyKeyLabel = $.getCtrlKey();
this.showCopyToolTip("Press " + copyKeyLabel +" + C to copy.", event, false);
}

p._handleCopySuccess = function(event) {
this.showCopyToolTip("Copied!", event);
}

p.showCopyToolTip = function(content, event, autoHide) {
var rect = event.trigger.getBoundingClientRect();
this._successToolTip.show("Copied!", rect);
this._successToolTip.show(content, rect);
var _this = this;
setTimeout(function() {
_this._successToolTip.hide();
}, 750);

if (autoHide !== false) {
setTimeout(function () {
_this._successToolTip.hide();
}, 750);
}
}

p.handleExpressionCopied = function (event) {
Expand Down
4 changes: 4 additions & 0 deletions scss/menus.scss
Expand Up @@ -36,6 +36,10 @@
}
}

header:not(:first-child) {
@include calc("padding-top", "0.375em*4");
}

.public-wrap {
padding-top: .5rem;
}
Expand Down

0 comments on commit 050d03f

Please sign in to comment.