ClassBasedOnClickListener
public struct ClassBasedOnClickListener
A ClassBasedOnClickListener
takes a closure which is performed if a given html class
is clicked. The closure will reveice the content of the specified parameter.
Eg. A ClassBasedOnClickListener with the className quote
and parameterName id
with the given epub html content <section class="quote" id="12345">
would call the given closure on a click on this section with the String 12345
as parameter.
-
The name of the URL scheme which should be used. Note: Make sure that the given
String
is a valid as scheme name.Declaration
Swift
public var schemeName: String
-
The query selector for the elements which the listener should be added to. See https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector for further information about query selectors.
Declaration
Swift
public var querySelector: String
-
The name of the attribute whose content should be passed to the
onClickAction
action.Declaration
Swift
public var attributeName: String
-
Whether the listener should be added to all found elements or only to the first one. See https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll for further information. The default value is
true
.Declaration
Swift
public var selectAll: Bool
-
The closure which will be called if the specified class was clicked.
attributeContent
contains the string content of the specified attribute andtouchPointRelativeToWebView
reprsents the touch point relative to the web view.Declaration
Swift
public var onClickAction: ((_ attributeContent: String?, _ touchPointRelativeToWebView: CGPoint) -> Void)
-
Initializes a
ClassBasedOnClickListener
instance. Append it to theclassBasedOnClickListeners
property from theFolioReaderConfig
to receive on click events. The defaultselectAll
value istrue
.Declaration
Swift
public init(schemeName: String, querySelector: String, attributeName: String, selectAll: Bool = true, onClickAction: @escaping ((_ attributeContent: String?, _ touchPointRelativeToWebView: CGPoint) -> Void))
Parameters
schemeName
The name of the URL scheme which should be used. Note: Make sure that the given
String
is a valid as scheme name.querySelector
The query selector for the elements which the listener should be added to. See https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector for further information about query selectors.
attributeName
The name of the attribute whose content should be passed to the
onClickAction
action.selectAll
Whether the listener should be added to all found elements or only to the first one. See https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll for further information. The default value is
true
.onClickAction
The closure which will be called if the specified class was clicked.
attributeContent
contains the string content of the specified attribute andtouchPointRelativeToWebView
reprsents the touch point relative to the web view.