Zopim is now called Zendesk Chat. All API functionality will continue to work as normal and the namespace will not change in the immediate future.

Javascript API

$zopim.livechat.button

Customize and control the chat button.

Summary
$zopim.livechat.buttonCustomize and control the chat button.
Functions
setColorSet the color of the widget.
setHideWhenOfflineConfigure whether the chat button is displayed when the account is offline.
hideHide the chat button.
showShow the chat button.
setOffsetVerticalSet the vertical offset of the chat button from the edge of the browser window.
setOffsetVerticalMobileSet the vertical offset of the chat button on mobile from the edge of the browser window.
setOffsetHorizontalSet the horizontal offset of the chat button from the edge of the browser window.
setOffsetHorizontalMobileSet the horizontal offset of the chat button on mobile from the edge of the browser window.
setPositionSet position of the chat button.
setPositionMobileSet the position of the chat button on mobile devices.

Functions

setColor

Set the color of the widget.

Important: This function is deprecated and may be removed in the future.  Use “$zopim.livechat.theme.setColor” instead.

Note: theme.reload must be called after setColor for changes to take effect (see example below).

Parameters

colorWidget color, in hexadecimal format (‘#AABBCC’)

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.setColor('#FFCC00');
    $zopim.livechat.theme.reload(); // apply new theme settings
  });

</script>

setHideWhenOffline

function setHideWhenOffline(bool)

Configure whether the chat button is displayed when the account is offline.

This setting may be overridden by other API functions.

Parameters

booltrue to hide the chat button when the account is offline, false to show the chat button (boolean)

hide

function hide()

Hide the chat button.

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.hide();
  });

</script>

show

function show()

Show the chat button.

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.show();
  });

</script>

setOffsetVertical

function setOffsetVertical(distance)

Set the vertical offset of the chat button from the edge of the browser window.

Parameters

distanceDistance from the edge of the browser window, in pixels (number)

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.setOffsetVertical(20);
  });

</script>

setOffsetVerticalMobile

function setOffsetVerticalMobile(distance)

Set the vertical offset of the chat button on mobile from the edge of the browser window.

Parameters

distanceDistance from the edge of the browser window, in pixels (number)

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.setOffsetVerticalMobile(20);
  });

</script>

setOffsetHorizontal

function setOffsetHorizontal(distance)

Set the horizontal offset of the chat button from the edge of the browser window.

Parameters

distanceDistance from the edge of the browser window, in pixels (number)

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.setOffsetHorizontal(30);
  });

</script>

setOffsetHorizontalMobile

function setOffsetHorizontalMobile(distance)

Set the horizontal offset of the chat button on mobile from the edge of the browser window.

Parameters

distanceDistance from the edge of the browser window, in pixels (number)

Example

<script>

  $zopim(function() {
    $zopim.livechat.button.setOffsetHorizontalMobile(30);
  });

</script>

setPosition

function setPosition(position)

Set position of the chat button.

Allowed values

  • br (Bottom right)
  • bm (Bottom middle)
  • bl (Bottom left)
  • tr (Top right)
  • tm (Top middle)
  • tl (Top left)

Parameters

positionChat button position (string)

Example

Select chat button position:
<a href="javascript:void($zopim.livechat.button.setPosition('bl'))">Bottom left</a>
<a href="javascript:void($zopim.livechat.button.setPosition('bm'))">Bottom middle</a>
<a href="javascript:void($zopim.livechat.button.setPosition('br'))">Bottom right</a>
<a href="javascript:void($zopim.livechat.button.setPosition('tl'))">Top left</a>
<a href="javascript:void($zopim.livechat.button.setPosition('tm'))">Top middle</a>
<a href="javascript:void($zopim.livechat.button.setPosition('tr'))">Top right</a>

setPositionMobile

function setPositionMobile(position)

Set the position of the chat button on mobile devices.

Allowed values

  • br (Bottom right)
  • bl (Bottom left)

Parameters

positionChat button position on mobile devices (string)
function setHideWhenOffline(bool)
Configure whether the chat button is displayed when the account is offline.
function hide()
Hide the chat button.
function show()
Show the chat button.
function setOffsetVertical(distance)
Set the vertical offset of the chat button from the edge of the browser window.
function setOffsetVerticalMobile(distance)
Set the vertical offset of the chat button on mobile from the edge of the browser window.
function setOffsetHorizontal(distance)
Set the horizontal offset of the chat button from the edge of the browser window.
function setOffsetHorizontalMobile(distance)
Set the horizontal offset of the chat button on mobile from the edge of the browser window.
function setPosition(position)
Set position of the chat button.
function setPositionMobile(position)
Set the position of the chat button on mobile devices.