ckeditor/plugins/crossreference/dialogs/crossreference-link.js
changeset 5 c925ae656709
parent 0 44d330dccc59
equal deleted inserted replaced
4:40e26009689c 5:c925ae656709
    11 		
    11 		
    12 		var type = null;
    12 		var type = null;
    13 		var typeName = dialog.getValueOf('tab-main', 'type');
    13 		var typeName = dialog.getValueOf('tab-main', 'type');
    14 		if (typeName)
    14 		if (typeName)
    15 			type = config.types[typeName];
    15 			type = config.types[typeName];
    16 		
       
    17 		dialog.setValueOf('tab-main', 'filter', '');
       
    18 		
    16 		
    19 		var anchorSelect = dialog.getContentElement('tab-main', 'anchor');
    17 		var anchorSelect = dialog.getContentElement('tab-main', 'anchor');
    20 		anchorSelect.clear();
    18 		anchorSelect.clear();
    21 		anchorSelect.add('', '');
    19 		anchorSelect.add('', '');
    22 		
    20 		
    57 				var option = $(this);
    55 				var option = $(this);
    58 				var text = option.text();
    56 				var text = option.text();
    59 				option.html(text);
    57 				option.html(text);
    60 			});
    58 			});
    61 			
    59 			
    62 			if (!dialog.insertMode)
    60 			if (dialog.insertMode)
       
    61 				filterAnchors(dialog);
       
    62 			else
    63 				anchorSelect.setup(dialog.element);
    63 				anchorSelect.setup(dialog.element);
    64 			
    64 			
    65 			dialog.setState(CKEDITOR.DIALOG_STATE_IDLE);
    65 			dialog.setState(CKEDITOR.DIALOG_STATE_IDLE);
    66 		});
    66 		});
    67 	};
    67 	};
   206 		onShow : function() {
   206 		onShow : function() {
   207 			var selection = editor.getSelection();
   207 			var selection = editor.getSelection();
   208 			this.element = selection.getStartElement();
   208 			this.element = selection.getStartElement();
   209 			if (this.element)
   209 			if (this.element)
   210 				this.element = this.element.getAscendant('a', true);
   210 				this.element = this.element.getAscendant('a', true);
   211 			if (!this.element || this.element.getName() != 'a') {
   211 			if (!this.element || this.element.getName() != 'a' || !this.element.hasAttribute('cross-link')) {
   212 				this.element = editor.document.createElement('a');
   212 				this.element = editor.document.createElement('a');
   213 				this.element.setAttribute('cross-link', '');
   213 				this.element.setAttribute('cross-link', '');
   214 				this.insertMode = true;
   214 				this.insertMode = true;
   215 			} else {
   215 			} else {
   216 				this.insertMode = false;
   216 				this.insertMode = false;
   217 			}
   217 			}
   218 			
   218 			
   219 			if (this.insertMode)
   219 			if (this.insertMode) {
       
   220 				this.setValueOf('tab-main', 'filter', selection.getSelectedText().trim());
   220 				updateAnchors(this);
   221 				updateAnchors(this);
   221 			else
   222 			} else
   222 				this.setupContent(this.element);
   223 				this.setupContent(this.element);
   223 		},
   224 		},
   224 		
   225 		
   225 		onOk : function() {
   226 		onOk : function() {
   226 			if (!this.getValueOf('tab-main', 'type'))
   227 			if (!this.getValueOf('tab-main', 'type'))