core_message/toggle_contact_button

Module to add/remove contact using ajax.

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Methods

(inner) addContact(element)

Source:

Send a request to the server to add the current user as a contact. The contents of the button are changed to the remove contact button upon success.

Parameters:
Name Type Description
element object

jQuery object for the button

(inner) enhance(element)

Source:

Enhances the given element with a loading gif and event handles to make ajax requests to add or remove a contact where appropriate.

Parameters:
Name Type Description
element object

jQuery object for the button

(inner) getUserId(element) → {int}

Source:

Get the id for the user being viewed.

Parameters:
Name Type Description
element object

jQuery object for the button

Returns:
Type
int

(inner) getUserId(element) → {int}

Source:

Get the id for the logged in user.

Parameters:
Name Type Description
element object

jQuery object for the button

Returns:
Type
int

(inner) isContact(element) → {bool}

Source:

Check the state of the element, if the current user is a contact or not.

Parameters:
Name Type Description
element object

jQuery object for the button

Returns:
Type
bool

(inner) isLoading(element) → {bool}

Source:

Check if this element is currently loading.

Parameters:
Name Type Description
element object

jQuery object for the button

Returns:
Type
bool

(inner) removeContact(element)

Source:

Send a request to the server to remove the current user as a contact. The contents of the button are changed to the add contact button upon success.

Parameters:
Name Type Description
element object

jQuery object for the button

(inner) sendRequest(element, request) → {object}

Source:

Sends an ajax request to the server and handles the element state while the request is being performed.

Parameters:
Name Type Description
element object

jQuery object for the button

request object

Request hash to send

Returns:

jQuery promise

Type
object

(inner) setContact(element)

Source:

Record that the user is a contact.

Parameters:
Name Type Description
element object

jQuery object for the button

(inner) setNotContact(element)

Source:

Record that the user is not a contact.

Parameters:
Name Type Description
element object

jQuery object for the button