关于JavaScript中的复制(2)

C += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' + E + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"><param value="always" /><param value="false" /><param value="' + ZeroClipboard.moviePath + '" /><param value="false" /><param value="false" /><param value="best" /><param value="#ffffff" /><param value="' + B + '"/><param value="transparent"/></object>'

} else {

C += '<embed src="' + ZeroClipboard.moviePath + '" loop="false" menu="false" quality="best" bgcolor="#ffffff" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + B + '" wmode="transparent" />'

}

return C

},

hide: function() {

if (this.div) {

this.div.style.left = "-2000px"

}

},

show: function() {

this.reposition()

},

destroy: function() {

if (this.domElement && this.div) {

this.hide();

this.div.innerHTML = "";

var A = document.getElementsByTagName("body")[0];

try {

A.removeChild(this.div)

} catch (B) {}

this.domElement = null;

this.div = null

}

},

/* 因为按钮上漂浮有一个 Flash 按钮,所以当页面大小发生变化时,Flash 按钮可能会错位,就点不着了

Zero Clipboard 提供了一个 reposition() 方法,可以重新计算 Flash 按钮的位置。我们可以将它绑定到 resize 事件上

bind(window, "resize", function(){ clip.reposition(); });

function bind(obj, type, fn) {

if (obj.attachEvent) {

obj['e' + type + fn] = fn;

obj[type + fn] = function() {

obj['e' + type + fn](window.event);

}

obj.attachEvent('on' + type, obj[type + fn]);

} else

obj.addEventListener(type, fn, false);

}*/

reposition: function(C) {

if (C) {

this.domElement = ZeroClipboard.$(C);

if (!this.domElement) {

this.hide()

}

}

if (this.domElement && this.div) {

var B = ZeroClipboard.getDOMObjectPosition(this.domElement);

var A = this.div.style;

A.left = "" + B.left + "px";

A.top = "" + B.top + "px"

}

},

setText: function(A) {

this.clipText = A;

if (this.ready) {

this.movie.setText(A)

}

},

addEventListener: function(A, B) {

A = A.toString().toLowerCase().replace(/^on/, "");

if (!this.handlers[A]) {

this.handlers[A] = []

}

this.handlers[A].push(B)

},

setHandCursor: function(A) {

this.handCursorEnabled = A;

if (this.ready) {

this.movie.setHandCursor(A)

}

},

/*鼠标移到按钮上或点击时,由于有 Flash 按钮的遮挡,所以像 css ":hover", ":active" 等伪类可能会失效。

setCSSEffects() 方法就是解决这个问题。首先我们需要将伪类改成类

copy - botton: hover {

border - color: #FF6633;

}

可以改成下面的 ":hover" 改成 ".hover"

copy - botton.hover {

border - color: #FF6633;

}

我们可以调用 clip.setCSSEffects( true ); 这样 Zero Clipboard 会自动为我们处理:将类 .hover 当成伪类 :hover*/

setCSSEffects: function(A) {

this.cssEffects = !! A

},

/*Zero Clipboard 提供了一些事件,你可以自定义函数处理这些事件。

Zero Clipboard 事件处理函数为 addEventListener(); 例如当 Flash 完全载入后会触发一个事件 "load"

clip.addEventListener( "load", function(client) {

alert("Flash 加载完毕!");

});*/

receiveEvent: function(D, E) {

D = D.toString().toLowerCase().replace(/^on/, "");

switch (D) {

case "load":

this.movie = document.getElementById(this.movieId);

if (!this.movie) {

var C = this;

setTimeout(function() {

C.receiveEvent("load", null)

}, 1);

return

}

if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {

var C = this;

setTimeout(function() {

C.receiveEvent("load", null)

}, 100);

this.ready = true;

return

}

this.ready = true;

this.movie.setText(this.clipText);

this.movie.setHandCursor(this.handCursorEnabled);

break;

case "mouseover":

if (this.domElement && this.cssEffects) {

this.domElement.addClass("hover");

if (this.recoverActive) {

this.domElement.addClass("active")

}

}

break;

case "mouseout":

if (this.domElement && this.cssEffects) {

this.recoverActive = false;

if (this.domElement.hasClass("active")) {

this.domElement.removeClass("active");

this.recoverActive = true

}

this.domElement.removeClass("hover")

}

break;

case "mousedown":

if (this.domElement && this.cssEffects) {

this.domElement.addClass("active")

}

break;

case "mouseup":

if (this.domElement && this.cssEffects) {

this.domElement.removeClass("active");

this.recoverActive = false

}

break

}

if (this.handlers[D]) {

for (var B = 0, A = this.handlers[D].length; B < A; B++) {

var F = this.handlers[D][B];

if (typeof(F) == "function") {

F(this, E)

} else {

if ((typeof(F) == "object") && (F.length == 2)) {

F[0][F[1]](this, E)

} else {

if (typeof(F) == "string") {

window[F](this, E)

}

}

}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6b5f953ee1ead9fa77c05b7c74ca6c25.html