[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/editor/tinymce/tiny_mce/3.5.11/themes/advanced/js/ -> anchor.js (source)

   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');
   9          v = ed.dom.getAttrib(elm, 'name') || ed.dom.getAttrib(elm, 'id');
  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, elm, name = document.forms[0].anchorName.value, attribName;
  21  
  22          if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {
  23              tinyMCEPopup.alert('advanced_dlg.anchor_invalid');
  24              return;
  25          }
  26  
  27          tinyMCEPopup.restoreSelection();
  28  
  29          if (this.action != 'update')
  30              ed.selection.collapse(1);
  31  
  32          var aRule = ed.schema.getElementRule('a');
  33          if (!aRule || aRule.attributes.name) {
  34              attribName = 'name';
  35          } else {
  36              attribName = 'id';
  37          }
  38  
  39          elm = ed.dom.getParent(ed.selection.getNode(), 'A');
  40          if (elm) {
  41              elm.setAttribute(attribName, name);
  42              elm[attribName] = name;
  43              ed.undoManager.add();
  44          } else {
  45              // create with zero-sized nbsp so that in Webkit where anchor is on last line by itself caret cannot be placed after it

  46              var attrs =  {'class' : 'mceItemAnchor'};
  47              attrs[attribName] = name;
  48              ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', attrs, '\uFEFF'));
  49              ed.nodeChanged();
  50          }
  51  
  52          tinyMCEPopup.close();
  53      }
  54  };
  55  
  56  tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog);


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1