thomascube
2011-04-20 a9251be2f09fb5f18a85d201c67668c70980efe3
commit | author | age
d9344f 1 tinyMCEPopup.requireLangPack();
S 2
3 var AnchorDialog = {
4     init : function(ed) {
5         var action, elm, f = document.forms[0];
6
7         this.editor = ed;
69d05c 8         elm = ed.dom.getParent(ed.selection.getNode(), 'A');
d9344f 9         v = ed.dom.getAttrib(elm, 'name');
S 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() {
69d05c 20         var ed = this.editor, elm, name = document.forms[0].anchorName.value;
A 21
a9251b 22         if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {
T 23             tinyMCEPopup.alert('advanced_dlg.anchor_invalid');
24             return;
25         }
26
d9344f 27         tinyMCEPopup.restoreSelection();
S 28
29         if (this.action != 'update')
30             ed.selection.collapse(1);
31
69d05c 32         elm = ed.dom.getParent(ed.selection.getNode(), 'A');
A 33         if (elm)
34             elm.name = name;
d9344f 35         else
69d05c 36             ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, ''));
d9344f 37
S 38         tinyMCEPopup.close();
39     }
40 };
41
42 tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog);