Ticket #1552: linkValidator.diff

File linkValidator.diff, 2.0 KB (added by guest, 9 years ago)

add XinhaConfig?.linkValidator option, used in Linker and CreateLink?

  • plugins/Linker/pluginMethods.js

     
    1111    return false; 
    1212  } 
    1313 
     14  if(this.editor.config.linkValidator) { 
     15    var errorMsg = this.editor.config.linkValidator(this.editor, a, this._lc); 
     16    if( errorMsg ) { 
     17      alert(errorMsg); 
     18      return false; 
     19    } 
     20  } 
     21 
    1422  var inputs = 
    1523  { 
    1624    type:     'url', 
  • XinhaCore.js

     
    11871187    "img": [function(e, target) {e._insertImage(target);}] 
    11881188  }; 
    11891189   
     1190  /** 
     1191   * A Javascript function to call when the user first clicks on the "Create Link" 
     1192   * button. The function can prevent the "Create Link" action from occurring by 
     1193   * returning a string error message to display to the user. For example, this 
     1194   * can be used to prevent the creation of links inside WikiLink text, if your 
     1195   * backend is using a mixed html+wiki syntax. 
     1196   * 
     1197   * The function will be called with three arguments: (editor, anchor_or_null, Xinha.lc) 
     1198   * 
     1199   *  Default: <code>null</code> 
     1200   */ 
     1201  this.linkValidator = null; 
     1202 
    11901203  /** A container for additional icons that may be swapped within one button (like fullscreen) 
    11911204   * @private 
    11921205   */ 
  • modules/CreateLink/pluginMethods.js

     
    1212                alert(this._lc("You need to select some text before creating a link")); 
    1313                return false; 
    1414        } 
    15  
     15        if(this.editor.config.linkValidator) { 
     16          var errorMsg = this.editor.config.linkValidator(this.editor, a, this._lc); 
     17          if( errorMsg ) { 
     18            alert(errorMsg); 
     19            return false; 
     20          } 
     21        } 
    1622        var inputs = 
    1723        { 
    1824                f_href   : '',