提交 9db1a1d1 编写于 作者: K Kohsuke Kawaguchi

[FIXED SECURITY-149]

ZeroClipboard 1.3.5 is rather incompatible with 1.1.7, and various API changes were needed.

 - setText() call doesn't work until the DOM is populated, which is at some unknown time AFAICT.
   installing it via the datarequested event avoids this problem.
 - constructor now demands the element to attach to, and it's unclear if relative positioning is working or not.
 - "display: inline-block" is needed for ZeroClipboard to correctly compute the height of the element
上级 a6a7bec0
......@@ -158,7 +158,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-zeroclipboard</artifactId>
<version>1.1.7-1</version>
<version>1.3.5-1</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
......
.copy-button {
display: inline-block;
}
.copy-button BUTTON {
background: url('clipboard.png') center center no-repeat;
width: 20px;
......
......@@ -5,8 +5,7 @@ Behaviour.specify("span.copy-button", 'copyButton', 0, function(e) {
var id = "copy-button"+(iota++);
btn.id = id;
var clip = new ZeroClipboard.Client();
clip.setText(e.getAttribute("text"));
var clip = new ZeroClipboard(e);
makeButton(btn);
clip.setHandCursor(true);
......@@ -14,24 +13,24 @@ Behaviour.specify("span.copy-button", 'copyButton', 0, function(e) {
if (container) {
container = $(e).up(container);
container.style.position = "relative";
clip.glue(id,container);
} else {
clip.glue(id);
}
clip.addEventListener('onComplete',function() {
clip.on('datarequested',function() {
clip.setText(e.getAttribute("text"));
});
clip.on('complete',function() {
notificationBar.show(e.getAttribute("message"));
});
clip.addEventListener('onMouseOver',function() {
clip.on('mouseOver',function() {
$(id).addClassName('yui-button-hover')
});
clip.addEventListener('onMouseOut',function() {
clip.on('mouseOut',function() {
$(id).removeClassName('yui-button-hover')
});
clip.addEventListener('onMouseDown',function() {
clip.on('mouseDown',function() {
$(id).addClassName('yui-button-active')
});
clip.addEventListener('onMouseUp',function() {
clip.on('mouseUp',function() {
$(id).removeClassName('yui-button-active')
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册