Updates delegate package which now exposes e.delegateTarget property #120

This commit is contained in:
Zeno Rocha
2015-11-13 00:24:46 -08:00
parent 5efcdf2810
commit cb4301658c
3 changed files with 10 additions and 6 deletions

View File

@@ -6,7 +6,9 @@
</head> </head>
<body> <body>
<!-- 1. Define some markup --> <!-- 1. Define some markup -->
<button id="btn" data-clipboard-text="1">Copy</button> <div id="btn" data-clipboard-text="1">
<span>Copy</span>
</div>
<!-- 2. Include library --> <!-- 2. Include library -->
<script src="../dist/clipboard.min.js"></script> <script src="../dist/clipboard.min.js"></script>

View File

@@ -11,7 +11,7 @@
"cut" "cut"
], ],
"dependencies": { "dependencies": {
"good-listener": "^1.1.2", "good-listener": "^1.1.4",
"select": "^1.0.4", "select": "^1.0.4",
"tiny-emitter": "^1.0.0" "tiny-emitter": "^1.0.0"
}, },

View File

@@ -42,15 +42,17 @@ class Clipboard extends Emitter {
* @param {Event} e * @param {Event} e
*/ */
onClick(e) { onClick(e) {
var trigger = e.delegateTarget || e.currentTarget;
if (this.clipboardAction) { if (this.clipboardAction) {
this.clipboardAction = null; this.clipboardAction = null;
} }
this.clipboardAction = new ClipboardAction({ this.clipboardAction = new ClipboardAction({
action : this.action(e.currentTarget), action : this.action(trigger),
target : this.target(e.currentTarget), target : this.target(trigger),
text : this.text(e.currentTarget), text : this.text(trigger),
trigger : e.currentTarget, trigger : trigger,
emitter : this emitter : this
}); });
} }