1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Bindings to mdc components.

use wasm_bindgen::prelude::*;
use web_sys::{Element, Event};

pub fn get_element_by_id(id: &str) -> Option<web_sys::Element> {
    web_sys::window()?.document()?.get_element_by_id(id)
}

#[wasm_bindgen(module = "@material/base/component/index")]
extern "C" {
    pub type MDCComponent;

    #[wasm_bindgen(method)]
    pub fn listen(this: &MDCComponent, evt_type: &str, handler: &Closure<dyn FnMut(Event)>);

    #[wasm_bindgen(method)]
    pub fn unlisten(this: &MDCComponent, evt_type: &str, handler: &Closure<dyn FnMut(Event)>);

    #[wasm_bindgen(method)]
    pub fn destroy(this: &MDCComponent);
}

#[wasm_bindgen(module = "@material/ripple/index")]
extern "C" {
    #[wasm_bindgen(extends = MDCComponent)]
    pub type MDCRipple;

    #[wasm_bindgen(constructor)]
    pub fn new(root: Element) -> MDCRipple;

    #[wasm_bindgen(method, getter)]
    pub fn unbounded(this: &MDCRipple) -> bool;
    
    #[wasm_bindgen(method, setter)]
    pub fn set_unbounded(this: &MDCRipple, unbounded: bool);

    #[wasm_bindgen(method)]
    pub fn activate(this: &MDCRipple);

    #[wasm_bindgen(method)]
    pub fn deactivate(this: &MDCRipple);

    #[wasm_bindgen(method)]
    pub fn layout(this: &MDCRipple);

    #[wasm_bindgen(method)]
    pub fn handle_focus(this: &MDCRipple);

    #[wasm_bindgen(method)]
    pub fn handle_blur(this: &MDCRipple);

}