+++ /dev/null
-/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-CKEDITOR.dialog.add( 'link', function( editor )\r
-{\r
- var plugin = CKEDITOR.plugins.link;\r
- // Handles the event when the "Target" selection box is changed.\r
- var targetChanged = function()\r
- {\r
- var dialog = this.getDialog(),\r
- popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ),\r
- targetName = dialog.getContentElement( 'target', 'linkTargetName' ),\r
- value = this.getValue();\r
-\r
- if ( !popupFeatures || !targetName )\r
- return;\r
-\r
- popupFeatures = popupFeatures.getElement();\r
- popupFeatures.hide();\r
- targetName.setValue( '' );\r
-\r
- switch ( value )\r
- {\r
- case 'frame' :\r
- targetName.setLabel( editor.lang.link.targetFrameName );\r
- targetName.getElement().show();\r
- break;\r
- case 'popup' :\r
- popupFeatures.show();\r
- targetName.setLabel( editor.lang.link.targetPopupName );\r
- targetName.getElement().show();\r
- break;\r
- default :\r
- targetName.setValue( value );\r
- targetName.getElement().hide();\r
- break;\r
- }\r
-\r
- };\r
-\r
- // Handles the event when the "Type" selection box is changed.\r
- var linkTypeChanged = function()\r
- {\r
- var dialog = this.getDialog(),\r
- partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],\r
- typeValue = this.getValue(),\r
- uploadTab = dialog.definition.getContents( 'upload' ),\r
- uploadInitiallyHidden = uploadTab && uploadTab.hidden;\r
-\r
- if ( typeValue == 'url' )\r
- {\r
- if ( editor.config.linkShowTargetTab )\r
- dialog.showPage( 'target' );\r
- if ( !uploadInitiallyHidden )\r
- dialog.showPage( 'upload' );\r
- }\r
- else\r
- {\r
- dialog.hidePage( 'target' );\r
- if ( !uploadInitiallyHidden )\r
- dialog.hidePage( 'upload' );\r
- }\r
-\r
- for ( var i = 0 ; i < partIds.length ; i++ )\r
- {\r
- var element = dialog.getContentElement( 'info', partIds[i] );\r
- if ( !element )\r
- continue;\r
-\r
- element = element.getElement().getParent().getParent();\r
- if ( partIds[i] == typeValue + 'Options' )\r
- element.show();\r
- else\r
- element.hide();\r
- }\r
-\r
- dialog.layout();\r
- };\r
-\r
- // Loads the parameters in a selected link to the link dialog fields.\r
- var javascriptProtocolRegex = /^javascript:/,\r
- emailRegex = /^mailto:([^?]+)(?:\?(.+))?$/,\r
- emailSubjectRegex = /subject=([^;?:@&=$,\/]*)/,\r
- emailBodyRegex = /body=([^;?:@&=$,\/]*)/,\r
- anchorRegex = /^#(.*)$/,\r
- urlRegex = /^((?:http|https|ftp|news):\/\/)?(.*)$/,\r
- selectableTargets = /^(_(?:self|top|parent|blank))$/,\r
- encodedEmailLinkRegex = /^javascript:void\(location\.href='mailto:'\+String\.fromCharCode\(([^)]+)\)(?:\+'(.*)')?\)$/,\r
- functionCallProtectedEmailLinkRegex = /^javascript:([^(]+)\(([^)]+)\)$/;\r
-\r
- var popupRegex =\r
- /\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*/;\r
- var popupFeaturesRegex = /(?:^|,)([^=]+)=(\d+|yes|no)/gi;\r
-\r
- var parseLink = function( editor, element )\r
- {\r
- var href = ( element && ( element.data( 'cke-saved-href' ) || element.getAttribute( 'href' ) ) ) || '',\r
- javascriptMatch,\r
- emailMatch,\r
- anchorMatch,\r
- urlMatch,\r
- retval = {};\r
-\r
- if ( ( javascriptMatch = href.match( javascriptProtocolRegex ) ) )\r
- {\r
- if ( emailProtection == 'encode' )\r
- {\r
- href = href.replace( encodedEmailLinkRegex,\r
- function ( match, protectedAddress, rest )\r
- {\r
- return 'mailto:' +\r
- String.fromCharCode.apply( String, protectedAddress.split( ',' ) ) +\r
- ( rest && unescapeSingleQuote( rest ) );\r
- });\r
- }\r
- // Protected email link as function call.\r
- else if ( emailProtection )\r
- {\r
- href.replace( functionCallProtectedEmailLinkRegex, function( match, funcName, funcArgs )\r
- {\r
- if ( funcName == compiledProtectionFunction.name )\r
- {\r
- retval.type = 'email';\r
- var email = retval.email = {};\r
-\r
- var paramRegex = /[^,\s]+/g,\r
- paramQuoteRegex = /(^')|('$)/g,\r
- paramsMatch = funcArgs.match( paramRegex ),\r
- paramsMatchLength = paramsMatch.length,\r
- paramName,\r
- paramVal;\r
-\r
- for ( var i = 0; i < paramsMatchLength; i++ )\r
- {\r
- paramVal = decodeURIComponent( unescapeSingleQuote( paramsMatch[ i ].replace( paramQuoteRegex, '' ) ) );\r
- paramName = compiledProtectionFunction.params[ i ].toLowerCase();\r
- email[ paramName ] = paramVal;\r
- }\r
- email.address = [ email.name, email.domain ].join( '@' );\r
- }\r
- } );\r
- }\r
- }\r
-\r
- if ( !retval.type )\r
- {\r
- if ( ( anchorMatch = href.match( anchorRegex ) ) )\r
- {\r
- retval.type = 'anchor';\r
- retval.anchor = {};\r
- retval.anchor.name = retval.anchor.id = anchorMatch[1];\r
- }\r
- // Protected email link as encoded string.\r
- else if ( ( emailMatch = href.match( emailRegex ) ) )\r
- {\r
- var subjectMatch = href.match( emailSubjectRegex ),\r
- bodyMatch = href.match( emailBodyRegex );\r
-\r
- retval.type = 'email';\r
- var email = ( retval.email = {} );\r
- email.address = emailMatch[ 1 ];\r
- subjectMatch && ( email.subject = decodeURIComponent( subjectMatch[ 1 ] ) );\r
- bodyMatch && ( email.body = decodeURIComponent( bodyMatch[ 1 ] ) );\r
- }\r
- // urlRegex matches empty strings, so need to check for href as well.\r
- else if ( href && ( urlMatch = href.match( urlRegex ) ) )\r
- {\r
- retval.type = 'url';\r
- retval.url = {};\r
- retval.url.protocol = urlMatch[1];\r
- retval.url.url = urlMatch[2];\r
- }\r
- else\r
- retval.type = 'url';\r
- }\r
-\r
- // Load target and popup settings.\r
- if ( element )\r
- {\r
- var target = element.getAttribute( 'target' );\r
- retval.target = {};\r
- retval.adv = {};\r
-\r
- // IE BUG: target attribute is an empty string instead of null in IE if it's not set.\r
- if ( !target )\r
- {\r
- var onclick = element.data( 'cke-pa-onclick' ) || element.getAttribute( 'onclick' ),\r
- onclickMatch = onclick && onclick.match( popupRegex );\r
- if ( onclickMatch )\r
- {\r
- retval.target.type = 'popup';\r
- retval.target.name = onclickMatch[1];\r
-\r
- var featureMatch;\r
- while ( ( featureMatch = popupFeaturesRegex.exec( onclickMatch[2] ) ) )\r
- {\r
- // Some values should remain numbers (#7300)\r
- if ( ( featureMatch[2] == 'yes' || featureMatch[2] == '1' ) && !( featureMatch[1] in { height:1, width:1, top:1, left:1 } ) )\r
- retval.target[ featureMatch[1] ] = true;\r
- else if ( isFinite( featureMatch[2] ) )\r
- retval.target[ featureMatch[1] ] = featureMatch[2];\r
- }\r
- }\r
- }\r
- else\r
- {\r
- var targetMatch = target.match( selectableTargets );\r
- if ( targetMatch )\r
- retval.target.type = retval.target.name = target;\r
- else\r
- {\r
- retval.target.type = 'frame';\r
- retval.target.name = target;\r
- }\r
- }\r
-\r
- var me = this;\r
- var advAttr = function( inputName, attrName )\r
- {\r
- var value = element.getAttribute( attrName );\r
- if ( value !== null )\r
- retval.adv[ inputName ] = value || '';\r
- };\r
- advAttr( 'advId', 'id' );\r
- advAttr( 'advLangDir', 'dir' );\r
- advAttr( 'advAccessKey', 'accessKey' );\r
-\r
- retval.adv.advName =\r
- element.data( 'cke-saved-name' )\r
- || element.getAttribute( 'name' )\r
- || '';\r
- advAttr( 'advLangCode', 'lang' );\r
- advAttr( 'advTabIndex', 'tabindex' );\r
- advAttr( 'advTitle', 'title' );\r
- advAttr( 'advContentType', 'type' );\r
- CKEDITOR.plugins.link.synAnchorSelector ?\r
- retval.adv.advCSSClasses = getLinkClass( element )\r
- : advAttr( 'advCSSClasses', 'class' );\r
- advAttr( 'advCharset', 'charset' );\r
- advAttr( 'advStyles', 'style' );\r
- advAttr( 'advRel', 'rel' );\r
- }\r
-\r
- // Find out whether we have any anchors in the editor.\r
- var anchors = retval.anchors = [],\r
- item;\r
-\r
- // For some browsers we set contenteditable="false" on anchors, making document.anchors not to include them, so we must traverse the links manually (#7893).\r
- if ( CKEDITOR.plugins.link.emptyAnchorFix )\r
- {\r
- var links = editor.document.getElementsByTag( 'a' );\r
- for ( i = 0, count = links.count(); i < count; i++ )\r
- {\r
- item = links.getItem( i );\r
- if ( item.data( 'cke-saved-name' ) || item.hasAttribute( 'name' ) )\r
- anchors.push( { name : item.data( 'cke-saved-name' ) || item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );\r
- }\r
- }\r
- else\r
- {\r
- var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors );\r
- for ( var i = 0, count = anchorList.count(); i < count; i++ )\r
- {\r
- item = anchorList.getItem( i );\r
- anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };\r
- }\r
- }\r
-\r
- if ( CKEDITOR.plugins.link.fakeAnchor )\r
- {\r
- var imgs = editor.document.getElementsByTag( 'img' );\r
- for ( i = 0, count = imgs.count(); i < count; i++ )\r
- {\r
- if ( ( item = CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, imgs.getItem( i ) ) ) )\r
- anchors.push( { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );\r
- }\r
- }\r
-\r
- // Record down the selected element in the dialog.\r
- this._.selectedElement = element;\r
- return retval;\r
- };\r
-\r
- var setupParams = function( page, data )\r
- {\r
- if ( data[page] )\r
- this.setValue( data[page][this.id] || '' );\r
- };\r
-\r
- var setupPopupParams = function( data )\r
- {\r
- return setupParams.call( this, 'target', data );\r
- };\r
-\r
- var setupAdvParams = function( data )\r
- {\r
- return setupParams.call( this, 'adv', data );\r
- };\r
-\r
- var commitParams = function( page, data )\r
- {\r
- if ( !data[page] )\r
- data[page] = {};\r
-\r
- data[page][this.id] = this.getValue() || '';\r
- };\r
-\r
- var commitPopupParams = function( data )\r
- {\r
- return commitParams.call( this, 'target', data );\r
- };\r
-\r
- var commitAdvParams = function( data )\r
- {\r
- return commitParams.call( this, 'adv', data );\r
- };\r
-\r
- function unescapeSingleQuote( str )\r
- {\r
- return str.replace( /\\'/g, '\'' );\r
- }\r
-\r
- function escapeSingleQuote( str )\r
- {\r
- return str.replace( /'/g, '\\$&' );\r
- }\r
-\r
- var emailProtection = editor.config.emailProtection || '';\r
-\r
- // Compile the protection function pattern.\r
- if ( emailProtection && emailProtection != 'encode' )\r
- {\r
- var compiledProtectionFunction = {};\r
-\r
- emailProtection.replace( /^([^(]+)\(([^)]+)\)$/, function( match, funcName, params )\r
- {\r
- compiledProtectionFunction.name = funcName;\r
- compiledProtectionFunction.params = [];\r
- params.replace( /[^,\s]+/g, function( param )\r
- {\r
- compiledProtectionFunction.params.push( param );\r
- } );\r
- } );\r
- }\r
-\r
- function protectEmailLinkAsFunction( email )\r
- {\r
- var retval,\r
- name = compiledProtectionFunction.name,\r
- params = compiledProtectionFunction.params,\r
- paramName,\r
- paramValue;\r
-\r
- retval = [ name, '(' ];\r
- for ( var i = 0; i < params.length; i++ )\r
- {\r
- paramName = params[ i ].toLowerCase();\r
- paramValue = email[ paramName ];\r
-\r
- i > 0 && retval.push( ',' );\r
- retval.push( '\'',\r
- paramValue ?\r
- escapeSingleQuote( encodeURIComponent( email[ paramName ] ) )\r
- : '',\r
- '\'');\r
- }\r
- retval.push( ')' );\r
- return retval.join( '' );\r
- }\r
-\r
- function protectEmailAddressAsEncodedString( address )\r
- {\r
- var charCode,\r
- length = address.length,\r
- encodedChars = [];\r
- for ( var i = 0; i < length; i++ )\r
- {\r
- charCode = address.charCodeAt( i );\r
- encodedChars.push( charCode );\r
- }\r
- return 'String.fromCharCode(' + encodedChars.join( ',' ) + ')';\r
- }\r
-\r
- function getLinkClass( ele )\r
- {\r
- var className = ele.getAttribute( 'class' );\r
- return className ? className.replace( /\s*(?:cke_anchor_empty|cke_anchor)(?:\s*$)?/g, '' ) : '';\r
- }\r
-\r
- var commonLang = editor.lang.common,\r
- linkLang = editor.lang.link;\r
-\r
- return {\r
- title : linkLang.title,\r
- minWidth : 350,\r
- minHeight : 230,\r
- contents : [\r
- {\r
- id : 'info',\r
- label : linkLang.info,\r
- title : linkLang.info,\r
- elements :\r
- [\r
- {\r
- id : 'linkType',\r
- type : 'select',\r
- label : linkLang.type,\r
- 'default' : 'url',\r
- items :\r
- [\r
- [ linkLang.toUrl, 'url' ],\r
- [ linkLang.toAnchor, 'anchor' ],\r
- [ linkLang.toEmail, 'email' ]\r
- ],\r
- onChange : linkTypeChanged,\r
- setup : function( data )\r
- {\r
- if ( data.type )\r
- this.setValue( data.type );\r
- },\r
- commit : function( data )\r
- {\r
- data.type = this.getValue();\r
- }\r
- },\r
- {\r
- type : 'vbox',\r
- id : 'urlOptions',\r
- children :\r
- [\r
- {\r
- type : 'hbox',\r
- widths : [ '25%', '75%' ],\r
- children :\r
- [\r
- {\r
- id : 'protocol',\r
- type : 'select',\r
- label : commonLang.protocol,\r
- 'default' : 'http://',\r
- items :\r
- [\r
- // Force 'ltr' for protocol names in BIDI. (#5433)\r
- [ 'http://\u200E', 'http://' ],\r
- [ 'https://\u200E', 'https://' ],\r
- [ 'ftp://\u200E', 'ftp://' ],\r
- [ 'news://\u200E', 'news://' ],\r
- [ linkLang.other , '' ]\r
- ],\r
- setup : function( data )\r
- {\r
- if ( data.url )\r
- this.setValue( data.url.protocol || '' );\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.url )\r
- data.url = {};\r
-\r
- data.url.protocol = this.getValue();\r
- }\r
- },\r
- {\r
- type : 'text',\r
- id : 'url',\r
- label : commonLang.url,\r
- required: true,\r
- onLoad : function ()\r
- {\r
- this.allowOnChange = true;\r
- },\r
- onKeyUp : function()\r
- {\r
- this.allowOnChange = false;\r
- var protocolCmb = this.getDialog().getContentElement( 'info', 'protocol' ),\r
- url = this.getValue(),\r
- urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/i,\r
- urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/i;\r
-\r
- var protocol = urlOnChangeProtocol.exec( url );\r
- if ( protocol )\r
- {\r
- this.setValue( url.substr( protocol[ 0 ].length ) );\r
- protocolCmb.setValue( protocol[ 0 ].toLowerCase() );\r
- }\r
- else if ( urlOnChangeTestOther.test( url ) )\r
- protocolCmb.setValue( '' );\r
-\r
- this.allowOnChange = true;\r
- },\r
- onChange : function()\r
- {\r
- if ( this.allowOnChange ) // Dont't call on dialog load.\r
- this.onKeyUp();\r
- },\r
- validate : function()\r
- {\r
- var dialog = this.getDialog();\r
-\r
- if ( dialog.getContentElement( 'info', 'linkType' ) &&\r
- dialog.getValueOf( 'info', 'linkType' ) != 'url' )\r
- return true;\r
-\r
- if ( this.getDialog().fakeObj ) // Edit Anchor.\r
- return true;\r
-\r
- var func = CKEDITOR.dialog.validate.notEmpty( linkLang.noUrl );\r
- return func.apply( this );\r
- },\r
- setup : function( data )\r
- {\r
- this.allowOnChange = false;\r
- if ( data.url )\r
- this.setValue( data.url.url );\r
- this.allowOnChange = true;\r
-\r
- },\r
- commit : function( data )\r
- {\r
- // IE will not trigger the onChange event if the mouse has been used\r
- // to carry all the operations #4724\r
- this.onChange();\r
-\r
- if ( !data.url )\r
- data.url = {};\r
-\r
- data.url.url = this.getValue();\r
- this.allowOnChange = false;\r
- }\r
- }\r
- ],\r
- setup : function( data )\r
- {\r
- if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )\r
- this.getElement().show();\r
- }\r
- },\r
- {\r
- type : 'button',\r
- id : 'browse',\r
- hidden : 'true',\r
- filebrowser : 'info:url',\r
- label : commonLang.browseServer\r
- }\r
- ]\r
- },\r
- {\r
- type : 'vbox',\r
- id : 'anchorOptions',\r
- width : 260,\r
- align : 'center',\r
- padding : 0,\r
- children :\r
- [\r
- {\r
- type : 'fieldset',\r
- id : 'selectAnchorText',\r
- label : linkLang.selectAnchor,\r
- setup : function( data )\r
- {\r
- if ( data.anchors.length > 0 )\r
- this.getElement().show();\r
- else\r
- this.getElement().hide();\r
- },\r
- children :\r
- [\r
- {\r
- type : 'hbox',\r
- id : 'selectAnchor',\r
- children :\r
- [\r
- {\r
- type : 'select',\r
- id : 'anchorName',\r
- 'default' : '',\r
- label : linkLang.anchorName,\r
- style : 'width: 100%;',\r
- items :\r
- [\r
- [ '' ]\r
- ],\r
- setup : function( data )\r
- {\r
- this.clear();\r
- this.add( '' );\r
- for ( var i = 0 ; i < data.anchors.length ; i++ )\r
- {\r
- if ( data.anchors[i].name )\r
- this.add( data.anchors[i].name );\r
- }\r
-\r
- if ( data.anchor )\r
- this.setValue( data.anchor.name );\r
-\r
- var linkType = this.getDialog().getContentElement( 'info', 'linkType' );\r
- if ( linkType && linkType.getValue() == 'email' )\r
- this.focus();\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.anchor )\r
- data.anchor = {};\r
-\r
- data.anchor.name = this.getValue();\r
- }\r
- },\r
- {\r
- type : 'select',\r
- id : 'anchorId',\r
- 'default' : '',\r
- label : linkLang.anchorId,\r
- style : 'width: 100%;',\r
- items :\r
- [\r
- [ '' ]\r
- ],\r
- setup : function( data )\r
- {\r
- this.clear();\r
- this.add( '' );\r
- for ( var i = 0 ; i < data.anchors.length ; i++ )\r
- {\r
- if ( data.anchors[i].id )\r
- this.add( data.anchors[i].id );\r
- }\r
-\r
- if ( data.anchor )\r
- this.setValue( data.anchor.id );\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.anchor )\r
- data.anchor = {};\r
-\r
- data.anchor.id = this.getValue();\r
- }\r
- }\r
- ],\r
- setup : function( data )\r
- {\r
- if ( data.anchors.length > 0 )\r
- this.getElement().show();\r
- else\r
- this.getElement().hide();\r
- }\r
- }\r
- ]\r
- },\r
- {\r
- type : 'html',\r
- id : 'noAnchors',\r
- style : 'text-align: center;',\r
- html : '<div role="label" tabIndex="-1">' + CKEDITOR.tools.htmlEncode( linkLang.noAnchors ) + '</div>',\r
- // Focus the first element defined in above html.\r
- focus : true,\r
- setup : function( data )\r
- {\r
- if ( data.anchors.length < 1 )\r
- this.getElement().show();\r
- else\r
- this.getElement().hide();\r
- }\r
- }\r
- ],\r
- setup : function( data )\r
- {\r
- if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )\r
- this.getElement().hide();\r
- }\r
- },\r
- {\r
- type : 'vbox',\r
- id : 'emailOptions',\r
- padding : 1,\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- id : 'emailAddress',\r
- label : linkLang.emailAddress,\r
- required : true,\r
- validate : function()\r
- {\r
- var dialog = this.getDialog();\r
-\r
- if ( !dialog.getContentElement( 'info', 'linkType' ) ||\r
- dialog.getValueOf( 'info', 'linkType' ) != 'email' )\r
- return true;\r
-\r
- var func = CKEDITOR.dialog.validate.notEmpty( linkLang.noEmail );\r
- return func.apply( this );\r
- },\r
- setup : function( data )\r
- {\r
- if ( data.email )\r
- this.setValue( data.email.address );\r
-\r
- var linkType = this.getDialog().getContentElement( 'info', 'linkType' );\r
- if ( linkType && linkType.getValue() == 'email' )\r
- this.select();\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.email )\r
- data.email = {};\r
-\r
- data.email.address = this.getValue();\r
- }\r
- },\r
- {\r
- type : 'text',\r
- id : 'emailSubject',\r
- label : linkLang.emailSubject,\r
- setup : function( data )\r
- {\r
- if ( data.email )\r
- this.setValue( data.email.subject );\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.email )\r
- data.email = {};\r
-\r
- data.email.subject = this.getValue();\r
- }\r
- },\r
- {\r
- type : 'textarea',\r
- id : 'emailBody',\r
- label : linkLang.emailBody,\r
- rows : 3,\r
- 'default' : '',\r
- setup : function( data )\r
- {\r
- if ( data.email )\r
- this.setValue( data.email.body );\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.email )\r
- data.email = {};\r
-\r
- data.email.body = this.getValue();\r
- }\r
- }\r
- ],\r
- setup : function( data )\r
- {\r
- if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )\r
- this.getElement().hide();\r
- }\r
- }\r
- ]\r
- },\r
- {\r
- id : 'target',\r
- label : linkLang.target,\r
- title : linkLang.target,\r
- elements :\r
- [\r
- {\r
- type : 'hbox',\r
- widths : [ '50%', '50%' ],\r
- children :\r
- [\r
- {\r
- type : 'select',\r
- id : 'linkTargetType',\r
- label : commonLang.target,\r
- 'default' : 'notSet',\r
- style : 'width : 100%;',\r
- 'items' :\r
- [\r
- [ commonLang.notSet, 'notSet' ],\r
- [ linkLang.targetFrame, 'frame' ],\r
- [ linkLang.targetPopup, 'popup' ],\r
- [ commonLang.targetNew, '_blank' ],\r
- [ commonLang.targetTop, '_top' ],\r
- [ commonLang.targetSelf, '_self' ],\r
- [ commonLang.targetParent, '_parent' ]\r
- ],\r
- onChange : targetChanged,\r
- setup : function( data )\r
- {\r
- if ( data.target )\r
- this.setValue( data.target.type || 'notSet' );\r
- targetChanged.call( this );\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.target )\r
- data.target = {};\r
-\r
- data.target.type = this.getValue();\r
- }\r
- },\r
- {\r
- type : 'text',\r
- id : 'linkTargetName',\r
- label : linkLang.targetFrameName,\r
- 'default' : '',\r
- setup : function( data )\r
- {\r
- if ( data.target )\r
- this.setValue( data.target.name );\r
- },\r
- commit : function( data )\r
- {\r
- if ( !data.target )\r
- data.target = {};\r
-\r
- data.target.name = this.getValue().replace(/\W/gi, '');\r
- }\r
- }\r
- ]\r
- },\r
- {\r
- type : 'vbox',\r
- width : '100%',\r
- align : 'center',\r
- padding : 2,\r
- id : 'popupFeatures',\r
- children :\r
- [\r
- {\r
- type : 'fieldset',\r
- label : linkLang.popupFeatures,\r
- children :\r
- [\r
- {\r
- type : 'hbox',\r
- children :\r
- [\r
- {\r
- type : 'checkbox',\r
- id : 'resizable',\r
- label : linkLang.popupResizable,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'status',\r
- label : linkLang.popupStatusBar,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- children :\r
- [\r
- {\r
- type : 'checkbox',\r
- id : 'location',\r
- label : linkLang.popupLocationBar,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'toolbar',\r
- label : linkLang.popupToolbar,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- children :\r
- [\r
- {\r
- type : 'checkbox',\r
- id : 'menubar',\r
- label : linkLang.popupMenuBar,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'fullscreen',\r
- label : linkLang.popupFullScreen,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- children :\r
- [\r
- {\r
- type : 'checkbox',\r
- id : 'scrollbars',\r
- label : linkLang.popupScrollBars,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'dependent',\r
- label : linkLang.popupDependent,\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- widths : [ '50%', '50%' ],\r
- labelLayout : 'horizontal',\r
- label : commonLang.width,\r
- id : 'width',\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- },\r
- {\r
- type : 'text',\r
- labelLayout : 'horizontal',\r
- widths : [ '50%', '50%' ],\r
- label : linkLang.popupLeft,\r
- id : 'left',\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- labelLayout : 'horizontal',\r
- widths : [ '50%', '50%' ],\r
- label : commonLang.height,\r
- id : 'height',\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- },\r
- {\r
- type : 'text',\r
- labelLayout : 'horizontal',\r
- label : linkLang.popupTop,\r
- widths : [ '50%', '50%' ],\r
- id : 'top',\r
- setup : setupPopupParams,\r
- commit : commitPopupParams\r
-\r
- }\r
- ]\r
- }\r
- ]\r
- }\r
- ]\r
- }\r
- ]\r
- },\r
- {\r
- id : 'upload',\r
- label : linkLang.upload,\r
- title : linkLang.upload,\r
- hidden : true,\r
- filebrowser : 'uploadButton',\r
- elements :\r
- [\r
- {\r
- type : 'file',\r
- id : 'upload',\r
- label : commonLang.upload,\r
- style: 'height:40px',\r
- size : 29\r
- },\r
- {\r
- type : 'fileButton',\r
- id : 'uploadButton',\r
- label : commonLang.uploadSubmit,\r
- filebrowser : 'info:url',\r
- 'for' : [ 'upload', 'upload' ]\r
- }\r
- ]\r
- },\r
- {\r
- id : 'advanced',\r
- label : linkLang.advanced,\r
- title : linkLang.advanced,\r
- elements :\r
- [\r
- {\r
- type : 'vbox',\r
- padding : 1,\r
- children :\r
- [\r
- {\r
- type : 'hbox',\r
- widths : [ '45%', '35%', '20%' ],\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- id : 'advId',\r
- label : linkLang.id,\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
- },\r
- {\r
- type : 'select',\r
- id : 'advLangDir',\r
- label : linkLang.langDir,\r
- 'default' : '',\r
- style : 'width:110px',\r
- items :\r
- [\r
- [ commonLang.notSet, '' ],\r
- [ linkLang.langDirLTR, 'ltr' ],\r
- [ linkLang.langDirRTL, 'rtl' ]\r
- ],\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
- },\r
- {\r
- type : 'text',\r
- id : 'advAccessKey',\r
- width : '80px',\r
- label : linkLang.acccessKey,\r
- maxLength : 1,\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- widths : [ '45%', '35%', '20%' ],\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- label : linkLang.name,\r
- id : 'advName',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- },\r
- {\r
- type : 'text',\r
- label : linkLang.langCode,\r
- id : 'advLangCode',\r
- width : '110px',\r
- 'default' : '',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- },\r
- {\r
- type : 'text',\r
- label : linkLang.tabIndex,\r
- id : 'advTabIndex',\r
- width : '80px',\r
- maxLength : 5,\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- }\r
- ]\r
- }\r
- ]\r
- },\r
- {\r
- type : 'vbox',\r
- padding : 1,\r
- children :\r
- [\r
- {\r
- type : 'hbox',\r
- widths : [ '45%', '55%' ],\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- label : linkLang.advisoryTitle,\r
- 'default' : '',\r
- id : 'advTitle',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- },\r
- {\r
- type : 'text',\r
- label : linkLang.advisoryContentType,\r
- 'default' : '',\r
- id : 'advContentType',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- widths : [ '45%', '55%' ],\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- label : linkLang.cssClasses,\r
- 'default' : '',\r
- id : 'advCSSClasses',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- },\r
- {\r
- type : 'text',\r
- label : linkLang.charset,\r
- 'default' : '',\r
- id : 'advCharset',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
-\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- widths : [ '45%', '55%' ],\r
- children :\r
- [\r
- {\r
- type : 'text',\r
- label : linkLang.rel,\r
- 'default' : '',\r
- id : 'advRel',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
- },\r
- {\r
- type : 'text',\r
- label : linkLang.styles,\r
- 'default' : '',\r
- id : 'advStyles',\r
- setup : setupAdvParams,\r
- commit : commitAdvParams\r
- }\r
- ]\r
- }\r
- ]\r
- }\r
- ]\r
- }\r
- ],\r
- onShow : function()\r
- {\r
- var editor = this.getParentEditor(),\r
- selection = editor.getSelection(),\r
- element = null;\r
-\r
- // Fill in all the relevant fields if there's already one link selected.\r
- if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) )\r
- selection.selectElement( element );\r
- else\r
- element = null;\r
-\r
- this.setupContent( parseLink.apply( this, [ editor, element ] ) );\r
- },\r
- onOk : function()\r
- {\r
- var attributes = {},\r
- removeAttributes = [],\r
- data = {},\r
- me = this,\r
- editor = this.getParentEditor();\r
-\r
- this.commitContent( data );\r
-\r
- // Compose the URL.\r
- switch ( data.type || 'url' )\r
- {\r
- case 'url':\r
- var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://',\r
- url = ( data.url && CKEDITOR.tools.trim( data.url.url ) ) || '';\r
- attributes[ 'data-cke-saved-href' ] = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;\r
- break;\r
- case 'anchor':\r
- var name = ( data.anchor && data.anchor.name ),\r
- id = ( data.anchor && data.anchor.id );\r
- attributes[ 'data-cke-saved-href' ] = '#' + ( name || id || '' );\r
- break;\r
- case 'email':\r
-\r
- var linkHref,\r
- email = data.email,\r
- address = email.address;\r
-\r
- switch( emailProtection )\r
- {\r
- case '' :\r
- case 'encode' :\r
- {\r
- var subject = encodeURIComponent( email.subject || '' ),\r
- body = encodeURIComponent( email.body || '' );\r
-\r
- // Build the e-mail parameters first.\r
- var argList = [];\r
- subject && argList.push( 'subject=' + subject );\r
- body && argList.push( 'body=' + body );\r
- argList = argList.length ? '?' + argList.join( '&' ) : '';\r
-\r
- if ( emailProtection == 'encode' )\r
- {\r
- linkHref = [ 'javascript:void(location.href=\'mailto:\'+',\r
- protectEmailAddressAsEncodedString( address ) ];\r
- // parameters are optional.\r
- argList && linkHref.push( '+\'', escapeSingleQuote( argList ), '\'' );\r
-\r
- linkHref.push( ')' );\r
- }\r
- else\r
- linkHref = [ 'mailto:', address, argList ];\r
-\r
- break;\r
- }\r
- default :\r
- {\r
- // Separating name and domain.\r
- var nameAndDomain = address.split( '@', 2 );\r
- email.name = nameAndDomain[ 0 ];\r
- email.domain = nameAndDomain[ 1 ];\r
-\r
- linkHref = [ 'javascript:', protectEmailLinkAsFunction( email ) ];\r
- }\r
- }\r
-\r
- attributes[ 'data-cke-saved-href' ] = linkHref.join( '' );\r
- break;\r
- }\r
-\r
- // Popups and target.\r
- if ( data.target )\r
- {\r
- if ( data.target.type == 'popup' )\r
- {\r
- var onclickList = [ 'window.open(this.href, \'',\r
- data.target.name || '', '\', \'' ];\r
- var featureList = [ 'resizable', 'status', 'location', 'toolbar', 'menubar', 'fullscreen',\r
- 'scrollbars', 'dependent' ];\r
- var featureLength = featureList.length;\r
- var addFeature = function( featureName )\r
- {\r
- if ( data.target[ featureName ] )\r
- featureList.push( featureName + '=' + data.target[ featureName ] );\r
- };\r
-\r
- for ( var i = 0 ; i < featureLength ; i++ )\r
- featureList[i] = featureList[i] + ( data.target[ featureList[i] ] ? '=yes' : '=no' ) ;\r
- addFeature( 'width' );\r
- addFeature( 'left' );\r
- addFeature( 'height' );\r
- addFeature( 'top' );\r
-\r
- onclickList.push( featureList.join( ',' ), '\'); return false;' );\r
- attributes[ 'data-cke-pa-onclick' ] = onclickList.join( '' );\r
-\r
- // Add the "target" attribute. (#5074)\r
- removeAttributes.push( 'target' );\r
- }\r
- else\r
- {\r
- if ( data.target.type != 'notSet' && data.target.name )\r
- attributes.target = data.target.name;\r
- else\r
- removeAttributes.push( 'target' );\r
-\r
- removeAttributes.push( 'data-cke-pa-onclick', 'onclick' );\r
- }\r
- }\r
-\r
- // Advanced attributes.\r
- if ( data.adv )\r
- {\r
- var advAttr = function( inputName, attrName )\r
- {\r
- var value = data.adv[ inputName ];\r
- if ( value )\r
- attributes[attrName] = value;\r
- else\r
- removeAttributes.push( attrName );\r
- };\r
-\r
- advAttr( 'advId', 'id' );\r
- advAttr( 'advLangDir', 'dir' );\r
- advAttr( 'advAccessKey', 'accessKey' );\r
-\r
- if ( data.adv[ 'advName' ] )\r
- attributes[ 'name' ] = attributes[ 'data-cke-saved-name' ] = data.adv[ 'advName' ];\r
- else\r
- removeAttributes = removeAttributes.concat( [ 'data-cke-saved-name', 'name' ] );\r
-\r
- advAttr( 'advLangCode', 'lang' );\r
- advAttr( 'advTabIndex', 'tabindex' );\r
- advAttr( 'advTitle', 'title' );\r
- advAttr( 'advContentType', 'type' );\r
- advAttr( 'advCSSClasses', 'class' );\r
- advAttr( 'advCharset', 'charset' );\r
- advAttr( 'advStyles', 'style' );\r
- advAttr( 'advRel', 'rel' );\r
- }\r
-\r
-\r
- // Browser need the "href" fro copy/paste link to work. (#6641)\r
- attributes.href = attributes[ 'data-cke-saved-href' ];\r
-\r
- if ( !this._.selectedElement )\r
- {\r
- // Create element if current selection is collapsed.\r
- var selection = editor.getSelection(),\r
- ranges = selection.getRanges( true );\r
- if ( ranges.length == 1 && ranges[0].collapsed )\r
- {\r
- // Short mailto link text view (#5736).\r
- var text = new CKEDITOR.dom.text( data.type == 'email' ?\r
- data.email.address : attributes[ 'data-cke-saved-href' ], editor.document );\r
- ranges[0].insertNode( text );\r
- ranges[0].selectNodeContents( text );\r
- selection.selectRanges( ranges );\r
- }\r
-\r
- // Apply style.\r
- var style = new CKEDITOR.style( { element : 'a', attributes : attributes } );\r
- style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why.\r
- style.apply( editor.document );\r
- }\r
- else\r
- {\r
- // We're only editing an existing link, so just overwrite the attributes.\r
- var element = this._.selectedElement,\r
- href = element.data( 'cke-saved-href' ),\r
- textView = element.getHtml();\r
-\r
- element.setAttributes( attributes );\r
- element.removeAttributes( removeAttributes );\r
-\r
- if ( data.adv && data.adv.advName && CKEDITOR.plugins.link.synAnchorSelector )\r
- element.addClass( element.getChildCount() ? 'cke_anchor' : 'cke_anchor_empty' );\r
-\r
- // Update text view when user changes protocol (#4612).\r
- if ( href == textView || data.type == 'email' && textView.indexOf( '@' ) != -1 )\r
- {\r
- // Short mailto link text view (#5736).\r
- element.setHtml( data.type == 'email' ?\r
- data.email.address : attributes[ 'data-cke-saved-href' ] );\r
- }\r
-\r
- delete this._.selectedElement;\r
- }\r
- },\r
- onLoad : function()\r
- {\r
- if ( !editor.config.linkShowAdvancedTab )\r
- this.hidePage( 'advanced' ); //Hide Advanded tab.\r
-\r
- if ( !editor.config.linkShowTargetTab )\r
- this.hidePage( 'target' ); //Hide Target tab.\r
-\r
- },\r
- // Inital focus on 'url' field if link is of type URL.\r
- onFocus : function()\r
- {\r
- var linkType = this.getContentElement( 'info', 'linkType' ),\r
- urlField;\r
- if ( linkType && linkType.getValue() == 'url' )\r
- {\r
- urlField = this.getContentElement( 'info', 'url' );\r
- urlField.select();\r
- }\r
- }\r
- };\r
-});\r
-\r
-/**\r
- * The e-mail address anti-spam protection option. The protection will be\r
- * applied when creating or modifying e-mail links through the editor interface.<br>\r
- * Two methods of protection can be choosed:\r
- * <ol> <li>The e-mail parts (name, domain and any other query string) are\r
- * assembled into a function call pattern. Such function must be\r
- * provided by the developer in the pages that will use the contents.\r
- * <li>Only the e-mail address is obfuscated into a special string that\r
- * has no meaning for humans or spam bots, but which is properly\r
- * rendered and accepted by the browser.</li></ol>\r
- * Both approaches require JavaScript to be enabled.\r
- * @name CKEDITOR.config.emailProtection\r
- * @since 3.1\r
- * @type String\r
- * @default '' (empty string = disabled)\r
- * @example\r
- * // href="mailto:tester@ckeditor.com?subject=subject&body=body"\r
- * config.emailProtection = '';\r
- * @example\r
- * // href="<a href=\"javascript:void(location.href=\'mailto:\'+String.fromCharCode(116,101,115,116,101,114,64,99,107,101,100,105,116,111,114,46,99,111,109)+\'?subject=subject&body=body\')\">e-mail</a>"\r
- * config.emailProtection = 'encode';\r
- * @example\r
- * // href="javascript:mt('tester','ckeditor.com','subject','body')"\r
- * config.emailProtection = 'mt(NAME,DOMAIN,SUBJECT,BODY)';\r
- */\r