//复制功能
var clip = null;
function copyThis() {
if($.browser.version==6.0){
//针对ie6
$('.copyit').live("click",function(){
var code=$(this).parent("p").siblings(".runcode").find("textarea").text();
window.clipboardData.setData("Text",code);
})
return;
}
ZeroClipboard.setMoviePath("http://www.phpvar.com/phpvar.com/wp-content/uploads/js/ZeroClipboard/ZeroClipboard.swf");//如果ZeroClipboard.js, ZeroClipboard.swf放在同一目录下,可省略这句;
clip = new ZeroClipboard.Client();
$('.copyit').live("mouseover", function() {
var code=$(this).parent("p").siblings(".runcode").find("textarea").text();
clip.setText(code);
if (clip.div) {//已创建过包含flash的父层div,则鼠标hover时重新定位flash层的位置
//clip.receiveEvent('mouseout', null);
clip.reposition(this);
}else{
clip.glue(this)};
//clip.receiveEvent('mouseover', null);
} );
clip.addEventListener( 'complete', function(client, text){
alert("已成功复制!");
});
}
copyThis();
// 全屏阅读
var $content = $("#post_entry .post_meta");
var content = $content[0];
var fullScreenLink = $('.fullScreenLink');
function toggleFullScreen() {
(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) ? (document.exitFullscreen ? document.exitFullscreen() : document.msExitFullscreen ? document.msExitFullscreen() :
document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen()) : (content.requestFullscreen ? content.requestFullscreen() : content.msRequestFullscreen ? content.msRequestFullscreen() :
content.mozRequestFullScreen ? content.mozRequestFullScreen() : content.webkitRequestFullscreen && content.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT))
}
$(document).on('click', '.fullScreenLink', function(event) {
event.preventDefault();
toggleFullScreen();
});
$(document).on('webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange', function() {
// fullScreen,非标准,弃用
// var isFullScreen=document.fullScreen || document.webkitIsFullScreen || document.mozFullScreen || document.msFullScreen;
fullScreenLink.toggleClass('exitFullScreen');
$content.toggleClass('fullScreenElement');
// isFullScreen ? fullScreenLink.text("退出全屏") : fullScreenLink.text("全屏");
fullScreenLink.hasClass('exitFullScreen') ? fullScreenLink.text("退出全屏") : fullScreenLink.text("全屏阅读");
})
$(document).on("keydown", function(e) {
if (e.keyCode == 13 && !$("#s,.runcode_text").is(":focus")) {
toggleFullScreen();
}
});