/**
 * Created by YaoJi on 2017/6/23.
 * Ckeditor Picture video plugin.
 * @author: CoverCMS Web steam.
 * @file: covervideo/plugin.js
 */
CKEDITOR.plugins.add('covervideo', {
    icons: 'covervideo',
    init: function (editor) {
        CKEDITOR.dialog.addIframe('covervideo', '添加视频', videoEntry, 520, 90, function () {}, {
            onOk: function (element) {
                if (uploadedVideo!='' && uploadedVideo!=null && uploadedVideo!=undefined){
                    var videoSrc = videoCloud+uploadedVideo;
                    var videoString = '<embed class="cv-editor-video" src="'+videoSrc+'" allowFullScreen="false" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>';
                    editor.insertHtml(videoString);
                    uploadedVideo = null;
                }
            },
            onCancel: function () {
                uploadedVideo = null;
            }
        });

        editor.addCommand('insertvideo', {
            exec: function (editor) {
                editor.openDialog('covervideo')
            }
        });

        editor.ui.addButton('covervideo', {
            label: '插入视频',
            command: 'insertvideo',
            toolbar: 'insert'
        });
    }
});