plugin.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. CKEDITOR.plugins.add('flashplayer', {
  2. init: function(editor) {
  3. //plugin code goes here
  4. var pluginName = 'flashplayer';
  5. CKEDITOR.dialog.add('flashplayer',  function(a) {
  6. var b = a.config;
  7. var  escape  =   function(value) {        
  8. return  value;    
  9. };    
  10. return  {        
  11. title:   '插入FLV,MP4视频',
  12.         resizable:  CKEDITOR.DIALOG_RESIZE_BOTH,
  13.         minWidth: 350,
  14. minHeight: 200,
  15.         contents:  [{          
  16. id: 'info',
  17. label: '常规',
  18. accessKey: 'P',
  19. elements: [{
  20. type: 'hbox',
  21. widths: ['80%', '20%'],
  22. children: [{
  23. id: 'src',
  24. type: 'text',
  25. label: '源文件'
  26. }, {
  27. type: 'button',
  28. id: 'browse',
  29. filebrowser: 'info:src',
  30. hidden: true,
  31. align: 'center',
  32. label: '浏览服务器'
  33. }]
  34. }, {
  35. type: 'hbox',
  36. widths: ['35%', '35%', '30%'],
  37. children: [{
  38. type:   'text',
  39.               label:   '视频宽度',
  40.               id:   'mywidth',
  41.               'default':   '480px',
  42.               style:   'width:50px'
  43. }, {
  44. type:   'text',
  45.               label:   '视频高度',
  46.               id:   'myheight',
  47.               'default':   '270px',
  48.               style:   'width:50px'
  49. }, {
  50. type:   'select',
  51.               label:   '自动播放',
  52.               id:   'myautoplay',
  53.               required:  true,
  54.               'default':   '0',
  55.               items:  [
  56. ['是',  '1'],  
  57. ['否',  '0']
  58. ]
  59. }] //children finish
  60. }, {          
  61. type:   'text',
  62.               style:   'width:300px;',
  63.               label:   '视频截图',
  64. 'default':   '',
  65.               id:   'mythumbnail'          
  66. }]
  67. }, {
  68. id: 'Upload',
  69. hidden: true,
  70. filebrowser: 'uploadButton',
  71. label: '上传视频',
  72. elements: [{
  73. type: 'file',
  74. id: 'upload',
  75. label: '上传视频',
  76. size: 38
  77. }, {
  78. type: 'fileButton',
  79. id: 'uploadButton',
  80. label: '上传到服务器上',
  81. filebrowser: 'info:src',
  82. 'for': ['Upload', 'upload'] //'page_id', 'element_id'
  83. }]        
  84. }],
  85.         onOk:   function() {            
  86. mywidth  =  this.getValueOf('info',  'mywidth');            
  87. myheight  =  this.getValueOf('info',  'myheight');            
  88. myautoplay  =  this.getValueOf('info',  'myautoplay');            
  89. mysrc  =  this.getValueOf('info',  'src');
  90. mythumbnail     =  this.getValueOf('info',  'mythumbnail');          
  91. html  =  ''  +  escape(mysrc)  +  '';             
  92. a.insertHtml("<embed type=\"application/x-shockwave-flash\" src=\"" + b.flv_path + "player\/player.swf\" id=\"f4Player\" width=\""  +  mywidth  +  "\" height=\""  +  myheight  +  "\" flashvars=\"autoplay=" + myautoplay + "&skin=" + b.flv_path + "player\/skin.swf&video="  +  html  +  "&thumbnail="+mythumbnail+"\" allowscriptaccess=\"always\" allowfullscreen=\"true\" bgcolor=\"#000000\"></embed>");        
  93. },
  94.         onLoad:   function() {        }    
  95. };
  96. });
  97. editor.config.flv_path = editor.config.flv_path || (this.path);
  98. editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
  99. editor.ui.addButton('flashplayer', {
  100. label: '插入Flv视频',
  101. command: pluginName,
  102. icon: this.path + 'icon.png'
  103. });
  104. }
  105. });