X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=plugins%2Flink%2Fdialogs%2Flink.js;h=a474a6485908951e435d01d732e98ebeeb5bf616;hb=9afde8772159bd3436f1f5b7862960307710ae5a;hp=c567e2ab1d383a4299d6f9d96fae460e98bf6cb2;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/plugins/link/dialogs/link.js b/plugins/link/dialogs/link.js index c567e2a..a474a64 100644 --- a/plugins/link/dialogs/link.js +++ b/plugins/link/dialogs/link.js @@ -3,9 +3,9 @@ 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=function(){var B=this.getDialog(),C=B.getContentElement('target','popupFeatures'),D=B.getContentElement('target','linkTargetName'),E=this.getValue();if(!C||!D)return;C=C.getElement();C.hide();D.setValue('');switch(E){case 'frame':D.setLabel(a.lang.link.targetFrameName);D.getElement().show();break;case 'popup':C.show();D.setLabel(a.lang.link.targetPopupName);D.getElement().show();break;default:D.setValue(E);D.getElement().hide();break;}},c=function(){var B=this.getDialog(),C=['urlOptions','anchorOptions','emailOptions'],D=this.getValue(),E=B.definition.getContents('upload'),F=E&&E.hidden;if(D=='url'){if(a.config.linkShowTargetTab)B.showPage('target');if(!F)B.showPage('upload');}else{B.hidePage('target');if(!F)B.hidePage('upload');}for(var G=0;G0&&C.push(',');C.push("'",G?w(encodeURIComponent(B[F])):'',"'");}C.push(')');return C.join('');};function A(B){var C,D=B.length,E=[];for(var F=0;F','']],setup:function(B){if(B.url)this.setValue(B.url.protocol||''); -},commit:function(B){if(!B.url)B.url={};B.url.protocol=this.getValue();}},{type:'text',id:'url',label:a.lang.common.url,required:true,onLoad:function(){this.allowOnChange=true;},onKeyUp:function(){var G=this;G.allowOnChange=false;var B=G.getDialog().getContentElement('info','protocol'),C=G.getValue(),D=/^(http|https|ftp|news):\/\/(?=.)/gi,E=/^((javascript:)|[#\/\.])/gi,F=D.exec(C);if(F){G.setValue(C.substr(F[0].length));B.setValue(F[0].toLowerCase());}else if(E.test(C))B.setValue('');G.allowOnChange=true;},onChange:function(){if(this.allowOnChange)this.onKeyUp();},validate:function(){var B=this.getDialog();if(B.getContentElement('info','linkType')&&B.getValueOf('info','linkType')!='url')return true;if(this.getDialog().fakeObj)return true;var C=CKEDITOR.dialog.validate.notEmpty(a.lang.link.noUrl);return C.apply(this);},setup:function(B){this.allowOnChange=false;if(B.url)this.setValue(B.url.url);this.allowOnChange=true;},commit:function(B){this.onChange();if(!B.url)B.url={};B.url.url=this.getValue();this.allowOnChange=false;}}],setup:function(B){if(!this.getDialog().getContentElement('info','linkType'))this.getElement().show();}},{type:'button',id:'browse',hidden:'true',filebrowser:'info:url',label:a.lang.common.browseServer}]},{type:'vbox',id:'anchorOptions',width:260,align:'center',padding:0,children:[{type:'fieldset',id:'selectAnchorText',label:a.lang.link.selectAnchor,setup:function(B){if(B.anchors.length>0)this.getElement().show();else this.getElement().hide();},children:[{type:'hbox',id:'selectAnchor',children:[{type:'select',id:'anchorName','default':'',label:a.lang.link.anchorName,style:'width: 100%;',items:[['']],setup:function(B){var E=this;E.clear();E.add('');for(var C=0;C0)this.getElement().show();else this.getElement().hide();}}]},{type:'html',id:'noAnchors',style:'text-align: center;',html:'
'+CKEDITOR.tools.htmlEncode(a.lang.link.noAnchors)+'
',focus:true,setup:function(B){if(B.anchors.length<1)this.getElement().show(); -else this.getElement().hide();}}],setup:function(B){if(!this.getDialog().getContentElement('info','linkType'))this.getElement().hide();}},{type:'vbox',id:'emailOptions',padding:1,children:[{type:'text',id:'emailAddress',label:a.lang.link.emailAddress,required:true,validate:function(){var B=this.getDialog();if(!B.getContentElement('info','linkType')||B.getValueOf('info','linkType')!='email')return true;var C=CKEDITOR.dialog.validate.notEmpty(a.lang.link.noEmail);return C.apply(this);},setup:function(B){if(B.email)this.setValue(B.email.address);var C=this.getDialog().getContentElement('info','linkType');if(C&&C.getValue()=='email')this.select();},commit:function(B){if(!B.email)B.email={};B.email.address=this.getValue();}},{type:'text',id:'emailSubject',label:a.lang.link.emailSubject,setup:function(B){if(B.email)this.setValue(B.email.subject);},commit:function(B){if(!B.email)B.email={};B.email.subject=this.getValue();}},{type:'textarea',id:'emailBody',label:a.lang.link.emailBody,rows:3,'default':'',setup:function(B){if(B.email)this.setValue(B.email.body);},commit:function(B){if(!B.email)B.email={};B.email.body=this.getValue();}}],setup:function(B){if(!this.getDialog().getContentElement('info','linkType'))this.getElement().hide();}}]},{id:'target',label:a.lang.link.target,title:a.lang.link.target,elements:[{type:'hbox',widths:['50%','50%'],children:[{type:'select',id:'linkTargetType',label:a.lang.common.target,'default':'notSet',style:'width : 100%;',items:[[a.lang.common.notSet,'notSet'],[a.lang.link.targetFrame,'frame'],[a.lang.link.targetPopup,'popup'],[a.lang.common.targetNew,'_blank'],[a.lang.common.targetTop,'_top'],[a.lang.common.targetSelf,'_self'],[a.lang.common.targetParent,'_parent']],onChange:b,setup:function(B){if(B.target)this.setValue(B.target.type);},commit:function(B){if(!B.target)B.target={};B.target.type=this.getValue();}},{type:'text',id:'linkTargetName',label:a.lang.link.targetFrameName,'default':'',setup:function(B){if(B.target)this.setValue(B.target.name);},commit:function(B){if(!B.target)B.target={};B.target.name=this.getValue();}}]},{type:'vbox',width:260,align:'center',padding:2,id:'popupFeatures',children:[{type:'fieldset',label:a.lang.link.popupFeatures,children:[{type:'hbox',children:[{type:'checkbox',id:'resizable',label:a.lang.link.popupResizable,setup:q,commit:t},{type:'checkbox',id:'status',label:a.lang.link.popupStatusBar,setup:q,commit:t}]},{type:'hbox',children:[{type:'checkbox',id:'location',label:a.lang.link.popupLocationBar,setup:q,commit:t},{type:'checkbox',id:'toolbar',label:a.lang.link.popupToolbar,setup:q,commit:t}]},{type:'hbox',children:[{type:'checkbox',id:'menubar',label:a.lang.link.popupMenuBar,setup:q,commit:t},{type:'checkbox',id:'fullscreen',label:a.lang.link.popupFullScreen,setup:q,commit:t}]},{type:'hbox',children:[{type:'checkbox',id:'scrollbars',label:a.lang.link.popupScrollBars,setup:q,commit:t},{type:'checkbox',id:'dependent',label:a.lang.link.popupDependent,setup:q,commit:t}]},{type:'hbox',children:[{type:'text',widths:['30%','70%'],labelLayout:'horizontal',label:a.lang.link.popupWidth,id:'width',setup:q,commit:t},{type:'text',labelLayout:'horizontal',widths:['55%','45%'],label:a.lang.link.popupLeft,id:'left',setup:q,commit:t}]},{type:'hbox',children:[{type:'text',labelLayout:'horizontal',widths:['30%','70%'],label:a.lang.link.popupHeight,id:'height',setup:q,commit:t},{type:'text',labelLayout:'horizontal',label:a.lang.link.popupTop,widths:['55%','45%'],id:'top',setup:q,commit:t}]}]}]}]},{id:'upload',label:a.lang.link.upload,title:a.lang.link.upload,hidden:true,filebrowser:'uploadButton',elements:[{type:'file',id:'upload',label:a.lang.common.upload,style:'height:40px',size:29},{type:'fileButton',id:'uploadButton',label:a.lang.common.uploadSubmit,filebrowser:'info:url','for':['upload','upload']}]},{id:'advanced',label:a.lang.link.advanced,title:a.lang.link.advanced,elements:[{type:'vbox',padding:1,children:[{type:'hbox',widths:['45%','35%','20%'],children:[{type:'text',id:'advId',label:a.lang.link.id,setup:r,commit:u},{type:'select',id:'advLangDir',label:a.lang.link.langDir,'default':'',style:'width:110px',items:[[a.lang.common.notSet,''],[a.lang.link.langDirLTR,'ltr'],[a.lang.link.langDirRTL,'rtl']],setup:r,commit:u},{type:'text',id:'advAccessKey',width:'80px',label:a.lang.link.acccessKey,maxLength:1,setup:r,commit:u}]},{type:'hbox',widths:['45%','35%','20%'],children:[{type:'text',label:a.lang.link.name,id:'advName',setup:r,commit:u},{type:'text',label:a.lang.link.langCode,id:'advLangCode',width:'110px','default':'',setup:r,commit:u},{type:'text',label:a.lang.link.tabIndex,id:'advTabIndex',width:'80px',maxLength:5,setup:r,commit:u}]}]},{type:'vbox',padding:1,children:[{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:a.lang.link.advisoryTitle,'default':'',id:'advTitle',setup:r,commit:u},{type:'text',label:a.lang.link.advisoryContentType,'default':'',id:'advContentType',setup:r,commit:u}]},{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:a.lang.link.cssClasses,'default':'',id:'advCSSClasses',setup:r,commit:u},{type:'text',label:a.lang.link.charset,'default':'',id:'advCharset',setup:r,commit:u}]},{type:'hbox',children:[{type:'text',label:a.lang.link.styles,'default':'',id:'advStyles',setup:r,commit:u}]}]}]}],onShow:function(){var H=this; -H.fakeObj=false;var B=H.getParentEditor(),C=B.getSelection(),D=C.getRanges(),E=null,F=H;if(D.length==1){var G=D[0].getCommonAncestor(true);E=G.getAscendant('a',true);if(E&&E.getAttribute('href'))C.selectElement(E);else if((E=G.getAscendant('img',true))&&E.getAttribute('_cke_real_element_type')&&E.getAttribute('_cke_real_element_type')=='anchor'){H.fakeObj=E;E=B.restoreRealElement(H.fakeObj);C.selectElement(H.fakeObj);}else E=null;}H.setupContent(o.apply(H,[B,E]));},onOk:function(){var B={href:'javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/'},C=[],D={href:B.href},E=this,F=this.getParentEditor();this.commitContent(D);switch(D.type||'url'){case 'url':var G=D.url&&D.url.protocol!=undefined?D.url.protocol:'http://',H=D.url&&D.url.url||'';B._cke_saved_href=H.indexOf('/')===0?H:G+H;break;case 'anchor':var I=D.anchor&&D.anchor.name,J=D.anchor&&D.anchor.id;B._cke_saved_href='#'+(I||J||'');break;case 'email':var K,L=D.email,M=L.address;switch(x){case '':case 'encode':var N=encodeURIComponent(L.subject||''),O=encodeURIComponent(L.body||''),P=[];N&&P.push('subject='+N);O&&P.push('body='+O);P=P.length?'?'+P.join('&'):'';if(x=='encode'){K=["javascript:void(location.href='mailto:'+",A(M)];P&&K.push("+'",w(P),"'");K.push(')');}else K=['mailto:',M,P];break;default:var Q=M.split('@',2);L.name=Q[0];L.domain=Q[1];K=['javascript:',z(L)];}B._cke_saved_href=K.join('');break;}if(D.target)if(D.target.type=='popup'){var R=["window.open(this.href, '",D.target.name||'',"', '"],S=['resizable','status','location','toolbar','menubar','fullscreen','scrollbars','dependent'],T=S.length,U=function(ag){if(D.target[ag])S.push(ag+'='+D.target[ag]);};for(var V=0;V',F.document);X=F.getSelection();ac.moveChildren(af);ac.copyAttributes(af,{name:1});af.replace(ac);ac=af;X.selectElement(ac);}ac.setAttributes(B);ac.removeAttributes(C);if(ad==ae)ac.setHtml(B._cke_saved_href);if(ac.getAttribute('name'))ac.addClass('cke_anchor');else ac.removeClass('cke_anchor');if(this.fakeObj)F.createFakeElement(ac,'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 B=this.getContentElement('info','linkType'),C;if(B&&B.getValue()=='url'){C=this.getContentElement('info','url');C.select();}}};}); +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();}}};});