MooRTE Hash: Elements

Hash used to store all buttons and elements that are available for use by the Rich Text Editor.

Syntax

 var ME = MooRTE.Elements;

MooRTE.Elements Method: extend

 MooRTE.Elements.extend(object);

Returns

  • (hash) - The instance of MooRTE.Element

Arguments

(object) - An object whose properties will be converted to an element of the RTE. All properties are optional.

  • The key is prepended with "rte" and added to the element as a class
     
    							MyBtn:{}  
    							//becomes
    							 
    						
  • All properties that do not have special meaning will become properties of the element that is created.
     
    							myBtn:{widget:'engaged'}
    							//becomes
    								
    						
  • The properties with special meaning are:
    • element: [string, usually defaults to 'a'] - the type of element to be created. If 'type' is an input (eg. type:'password'), defaults to 'input' instead.
    • shortcut: [string] - keyboard character that when pressed together with the 'Ctrl' key will run the onClick method.
    • img: [string] - url to the background image (if a number, sets the background-position & image must be defined in CSS).
    • contains: [JSON object, array, or string] - other elements (keys) that should be included into this element. run between 'onLoad' and 'onShow'.
    • onLoad: [function, see options below] - function to run when button is loaded onto screen.
    • onClick: [see options below] - function to run when button is clicked.
    • onUpdate: [see options below] - function to run when on every keystroke or mouseclick within the fields the button affects.
    • args: [mixed, DEPRECATED] - arguments to be passed into the function, or a function to be run to receive the arguments. [Passed into all onEvent methods when they contain a function reference.]
  • In addition, the following are defined in the add function, and only run when hiding or showing/creating a new group.
    • onHide - function to run when group is hidden
    • onShow - function to run when group is created or shown
    • hides - Deprecated - array of other elements to hide when this is shown

Option: OnEvent (Load,Click,Show,Hide)

  • Within the function, 'this' refers to the button being pressed.
  • If argument is the string 'on[Event]', it references the pointed to event. In this example, 'alive!' will be alerted when the button loads & when clicked.
    							MyBtn:{ 
    								onLoad:function(){alert('alive!')}, 
    								onClick:'onLoad' 
    							}
    						
  • If argument is a string, MooRTE will assume it to be a Utilities method call.
    The following are identical:
     
    							onClick:'exec(indent)'
    							onClick:function(){ MooRTE.Utilities.exec('indent'); } 
    						
  • If argument is an array or object, it is passed to MooRTE.Utilities.add.
    The following are identical:
     
    							onClick: ['bold','italic']
    							onClick: 'add([bold,italic])'
    							onClick: function(){ MooRTE.Utilities.add('bold, italic'); } 
    						

Examples

 
					MyEl:{ element:'myEl', 
						onClick:function(){ alert(this.get('tag'))}  }
					// creates: 
					// when clicked, will alert "myEL"!
				
MooRTE.Elements MooRTE.Elements.extend