/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:28
*/
KISSY.add("editor/plugin/video/dialog",function(h,c,i,j){function d(){d.superclass.constructor.apply(this,arguments)}h.extend(d,i,{_config:function(){var b=this.config;this._cls="ke_video";this._type="video";this._title="视频";this._bodyHtml="<div style='padding:20px 20px 0 20px'><p><label>链接： <input class='ks-editor-video-url ks-editor-input' style='width:410px;vertical-align:middle;'/></label></p><table style='margin:10px 0 5px  40px;width:400px;'><tr><td><label>宽度：  <input  data-verify='^(自动|((?!0$)\\d+))?$'  data-warning='宽度请输入正整数' class='ks-editor-video-width ks-editor-input' style='width:60px;margin-left:2px;vertical-align:middle;' /> 像素</label></td><td><label> 高度：  <input  data-verify='^(自动|((?!0$)\\d+))?$'  data-warning='高度请输入正整数' class='ks-editor-video-height ks-editor-input' style='width:60px;vertical-align:middle;'/> 像素</label></td></tr><tr><td><label>对齐： <select class='ks-editor-video-align' title='对齐'><option value='none'>无</option><option value='left'>左对齐</option><option value='right'>右对齐</option></select></td><td><label>间距： <input  data-verify='^\\d+$'  data-warning='间距请输入非负整数' class='ks-editor-video-margin ks-editor-input' style='width:60px;vertical-align:middle;' value='0'/> 像素</label></td></tr></table></div>";
this._footHtml="<div style='padding:5px 20px 20px;'><a class='ks-editor-video-ok ks-editor-button ks-inline-block' style='margin-left:40px;margin-right:20px;'>确定</button> <a class='ks-editor-video-cancel ks-editor-button ks-inline-block'>取消</a></div>";this.urlCfg=b.video&&b.video.urlCfg;this._urlTip=b.video&&b.video.urlTip||"请输入视频播放链接..."},_initD:function(){var b=this.dialog,a=b.get("el");this.dUrl=a.one(".ks-editor-video-url");this.dAlign=j.Select.decorate(a.one(".ks-editor-video-align"),{prefixCls:"ks-editor-big-",
elAttrs:{hideFocus:"hideFocus"},width:80,menuCfg:{prefixCls:"ks-editor-",render:a}});this.dMargin=a.one(".ks-editor-video-margin");this.dWidth=a.one(".ks-editor-video-width");this.dHeight=a.one(".ks-editor-video-height");var d=a.one(".ks-editor-video-ok"),a=a.one(".ks-editor-video-cancel");d.on("click",this._gen,this);a.on("click",function(a){b.hide();a.halt()});c.Utils.placeholder(this.dUrl,this._urlTip);c.Utils.placeholder(this.dWidth,"自动");c.Utils.placeholder(this.dHeight,"自动");this.addRes(this.dAlign)},
_getDInfo:function(){var b=this.dUrl.val(),a=this.config.getProvider(b);if(a){b=a.detect(b);if(!b){alert("不支持该链接，请直接输入该视频提供的分享链接");return}return{url:b,attrs:{height:parseInt(this.dHeight.val())||a.height,width:parseInt(this.dWidth.val())||a.width,style:"margin:"+(parseInt(this.dMargin.val())||0)+"px;float:"+this.dAlign.get("value")+";"}}}alert("不支持该链接来源!")},_gen:function(b){var a=this,c=a.dUrl.val(),e=a.urlCfg;if(e)for(var f=0;f<e.length;f++){var g=e[f];if(g.reg.test(c)){a.dialog.loading();b={};b[g.paramName||
"url"]=c;h.io({url:g.url,data:b,dataType:"jsonp",success:function(b){a._dynamicUrlPrepare(b[1])}});return}}d.superclass._gen.call(a);b&&b.halt()},_dynamicUrlPrepare:function(b){this.dUrl.val(b);this.dialog.unloading();d.superclass._gen.call(this)},_updateD:function(){var b=this.editor,a=this.selectedFlash;a?(b=b.restoreRealElement(a),c.Utils.valInput(this.dUrl,this._getFlashUrl(b)),this.dAlign.set("value",a.css("float")),this.dMargin.val(parseInt(b.style("margin"))||0),c.Utils.valInput(this.dWidth,
parseInt(a.css("width"))),c.Utils.valInput(this.dHeight,parseInt(a.css("height")))):(c.Utils.resetInput(this.dUrl),this.dAlign.set("value","none"),this.dMargin.val(0),c.Utils.resetInput(this.dWidth),c.Utils.resetInput(this.dHeight))}});return d},{requires:["editor","../flash/dialog","../menubutton/"]});
