1 CKEDITOR
.dialog
.add("audio",function(d
){function g(a
,c
){var b
=this.getValue();!b
&&"id"==this.id
&&(b
=m());a
.setAttribute(this.id
,b
);if(b
)switch(this.id
){case "poster":c
.backgroundImage
="url("+b
+")";break;case "width":c
.width
=b
+"px";break;case "height":c
.height
=b
+"px"}}function i(a
,c
,b
){c
=this.id
.match(/(\w+)(\d)/);a
=c
[1];c
=parseInt(c
[2],10);(b
[c
]||(b
[c
]={}))[a
]=this.getValue()}function j(a
){a
?this.setValue(a
.getAttribute(this.id
)):"id"==this.id
&&this.setValue(m())}function h(a
,c
){var b
=this.id
.match(/(\w+)(\d)/),
2 d
=b
[1],b
=parseInt(b
[2],10);(b
=c
[b
])&&this.setValue(b
[d
])}function m(){var a
=new Date
;return"audio"+a
.getFullYear()+a
.getMonth()+a
.getDate()+a
.getHours()+a
.getMinutes()+a
.getSeconds()}var e
=d
.lang
.audio
,l=function(){var a
=this.previewImage
;a
.removeListener("load",l
);a
.removeListener("error",f
);a
.removeListener("abort",f
);this.setValueOf("info","width",a
.$.width
);this.setValueOf("info","height",a
.$.height
)},f=function(){var a
=this.previewImage
;a
.removeListener("load",l
);a
.removeListener("error",f
);
3 a
.removeListener("abort",f
)};return{title:e
.dialogTitle
,minWidth:400,minHeight:200,onShow:function(){this.fakeImage
=this.audioNode
=null;this.previewImage
=d
.document
.createElement("img");var a
=this.getSelectedElement();if(a
&&a
.data("cke-real-element-type")&&"audio"==a
.data("cke-real-element-type")){this.fakeImage
=a
;var a
=d
.restoreRealElement(a
),c
=[],b
=a
.getElementsByTag("source","");0==b
.count()&&(b
=a
.getElementsByTag("source","cke"));for(var e
=0,f
=b
.count();e
<f
;e
++){var g
=b
.getItem(e
);c
.push({src:g
.getAttribute("src"),
4 type:g
.getAttribute("type")})}this.audioNode
=a
;this.setupContent(a
,c
)}else this.setupContent(null,[])},onOk:function(){var a
=null;this.fakeImage
?a
=this.audioNode:(a
=CKEDITOR
.dom
.element
.createFromHtml("<cke:audio></cke:audio>",d
.document
),a
.setAttributes({controls:"controls"}));var c
={},b
=[];this.commitContent(a
,c
,b
);for(var f
="",g
="",i
=e
.linkTemplate
||"",j
=e
.fallbackTemplate
||"",h
=0;h
<b
.length
;h
++){var k
=b
[h
];k
&&k
.src
&&(f
+='<cke:source src="'+k
.src
+'" type="'+k
.type
+'" />',g
+=i
.replace("%src%",k
.src
).replace("%type%",
5 k
.type
))}a
.setHtml(f
+j
.replace("%links%",g
));a
=d
.createFakeElement(a
,"cke_audio","audio",!1);a
.setStyles(c
);this.fakeImage
?(a
.replace(this.fakeImage
),d
.getSelection().selectElement(a
)):(c
=new CKEDITOR
.dom
.element("DIV",d
.document
),d
.insertElement(c
),c
.append(a
))},onHide:function(){this.previewImage
&&(this.previewImage
.removeListener("load",l
),this.previewImage
.removeListener("error",f
),this.previewImage
.removeListener("abort",f
),this.previewImage
.remove(),this.previewImage
=null)},contents:[{id:"info",
6 elements:[{type:"hbox",widths:["","100px"],children:[{type:"text",id:"poster",label:e
.poster
,commit:g
,setup:j
,onChange:function(){var a
=this.getDialog(),c
=this.getValue();if(0<c
.length
){var a
=this.getDialog(),b
=a
.previewImage
;b
.on("load",l
,a
);b
.on("error",f
,a
);b
.on("abort",f
,a
);b
.setAttribute("src",c
)}}},{type:"button",id:"browse",hidden:"true",style:"display:inline-block;margin-top:10px;",filebrowser:{action:"Browse",target:"info:poster",url:d
.config
.filebrowserImageBrowseUrl
||d
.config
.filebrowserBrowseUrl
},
7 label:d
.lang
.common
.browseServer
}]},{type:"hbox",widths:["33%","33%","33%"],children:[{type:"text",id:"width",label:d
.lang
.common
.width
,"default":400,validate:CKEDITOR
.dialog
.validate
.notEmpty(e
.widthRequired
),commit:g
,setup:j
},{type:"text",id:"height",label:d
.lang
.common
.height
,"default":300,validate:CKEDITOR
.dialog
.validate
.notEmpty(e
.heightRequired
),commit:g
,setup:j
},{type:"text",id:"id",label:"Id",commit:g
,setup:j
}]},{type:"hbox",widths:["","100px","75px"],children:[{type:"text",id:"src0",label:e
.sourceaudio
,
8 commit:i
,setup:h
},{type:"button",id:"browse",hidden:"true",style:"display:inline-block;margin-top:10px;",filebrowser:{action:"Browse",target:"info:src0",url:d
.config
.filebrowserAudioBrowseUrl
||d
.config
.filebrowserBrowseUrl
},label:d
.lang
.common
.browseServer
},{id:"type0",label:e
.sourceType
,type:"select","default":"audio/mp3",items:[["MP3","audio/mp3"],["WAV","audio/wav"]],commit:i
,setup:h
}]},{type:"hbox",widths:["","100px","75px"],children:[{type:"text",id:"src1",label:e
.sourceaudio
,commit:i
,setup:h
},
9 {type:"button",id:"browse",hidden:"true",style:"display:inline-block;margin-top:10px;",filebrowser:{action:"Browse",target:"info:src1",url:d
.config
.filebrowserAudioBrowseUrl
||d
.config
.filebrowserBrowseUrl
},label:d
.lang
.common
.browseServer
},{id:"type1",label:e
.sourceType
,type:"select","default":"audio/wav",items:[["MP3","audio/mp3"],["WAV","audio/wav"]],commit:i
,setup:h
}]}]}]}});