Changeset 1296


Ignore:
Timestamp:
11/24/10 20:48:25 (3 years ago)
Author:
ejucovy
Message:

close #1541: add xinha_config.formatblockDetector option, which can be used, in coordination with a clever onExecCommand(formatblock), to customize the behavior of the formatblock dropdown with custom options that don't directly correspond one-to-one to HTML block tags and/or require application-specific logic to identify.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1294 r1296  
    10591059    "Formatted": "pre" 
    10601060  }; 
    1061    
     1061 
     1062  /** You can provide custom functions that will be used to determine which of the 
     1063   * "formatblock" options is currently active and selected in the dropdown. 
     1064   * 
     1065   * Example: 
     1066   * <pre> 
     1067   * xinha_config.formatblockDetector['h5'] = function(xinha, currentElement) 
     1068   * { 
     1069   *   if (my_special_matching_logic(currentElement)) { 
     1070   *     return true; 
     1071   *   } else { 
     1072   *     return false; 
     1073   *   } 
     1074   * }; 
     1075   * </pre> 
     1076   * 
     1077   * You probably don't want to mess with this, unless you are adding new, custom 
     1078   * "formatblock" options which don't correspond to real HTML tags.  If you want 
     1079   * to do that, you can use this configuration option to tell xinha how to detect 
     1080   * when it is within your custom context. 
     1081   * 
     1082   * For more, see: http://www.coactivate.org/projects/xinha/custom-formatblock-options 
     1083   */ 
     1084  this.formatblockDetector = {}; 
     1085 
    10621086  this.dialogOptions = 
    1063   {  
     1087  { 
    10641088    'centered' : true, //true: dialog is shown in the center the screen, false dialog is shown near the clicked toolbar button 
    10651089    'greyout':true, //true: when showing modal dialogs, the page behind the dialoge is greyed-out 
     
    49024926        for ( var indexBlock in this.config.formatblock ) 
    49034927        { 
     4928          var blockname = this.config.formatblock[indexBlock]; 
    49044929          // prevent iterating over wrong type 
    4905           if ( typeof this.config.formatblock[indexBlock] == 'string' ) 
     4930          if ( typeof blockname == 'string' ) 
    49064931          { 
    4907             blocks[blocks.length] = this.config.formatblock[indexBlock]; 
     4932            blocks[blocks.length] = this.config.formatblockDetector[blockname] || blockname; 
    49084933          } 
    49094934        } 
     
    49114936        var match = this._getFirstAncestorAndWhy(this.getSelection(), blocks); 
    49124937        var deepestAncestor = match[0]; 
    4913         var matchIndex = match[1];  
     4938        var matchIndex = match[1]; 
    49144939 
    49154940 
Note: See TracChangeset for help on using the changeset viewer.