/* Copyright (c) 2003-2009, 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 s=this.getDialog(),t=s.getContentElement('target','popupFeatures'),u=s.getContentElement('target','linkTargetName'),v=this.getValue();if(!t||!u)return;t=t.getElement();if(v=='popup'){t.show();u.setLabel(a.lang.link.targetPopupName);}else{t.hide();u.setLabel(a.lang.link.targetFrameName);this.getDialog().setValueOf('target','linkTargetName',v.charAt(0)=='_'?v:'');}},c=function(){var s=this.getDialog(),t=['urlOptions','anchorOptions','emailOptions'],u=this.getValue(),v=s.definition.getContents('upload').hidden;if(u=='url'){if(a.config.linkShowTargetTab)s.showPage('target');if(!v)s.showPage('upload');}else{s.hidePage('target');if(!v)s.hidePage('upload');}for(var w=0;w','']],setup:function(s){if(s.url)this.setValue(s.url.protocol);},commit:function(s){if(!s.url)s.url={};s.url.protocol=this.getValue();}},{type:'text',id:'url',label:a.lang.common.url,onLoad:function(){this.allowOnChange=true;},onKeyUp:function(){var x=this;x.allowOnChange=false;var s=x.getDialog().getContentElement('info','protocol'),t=x.getValue(),u=/^(http|https|ftp|news):\/\/(?=.)/gi,v=/^((javascript:)|[#\/\.])/gi,w=u.exec(t);if(w){x.setValue(t.substr(w[0].length));s.setValue(w[0].toLowerCase());}else if(v.test(t))s.setValue('');x.allowOnChange=true;},onChange:function(){if(this.allowOnChange)this.onKeyUp();},validate:function(){var s=this.getDialog();if(s.getContentElement('info','linkType')&&s.getValueOf('info','linkType')!='url')return true;if(this.getDialog().fakeObj)return true;var t=CKEDITOR.dialog.validate.notEmpty(a.lang.link.noUrl);return t.apply(this);},setup:function(s){var u=this;u.allowOnChange=false;if(s.url)u.setValue(s.url.url);u.allowOnChange=true;var t=u.getDialog().getContentElement('info','linkType');if(t&&t.getValue()=='url')u.select();},commit:function(s){if(!s.url)s.url={};s.url.url=this.getValue();this.allowOnChange=false;}}],setup:function(s){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:'html',id:'selectAnchorText',html:CKEDITOR.tools.htmlEncode(a.lang.link.selectAnchor),setup:function(s){if(s.anchors.length>0)this.getElement().show();else this.getElement().hide();}},{type:'html',id:'noAnchors',style:'text-align: center;',html:'
'+CKEDITOR.tools.htmlEncode(a.lang.link.noAnchors)+'
',setup:function(s){if(s.anchors.length<1)this.getElement().show();else this.getElement().hide();}},{type:'hbox',id:'selectAnchor',children:[{type:'select',id:'anchorName','default':'',label:a.lang.link.anchorName,style:'width: 100%;',items:[['']],setup:function(s){var v=this;v.clear();v.add('');for(var t=0;t0)this.getElement().show();else this.getElement().hide();}}],setup:function(s){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,validate:function(){var s=this.getDialog();if(!s.getContentElement('info','linkType')||s.getValueOf('info','linkType')!='email')return true;var t=CKEDITOR.dialog.validate.notEmpty(a.lang.link.noEmail);return t.apply(this);},setup:function(s){if(s.email)this.setValue(s.email.address);var t=this.getDialog().getContentElement('info','linkType');if(t&&t.getValue()=='email')this.select();},commit:function(s){if(!s.email)s.email={};s.email.address=this.getValue();}},{type:'text',id:'emailSubject',label:a.lang.link.emailSubject,setup:function(s){if(s.email)this.setValue(s.email.subject);},commit:function(s){if(!s.email)s.email={};s.email.subject=this.getValue();}},{type:'textarea',id:'emailBody',label:a.lang.link.emailBody,rows:3,'default':'',setup:function(s){if(s.email)this.setValue(s.email.body); },commit:function(s){if(!s.email)s.email={};s.email.body=this.getValue();}}],setup:function(s){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.link.target,'default':'notSet',style:'width : 100%;',items:[[a.lang.link.targetNotSet,'notSet'],[a.lang.link.targetFrame,'frame'],[a.lang.link.targetPopup,'popup'],[a.lang.link.targetNew,'_blank'],[a.lang.link.targetTop,'_top'],[a.lang.link.targetSelf,'_self'],[a.lang.link.targetParent,'_parent']],onChange:b,setup:function(s){if(s.target)this.setValue(s.target.type);},commit:function(s){if(!s.target)s.target={};s.target.type=this.getValue();}},{type:'text',id:'linkTargetName',label:a.lang.link.targetFrameName,'default':'',setup:function(s){if(s.target)this.setValue(s.target.name);},commit:function(s){if(!s.target)s.target={};s.target.name=this.getValue();}}]},{type:'vbox',width:260,align:'center',padding:2,id:'popupFeatures',children:[{type:'html',html:CKEDITOR.tools.htmlEncode(a.lang.link.popupFeatures)},{type:'hbox',children:[{type:'checkbox',id:'resizable',label:a.lang.link.popupResizable,setup:n,commit:q},{type:'checkbox',id:'status',label:a.lang.link.popupStatusBar,setup:n,commit:q}]},{type:'hbox',children:[{type:'checkbox',id:'location',label:a.lang.link.popupLocationBar,setup:n,commit:q},{type:'checkbox',id:'toolbar',label:a.lang.link.popupToolbar,setup:n,commit:q}]},{type:'hbox',children:[{type:'checkbox',id:'menubar',label:a.lang.link.popupMenuBar,setup:n,commit:q},{type:'checkbox',id:'fullscreen',label:a.lang.link.popupFullScreen,setup:n,commit:q}]},{type:'hbox',children:[{type:'checkbox',id:'scrollbars',label:a.lang.link.popupScrollBars,setup:n,commit:q},{type:'checkbox',id:'dependent',label:a.lang.link.popupDependent,setup:n,commit:q}]},{type:'hbox',children:[{type:'text',widths:['30%','70%'],labelLayout:'horizontal',label:a.lang.link.popupWidth,id:'width',setup:n,commit:q},{type:'text',labelLayout:'horizontal',widths:['55%','45%'],label:a.lang.link.popupLeft,id:'left',setup:n,commit:q}]},{type:'hbox',children:[{type:'text',labelLayout:'horizontal',widths:['30%','70%'],label:a.lang.link.popupHeight,id:'height',setup:n,commit:q},{type:'text',labelLayout:'horizontal',label:a.lang.link.popupTop,widths:['55%','45%'],id:'top',setup:n,commit:q}]}]}]},{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:o,commit:r},{type:'select',id:'advLangDir',label:a.lang.link.langDir,'default':'',style:'width:110px',items:[[a.lang.link.langDirNotSet,''],[a.lang.link.langDirLTR,'ltr'],[a.lang.link.langDirRTL,'rtl']],setup:o,commit:r},{type:'text',id:'advAccessKey',width:'80px',label:a.lang.link.acccessKey,maxLength:1,setup:o,commit:r}]},{type:'hbox',widths:['45%','35%','20%'],children:[{type:'text',label:a.lang.link.name,id:'advName',setup:o,commit:r},{type:'text',label:a.lang.link.langCode,id:'advLangCode',width:'110px','default':'',setup:o,commit:r},{type:'text',label:a.lang.link.tabIndex,id:'advTabIndex',width:'80px',maxLength:5,setup:o,commit:r}]}]},{type:'vbox',padding:1,children:[{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:a.lang.link.advisoryTitle,'default':'',id:'advTitle',setup:o,commit:r},{type:'text',label:a.lang.link.advisoryContentType,'default':'',id:'advContentType',setup:o,commit:r}]},{type:'hbox',widths:['45%','55%'],children:[{type:'text',label:a.lang.link.cssClasses,'default':'',id:'advCSSClasses',setup:o,commit:r},{type:'text',label:a.lang.link.charset,'default':'',id:'advCharset',setup:o,commit:r}]},{type:'hbox',children:[{type:'text',label:a.lang.link.styles,'default':'',id:'advStyles',setup:o,commit:r}]}]}]}],onShow:function(){var y=this; y.fakeObj=false;var s=y.getParentEditor(),t=s.getSelection(),u=t.getRanges(),v=null,w=y;if(u.length==1){var x=u[0].getCommonAncestor(true);v=x.getAscendant('a',true);if(v&&v.getAttribute('href'))t.selectElement(v);else if((v=x.getAscendant('img',true))&&(v.getAttribute('_cke_real_element_type')&&v.getAttribute('_cke_real_element_type')=='anchor')){y.fakeObj=v;v=s.restoreRealElement(y.fakeObj);t.selectElement(y.fakeObj);}else v=null;}y.setupContent(l.apply(y,[s,v]));},onOk:function(){var s={href:'javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/'},t=[],u={href:s.href},v=this,w=this.getParentEditor();this.commitContent(u);switch(u.type||'url'){case 'url':var x=u.url&&u.url.protocol!=undefined?u.url.protocol:'http://',y=u.url&&u.url.url||'';s._cke_saved_href=y.indexOf('/')===0?y:x+y;break;case 'anchor':var z=u.anchor&&u.anchor.name,A=u.anchor&&u.anchor.id;s._cke_saved_href='#'+(z||A||'');break;case 'email':var B=u.email&&u.email.address,C=u.email&&encodeURIComponent(u.email.subject||''),D=u.email&&encodeURIComponent(u.email.body||''),E=['mailto:',B];if(C||D){var F=[];E.push('?');C&&F.push('subject='+C);D&&F.push('body='+D);E.push(F.join('&'));}s._cke_saved_href=E.join('');break;default:}if(u.target)if(u.target.type=='popup'){var G=["window.open(this.href, '",u.target.name||'',"', '"],H=['resizable','status','location','toolbar','menubar','fullscreen','scrollbars','dependent'],I=H.length,J=function(T){if(u.target[T])H.push(T+'='+u.target[T]);};for(var K=0;K',w.document);M=w.getSelection();R.moveChildren(S);R.copyAttributes(S,{name:1});S.replace(R);R=S;M.selectElement(R);}R.setAttributes(s);R.removeAttributes(t);if(R.getAttribute('name'))R.addClass('cke_anchor');else R.removeClass('cke_anchor');if(this.fakeObj)w.createFakeElement(R,'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');}};});