/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

(function(){(function(){var a={id:{name:'id'},src:{name:'src'},width:{name:'width'},height:{name:'height'},autostart:{name:'autostart'}};function b(e){var i=this;var f=a[i.id];if(!f)return;var g=i instanceof CKEDITOR.ui.dialog.checkbox,h=f;if(e.getAttribute(h.name)){value=e.getAttribute(h.name);if(i.id=='src')if(value.indexOf('player_flv_maxi.swf')>0)value=e.getAttribute('FlashVars').replace('file=','').replace('&showplayer=always&showiconplay=true&usefullscreen=true','').replace('&autostart=true','');if(g)i.setValue(value.toLowerCase()=='true');else i.setValue(value);return;}else if(g)i.setValue(!!h['default']);};function c(e){var l=this;var f=a[l.id];if(!f)return;var g=l.getValue()==='',h=l instanceof CKEDITOR.ui.dialog.checkbox,i=f;value=l.getValue();if(l.id=='src'){var j=d(value);if(j=='flv'||j=='fla'||j=='f4v')if(j=='flv'||j=='f4v'){if(g||h&&value===i['default'])e.removeAttribute(i.name);else{var k=CKEDITOR.plugins.get('media').path+'swf/player_flv_maxi.swf';e.setAttribute(i.name,k);e.setAttribute('allowFullScreen','true');e.setAttribute('FlashVars','file='+value+'&showplayer=always&showiconplay=true&usefullscreen=true');return;}}else if(value.indexOf('youtube.com/')>0)value=value.replace(/youtube\.com\/watch\?v=/i,'youtube.com/v/');}if(g||h&&value===i['default'])e.removeAttribute(i.name);else e.setAttribute(i.name,value);if(l.id=='autostart'){if(l.getValue()){e.setAttribute('FlashVars',e.getAttribute('FlashVars')+'&autostart=true')}}};function d(e){var f=e.match(/\.(avi|asf|fla|flv|mov|mp3|mp4|mpg|mpeg|qt|swf|wma|wmv|f4v)$/i);if(f!=null&&f.length&&f.length>0)f=f[1];else if(e.indexOf('youtube.com/')>0)f='swf';else f='';return f;};CKEDITOR.dialog.add('media',function(e){var f,g='<div>'+CKEDITOR.tools.htmlEncode(e.lang.common.preview)+'<br>'+'<div id="cke_FlashPreviewLoader'+CKEDITOR.tools.getNextNumber()+'" style="display:none"><div class="loading">&nbsp;</div></div>'+'<div id="cke_FlashPreviewBox'+CKEDITOR.tools.getNextNumber()+'" class="FlashPreviewBox"></div></div>';return{title:'媒体属性',minWidth:420,minHeight:310,onShow:function(){var l=this;l.fakeImage=l.objectNode=l.embedNode=null;f=new CKEDITOR.dom.element('embed',e.document);var h=l.getSelectedElement();if(h&&h.data('cke-real-element-type')&&h.data('cke-real-element-type')=='media'){l.fakeImage=h;var i=e.restoreRealElement(h),j=null,k=null;if(i.getName()=='cke:embed')k=i;l.objectNode=j;l.embedNode=k;l.setupContent(k,h);}},onOk:function(){var k=this;var h=null;if(!k.fakeImage)h=CKEDITOR.dom.element.createFromHtml('<cke:embed></cke:embed>',e.document);else h=k.embedNode;var i={};k.commitContent(h,i);var j=e.createFakeElement(h,'cke_media','media',true);
j.setStyles(i);if(k.fakeImage){j.replace(k.fakeImage);e.getSelection().selectElement(j);}else e.insertElement(j);},onHide:function(){if(this.preview)this.preview.setHtml('');},contents:[{id:'info',label:e.lang.common.generalTab,accessKey:'I',elements:[{type:'vbox',padding:0,children:[{type:'hbox',widths:['280px','110px'],align:'right',children:[{id:'src',type:'text',label:e.lang.common.url,required:true,validate:CKEDITOR.dialog.validate.notEmpty('源文件地址不能为空'),setup:b,commit:c,onLoad:function(){var h=this.getDialog(),i=function(j){var k=j,l=d(j);if(l=='flv'||l=='fla'||l=='f4v')if(l=='flv'||l=='f4v')k=CKEDITOR.plugins.get('media').path+'swf/player_flv_maxi.swf';else if(k.indexOf('youtube.com/')>0)j=j.replace(/youtube\.com\/watch\?v=/i,'youtube.com/v/');var m='<embed height="100%" width="100%" src="'+CKEDITOR.tools.htmlEncode(k);if(k.indexOf('player_flv_maxi.swf')>0)m+='" flashVars="file='+j+'&showplayer=always&showiconplay=true&usefullscreen=true';m+='" autostart="true"></embed>';h.preview.setHtml(m);};h.preview=h.getContentElement('info','preview').getElement().getChild(3);this.on('change',function(j){if(j.data&&j.data.value)i(j.data.value);});this.getInputElement().on('change',function(j){i(this.getValue());},this);}}]}]},{type:'hbox',widths:['25%','25%','25%','25%','25%'],children:[{type:'text',id:'width',style:'width:95px',label:e.lang.common.width,validate:CKEDITOR.dialog.validate.integer(e.lang.flash.validateWidth),setup:function(h,i){b.apply(this,arguments);if(i){var j=parseInt(i.$.style.width,10);if(!isNaN(j))this.setValue(j);}},commit:function(h,i){c.apply(this,arguments);if(this.getValue())i.width=this.getValue()+'px';}},{type:'text',id:'height',style:'width:95px',label:e.lang.common.height,validate:CKEDITOR.dialog.validate.integer(e.lang.flash.validateHeight),setup:function(h,i){b.apply(this,arguments);if(i){var j=parseInt(i.$.style.height,10);if(!isNaN(j))this.setValue(j);}},commit:function(h,i){c.apply(this,arguments);if(this.getValue())i.height=this.getValue()+'px';}},{type:'vbox',padding:0,children:[{type:'html',html:'选项'},{type:'checkbox',id:'autostart',label:'自动播放','default':true,setup:b,commit:c}]}]},{type:'vbox',children:[{type:'html',id:'preview',style:'width:95%;',html:g}]}]},{id:'Upload',hidden:true,filebrowser:'uploadButton',label:e.lang.common.upload,enabledUpload:e.config.flashUpload,elements:[{type:'file',id:'upload',label:e.lang.common.upload,size:38},{type:'fileButton',id:'uploadButton',filebrowser:{action:'QuickUpload',target:'info:src',params:{type:'flash',modelId:e.config.modelId,nodeId:e.config.nodeId,moduleName:e.config.moduleName,fieldName:e.config.fieldName,wordPic:e.config.wordPic,foreground:e.config.foreground,watermark:e.config.watermark,thumbnail:e.config.thumbnail,fileRecord:e.config.fileRecord,departmentUploader:e.config.departmentUploader}},label:e.lang.common.uploadSubmit,'for':['Upload','upload']}]},{id:'fileUpload',hidden:!e.config.imageUpload,label:'上传',expand:true,elements:[{type:'iframe',src:CKEDITOR.basePath+'FileUpload.aspx?type=media&CKEditor='+encodeURIComponent(e.name)+'&CKEditorFuncNum='+encodeURIComponent(e._.filebrowserFn)+'&modelId='+encodeURIComponent(e.config.modelId)+'&nodeId='+encodeURIComponent(e.config.nodeId)+'&moduleName='+encodeURIComponent(e.config.moduleName)+'&fieldName='+encodeURIComponent(e.config.fieldName)+'&wordPic='+encodeURIComponent(e.config.wordPic)+'&foreground='+encodeURIComponent(e.config.foreground)+'&watermark='+encodeURIComponent(e.config.watermark)+'&thumbnail='+encodeURIComponent(e.config.thumbnail)+'&fileRecord='+encodeURIComponent(e.config.fileRecord)+'&departmentUploader='+encodeURIComponent(e.config.departmentUploader),width:'100%',height:'100%',onContentLoad:function(){var h=this.getDialog(),i=h.getParentEditor();
i._.filebrowserSe=h.getContentElement('Upload','upload');}}]},{id:'browseUploaded',label:'从已上传中选择',hidden:!e.config.flashUpload,elements:[{type:'iframe',src:CKEDITOR.basePath.replace('/Editor/','/')+(e.config.foreground?'user/Accessories/ShowUploadFiles.aspx':e.config.manageDir+'/Accessories/ShowUploadFiles.aspx')+'?type=flash&CKEditor='+encodeURIComponent(e.name)+'&CKEditorFuncNum='+encodeURIComponent(e._.filebrowserFn),width:'100%',height:'340px',onContentLoad:function(){var h=this.getDialog(),i=h.getParentEditor();i._.filebrowserSe=h.getContentElement('Upload','upload');}}]}]};});})();})();
