diff options
Diffstat (limited to 'plugins/link/dialogs/anchor.js')
| -rwxr-xr-x[-rw-r--r--] | plugins/link/dialogs/anchor.js | 128 |
1 files changed, 8 insertions, 120 deletions
diff --git a/plugins/link/dialogs/anchor.js b/plugins/link/dialogs/anchor.js index daa4660..562417a 100644..100755 --- a/plugins/link/dialogs/anchor.js +++ b/plugins/link/dialogs/anchor.js @@ -1,120 +1,8 @@ -/**
- * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.html or http://ckeditor.com/license
- */
-
-CKEDITOR.dialog.add( 'anchor', function( editor ) {
- // Function called in onShow to load selected element.
- var loadElements = function( element ) {
- this._.selectedElement = element;
-
- var attributeValue = element.data( 'cke-saved-name' );
- this.setValueOf( 'info', 'txtName', attributeValue || '' );
- };
-
- function createFakeAnchor( editor, anchor ) {
- return editor.createFakeElement( anchor, 'cke_anchor', 'anchor' );
- }
-
- return {
- title: editor.lang.link.anchor.title,
- minWidth: 300,
- minHeight: 60,
- onOk: function() {
- var name = CKEDITOR.tools.trim( this.getValueOf( 'info', 'txtName' ) );
- var attributes = {
- id: name,
- name: name,
- 'data-cke-saved-name': name
- };
-
- if ( this._.selectedElement ) {
- if ( this._.selectedElement.data( 'cke-realelement' ) ) {
- var newFake = createFakeAnchor( editor, editor.document.createElement( 'a', { attributes: attributes } ) );
- newFake.replace( this._.selectedElement );
- } else
- this._.selectedElement.setAttributes( attributes );
- } else {
- var sel = editor.getSelection(),
- range = sel && sel.getRanges()[ 0 ];
-
- // Empty anchor
- if ( range.collapsed ) {
- if ( CKEDITOR.plugins.link.synAnchorSelector )
- attributes[ 'class' ] = 'cke_anchor_empty';
-
- if ( CKEDITOR.plugins.link.emptyAnchorFix ) {
- attributes[ 'contenteditable' ] = 'false';
- attributes[ 'data-cke-editable' ] = 1;
- }
-
- var anchor = editor.document.createElement( 'a', { attributes: attributes } );
-
- // Transform the anchor into a fake element for browsers that need it.
- if ( CKEDITOR.plugins.link.fakeAnchor )
- anchor = createFakeAnchor( editor, anchor );
-
- range.insertNode( anchor );
- } else {
- if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
- attributes[ 'class' ] = 'cke_anchor';
-
- // Apply style.
- var style = new CKEDITOR.style({ element: 'a', attributes: attributes } );
- style.type = CKEDITOR.STYLE_INLINE;
- editor.applyStyle( style );
- }
- }
- },
-
- onHide: function() {
- delete this._.selectedElement;
- },
-
- onShow: function() {
- var selection = editor.getSelection(),
- fullySelected = selection.getSelectedElement(),
- partialSelected;
-
- // Detect the anchor under selection.
- if ( fullySelected ) {
- if ( CKEDITOR.plugins.link.fakeAnchor ) {
- var realElement = CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, fullySelected );
- realElement && loadElements.call( this, realElement );
- this._.selectedElement = fullySelected;
- } else if ( fullySelected.is( 'a' ) && fullySelected.hasAttribute( 'name' ) )
- loadElements.call( this, fullySelected );
- } else {
- partialSelected = CKEDITOR.plugins.link.getSelectedLink( editor );
- if ( partialSelected ) {
- loadElements.call( this, partialSelected );
- selection.selectElement( partialSelected );
- }
- }
-
- this.getContentElement( 'info', 'txtName' ).focus();
- },
- contents: [
- {
- id: 'info',
- label: editor.lang.link.anchor.title,
- accessKey: 'I',
- elements: [
- {
- type: 'text',
- id: 'txtName',
- label: editor.lang.link.anchor.name,
- required: true,
- validate: function() {
- if ( !this.getValue() ) {
- alert( editor.lang.link.anchor.errorName );
- return false;
- }
- return true;
- }
- }
- ]
- }
- ]
- };
-});
+/* + Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. + For licensing, see LICENSE.md or http://ckeditor.com/license +*/ +CKEDITOR.dialog.add("anchor",function(c){var d=function(a){this._.selectedElement=a;this.setValueOf("info","txtName",a.data("cke-saved-name")||"")};return{title:c.lang.link.anchor.title,minWidth:300,minHeight:60,onOk:function(){var a=CKEDITOR.tools.trim(this.getValueOf("info","txtName")),a={id:a,name:a,"data-cke-saved-name":a};if(this._.selectedElement)this._.selectedElement.data("cke-realelement")?(a=c.document.createElement("a",{attributes:a}),c.createFakeElement(a,"cke_anchor","anchor").replace(this._.selectedElement)): +this._.selectedElement.setAttributes(a);else{var b=c.getSelection(),b=b&&b.getRanges()[0];b.collapsed?(CKEDITOR.plugins.link.synAnchorSelector&&(a["class"]="cke_anchor_empty"),CKEDITOR.plugins.link.emptyAnchorFix&&(a.contenteditable="false",a["data-cke-editable"]=1),a=c.document.createElement("a",{attributes:a}),CKEDITOR.plugins.link.fakeAnchor&&(a=c.createFakeElement(a,"cke_anchor","anchor")),b.insertNode(a)):(CKEDITOR.env.ie&&9>CKEDITOR.env.version&&(a["class"]="cke_anchor"),a=new CKEDITOR.style({element:"a", +attributes:a}),a.type=CKEDITOR.STYLE_INLINE,c.applyStyle(a))}},onHide:function(){delete this._.selectedElement},onShow:function(){var a=c.getSelection(),b=a.getSelectedElement();if(b)CKEDITOR.plugins.link.fakeAnchor?((a=CKEDITOR.plugins.link.tryRestoreFakeAnchor(c,b))&&d.call(this,a),this._.selectedElement=b):b.is("a")&&b.hasAttribute("name")&&d.call(this,b);else if(b=CKEDITOR.plugins.link.getSelectedLink(c))d.call(this,b),a.selectElement(b);this.getContentElement("info","txtName").focus()},contents:[{id:"info", +label:c.lang.link.anchor.title,accessKey:"I",elements:[{type:"text",id:"txtName",label:c.lang.link.anchor.name,required:!0,validate:function(){return!this.getValue()?(alert(c.lang.link.anchor.errorName),!1):!0}}]}]}});
\ No newline at end of file |
