Class: API


new API()
X-doc-API - available as global CMS object in the editor iframe

Version: 1.2 (2014-02-03)



Space

Methods

applyRichTextEditorConfig(unitId, section, config)
Arguments:
  • unitId (String) – The id of the unit
  • section (String) – The name of the section
  • config (Object) – The RichTextEditor config object which will be merged with the default config
Applies the given RichTextEditor config object to the default config set in the module of the unit for a specific section of a unit

Example

CMS.applyRichTextEditorConfig('MUNIT-9b6e6080-c9df-4754-a688-5a5c347810e7-MUNIT', 'text', {
  bold: false,
  italic: true,
  customStyles: [{
    label: 'Headline 1',
    element: 'h1',
    classes: ''
  }, {
    label: 'Headline 2',
    element: 'h2',
    classes: ''
  }, {
    label: 'API-Style',
    element: 'p',
    classes: 'myAPIStyle'
  }]
});

// Another Example with all possible properties
CMS.applyRichTextEditorConfig('MUNIT-9b6e6080-c9df-4754-a688-5a5c347810e7-MUNIT', 'text', {
  bold: true,
  strikethrough: true,
  italic: true,
  subscript: true,
  underline: true,
  superscript: true,
  bullist: true,
  link: true,
  numlist: true,
  table: true,
  enterKey: "paragraph", // none|paragraph|linebreak
  customStyles: [{
    label: "Headline 1",
    element": "h1",
    classes": "myClass"
  }],
  linkTargets: [
    ["", "Same Window"],
    ["_blank", "New Window"]
  ]
});

Space

createPreviewTicket(callback, options *opt*, options.protect, options.credentials, options.credentials.username, options.credentials.password, options.ticketLifetime, options.sessionLifetime, options.remainingCalls, scope *opt*)
Arguments:
  • callback (CMS.api.API~createTicketCallback) – The callback function to be called after the ticket has been created
  • optionsoptional (Object) – Configuration of the ticket, e.g. to protect it with credentials
  • scopeoptional (Object) – The object in whose scope the callback function should be executed
Creates a preview ticket for the current page or template so external users can preview it without the need of having a regular user account.

Example

CMS.createPreviewTicket(function (ticket) { alert(ticket.url); }, {
  protect: false,
  credentials: {
    username: 'test',
    password: 'test'
  },
  ticketLifetime: 60,
  sessionLifetime: 60,
  remainingCalls: 1
}, this);

Space

deselect()
Deselects the specified unit in both tree and iframe.

Space

duplicate(unitId) Boolean()
Arguments:
  • unitId (String) – The id of the unit which is to be duplicated
Duplicates the given unit

Space

get(id, includeFormValues *opt* ) Object()
Arguments:
  • id (String) – The id of the unit
  • includeFormValuesoptionaltrue (Boolean) – include the formValues
Gets the configuration of the unit.

Space

getAllUnitIds(moduleId) Array.String()
Arguments:
  • moduleId (String) – unit ids from the given module id
Returns the unit ids of all units of a specific module

Since: 1.1 (2014-01-08)



Space

getColorById(colorId) String()
Arguments:
  • colorId (String) – The id of the color
Returns the rgba values for the given color id

Space

getCurrentResolution() String()
Returns the id currently active resolution

Space

getImageUrl(mediaDbId, width *opt* , quality *opt* ) String()
Arguments:
  • mediaDbId (String) – for example: MDB-uuid-MDB
  • widthoptional (Number) – width of the image; 0 = original size (height is determined automatically)
  • qualityoptional (Number) – quality 0 (bad) - 100 (best) - works only on formats that support it, like jpg
Get image URL by Media DB item

Space

getInsertable(unitId) Object()
Arguments:
  • unitId (String) – The id of the unit in whose context units are going to be inserted
Returns the sibling and child units of the given unit which can be inserted (TODO: this is only valid in the page context? Are these Ghost Units?)

Space

getMediaUrl(mediaDbId, download *opt* ) String()
Arguments:
  • mediaDbId (String) –
  • downloadoptional (Boolean) – weather the response should download the file (content-disposition: attachment)
Get Media URL by Media DB ID

Since: 1.2 (2014-02-03)



Space

getModule(moduleId) Object()
Arguments:
  • moduleId (String) – The id of the module
Gets meta-data of a module

Space

getResolutions() Resolutions()
Get configured resolutions (breakpoints) for responsive CSS

Space

getSelected(includeFormValues *opt* ) Object()
Arguments:
  • includeFormValuesoptional (Boolean) – include the formValues; default = true
Gets the configuration of the currently selected unit.

Space

getVisualHelpersState() Object()
Returns the state of the visual helpers (if they should be visible/hidden)

Space

i18n(input) String|Mixed()
Arguments:
  • input (Object) – An object with texts for all available languages (e.g. {de: “Hallo Welt!”, en: “Hello World!”}
Gives the text in current application language for given input

Space

insert(unitId, position, ownerUnitId) Boolean()
Arguments:
  • unitId (String) – The id of the unit which should be inserted
  • position (String) – The position where it should be inserted (above, below, inside)
  • ownerUnitId (String) – The id of the unit in whose context the new unit should be inserted
Inserts the given unit in the context of the given owner unit at the given position

Space

moveDown(unitId) Boolean()
Arguments:
  • unitId
Moves the unit down in the structure tree

Space

moveUp(unitId) Boolean()
Arguments:
  • unitId
Moves the unit up in the structure tree

Space

on(event, filter *opt*, handler, scope *opt*)
Arguments:
  • event (String) –
The name of the event, use one of the following:
Arguments:
  • filteroptional (CMS.api.API~EventFilter|String) – The id of a unit or a filter object
  • handler (CMS.api.API~eventListenerCallback) – The callback function
  • scopeoptional (Object) – The execution context for the event handler
Register listener for a CMS Event

Space

openFormPanel(varName *opt*, showPanel *opt*)
Arguments:
  • varNameoptional (String) – The name of the unit property whose form group has to be opened
  • showPaneloptionaltrue (Boolean) – <tt>false</tt> to prevent activation of the containing form panel.
Opens the form group which corresponds to the given form group id. If no argument is passed, it will just bring the form panel to front.

Space

openInsertWindow(unitId *opt*, position *opt*)
Arguments:
  • unitIdoptional (String) – The id of the unit in whose context the insert window should be opened
  • positionoptional (Integer) –
The default position choice in the dialog. Possible values:
  • -1 - above
  • 0 - inside
  • 1 - below (default)
Tells the CMS to open the "Insert Unit" window

Space

openTreePanel()
Opens the structure tree panel

Space

preventRendering()
Informs the CMS that the module developer wants to stop the next reload from happening. NOTE: Call to this function is only allowed in the following event handlers: beforeRenderPage formValueChange

Space

processInsertedUnits(filter *opt* , callback *opt* , scope *opt* ) Array()
Arguments:
  • filteroptional (Object) – A filter object, e.g. to filter by moduleId
  • callbackoptional (function) – The callback function to be called for each inserted unit
  • scopeoptional (Object) – The object in whose scope the callback function should be executed
Processes all units which were inserted before the current page/template reload.

Deprecated: Use http://developers.rukzuk.com/js_module_api.html#getAllUnitIds after a reload

Space

refresh(unitId *opt*)
Arguments:
  • unitIdoptional (String) – The id of the unit which should be re-rendered
Re-renders the specified unit or if no unit id was given the whole page.

Space

remove(unitId, showConfirmation *opt*, callback *opt*, scope *opt*)
Arguments:
  • unitId (String) – The id of the unit which is to be deleted.
  • showConfirmationoptional (Boolean) – Whether the CMS should ask the user for confirmation before removing the unit
  • callbackoptional (Boolean) – The function which will be executed when the unit is actually deleted or not
  • scopeoptional (Object) – The object in whose scope the callback function should be executed
Removes the specified unit.

Space

select(unitId)
Arguments:
  • unitId (String) – The id of the unit which should be selected
Selects the specified unit in both tree and iframe.

Space

set(id, key, value) Boolean()
Arguments:
  • id (String) – The id of the unit
  • key (String) – The name of the unit property which is changed
  • value (Mixed) – The new value of the unit property
Store the given key value pair in the configuration of the specified unit and updates the editor window

Space

setInfo(id, key, value) Boolean()
Arguments:
  • id (String) – The id of the unit
  • key (String) – The name of the meta property which is changed
  • value (Mixed) – The new value of the meta property
Allows to set meta information which should visualize unit settings (replaces http://developers.rukzuk.com/js_module_api.html#setName)

Space

setName(id, name) Boolean()
Arguments:
  • id (String) – The id of the unit
  • name (String) – The new name of the unit
Updates the specified unit's name

Deprecated: Does not effect the unit's name anymore; Use http://developers.rukzuk.com/js_module_api.html#setInfo visualize unit settings

Space

un(event)
Arguments:
  • event (String) – The name of the event
Remove listener for a CMS Event

Space

updateFormFieldConfig(unitId, key, config)
Arguments:
  • unitId (String) – The id of the unit
  • key (String) – The variable name of the form field
  • config (Object) – The form field config object
Updates the configuration of a form field (e.g. the options of a combobox/drop-down element)

Example

CMS.updateFormFieldConfig(unitId, 'additionalSelector', {
  fieldLabel: 'Filter',
  options: [
    ['.text a', 'Link'],
    ['.text p', 'Text']
  ]
});

Space

Type Definitions

createTicketCallback(ticket, ticket.id, ticket.url, ticket.protect, ticket.credentials, ticket.credentials.username, ticket.credentials.password, ticket.ticketLifetime, ticket.sessionLifetime, ticket.remainingCalls)
Arguments:
  • ticket (Object) – resulting ticket object


Space

Object EventFilter()
:param moduleId: only listen to event of units from the given module id

Event filter

eventListenerCallback(config)
Arguments:
  • config (Object) – config object depends on type of event
Event listener function

Space

Events

afterRemoveUnit()
Arguments:
  • unitId (String) – id of the unit which is open in editor


Space

afterRenderPage()


Deprecated: Use http://developers.rukzuk.com/js_module_api.html#getAllUnitIds after a reload

Space

afterRenderUnit()
Arguments:
  • unitId (String) – id of the unit which is open in editor


Space

beforeInsertUnit()
Arguments:
  • config (Object) – Config Object


Space

beforeMoveUnit()
Arguments:
  • config (Object) – Config Object


Space

beforeRemoveUnit()
Arguments:
  • unitId (String) – id of the unit which is open in editor


Space

beforeRenderPage()
Page is about to reload. You can cancel this reload/unit-replace by calling http://developers.rukzuk.com/js_module_api.html#preventRendering.

Space

beforeRenderUnit()
Arguments:
  • unitId (String) – id of the unit which is open in editor


Space

formValueChange()
Arguments:
  • config (Object) – Config Object
A form value has changed. You can prevent the reload/unitReplace by calling http://developers.rukzuk.com/js_module_api.html#preventRendering.

Space

frameMouseEnter()
Arguments:
  • config (Object) – Config Object


Space

frameMouseOut()
Arguments:
  • config (Object) – Config Object


Space

resolutionChange()
Arguments:
  • config (Object) – A configuration Object
Fired after changing the resolution in the client

Since: 2014-1-21



Space

showEditor()
Arguments:
  • unitId (String) – id of the unit which is open in editor


Space

treeMouseEnter()
Arguments:
  • config (Object) – Config Object


Space

treeMouseOut()
Arguments:
  • config (Object) – Config Object


Space

unitDeselect()
Arguments:
  • config (Object) – Config Object


Space

unitFrameDeselect()
Arguments:
  • config (Object) – Config Object


Space

unitFrameSelect()
Arguments:
  • config (Object) – Config Object


Space

unitSelect()
Arguments:
  • config (Object) – Config Object


Space

unitTreeDeselect()
Arguments:
  • config (Object) – Config Object


Space

unitTreeSelect()
Arguments:
  • config (Object) – Config Object


Space

visualHelpersStateChange()
Arguments:
  • config (Object) – Config Object

Since: 8db1dfb (2013-03-11)



Space