Changeset 1196 for trunk


Ignore:
Timestamp:
11/08/09 04:34:16 (9 years ago)
Author:
gogo
Message:

Ticket #1446

Provide a means for adding custom hooks into the ContextMenu? plugin.

xinha_config.ContextMenu.customHooks = {
	 'a': [ 
		['Label', function() { alert('Action'); }, 'Tooltip', '/__classpath/xinha/images/ed_copy.gif' ] 
	      ] 
};
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/testbed.html

    r1084 r1196  
    5555      xinha_plugins = xinha_plugins ? xinha_plugins : 
    5656      [ 
    57         'CharacterMap', 'SpellChecker', 'Linker' 
     57        'CharacterMap', 'SpellChecker', 'Linker', 'ContextMenu' 
    5858      ]; 
    5959             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :) 
     
    8686       xinha_config.fullPage = true; 
    8787       xinha_config.CharacterMap.mode = 'panel'; 
     88       xinha_config.ContextMenu.customHooks = { 'a': [ ['Label', function() { alert('Action'); }, 'Tooltip', '/__classpath/xinha/images/ed_copy.gif' ] ] } 
    8889/* 
    8990       // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL 
  • trunk/plugins/ContextMenu/ContextMenu.js

    r1084 r1196  
    2727 
    2828Xinha.Config.prototype.ContextMenu = { 
    29         disableMozillaSpellCheck : false 
     29        disableMozillaSpellCheck : false, 
     30  customHooks : { } // 'a': [ ['Label', function() { alert('Action'); }, 'Tooltip', '/icon.jpg' ] ] 
    3031} 
    3132 
     
    238239                                  Xinha._lc("Create a link", "ContextMenu"), 
    239240                                  config.btnList["createlink"][1] ]); 
     241 
     242  if(editor.config.ContextMenu.customHooks[currentTarget.tagName.toLowerCase()])  
     243  {  
     244    var items = editor.config.ContextMenu.customHooks[currentTarget.tagName.toLowerCase()];  
     245     
     246    for (var i = 0; i < items.length; ++i) 
     247    { 
     248      menu.push(items[i]);  
     249    } 
     250  } 
    240251 
    241252        for (var i = 0; i < elmenus.length; ++i) 
Note: See TracChangeset for help on using the changeset viewer.