bgneal@312: tinyMCEPopup.requireLangPack(); bgneal@312: bgneal@312: var AnchorDialog = { bgneal@312: init : function(ed) { bgneal@312: var action, elm, f = document.forms[0]; bgneal@312: bgneal@312: this.editor = ed; bgneal@312: elm = ed.dom.getParent(ed.selection.getNode(), 'A'); bgneal@312: v = ed.dom.getAttrib(elm, 'name'); bgneal@312: bgneal@312: if (v) { bgneal@312: this.action = 'update'; bgneal@312: f.anchorName.value = v; bgneal@312: } bgneal@312: bgneal@312: f.insert.value = ed.getLang(elm ? 'update' : 'insert'); bgneal@312: }, bgneal@312: bgneal@312: update : function() { bgneal@312: var ed = this.editor, elm, name = document.forms[0].anchorName.value; bgneal@312: bgneal@442: if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) { bgneal@442: tinyMCEPopup.alert('advanced_dlg.anchor_invalid'); bgneal@442: return; bgneal@442: } bgneal@442: bgneal@312: tinyMCEPopup.restoreSelection(); bgneal@312: bgneal@312: if (this.action != 'update') bgneal@312: ed.selection.collapse(1); bgneal@312: bgneal@312: elm = ed.dom.getParent(ed.selection.getNode(), 'A'); bgneal@312: if (elm) bgneal@312: elm.name = name; bgneal@312: else bgneal@312: ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, '')); bgneal@312: bgneal@312: tinyMCEPopup.close(); bgneal@312: } bgneal@312: }; bgneal@312: bgneal@312: tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog);