Classes

Class ContentObjectAPI


Defined in: abstract-content-object.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ContentObjectAPI(id, success, error, settings)
Initializes this content object.
Field Summary
Field Attributes Field Name and Description
<static>  
ContentObjectAPI.WRITEABLE_PROPS
An array of all properties of an object that can be changed by the user.
<static>  
ContentObjectAPI.WRITEABLE_PROPS_CONSTRAINTS

This object can contain various contrains for writeable props.

Method Summary
Method Attributes Method Name and Description
<static>  
ContentObjectAPI.clear()
Clears this object from its constructor's cache so that the next attempt to access this object will result in a brand new instance being initialized and placed in the cache.
<static>  
ContentObjectAPI.decode(str, success, error)
For a given string, replace all occurances of "<node>" with appropriate HTML markup, allowing notated tags to be rendered within the surrounding HTML content.
<static>  
ContentObjectAPI.encode($element, serializeFn)

Replaces tag blocks and editables with appropriate "<node *>" notation in a given string.

<static>  
ContentObjectAPI.folder(success, error)
Retrieves this objects parent folder.
<static>  
ContentObjectAPI.id()
Gets this object's id.
<static>  
ContentObjectAPI.localize(success, error)
Get a channel-local copy of this content object.
<static>  
ContentObjectAPI.nodeId()
Gets this object's node id.
<static>  
ContentObjectAPI.prop(property, value, error)
Reads the property `property' of this content object if this property is among those in the WRITEABLE_PROPS array.
<static>  
ContentObjectAPI.remove(success, error)
Deletes this content object from its containing parent.
<static>  
ContentObjectAPI.save(settings, success, error)
Saves changes made to this content object to the backend.
<static>  
ContentObjectAPI.unlocalize(success, error)
Remove this channel-local object, and delete its local copy in the backend.

Class Detail

ContentObjectAPI(id, success, error, settings)

Initializes this content object. If a `success' callback is provided, it will cause this object's data to be fetched and passed to the callback. This object's data will be fetched from the cache if is available, otherwise it will be fetched from the server. If this content object API contains parent chainbacks, it will get its parent to fetch its own data first.

Basic content object implementation which all other content objects will inherit from.

If a `success' callback is provided, it will cause this object's data to be fetched and passed to the callback. This object's data will be fetched from the cache if is available, otherwise it will be fetched from the server. If this content object API contains parent chainbacks, it will get its parent to fetch its own data first.

You might also provide an object for initialization, to directly instantiate the object's data without loading it from the server. To do so just pass in a data object as received from the server instead of an id--just make sure this object has an `id' property.

If an `error' handler is provided, as the third parameter, it will catch any errors that have occured since the invocation of this call. It allows the global error handler to be intercepted before stopping the error or allowing it to propagate on to the global handler.

Parameters:
{number|string|object} id
{function(ContentObjectAPI))=} success
Optional success callback that will receive this object as its only argument.
{function(GCNError):boolean=} error
Optional custom error handler.
{object} settings
Basic settings for this object - depends on the ContentObjetAPI Object used.
Throws:
INVALID_DATA If no id is found when providing an object for initialization.

Field Detail

ContentObjectAPI.WRITEABLE_PROPS

An array of all properties of an object that can be changed by the user. Writeable properties for all content objects.

ContentObjectAPI.WRITEABLE_PROPS_CONSTRAINTS

This object can contain various contrains for writeable props. Those contrains will be checked when the user tries to set/save a property. Currently only maxLength is beeing handled.

Example:

WRITEABLE_PROPS_CONSTRAINTS: {
   'name': {
       maxLength: 255
    } 
}

Method Detail

ContentObjectAPI.clear()

Clears this object from its constructor's cache so that the next attempt to access this object will result in a brand new instance being initialized and placed in the cache.

ContentObjectAPI.decode(str, success, error)

For a given string, replace all occurances of "<node>" with appropriate HTML markup, allowing notated tags to be rendered within the surrounding HTML content. The success() handler will receives a string containing the contents of the `str' string with references to "" having been inflated into their appropriate tag rendering.
Parameters:
{string} str
The content string, in which "" tags will be inflated with their HTML rendering.
{function(ContentObjectAPI))} success
Success callback that will receive the decoded string.
{function(GCNError):boolean=} error
Optional custom error handler.

{string} ContentObjectAPI.encode($element, serializeFn)

Replaces tag blocks and editables with appropriate "<node *>" notation in a given string. Given an element whose innerHTML is:

		<span id="GENTICS_BLOCK_123">My Tag</span>

encode() will return:

		<node 123>
Parameters:
{!jQuery} $element
An element whose contents are to be encoded.
{?function(!Element): string} serializeFn
A function that returns the serialized contents of the given element as a HTML string, excluding the start and end tag of the element. If not provided, jQuery.html() will be used.
Returns:
{string} The encoded HTML string.

{FolderAPI} ContentObjectAPI.folder(success, error)

Retrieves this objects parent folder.
Parameters:
{function(FolderAPI)=} success
Callback that will receive the requested object.
{function(GCNError):boolean=} error
Custom error handler.
Returns:
{FolderAPI} API object for the retrieved GCN folder.

{number} ContentObjectAPI.id()

Gets this object's id. We'll return the id of the object when it has been loaded - this can only be a localid. Otherwise we'll return the id which was provided by the user. This can either be a localid or a globalid.
Returns:
{number}

ContentObjectAPI.localize(success, error)

Get a channel-local copy of this content object.
Parameters:
{funtion(ContentObjectAPI)=} success
Optional callback to receive this content object as the only argument.
{function(GCNError):boolean=} error
Optional custom error handler.

{number} ContentObjectAPI.nodeId()

Gets this object's node id. If used in a multichannelling is enabled it will return the channel id or 0 if no channel was set.
Returns:
{number} The channel to which this object is set. 0 if no channel is set.

{?*} ContentObjectAPI.prop(property, value, error)

Reads the property `property' of this content object if this property is among those in the WRITEABLE_PROPS array. If a second argument is provided, them the property is updated with that value.
Parameters:
{String} property
Name of the property to be read or updated.
{String} value
Optional value to set property to. If omitted the property will just be read.
{function(GCNError):boolean=} error
Custom error handler to stop error propagation for this synchronous call.
Throws:
UNFETCHED_OBJECT_ACCESS if the object has not been fetched from the server yet
READONLY_ATTRIBUTE whenever trying to write to an attribute that's readonly
Returns:
{?*} Meta attribute.

ContentObjectAPI.remove(success, error)

Deletes this content object from its containing parent.
Parameters:
{function(ContentObjectAPI)=} success
Optional callback that receives this object as its only argument.
{function(GCNError):boolean=} error
Optional customer error handler.

ContentObjectAPI.save(settings, success, error)

Saves changes made to this content object to the backend.
Parameters:
{object=} settings
Optional settings to pass on to the ajax function.
{function(ContentObjectAPI)=} success
Optional callback that receives this object as its only argument.
{function(GCNError):boolean=} error
Optional customer error handler.

ContentObjectAPI.unlocalize(success, error)

Remove this channel-local object, and delete its local copy in the backend.
Parameters:
{funtion(ContentObjectAPI)=} success
Optional callback to receive this content object as the only argument.
{function(GCNError):boolean=} error
Optional custom error handler.

Documentation generated by JsDoc Toolkit 2.3.2 on Tue Apr 16 2024 17:52:29 GMT-0000 (UTC)