modo.AceEditor
A modo element wrapper for the Ace text editor from http://ace.c9.io/. It also implements the full get/set functionality to be used inside a FormContainer.
This element definition will automatically try to load the Ace sources from MaxCDN.
Make sure to include the Ace source manually before loading this module if you want to use a local copy of Ace, instead of a hosted one.
If you have suggestions about functionality, please leave a comment below.
Constructor
modo.AceEditor(params)modo.AceEditor
The following list of parameters can be used in the params object, passed to the constructor. Parameters in [brackets] are optional.
Property | Description |
---|---|
[theme] | Which theme should be loaded for Ace? . Defaults to |
[mode] | The editor mode you want to use. Defaults to |
[className] | A string with custom CSS classes to apply to the generated DOM element |
[dataAttributes] | A object with attributes to assign to the generated DOM element. Omit the "data-" part. So for example |
[el] | The jQuery enhanced DOM element to be generated. If nothing is set, a standard DIV container will be created. If you want to use a different DOM element, pass a jQuery generated DOM element to this parameter. |
[showEffect] | The default show effect for the element. See associated property description. Default: |
[hideEffect] | The default hide effect for the element. See associated property description. Default: |
Properties
_editorobject
Reference to the ace editor object.
Inherited Properties from modo.Element
elObject
Contains the jQuery enhanced DOM Node of this modoJS element.
modoIdNumber
Contains a internally given, numeric ID for this element.
visibleBool
Will be set by .show()
and .hide()
. Access this property to check the current visibility of the element.
showEffectobject
Set a default show effect (like the options you can pass to the show()
/ hide()
methods.
Example:
element.showEffect = {
effect: 'slideDown',
effectArgs: ['fast']
};
hideEffectobject
Define a default hide effect instead of a simple, instant hide.
Methods
get()string
Returns the editor contents.
set(value, [options])this
Will set the editor contents to the given value. Triggers a change
event unless you pass {silent: true}
as a option object.
setMode(mode, [options])this
Sets a new syntax mode for the editor. Triggers a changeMode
event unless you pass {silent: true}
as a option object.
resize()this
Calls the editors resize method, if the editor has been initialized yet.
Inherited Methods from modo.Element
setFlexible([value])this
Pass either true or false to this value to make the element stretch inside a modo.FlexContainer element.
show(options)this
Make the connected DOM object visible and trigger the Backbone Event "show".
You can control the way the element is shown by passing an object of options.
Example:
element.show({
effect: 'slideDown',
effectArgs: ['fast']
});
hide()this
Make the connected DOM object invisible and trigger the Backbone Event "hide".
You can control the hide effect the same way as with the show()
method.
addClass(classname, doPrefix)this
Will add another class name to the DOM element. The class name will be automatically prefixed (i.e. with mdo-) if doPrefix = true
(default).
removeClass(classname, doPrefix)this
Will remove a class name from the DOM element. The class name will be automatically prefixed.
addClassTemporary(classname, timeout, doPrefix)this
Helps with adding a classname temporarily to the object. Just call this method and after the specified amount of time, the added class(es) will be removed.
Note: All modoJS Objects are extended with all methods of the Backbone.Events class.
Events
change
Triggered when the elements value has been changed through set()
or a user input.
changeMode
Triggered, when the editors syntax mode has been changed through setMode()
.
Inherited Events from modo.Element
show
Triggered, when the object has been displayed through show()
hide
Triggered, when the object has been hidden through hide()
CSS Classes
mdo-aceEditor
Applied on the element.
Heads up: Most styling possibilities take place in ace's css classes. Read more about it in the ace documentation.
Inherited CSS Classes from modo.Element
mdo-element
Basic class that will be applied to every element that extends modo.Element
.
mdo-flexible
Will be applied to every modo element where setFlexible(true)
has been called upon.