1 CKEDITOR.dialog.add('crossreference-anchor-dialog', function(editor) {
3 var config = editor.config.crossreference;
5 var generateUUID = function() {
6 var d = new Date().getTime();
7 if(window.performance && typeof window.performance.now === "function"){
8 d += performance.now(); // use high-precision timer if available
10 var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
11 var r = (d + Math.random()*16)%16 | 0;
13 return (c=='x' ? r : (r&0x3|0x8)).toString(16);
19 title : editor.lang.crossreference.anchor,
26 label : editor.lang.crossreference.anchor,
35 html : '<div style="white-space: normal; text-align: justify;">' + editor.lang.crossreference.anchorDescription + '</div>',
41 label : editor.lang.crossreference.anchorType,
46 this.getInputElement().setStyle('width', '100%');
47 for (var typeName in config.types) {
48 var type = config.types[typeName];
49 var label = type.name;
50 if (type.allowCreateAnchors == false)
52 this.add(label, type.type);
55 setup: function(element) {
56 this.setValue(element.getAttribute('cross-reference'));
58 commit: function(element) {
59 element.setAttribute('cross-reference', this.getValue());
60 element.setAttribute('cross-anchor', '');
67 label : editor.lang.crossreference.anchorName,
69 setup: function(element) {
70 this.setValue(element.getAttribute('cross-name'));
72 commit: function(element) {
73 element.setAttribute('cross-name', this.getValue());
87 var selection = editor.getSelection();
88 this.element = selection.getStartElement();
90 this.element = this.element.getAscendant('a', true);
91 if (!this.element || this.element.getName() != 'a') {
92 this.element = editor.document.createElement('a');
93 var guid = generateUUID();
94 this.element.setAttribute('cross-guid', guid);
95 this.insertMode = true;
97 this.insertMode = false;
100 if (!this.insertMode)
101 this.setupContent(this.element);
105 if (!this.getValueOf('tab-main', 'type'))
108 this.commitContent(this.element);
111 editor.insertElement(this.element);
113 editor.execCommand('update-crossreferences');