Show:

File: doc/api/util-api.js

/**
* A set of helper methods for use by jsPlumb.
* @class jsPlumbUtil
* @static
*/

/** 
* Returns whether the given object is an Array. 
* @method isArray
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is an Array, false otherwise.
*/

/** 
* Returns whether the given object is a String. 
* @method isString
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is a String, false otherwise.
*/

/** 
* Returns whether the given object is a Boolean. 
* @method isBoolean
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is a Boolean, false otherwise.
*/

/** 
* Returns whether the given object is null. 
* @method isNull
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is null, false otherwise.
*/

/** 
* Returns whether the given object is an Object. 
* @method isObject
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is an Object, false otherwise.
*/
/** 
* Returns whether the given object is a Date. 
* @method isDate
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is a Date, false otherwise.
*/
/** 
* Returns whether the given object is a Function. 
* @method isFunction
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is a Function, false otherwise.
*/
/** 
* Returns whether the given object (an Object or Array) is empty. 
* @method isEmpty
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is empty, false otherwise.
*/
/** 
* Returns whether the given object is a Number. 
* @method isNumber
* @static
* @param {Object} obj Object to test
* @return {Boolean} True if the object is a Number, false otherwise.
*/

/**
* Merges one object into another, optionally folding individual values into arrays.
* @method merge
* @static
* @param {Object} a Object to merge into
* @param {Object} b Object to merge from.
* @param [String[]] [collations] Optional list of parameter keys for values that, if present in both 'a' and 'b', should result in an array with values from each (rather than the default behaviour of overwriting a's value with b's)
*/

/**
 * Provides event bind/fire functionality.
 * @class jsPlumbUtil.EventGenerator 
 */

/**
 * Binds a listener to one or more events.
 * @method bind
 * @param {String|String[]} event Name(s) of the event(s) to bind to. Note that if you provide multiple event names they all are bound with the same function.
 * @param {Function} listener Function to execute.
 * @param {Boolean} [insertAtStart=false] Whether or not to insert this listener at the start of the listener list, so it is fired before the other currently registered listeners.
 */

  /**
   * Fires an update for the given event.
   * @method fire
   * @private
   * @param {String} event Event to fire
   * @param {Object} value Value to pass to the event listener(s).
   * @param {Event} originalEvent The original event from the browser
   */

   /**
   * Clears either all listeners, or listeners for some specific event, or just some listener. You can call this method
   * with zero, one or two arguments: with zero arguments, all listeners are cleared. With one argument that is a string, all listeners for
   * the specified event type are cleared. With one argument that is a function, it is removed from the appropriate event list.
   * With two arguments, the first is an event type, and the second is a function to be unbound. In fact this is perhaps unnecessary
   * given that you can unbind a function just by passing it.
   * @method unbind
   * @param {String|Function} [eventOrListener] If a string, constrains the clear to just listeners for the event identified by the string. If a Function, unbinds this function wherever it may have been bound.
   * @param {Function} [listener] If provided, removes just this listener for the given event.
   */
   /**
   * Sets whether or not events are suspended.
   * @method setSuspendEvents
   * @param {Boolean} val Whether or not to suspend events.
   */
   /**
   * Checks whether or not events are currently suspended.
   * @method isSuspendEvents
   * @return {Boolean} True if events are suspended, false otherwise.
   */
   /**
   * Removes all listeners.
   * @method cleanupListeners
   */

/**
* Replaces values inside some JS object according to a given path spec. A path spec is a string in dotted notation,
* with each component optionally declaring an array index. Some examples are:
*
* foo.bar
* foo.baz[2]
* foo.qux[3].baz[3].shwee
*
* The function fails gracefully if the path identifies a non-existent object.
*
* @method jsPlumbUtil.replace 
* @param {Object} inObj Object to perform replacements inside.
* @param {String} path Path to use for replacements
* @param {Object} value Value to set.
*/