zoukankan      html  css  js  c++  java
  • ueditor 插入视频代码解析

     /*
         * 创建插入视频字符窜
         * @param url 视频地址
         * @param width 视频宽度
         * @param height 视频高度
         * @param align 视频对齐
         * @param toEmbed 是否以flash代替显示
         * @param addParagraph  是否需要添加P 标签
         
         */
        function creatInsertStr(url,width,height,id,align,classname,type){
            var str;
            switch (type){
                case 'image':
                    str = '<img ' + (id ? 'id="' + id+'"' : '') + ' width="'+ width +'" height="' + height + '" _url="'+url+'" class="' + classname + '"'  +
                        ' 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;'+(align ? 'float:' + align + ';': '')+'" />'
                    break;
                case 'embed':
                    str = '<embed type="application/x-shockwave-flash" class="' + classname + '" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
                        ' src="' +  utils.html(url) + '" width="' + width  + '" height="' + height  + '"'  + (align ? ' style="float:' + align + '"': '') +
                        ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >';
                    break;
                case 'video':
                    var ext = url.substr(url.lastIndexOf('.') + 1);
                    if(ext == 'ogv') ext = 'ogg';
                    str = '<video' + (id ? ' id="' + id + '"' : '') + ' class="' + classname + '" ' + (align ? ' style="float:' + align + '"': '') +
                        ' controls preload="none" width="' + width + '" height="' + height + '" src="' + url + '" data-setup="{}">' +
                        '<source src="' + url + '" type="video/' + ext + '" /></video>';
                    break;
            }
            return str;
        }
        //插入在线视频传入的类名是edui-faked-video  插入上传的视频类名是edui-upload-video
        function switchImgAndVideo(root,img2video){ 
            utils.each(root.getNodesByTagName(img2video ? 'img' : 'embed video'),function(node){
                var className = node.getAttr('class');
                if(className && className.indexOf('edui-faked-video') != -1){
                    var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'),node.getAttr('width'),node.getAttr('height'),null,node.getStyle('float') || '',className,img2video ? 'embed':'image');
                    node.parentNode.replaceChild(UE.uNode.createElement(html),node);
                }
                if(className && className.indexOf('edui-upload-video') != -1){
                    var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'),node.getAttr('width'),node.getAttr('height'),null,node.getStyle('float') || '',className,img2video ? 'video':'image');
                    node.parentNode.replaceChild(UE.uNode.createElement(html),node);
                }
            })
        }
    
        me.addOutputRule(function(root){   //可能是代码与设计模式切换时html的转换,img站位标签和实际标签转换
            switchImgAndVideo(root,true)
        });
        me.addInputRule(function(root){
            switchImgAndVideo(root)
        });
  • 相关阅读:
    STL笔记之【map之总概】
    STL笔记之set
    Effective C++笔记之Item49【了解new-handler的行为】
    明成软件条形码打印设置
    将Excel数据导入到SqlServer及导入时数据类型转换失败解决方案
    远程桌面无法复制粘贴传输文件解决办法
    DELPHI如何读取cxcheckcombobox中的值
    Delphi 插入Excel图片和值
    SQL 查询语句先执行 SELECT?
    Linux之xargs命令传递参数的一个过滤器
  • 原文地址:https://www.cnblogs.com/djiz/p/13965181.html
Copyright © 2011-2022 走看看