Collapse.hpp

Sets up a collapsable DOM element.

class CollapseCoupling
#include <Collapse.hpp>

CollapseCoupling class maintains a group of targets and controllers. When a controller is clicked on a web page, all the associated targets will change state (expand/collapse).

Public Functions

inline CollapseCoupling(Widget controller, Widget target, const bool expanded = false, const std::string in_class = "")

Constructor which takes web elements as the controller and target. It will put each in a vector and call the constructor which takes vectors as controller and target parameters.

inline CollapseCoupling(vector<Widget> controllers, vector<Widget> targets, const bool expanded = false, const std::string in_class = "")

Constructor which takes vectors of web elements as the controller and target It will create the collapse coupling by adding necessary HTML attributes to all controllers and targets

inline CollapseCoupling(const std::string controller, const std::string target, const bool expanded = false, const std::string in_class = "")

Constructor which takes strings as the controller and target It will put each in a Div element and call the constructor which takes web elements as controller and target parameters.

inline void AddController(Widget controller, const bool expanded)

Adds a controller to the vector of controllers for this CollapseCouple

Parameters:
  • controller – new controller to add to coupling is of type Widget

  • expanded – initial state of the target(s), is it expanded or not?

inline void AddController(const std::string controller, const bool expanded)

Adds a controller to the vector of controllers for this CollapseCouple.

Parameters:
  • controller – new controller to add to coupling is of type string

  • expanded – initial state of the target(s), is it expanded or not?

inline void AddTarget(internal::FacetedWidget widget, const bool expanded)

Adds a target to the vector of targets for this CollapseCouple

Parameters:
  • widget – new target to add to coupling is a web element

  • expanded – initial state of the target(s), is it expanded or not?

inline void AddTarget(const std::string target, const bool expanded)

Adds a target to the vector of targets for this CollapseCouple

Parameters:
  • target – new target to add to coupling is a string

  • expanded – initial state of the target(s), is it expanded or not?

inline std::string GetTargetClass()

Returns the target_class associated with this CollapseCouple.

inline vector<Widget> &GetControllerDivs()

Returns the vector of all controllers associated with this CollapseCouple.

inline Widget &GetControllerDiv(const size_t index = 0)

Returns the controller at the given index.

inline vector<Widget> &GetTargetDivs()

Returns the vector of all targets associated with this CollapseCouple.

inline Widget &GetTargetDiv(const size_t index = 0)

Returns the target at the given index.

Private Members

vector<Widget> targets
vector<Widget> controllers
std::string target_class

Private Static Attributes

static int counter = 0