/* 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 C=this.getDialog(),D=C.getContentElement('target','popupFeatures'),E=C.getContentElement('target','linkTargetName'),F=this.getValue();if(!D||!E)return;D=D.getElement();D.hide();E.setValue('');switch(F){case 'frame':E.setLabel(a.lang.link.targetFrameName);E.getElement().show();break;case 'popup':D.show();E.setLabel(a.lang.link.targetPopupName);E.getElement().show();break;default:E.setValue(F);E.getElement().hide();break;}},d=function(){var C=this.getDialog(),D=['urlOptions','anchorOptions','emailOptions'],E=this.getValue(),F=C.definition.getContents('upload'),G=F&&F.hidden;if(E=='url'){if(a.config.linkShowTargetTab)C.showPage('target');if(!G)C.showPage('upload');}else{C.hidePage('target');if(!G)C.hidePage('upload');}for(var H=0;H0&&D.push(',');D.push("'",H?x(encodeURIComponent(C[G])):'',"'");}D.push(')');return D.join('');};function B(C){var D,E=C.length,F=[];for(var G=0;G0)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(C){var F=this;F.clear();F.add('');for(var D=0;D0)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(C){if(C.anchors.length<1)this.getElement().show(); else this.getElement().hide();}}],setup:function(C){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 C=this.getDialog();if(!C.getContentElement('info','linkType')||C.getValueOf('info','linkType')!='email')return true;var D=CKEDITOR.dialog.validate.notEmpty(a.lang.link.noEmail);return D.apply(this);},setup:function(C){if(C.email)this.setValue(C.email.address);var D=this.getDialog().getContentElement('info','linkType');if(D&&D.getValue()=='email')this.select();},commit:function(C){if(!C.email)C.email={};C.email.address=this.getValue();}},{type:'text',id:'emailSubject',label:a.lang.link.emailSubject,setup:function(C){if(C.email)this.setValue(C.email.subject);},commit:function(C){if(!C.email)C.email={};C.email.subject=this.getValue();}},{type:'textarea',id:'emailBody',label:a.lang.link.emailBody,rows:3,'default':'',setup:function(C){if(C.email)this.setValue(C.email.body);},commit:function(C){if(!C.email)C.email={};C.email.body=this.getValue();}}],setup:function(C){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:c,setup:function(C){if(C.target)this.setValue(C.target.type);},commit:function(C){if(!C.target)C.target={};C.target.type=this.getValue();}},{type:'text',id:'linkTargetName',label:a.lang.link.targetFrameName,'default':'',setup:function(C){if(C.target)this.setValue(C.target.name);},commit:function(C){if(!C.target)C.target={};C.target.name=this.getValue().replace(/\W/gi,'');}}]},{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:r,commit:u},{type:'checkbox',id:'status',label:a.lang.link.popupStatusBar,setup:r,commit:u}]},{type:'hbox',children:[{type:'checkbox',id:'location',label:a.lang.link.popupLocationBar,setup:r,commit:u},{type:'checkbox',id:'toolbar',label:a.lang.link.popupToolbar,setup:r,commit:u}]},{type:'hbox',children:[{type:'checkbox',id:'menubar',label:a.lang.link.popupMenuBar,setup:r,commit:u},{type:'checkbox',id:'fullscreen',label:a.lang.link.popupFullScreen,setup:r,commit:u}]},{type:'hbox',children:[{type:'checkbox',id:'scrollbars',label:a.lang.link.popupScrollBars,setup:r,commit:u},{type:'checkbox',id:'dependent',label:a.lang.link.popupDependent,setup:r,commit:u}]},{type:'hbox',children:[{type:'text',widths:['30%','70%'],labelLayout:'horizontal',label:a.lang.link.popupWidth,id:'width',setup:r,commit:u},{type:'text',labelLayout:'horizontal',widths:['55%','45%'],label:a.lang.link.popupLeft,id:'left',setup:r,commit:u}]},{type:'hbox',children:[{type:'text',labelLayout:'horizontal',widths:['30%','70%'],label:a.lang.link.popupHeight,id:'height',setup:r,commit:u},{type:'text',labelLayout:'horizontal',label:a.lang.link.popupTop,widths:['55%','45%'],id:'top',setup:r,commit:u}]}]}]}]},{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:s,commit:v},{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:s,commit:v},{type:'text',id:'advAccessKey',width:'80px',label:a.lang.link.acccessKey,maxLength:1,setup:s,commit:v}]},{type:'hbox',widths:['45%','35%','20%'],children:[{type:'text',label:a.lang.link.name,id:'advName',setup:s,commit:v},{type:'text',label:a.lang.link.langCode,id:'advLangCode',width:'110px','default':'',setup:s,commit:v},{type:'text',label:a.lang.link.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:a.lang.link.advisoryTitle,'default':'',id:'advTitle',setup:s,commit:v},{type:'text',label:a.lang.link.advisoryContentType,'default':'',id:'advContentType',setup:s,commit:v}]},{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:a.lang.link.cssClasses,'default':'',id:'advCSSClasses',setup:s,commit:v},{type:'text',label:a.lang.link.charset,'default':'',id:'advCharset',setup:s,commit:v}]},{type:'hbox',children:[{type:'text',label:a.lang.link.styles,'default':'',id:'advStyles',setup:s,commit:v}]}]}]}],onShow:function(){var F=this; F.fakeObj=false;var C=F.getParentEditor(),D=C.getSelection(),E=null;if((E=b.getSelectedLink(C))&&E.hasAttribute('href'))D.selectElement(E);else if((E=D.getSelectedElement())&&E.is('img')&&E.getAttribute('_cke_real_element_type')&&E.getAttribute('_cke_real_element_type')=='anchor'){F.fakeObj=E;E=C.restoreRealElement(F.fakeObj);D.selectElement(F.fakeObj);}else E=null;F.setupContent(p.apply(F,[C,E]));},onOk:function(){var C={href:'javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/'},D=[],E={href:C.href},F=this,G=this.getParentEditor();this.commitContent(E);switch(E.type||'url'){case 'url':var H=E.url&&E.url.protocol!=undefined?E.url.protocol:'http://',I=E.url&&E.url.url||'';C._cke_saved_href=I.indexOf('/')===0?I:H+I;break;case 'anchor':var J=E.anchor&&E.anchor.name,K=E.anchor&&E.anchor.id;C._cke_saved_href='#'+(J||K||'');break;case 'email':var L,M=E.email,N=M.address;switch(y){case '':case 'encode':var O=encodeURIComponent(M.subject||''),P=encodeURIComponent(M.body||''),Q=[];O&&Q.push('subject='+O);P&&Q.push('body='+P);Q=Q.length?'?'+Q.join('&'):'';if(y=='encode'){L=["javascript:void(location.href='mailto:'+",B(N)];Q&&L.push("+'",x(Q),"'");L.push(')');}else L=['mailto:',N,Q];break;default:var R=N.split('@',2);M.name=R[0];M.domain=R[1];L=['javascript:',A(M)];}C._cke_saved_href=L.join('');break;}if(E.target)if(E.target.type=='popup'){var S=["window.open(this.href, '",E.target.name||'',"', '"],T=['resizable','status','location','toolbar','menubar','fullscreen','scrollbars','dependent'],U=T.length,V=function(ah){if(E.target[ah])T.push(ah+'='+E.target[ah]);};for(var W=0;W',G.document);Y=G.getSelection();ad.moveChildren(ag);ad.copyAttributes(ag,{name:1});ag.replace(ad);ad=ag;Y.selectElement(ad);}ad.setAttributes(C);ad.removeAttributes(D);if(ae==af)ad.setHtml(C._cke_saved_href);if(ad.getAttribute('name'))ad.addClass('cke_anchor');else ad.removeClass('cke_anchor');if(this.fakeObj)G.createFakeElement(ad,'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 C=this.getContentElement('info','linkType'),D;if(C&&C.getValue()=='url'){D=this.getContentElement('info','url');D.select();}}};});