1 /** 2 * Add flash plugin. 3 * @author yiminghe@gmail.com 4 */ 5 KISSY.add("editor/plugin/flash/index", function (S, Editor, FlashBaseClass, flashUtils) { 6 7 var CLS_FLASH = 'ke_flash', 8 TYPE_FLASH = 'flash'; 9 10 function FlashPlugin(config) { 11 this.config = config || {}; 12 } 13 14 S.augment(FlashPlugin, { 15 renderUI:function (editor) { 16 var dataProcessor = editor.htmlDataProcessor, 17 dataFilter = dataProcessor.dataFilter; 18 19 dataFilter.addRules({ 20 tags:{ 21 'object':function (element) { 22 var classId = element.getAttribute("classid"), i; 23 if (!classId) { 24 var childNodes = element.childNodes; 25 // Look for the inner <embed> 26 for (i = 0; i < childNodes.length; i++) { 27 if (childNodes[i].nodeName == 'embed') { 28 if (!flashUtils.isFlashEmbed(childNodes[i][ i ])) { 29 return dataProcessor 30 .createFakeParserElement(element, 31 CLS_FLASH, TYPE_FLASH, true); 32 } else { 33 return null; 34 } 35 } 36 } 37 return null; 38 } 39 return dataProcessor.createFakeParserElement(element, 40 CLS_FLASH, TYPE_FLASH, true); 41 }, 42 'embed':function (element) { 43 if (flashUtils.isFlashEmbed(element)) { 44 return dataProcessor 45 .createFakeParserElement(element, CLS_FLASH, TYPE_FLASH, true); 46 } else { 47 return null; 48 } 49 } 50 }}, 51 5); 52 53 54 var flashControl = new FlashBaseClass({ 55 editor:editor, 56 cls:CLS_FLASH, 57 type:TYPE_FLASH, 58 pluginConfig:this.config, 59 bubbleId:"flash", 60 contextMenuId:'flash', 61 contextMenuHandlers:{ 62 Flash属性:function () { 63 var selectedEl = this.get("editorSelectedEl"); 64 if (selectedEl) { 65 flashControl.show(selectedEl); 66 } 67 } 68 } 69 }); 70 71 this.flashControl = flashControl; 72 73 editor.addButton("flash", { 74 tooltip:"插入Flash", 75 listeners:{ 76 click:function () { 77 flashControl.show(); 78 } 79 }, 80 mode:Editor.WYSIWYG_MODE 81 }); 82 } 83 // , 84 // 85 // destructor:function () { 86 // this.flashControl.destroy(); 87 // } 88 }); 89 90 return FlashPlugin; 91 92 }, { 93 requires:['editor', '../flashCommon/baseClass', '../flashCommon/utils'] 94 });