Ejemplo n.º 1
0
KISSY.add('kg/editor-plugins/1.1.0/video/dialog',["util","editor","io","../flash/dialog","../menubutton"],function(S ,require, exports, module) {function e(){e.superclass.constructor.apply(this,arguments)}var i=require("util"),t=require("editor"),l=require("io"),r=require("../flash/dialog"),d=require("../menubutton"),a="ke_video",n="video",o="自动",s=0,p='<div style="padding:20px 20px 0 20px"><p><label>链接: <input class="{prefixCls}editor-video-url {prefixCls}editor-input" style="width:410px;"/></label></p><table style="margin:10px 0 5px  40px;width:400px;"><tr><td><label>宽度:  <input  data-verify="^('+o+'|((?!0$)\\d+))?$"  data-warning="宽度请输入正整数" class="{prefixCls}editor-video-width {prefixCls}editor-input" style="width:60px;" /> 像素</label></td><td><label> 高度:  <input  data-verify="^('+o+'|((?!0$)\\d+))?$"  data-warning="高度请输入正整数" class="{prefixCls}editor-video-height {prefixCls}editor-input" style="width:60px;"/> 像素</label></td></tr><tr><td><label>对齐: <select class="{prefixCls}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="{prefixCls}editor-video-margin {prefixCls}editor-input" style="width:60px;" value="'+s+'"/> 像素</label></td></tr></table></div>',u='<div style="padding:10px 0 35px 20px;"><a class="{prefixCls}editor-video-ok {prefixCls}editor-button ks-inline-block" style="margin-left:40px;margin-right:20px;">确定</button> <a class="{prefixCls}editor-video-cancel {prefixCls}editor-button ks-inline-block">取消</a></div>';i.extend(e,r,{_config:function(){var e=this,t=e.editor,l=t.get("prefixCls"),r=e.config;e._cls=a,e._type=n,e._title="视频",e._bodyHTML=i.substitute(p,{prefixCls:l}),e._footHTML=i.substitute(u,{prefixCls:l}),e.urlCfg=r.urlCfg,e._urlTip=r.urlTip||"请输入视频播放链接..."},_initD:function(){var e=this,i=e.dialog,l=e.editor,r=l.get("prefixCls"),a=i.get("el");e.dUrl=a.one("."+r+"editor-video-url"),e.dAlign=d.Select.decorate(a.one("."+r+"editor-video-align"),{prefixCls:r+"editor-big-",width:80,menuCfg:{prefixCls:r+"editor-",render:a}}),e.dMargin=a.one("."+r+"editor-video-margin"),e.dWidth=a.one("."+r+"editor-video-width"),e.dHeight=a.one("."+r+"editor-video-height");var n=a.one("."+r+"editor-video-ok"),s=a.one("."+r+"editor-video-cancel");n.on("click",e._gen,e),s.on("click",function(e){i.hide(),e.halt()}),t.Utils.placeholder(e.dUrl,e._urlTip),t.Utils.placeholder(e.dWidth,o),t.Utils.placeholder(e.dHeight,o),e.addRes(e.dAlign)},_getDInfo:function(){var e=this,i=e.dUrl.val(),t=e.config,l=t.getProvider(i);if(l){var r=l.detect(i);return r?{url:r,attrs:{height:parseInt(e.dHeight.val(),10)||l.height,width:parseInt(e.dWidth.val(),10)||l.width,style:"margin:"+(parseInt(e.dMargin.val(),10)||0)+"px;float:"+e.dAlign.get("value")+";"}}:void window.alert("不支持该链接,请直接输入该视频提供的分享链接")}return void window.alert("不支持该链接来源!")},_gen:function(i){var t=this,r=t.dUrl.val(),d=t.urlCfg;if(d)for(var a=0;a<d.length;a++){var n=d[a];if(n.reg.test(r)){t.dialog.loading();var o={};return o[n.paramName||"url"]=r,void l({url:n.url,data:o,dataType:"jsonp",success:function(e){t._dynamicUrlPrepare(e[1])}})}}e.superclass._gen.call(t,i),i&&i.halt()},_dynamicUrlPrepare:function(i){var t=this;t.dUrl.val(i),t.dialog.unloading(),e.superclass._gen.call(t)},_updateD:function(){var e=this,i=e.editor,l=e.selectedFlash;if(l){var r=i.restoreRealElement(l);t.Utils.valInput(e.dUrl,e._getFlashUrl(r)),e.dAlign.set("value",l.css("float")),e.dMargin.val(parseInt(r.style("margin"),10)||0),t.Utils.valInput(e.dWidth,parseInt(l.css("width"),10)),t.Utils.valInput(e.dHeight,parseInt(l.css("height"),10))}else t.Utils.resetInput(e.dUrl),e.dAlign.set("value","none"),e.dMargin.val(s),t.Utils.resetInput(e.dWidth),t.Utils.resetInput(e.dHeight)}}),module.exports=e;});
Ejemplo n.º 2
0
KISSY.add('editor-plugins/lib/flash/dialog',["util","editor","../flash-common/utils","../dialog","../menubutton"],function(S ,require, exports, module) {function t(t,e){var l=this;l.editor=t,l.config=e||{},i.Utils.lazyRun(l,"_prepareShow","_realShow"),l._config()}var e=require("util"),i=require("editor"),l=require("../flash-common/utils"),a=require("../dialog"),r=require("../menubutton"),s="ke_flash",n="flash",d="请输入如 http://www.xxx.com/xxx.swf",o='<div style="padding:20px 20px 0 20px"><p><label>网址: <input  data-verify="^https?://[^\\s]+$"  data-warning="网址格式为:http://" class="{prefixCls}editor-flash-url {prefixCls}editor-input" style="width:300px;" /></label></p><table style="margin:10px 0 5px  40px;width:300px;"><tr><td><label>宽度: <input  data-verify="^(?!0$)\\d+$"  data-warning="宽度请输入正整数" class="{prefixCls}editor-flash-width {prefixCls}editor-input" style="width:60px;" /> 像素 </label></td><td><label>高度: <input  data-verify="^(?!0$)\\d+$"  data-warning="高度请输入正整数" class="{prefixCls}editor-flash-height {prefixCls}editor-input" style="width:60px;" /> 像素 </label></td></tr><tr><td><label>对齐: </label><select class="{prefixCls}editor-flash-align" title="对齐"><option value="none">无</option><option value="left">左对齐</option><option value="right">右对齐</option></select></td><td><label>间距: </label><input  data-verify="^\\d+$"  data-warning="间距请输入非负整数" class="{prefixCls}editor-flash-margin {prefixCls}editor-input" style="width:60px;" value="5"/> 像素</td></tr></table></div>',h='<div style="padding:10px 0 35px 20px;"><a class="{prefixCls}editor-flash-ok {prefixCls}editor-button ks-inline-block" style="margin-left:40px;margin-right:20px;">确定</a> <a class="{prefixCls}editor-flash-cancel {prefixCls}editor-button ks-inline-block">取消</a></div>';e.augment(t,{addRes:i.Utils.addRes,destroyRes:i.Utils.destroyRes,_config:function(){var t=this,i=t.editor,l=i.get("prefixCls");t._urlTip=d,t._type=n,t._cls=s,t._configDWidth="400px",t._title="Flash",t._bodyHTML=e.substitute(o,{prefixCls:l}),t._footHTML=e.substitute(h,{prefixCls:l})},_prepareShow:function(){var t=this;t.dialog=new a({headerContent:t._title,bodyContent:t._bodyHTML,footerContent:t._footHTML,width:t._configDWidth||"500px",mask:!0}).render(),t.addRes(t.dialog),t._initD()},_realShow:function(){this._updateD(),this.dialog.show()},_getFlashUrl:function(t){return l.getUrl(t)},_updateD:function(){var t=this,e=t.editor,l=t.config,a=t.selectedFlash;if(a){var r=e.restoreRealElement(a);if(!r)return;a.css("width")&&t.dWidth.val(parseInt(a.css("width"),10)),a.css("height")&&t.dHeight.val(parseInt(a.css("height"),10)),t.dAlign.set("value",a.css("float")),i.Utils.valInput(t.dUrl,t._getFlashUrl(r)),t.dMargin.val(parseInt(r.style("margin"),10)||0)}else i.Utils.resetInput(t.dUrl),t.dWidth.val(l.defaultWidth||""),t.dHeight.val(l.defaultHeight||""),t.dAlign.set("value","none"),t.dMargin.val("5")},show:function(t){var e=this;e.selectedFlash=t,e._prepareShow()},_initD:function(){var t=this,e=t.dialog,l=t.editor,a=l.get("prefixCls"),s=e.get("el");t.dHeight=s.one("."+a+"editor-flash-height"),t.dWidth=s.one("."+a+"editor-flash-width"),t.dUrl=s.one("."+a+"editor-flash-url"),t.dAlign=r.Select.decorate(s.one("."+a+"editor-flash-align"),{prefixCls:a+"editor-big-",width:80,menuCfg:{prefixCls:a+"editor-",render:s}}),t.dMargin=s.one("."+a+"editor-flash-margin");var n=s.one("."+a+"editor-flash-ok"),d=s.one("."+a+"editor-flash-cancel");n.on("click",t._gen,t),d.on("click",function(t){e.hide(),t.halt()}),i.Utils.placeholder(t.dUrl,t._urlTip),t.addRes(t.dAlign)},_getDInfo:function(){var t=this;return{url:t.dUrl.val(),attrs:{width:t.dWidth.val(),height:t.dHeight.val(),style:"margin:"+(parseInt(t.dMargin.val(),10)||0)+"px;float:"+t.dAlign.get("value")+";"}}},_gen:function(t){t&&t.halt();var a=this,r=a.editor,s=a._getDInfo(),n=s&&e.trim(s.url),d=s&&s.attrs;if(s){var o=i.Utils.verifyInputs(a.dialog.get("el").all("input"));if(o){a.dialog.hide();var h=l.insertFlash(r,n,d,a._cls,a._type);a.selectedFlash&&r.getSelection().selectElement(h),r.notifySelectionChange()}}},destroy:function(){this.destroyRes()}}),module.exports=t;});