-----------------------------------------------------------------------------------
-------------------- How to develop a command in AXEL-FORMS  ----------------------
-----------------------------------------------------------------------------------

Stéphane Sire
Last update: 2012-12-19

Summary
=======
Command functionalities
=======================

Command registration
====================

The $axel.command.register method takes as parameter a command identifier ...

The check option instructs the command module to disable the command host node (by setting its disabled property to true) in case the associated editor pointed to by the data-target attribute does not exist. This is useful if you do not want the command to be enabled in that case (most probable if it depends on the missing editor's content).

$axel.command.register( 'identifier', { check : true } | null, // option hash _Command );
The option hash only supports a single 'error' option. The parameter hash defines the default values for the extra parameters which can be declared ... The method hash ... The "this" object inside methods will refer to the binding instance. Note that it is always possible to use a closure to define binding's private variables and methods.
Command parameters
==================

Scope of Commands
=================
Command file skeleton
=====================

The code below can be used as a template for writing a new command class.

(function ($axel) { // you may use the closure to declare private objects and methods here ////////////////////////////////// // Command constructor function // ////////////////////////////////// function _Command ( identifier, node, doc ) { // identifier is the name of the target editor associated with the command // node is the DOM node that hosts the command declaration // doc is the document where the command is instantiated $(node).bind('click', $.proxy(this, 'execute')); } /////////////////////// // Command prototype // /////////////////////// _Command.prototype = { // conventional execute method to trigger command execution execute : function (event) { } }; $axel.command.register( 'name', { check : true } // option hash _Command, ); }($axel));