Rev | Line | |
---|
[44] | 1 | tinyMCEPopup.requireLangPack();
|
---|
| 2 |
|
---|
| 3 | var AnchorDialog = {
|
---|
| 4 | init : function(ed) {
|
---|
| 5 | var action, elm, f = document.forms[0];
|
---|
| 6 |
|
---|
| 7 | this.editor = ed;
|
---|
| 8 | elm = ed.dom.getParent(ed.selection.getNode(), 'A,IMG');
|
---|
| 9 | v = ed.dom.getAttrib(elm, 'name');
|
---|
| 10 |
|
---|
| 11 | if (v) {
|
---|
| 12 | this.action = 'update';
|
---|
| 13 | f.anchorName.value = v;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | f.insert.value = ed.getLang(elm ? 'update' : 'insert');
|
---|
| 17 | },
|
---|
| 18 |
|
---|
| 19 | update : function() {
|
---|
| 20 | var ed = this.editor;
|
---|
| 21 |
|
---|
| 22 | tinyMCEPopup.restoreSelection();
|
---|
| 23 |
|
---|
| 24 | if (this.action != 'update')
|
---|
| 25 | ed.selection.collapse(1);
|
---|
| 26 |
|
---|
| 27 | // Webkit acts weird if empty inline element is inserted so we need to use a image instead
|
---|
| 28 | if (tinymce.isWebKit)
|
---|
| 29 | ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('img', {mce_name : 'a', name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'}));
|
---|
| 30 | else
|
---|
| 31 | ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'}, ''));
|
---|
| 32 |
|
---|
| 33 | tinyMCEPopup.close();
|
---|
| 34 | }
|
---|
| 35 | };
|
---|
| 36 |
|
---|
| 37 | tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.