Intro

Events in Ctesius are small JavaScript callbacks which will be run a set times, or after certain page interactions. Events are registered by calling Ctesius.registerEvent with the event name and a callback function, which can optionally take n arguments:

Ctesius.registerEvent('EVENT_NAME', function(..ARGS..){
    ...
});

Events can also be triggered by ‘kicking’:

Ctesius.kickEvent('EVENT_NAME', arg1, arg2, argn...);

Toggles

If you want plug in to the toggle system (grid view, list view, etc), the following events will be kicked when appropriate:

  • before_properties_map_and_list_toggle_view_displayed
  • before_properties_map_toggle_view_displayed
  • before_properties_map_toggle_view_displayed
  • properties_grid_toggle_view_displayed
  • properties_map_and_list_toggle_view_displayed
  • properties_map_toggle_view_displayed
  • togglable_list_displayed
  • render_tab(tab_name)
  • no_root_view_displayed

Map events

The following events will trigger when there is an action on a map.

When various help texts are displayed on a drawable map the following actions may be kicked:

  • deletebannertoggled
  • drawbannertoggled
  • editbannertoggled
  • deletebanner
  • deletebannertoggled

When a map state has been changed and new properties should be fetched:

  • before_draggable_map_updated

Called before a Draggable (or drawn) map is updated with fresh properties called from the server. Useful for showing ‘updating map’ style page statuses.

  • draggable_map_updated(properties)

Called when results have been returned from a draggable map update. Returns the raw response from the server. The map has not yet been updated with new pins.

  • map_marker_rendered(property)

Called when a map marker has been rendered for the given property.

When interacting with a map:

  • map_marker_opened(marker)

Called when a map marker’s popup section has been opened.

  • map_view_rendered

Called whenever a map has been rendered.

  • small_map_view_rendered
  • branch_map_view_rendered
  • page_reloading

Some actions, like a redrawing of a polygon, may require a reloading of the page if a tab is switched. This event is kicked just before that happens, giving time for the page to show a ‘loading’ style alert.

Saving Properties

The following events will be kicked when a saved property is added or removed. The by_action events signify that the user has saved a property where it was not previously saved - these events are useful for displaying a flash message or a subtle animation. Without the by_action, the event should be used to decorate saved properties or remove descorating. For instance, changing text from ‘Save property’ to ‘Remove property’:

  • before_saved_property_removed_by_action(property)
  • after_saved_property_added_by_action(property)
  • saved_property_added(property)
  • saved_property_removed(property)

The following methods will be called if a saved properties list is rendered:

  • saved_properties_view_rendered
  • saved_property_view_rendered(property)

Saved Searches

Saved searches work in a similar way to saved properties:

  • saved_search_added
  • saved_search_removed

Users

  • before_create_new_user

Called before validation on a user, when data is submitted using the action.

  • user_history_ready
  • user_history_search_added
  • user_log_in_failed
  • user_logged_in
  • user_logged_out
  • user_sign_up
  • user_sign_up_failed
  • before_user_log_in
  • before_user_sign_up

Views

When a JavaScript view is rendered, events are typically kicked before and after:

  • disambiguation_rendered
  • before_most_recent_search_view_rendered
  • before_redirection_flash_ready

Called before the system will display a flash notification (#/flash/some-notification):

  • redirection_flash_ready
  • user_micro_view_rendered
  • user_profile_lightview_rendered
  • before_user_micro_view_rendered
  • before_user_profile_lightview_rendered
  • previous_property_rendered
  • next_property_rendered
  • most_recent_search_view_rendered

Misc

  • before_search_form_submitted

Called before validation search form data.