@@ -50,10 +50,21 @@ p.initialize = function (element, docsView) {
50
50
this . sharePatternTxt = $ . el ( "#sharePatternTxt" , this . element ) ;
51
51
this . shareJavascriptTxt = $ . el ( "#shareJavascriptTxt" , this . element ) ;
52
52
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 ) ) ;
57
68
58
69
this . _successToolTip = new Tooltip ( $ . el ( ".share-link-btn" ) , "" , { mode : "custom" } ) ;
59
70
@@ -64,13 +75,25 @@ p.initialize = function (element, docsView) {
64
75
}
65
76
} ;
66
77
78
+ p . _handleCopyError = function ( event ) {
79
+ var copyKeyLabel = $ . getCtrlKey ( ) ;
80
+ this . showCopyToolTip ( "Press " + copyKeyLabel + " + C to copy." , event , false ) ;
81
+ }
82
+
67
83
p . _handleCopySuccess = function ( event ) {
84
+ this . showCopyToolTip ( "Copied!" , event ) ;
85
+ }
86
+
87
+ p . showCopyToolTip = function ( content , event , autoHide ) {
68
88
var rect = event . trigger . getBoundingClientRect ( ) ;
69
- this . _successToolTip . show ( "Copied!" , rect ) ;
89
+ this . _successToolTip . show ( content , rect ) ;
70
90
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
+ }
74
97
}
75
98
76
99
p . handleExpressionCopied = function ( event ) {
0 commit comments