/*
Copyright 2013, KISSY UI Library v1.31
MIT Licensed
build time: Jul 29 13:11
*/
KISSY.add("editor/plugin/link/dialog",function(e,d,i,g){function h(a,b){this.editor=a;this.config=b||{};d.Utils.lazyRun(this,"_prepareShow","_real")}var j=i.Dialog,k=g._ke_saved_href;e.augment(h,{_prepareShow:function(){var a=this.editor.get("prefixCls"),b=(new j({width:500,headerContent:"\u94fe\u63a5",bodyContent:e.substitute("<div style='padding:20px 20px 0 20px'><p><label>\u94fe\u63a5\u7f51\u5740\uff1a <input  data-verify='^(https?://[^\\s]+)|(#.+)$'  data-warning='\u8bf7\u8f93\u5165\u5408\u9002\u7684\u7f51\u5740\u683c\u5f0f' class='{prefixCls}editor-link-url {prefixCls}editor-input' style='width:390px;' /></label></p><p style='margin: 15px 0 10px 0px;'><label>\u94fe\u63a5\u540d\u79f0\uff1a <input class='{prefixCls}editor-link-title {prefixCls}editor-input' style='width:100px;'></label> <label><input class='{prefixCls}editor-link-blank' style='vertical-align: middle; margin-left: 21px;' type='checkbox'/> &nbsp; \u5728\u65b0\u7a97\u53e3\u6253\u5f00\u94fe\u63a5</label></p></div>",
{prefixCls:a}),footerContent:e.substitute("<div style='padding:5px 20px 20px;'><a href='javascript:void('\u786e\u5b9a')' class='{prefixCls}editor-link-ok {prefixCls}editor-button ks-inline-block' style='margin-left:65px;margin-right:20px;'>\u786e\u5b9a</a> <a href='javascript:void('\u53d6\u6d88')' class='{prefixCls}editor-link-cancel {prefixCls}editor-button ks-inline-block'>\u53d6\u6d88</a></div>",{prefixCls:a}),mask:!0})).render();this.dialog=b;var c=b.get("body"),f=b.get("footer");b.urlEl=c.one("."+a+"editor-link-url");b.urlTitle=c.one("."+
a+"editor-link-title");b.targetEl=c.one("."+a+"editor-link-blank");c=f.one("."+a+"editor-link-cancel");f.one("."+a+"editor-link-ok").on("click",this._link,this);c.on("click",function(a){a&&a.halt();b.hide()});d.Utils.placeholder(b.urlEl,"http://")},_link:function(a){a.halt();var b=this,a=b.dialog,c=a.urlEl.val();if(d.Utils.verifyInputs(a.get("el").all("input"))){a.hide();var f={href:c,target:a.targetEl[0].checked?"_blank":"_self",title:e.trim(a.urlTitle.val())};setTimeout(function(){g.applyLink(b.editor,
f,b._selectedEl)},0)}},_real:function(){var a=this.config,b=this.dialog,c=this._selectedEl;c?(a=c.attr(k)||c.attr("href"),d.Utils.valInput(b.urlEl,a),b.urlTitle.val(c.attr("title")||""),b.targetEl[0].checked="_blank"==c.attr("target")):(d.Utils.resetInput(b.urlEl),b.urlTitle.val(""),a.target&&(b.targetEl[0].checked=!0));b.show()},show:function(a){this._selectedEl=a;this._prepareShow()}});return h},{requires:["editor","../overlay/","./utils"]});
