01.code/LanweiUI/UEditor/_src/plugins/video.js
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
///import core
///import plugins/inserthtml.js
///commands 视频
///commandsName InsertVideo
///commandsTitle 插入视频
///commandsDialog dialogs\video\video.html
UE.plugins['video'] = function (){
var me =this,
div;
/**
* 创建插入视频字符窜
* @param url 视频地址
* @param width 视频宽度
* @param height 视频高度
* @param align 视频对齐
* @param toEmbed 是否以图片代替显示
* @param addParagraph 是否需要添加P 标签
*/
function creatInsertStr(url,width,height,align,toEmbed,addParagraph){
return !toEmbed ?
(addParagraph? ('<p '+ (align !="none" ? ( align == "center"? ' style="text-align:center;" ':' style="float:"'+ align ) : '') + '>'): '') +
'<img align="'+align+'" width="'+ width +'" height="' + height + '" _url="'+url+'" class="edui-faked-video"' +
' src="'+me.options.UEDITOR_HOME_URL+'themes/default/images/spacer.gif" style="background:url('+me.options.UEDITOR_HOME_URL+'themes/default/images/videologo.gif) no-repeat center center; border:1px solid gray;" />' +
(addParagraph?'</p>':'')
:
'<embed type="application/x-shockwave-flash" class="edui-faked-video" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
' src="' + url + '" width="' + width + '" height="' + height + '" align="' + align + '"' +
( align !="none" ? ' style= "'+ ( align == "center"? "display:block;":" float: "+ align ) + '"' :'' ) +
' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >';
}
function switchImgAndEmbed(img2embed){
var tmpdiv,
nodes =domUtils.getElementsByTagName(me.document, !img2embed ? "embed" : "img");
for(var i=0,node;node = nodes[i++];){
if(node.className!="edui-faked-video")continue;
tmpdiv = me.document.createElement("div");
//先看float在看align,浮动有的是时候是在float上定义的
var align = node.style.cssFloat;
tmpdiv.innerHTML = creatInsertStr(img2embed ? node.getAttribute("_url"):node.getAttribute("src"),node.width,node.height,align || node.getAttribute("align"),img2embed);
node.parentNode.replaceChild(tmpdiv.firstChild,node);
}
}
me.addListener("beforegetcontent",function(){
switchImgAndEmbed(true);
});
me.addListener('aftersetcontent',function(){
switchImgAndEmbed(false);
});
me.addListener('aftergetcontent',function(cmdName){
if(cmdName == 'aftergetcontent' && me.queryCommandState('source'))
return;
switchImgAndEmbed(false);
});
me.commands["insertvideo"] = {
execCommand: function (cmd, videoObjs){
videoObjs = utils.isArray(videoObjs)?videoObjs:[videoObjs];
var html = [];
后面还有 13 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
