X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=plugins%2Flink%2Fdialogs%2Flink.js;h=8cd71897ad089acd8dbf11f747c9928ecf4a1b5e;hp=a474a6485908951e435d01d732e98ebeeb5bf616;hb=1f91409c05f689832bd6dfbbb5161b6d18c3b50c;hpb=9afde8772159bd3436f1f5b7862960307710ae5a diff --git a/plugins/link/dialogs/link.js b/plugins/link/dialogs/link.js index a474a64..8cd7189 100644 --- a/plugins/link/dialogs/link.js +++ b/plugins/link/dialogs/link.js @@ -1,11 +1,35 @@ -/* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. -For licensing, see LICENSE.html or http://ckeditor.com/license -*/ - -CKEDITOR.dialog.add('link',function(a){var b=CKEDITOR.plugins.link,c=function(){var E=this.getDialog(),F=E.getContentElement('target','popupFeatures'),G=E.getContentElement('target','linkTargetName'),H=this.getValue();if(!F||!G)return;F=F.getElement();F.hide();G.setValue('');switch(H){case 'frame':G.setLabel(a.lang.link.targetFrameName);G.getElement().show();break;case 'popup':F.show();G.setLabel(a.lang.link.targetPopupName);G.getElement().show();break;default:G.setValue(H);G.getElement().hide();break;}},d=function(){var E=this.getDialog(),F=['urlOptions','anchorOptions','emailOptions'],G=this.getValue(),H=E.definition.getContents('upload'),I=H&&H.hidden;if(G=='url'){if(a.config.linkShowTargetTab)E.showPage('target');if(!I)E.showPage('upload');}else{E.hidePage('target');if(!I)E.hidePage('upload');}for(var J=0;J0&&F.push(',');F.push("'",J?x(encodeURIComponent(E[I])):'',"'");}F.push(')');return F.join('');};function B(E){var F,G=E.length,H=[];for(var I=0;I0)this.getElement().show();else this.getElement().hide();},children:[{type:'hbox',id:'selectAnchor',children:[{type:'select',id:'anchorName','default':'',label:D.anchorName,style:'width: 100%;',items:[['']],setup:function(E){var H=this;H.clear();H.add('');for(var F=0;F0)this.getElement().show();else this.getElement().hide();}}]},{type:'html',id:'noAnchors',style:'text-align: center;',html:'
'+CKEDITOR.tools.htmlEncode(D.noAnchors)+'
',focus:true,setup:function(E){if(E.anchors.length<1)this.getElement().show(); -else this.getElement().hide();}}],setup:function(E){if(!this.getDialog().getContentElement('info','linkType'))this.getElement().hide();}},{type:'vbox',id:'emailOptions',padding:1,children:[{type:'text',id:'emailAddress',label:D.emailAddress,required:true,validate:function(){var E=this.getDialog();if(!E.getContentElement('info','linkType')||E.getValueOf('info','linkType')!='email')return true;var F=CKEDITOR.dialog.validate.notEmpty(D.noEmail);return F.apply(this);},setup:function(E){if(E.email)this.setValue(E.email.address);var F=this.getDialog().getContentElement('info','linkType');if(F&&F.getValue()=='email')this.select();},commit:function(E){if(!E.email)E.email={};E.email.address=this.getValue();}},{type:'text',id:'emailSubject',label:D.emailSubject,setup:function(E){if(E.email)this.setValue(E.email.subject);},commit:function(E){if(!E.email)E.email={};E.email.subject=this.getValue();}},{type:'textarea',id:'emailBody',label:D.emailBody,rows:3,'default':'',setup:function(E){if(E.email)this.setValue(E.email.body);},commit:function(E){if(!E.email)E.email={};E.email.body=this.getValue();}}],setup:function(E){if(!this.getDialog().getContentElement('info','linkType'))this.getElement().hide();}}]},{id:'target',label:D.target,title:D.target,elements:[{type:'hbox',widths:['50%','50%'],children:[{type:'select',id:'linkTargetType',label:C.target,'default':'notSet',style:'width : 100%;',items:[[C.notSet,'notSet'],[D.targetFrame,'frame'],[D.targetPopup,'popup'],[C.targetNew,'_blank'],[C.targetTop,'_top'],[C.targetSelf,'_self'],[C.targetParent,'_parent']],onChange:c,setup:function(E){if(E.target)this.setValue(E.target.type);c.call(this);},commit:function(E){if(!E.target)E.target={};E.target.type=this.getValue();}},{type:'text',id:'linkTargetName',label:D.targetFrameName,'default':'',setup:function(E){if(E.target)this.setValue(E.target.name);},commit:function(E){if(!E.target)E.target={};E.target.name=this.getValue().replace(/\W/gi,'');}}]},{type:'vbox',width:'100%',align:'center',padding:2,id:'popupFeatures',children:[{type:'fieldset',label:D.popupFeatures,children:[{type:'hbox',children:[{type:'checkbox',id:'resizable',label:D.popupResizable,setup:r,commit:u},{type:'checkbox',id:'status',label:D.popupStatusBar,setup:r,commit:u}]},{type:'hbox',children:[{type:'checkbox',id:'location',label:D.popupLocationBar,setup:r,commit:u},{type:'checkbox',id:'toolbar',label:D.popupToolbar,setup:r,commit:u}]},{type:'hbox',children:[{type:'checkbox',id:'menubar',label:D.popupMenuBar,setup:r,commit:u},{type:'checkbox',id:'fullscreen',label:D.popupFullScreen,setup:r,commit:u}]},{type:'hbox',children:[{type:'checkbox',id:'scrollbars',label:D.popupScrollBars,setup:r,commit:u},{type:'checkbox',id:'dependent',label:D.popupDependent,setup:r,commit:u}]},{type:'hbox',children:[{type:'text',widths:['50%','50%'],labelLayout:'horizontal',label:C.width,id:'width',setup:r,commit:u},{type:'text',labelLayout:'horizontal',widths:['50%','50%'],label:D.popupLeft,id:'left',setup:r,commit:u}]},{type:'hbox',children:[{type:'text',labelLayout:'horizontal',widths:['50%','50%'],label:C.height,id:'height',setup:r,commit:u},{type:'text',labelLayout:'horizontal',label:D.popupTop,widths:['50%','50%'],id:'top',setup:r,commit:u}]}]}]}]},{id:'upload',label:D.upload,title:D.upload,hidden:true,filebrowser:'uploadButton',elements:[{type:'file',id:'upload',label:C.upload,style:'height:40px',size:29},{type:'fileButton',id:'uploadButton',label:C.uploadSubmit,filebrowser:'info:url','for':['upload','upload']}]},{id:'advanced',label:D.advanced,title:D.advanced,elements:[{type:'vbox',padding:1,children:[{type:'hbox',widths:['45%','35%','20%'],children:[{type:'text',id:'advId',label:D.id,setup:s,commit:v},{type:'select',id:'advLangDir',label:D.langDir,'default':'',style:'width:110px',items:[[C.notSet,''],[D.langDirLTR,'ltr'],[D.langDirRTL,'rtl']],setup:s,commit:v},{type:'text',id:'advAccessKey',width:'80px',label:D.acccessKey,maxLength:1,setup:s,commit:v}]},{type:'hbox',widths:['45%','35%','20%'],children:[{type:'text',label:D.name,id:'advName',setup:s,commit:v},{type:'text',label:D.langCode,id:'advLangCode',width:'110px','default':'',setup:s,commit:v},{type:'text',label:D.tabIndex,id:'advTabIndex',width:'80px',maxLength:5,setup:s,commit:v}]}]},{type:'vbox',padding:1,children:[{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:D.advisoryTitle,'default':'',id:'advTitle',setup:s,commit:v},{type:'text',label:D.advisoryContentType,'default':'',id:'advContentType',setup:s,commit:v}]},{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:D.cssClasses,'default':'',id:'advCSSClasses',setup:s,commit:v},{type:'text',label:D.charset,'default':'',id:'advCharset',setup:s,commit:v}]},{type:'hbox',children:[{type:'text',label:D.styles,'default':'',id:'advStyles',setup:s,commit:v}]}]}]}],onShow:function(){var H=this; -H.fakeObj=false;var E=H.getParentEditor(),F=E.getSelection(),G=null;if((G=b.getSelectedLink(E))&&G.hasAttribute('href'))F.selectElement(G);else if((G=F.getSelectedElement())&&G.is('img')&&G.data('cke-real-element-type')&&G.data('cke-real-element-type')=='anchor'){H.fakeObj=G;G=E.restoreRealElement(H.fakeObj);F.selectElement(H.fakeObj);}else G=null;H.setupContent(p.apply(H,[E,G]));},onOk:function(){var E={href:'javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/'},F=[],G={href:E.href},H=this,I=this.getParentEditor();this.commitContent(G);switch(G.type||'url'){case 'url':var J=G.url&&G.url.protocol!=undefined?G.url.protocol:'http://',K=G.url&&G.url.url||'';E['data-cke-saved-href']=K.indexOf('/')===0?K:J+K;break;case 'anchor':var L=G.anchor&&G.anchor.name,M=G.anchor&&G.anchor.id;E['data-cke-saved-href']='#'+(L||M||'');break;case 'email':var N,O=G.email,P=O.address;switch(y){case '':case 'encode':var Q=encodeURIComponent(O.subject||''),R=encodeURIComponent(O.body||''),S=[];Q&&S.push('subject='+Q);R&&S.push('body='+R);S=S.length?'?'+S.join('&'):'';if(y=='encode'){N=["javascript:void(location.href='mailto:'+",B(P)];S&&N.push("+'",x(S),"'");N.push(')');}else N=['mailto:',P,S];break;default:var T=P.split('@',2);O.name=T[0];O.domain=T[1];N=['javascript:',A(O)];}E['data-cke-saved-href']=N.join('');break;}if(G.target)if(G.target.type=='popup'){var U=["window.open(this.href, '",G.target.name||'',"', '"],V=['resizable','status','location','toolbar','menubar','fullscreen','scrollbars','dependent'],W=V.length,X=function(aj){if(G.target[aj])V.push(aj+'='+G.target[aj]);};for(var Y=0;Y',I.document);aa=I.getSelection();af.moveChildren(ai);af.copyAttributes(ai,{name:1});ai.replace(af);af=ai;aa.selectElement(af);}af.setAttributes(E);af.removeAttributes(F);if(ag==ah||G.type=='email'&&ah.indexOf('@')!=-1)af.setHtml(G.type=='email'?G.email.address:E['data-cke-saved-href']);if(af.getAttribute('name'))af.addClass('cke_anchor');else af.removeClass('cke_anchor');if(this.fakeObj)I.createFakeElement(af,'cke_anchor','anchor').replace(this.fakeObj);delete this._.selectedElement;}},onLoad:function(){if(!a.config.linkShowAdvancedTab)this.hidePage('advanced');if(!a.config.linkShowTargetTab)this.hidePage('target');},onFocus:function(){var E=this.getContentElement('info','linkType'),F;if(E&&E.getValue()=='url'){F=this.getContentElement('info','url');F.select();}}};}); +/* + Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved. + For licensing, see LICENSE.md or http://ckeditor.com/license +*/ +CKEDITOR.dialog.add("link",function(m){var o,p;function q(a){return a.replace(/'/g,"\\$&")}function s(a){var g,c=o,d,e;g=[p,"("];for(var b=0;b0?this.getElement().show():this.getElement().hide()},children:[{type:"hbox",id:"selectAnchor",children:[{type:"select",id:"anchorName","default":"",label:b.anchorName,style:"width: 100%;",items:[[""]],setup:function(a){this.clear();this.add("");for(var b=0;b0?this.getElement().show(): +this.getElement().hide()}}]},{type:"html",id:"noAnchors",style:"text-align: center;",html:'
'+CKEDITOR.tools.htmlEncode(b.noAnchors)+"
",focus:!0,setup:function(a){a.anchors.length<1?this.getElement().show():this.getElement().hide()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}},{type:"vbox",id:"emailOptions",padding:1,children:[{type:"text",id:"emailAddress",label:b.emailAddress,required:!0,validate:function(){var a= +this.getDialog();return!a.getContentElement("info","linkType")||a.getValueOf("info","linkType")!="email"?true:CKEDITOR.dialog.validate.notEmpty(b.noEmail).apply(this)},setup:function(a){a.email&&this.setValue(a.email.address);(a=this.getDialog().getContentElement("info","linkType"))&&a.getValue()=="email"&&this.select()},commit:function(a){if(!a.email)a.email={};a.email.address=this.getValue()}},{type:"text",id:"emailSubject",label:b.emailSubject,setup:function(a){a.email&&this.setValue(a.email.subject)}, +commit:function(a){if(!a.email)a.email={};a.email.subject=this.getValue()}},{type:"textarea",id:"emailBody",label:b.emailBody,rows:3,"default":"",setup:function(a){a.email&&this.setValue(a.email.body)},commit:function(a){if(!a.email)a.email={};a.email.body=this.getValue()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}}]},{id:"target",requiredContent:"a[target]",label:b.target,title:b.target,elements:[{type:"hbox",widths:["50%","50%"],children:[{type:"select", +id:"linkTargetType",label:h.target,"default":"notSet",style:"width : 100%;",items:[[h.notSet,"notSet"],[b.targetFrame,"frame"],[b.targetPopup,"popup"],[h.targetNew,"_blank"],[h.targetTop,"_top"],[h.targetSelf,"_self"],[h.targetParent,"_parent"]],onChange:r,setup:function(a){a.target&&this.setValue(a.target.type||"notSet");r.call(this)},commit:function(a){if(!a.target)a.target={};a.target.type=this.getValue()}},{type:"text",id:"linkTargetName",label:b.targetFrameName,"default":"",setup:function(a){a.target&& +this.setValue(a.target.name)},commit:function(a){if(!a.target)a.target={};a.target.name=this.getValue().replace(/\W/gi,"")}}]},{type:"vbox",width:"100%",align:"center",padding:2,id:"popupFeatures",children:[{type:"fieldset",label:b.popupFeatures,children:[{type:"hbox",children:[{type:"checkbox",id:"resizable",label:b.popupResizable,setup:i,commit:k},{type:"checkbox",id:"status",label:b.popupStatusBar,setup:i,commit:k}]},{type:"hbox",children:[{type:"checkbox",id:"location",label:b.popupLocationBar, +setup:i,commit:k},{type:"checkbox",id:"toolbar",label:b.popupToolbar,setup:i,commit:k}]},{type:"hbox",children:[{type:"checkbox",id:"menubar",label:b.popupMenuBar,setup:i,commit:k},{type:"checkbox",id:"fullscreen",label:b.popupFullScreen,setup:i,commit:k}]},{type:"hbox",children:[{type:"checkbox",id:"scrollbars",label:b.popupScrollBars,setup:i,commit:k},{type:"checkbox",id:"dependent",label:b.popupDependent,setup:i,commit:k}]},{type:"hbox",children:[{type:"text",widths:["50%","50%"],labelLayout:"horizontal", +label:h.width,id:"width",setup:i,commit:k},{type:"text",labelLayout:"horizontal",widths:["50%","50%"],label:b.popupLeft,id:"left",setup:i,commit:k}]},{type:"hbox",children:[{type:"text",labelLayout:"horizontal",widths:["50%","50%"],label:h.height,id:"height",setup:i,commit:k},{type:"text",labelLayout:"horizontal",label:b.popupTop,widths:["50%","50%"],id:"top",setup:i,commit:k}]}]}]}]},{id:"upload",label:b.upload,title:b.upload,hidden:!0,filebrowser:"uploadButton",elements:[{type:"file",id:"upload", +label:h.upload,style:"height:40px",size:29},{type:"fileButton",id:"uploadButton",label:h.uploadSubmit,filebrowser:"info:url","for":["upload","upload"]}]},{id:"advanced",label:b.advanced,title:b.advanced,elements:[{type:"vbox",padding:1,children:[{type:"hbox",widths:["45%","35%","20%"],children:[{type:"text",id:"advId",requiredContent:"a[id]",label:b.id,setup:j,commit:l},{type:"select",id:"advLangDir",requiredContent:"a[dir]",label:b.langDir,"default":"",style:"width:110px",items:[[h.notSet,""],[b.langDirLTR, +"ltr"],[b.langDirRTL,"rtl"]],setup:j,commit:l},{type:"text",id:"advAccessKey",requiredContent:"a[accesskey]",width:"80px",label:b.acccessKey,maxLength:1,setup:j,commit:l}]},{type:"hbox",widths:["45%","35%","20%"],children:[{type:"text",label:b.name,id:"advName",requiredContent:"a[name]",setup:j,commit:l},{type:"text",label:b.langCode,id:"advLangCode",requiredContent:"a[lang]",width:"110px","default":"",setup:j,commit:l},{type:"text",label:b.tabIndex,id:"advTabIndex",requiredContent:"a[tabindex]", +width:"80px",maxLength:5,setup:j,commit:l}]}]},{type:"vbox",padding:1,children:[{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:b.advisoryTitle,requiredContent:"a[title]","default":"",id:"advTitle",setup:j,commit:l},{type:"text",label:b.advisoryContentType,requiredContent:"a[type]","default":"",id:"advContentType",setup:j,commit:l}]},{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:b.cssClasses,requiredContent:"a(cke-xyz)","default":"",id:"advCSSClasses",setup:j,commit:l}, +{type:"text",label:b.charset,requiredContent:"a[charset]","default":"",id:"advCharset",setup:j,commit:l}]},{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:b.rel,requiredContent:"a[rel]","default":"",id:"advRel",setup:j,commit:l},{type:"text",label:b.styles,requiredContent:"a{cke-xyz}","default":"",id:"advStyles",validate:CKEDITOR.dialog.validate.inlineStyle(m.lang.common.invalidInlineStyle),setup:j,commit:l}]}]}]}],onShow:function(){var a=this.getParentEditor(),b=a.getSelection(),c= +null;(c=v.getSelectedLink(a))&&c.hasAttribute("href")?b.getSelectedElement()||b.selectElement(c):c=null;this.setupContent(H.apply(this,[a,c]))},onOk:function(){var a={},b=[],c={},d=this.getParentEditor();this.commitContent(c);switch(c.type||"url"){case "url":var e=c.url&&c.url.protocol!=void 0?c.url.protocol:"http://",h=c.url&&CKEDITOR.tools.trim(c.url.url)||"";a["data-cke-saved-href"]=h.indexOf("/")===0?h:e+h;break;case "anchor":e=c.anchor&&c.anchor.id;a["data-cke-saved-href"]="#"+(c.anchor&&c.anchor.name|| +e||"");break;case "email":var f=c.email,e=f.address;switch(n){case "":case "encode":var h=encodeURIComponent(f.subject||""),i=encodeURIComponent(f.body||""),f=[];h&&f.push("subject="+h);i&&f.push("body="+i);f=f.length?"?"+f.join("&"):"";if(n=="encode"){e=["javascript:void(location.href='mailto:'+",t(e)];f&&e.push("+'",q(f),"'");e.push(")")}else e=["mailto:",e,f];break;default:e=e.split("@",2);f.name=e[0];f.domain=e[1];e=["javascript:",s(f)]}a["data-cke-saved-href"]=e.join("")}if(c.target)if(c.target.type== +"popup"){for(var e=["window.open(this.href, '",c.target.name||"","', '"],j=["resizable","status","location","toolbar","menubar","fullscreen","scrollbars","dependent"],h=j.length,f=function(a){c.target[a]&&j.push(a+"="+c.target[a])},i=0;i