增加浏览器是否支持 flash 的判断,复制插件依赖 Flash

This commit is contained in:
virusdefender 2015-09-11 18:21:28 +08:00
parent 66b51ab741
commit 7ac93841d6

View File

@ -6,9 +6,26 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"],
return;
}
// 提供点击复制到剪切板的功能
ZeroClipboard.config({swfPath: "/static/img/ZeroClipboard.swf"});
new ZeroClipboard($(".copy-sample"));
// 复制样例需要 Flash 的支持 检测浏览器是否安装了 Flash
function detect_flash() {
var ie_flash;
try {
ie_flash = (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) !== false)
} catch (err) {
ie_flash = false;
}
var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || ie_flash);
return _flash_installed;
}
if(detect_flash()) {
// 提供点击复制到剪切板的功能
ZeroClipboard.config({swfPath: "/static/img/ZeroClipboard.swf"});
new ZeroClipboard($(".copy-sample"));
}
else{
$(".copy-sample").hide();
}
var codeEditor = codeMirror(codeEditorSelector, "text/x-csrc");
var language = $("input[name='language'][checked]").val();
@ -186,4 +203,4 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"],
}
}
})
});
});