1use wasm_bindgen::prelude::*;
2use web_sys::Element;
3#[wasm_bindgen]
4extern "C" {
5 #[wasm_bindgen(js_namespace = bootstrap)]
6 type Modal;
7 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
8 fn new(element: &Element, options: &JsValue) -> Modal;
9 #[wasm_bindgen(method, js_namespace = bootstrap)]
10 fn show(this: &Modal);
11 #[wasm_bindgen(method, js_namespace = bootstrap)]
12 fn hide(this: &Modal);
13 #[wasm_bindgen(method, js_namespace = bootstrap)]
14 fn toggle(this: &Modal);
15 #[wasm_bindgen(js_namespace = bootstrap)]
16 type Dropdown;
17 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
18 fn new(element: &Element, options: &JsValue) -> Dropdown;
19 #[wasm_bindgen(method, js_namespace = bootstrap)]
20 fn show(this: &Dropdown);
21 #[wasm_bindgen(method, js_namespace = bootstrap)]
22 fn hide(this: &Dropdown);
23 #[wasm_bindgen(method, js_namespace = bootstrap)]
24 fn toggle(this: &Dropdown);
25 #[wasm_bindgen(js_namespace = bootstrap)]
26 type Alert;
27 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
28 fn new(element: &Element) -> Alert;
29 #[wasm_bindgen(method, js_namespace = bootstrap)]
30 fn close(this: &Alert);
31 #[wasm_bindgen(js_namespace = bootstrap)]
32 type Collapse;
33 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
34 fn new(element: &Element, options: &JsValue) -> Collapse;
35 #[wasm_bindgen(method, js_namespace = bootstrap)]
36 fn show(this: &Collapse);
37 #[wasm_bindgen(method, js_namespace = bootstrap)]
38 fn hide(this: &Collapse);
39 #[wasm_bindgen(method, js_namespace = bootstrap)]
40 fn toggle(this: &Collapse);
41 #[wasm_bindgen(js_namespace = bootstrap)]
42 type Toast;
43 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
44 fn new(element: &Element, options: &JsValue) -> Toast;
45 #[wasm_bindgen(method, js_namespace = bootstrap)]
46 fn show(this: &Toast);
47 #[wasm_bindgen(method, js_namespace = bootstrap)]
48 fn hide(this: &Toast);
49 #[wasm_bindgen(js_namespace = bootstrap)]
50 type Offcanvas;
51 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
52 fn new(element: &Element, options: &JsValue) -> Offcanvas;
53 #[wasm_bindgen(method, js_namespace = bootstrap)]
54 fn show(this: &Offcanvas);
55 #[wasm_bindgen(method, js_namespace = bootstrap)]
56 fn hide(this: &Offcanvas);
57 #[wasm_bindgen(method, js_namespace = bootstrap)]
58 fn toggle(this: &Offcanvas);
59 #[wasm_bindgen(js_namespace = bootstrap)]
60 type Carousel;
61 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
62 fn new(element: &Element, options: &JsValue) -> Carousel;
63 #[wasm_bindgen(method, js_namespace = bootstrap)]
64 fn cycle(this: &Carousel);
65 #[wasm_bindgen(method, js_namespace = bootstrap)]
66 fn pause(this: &Carousel);
67 #[wasm_bindgen(method, js_namespace = bootstrap)]
68 fn prev(this: &Carousel);
69 #[wasm_bindgen(method, js_namespace = bootstrap)]
70 fn next(this: &Carousel);
71 #[wasm_bindgen(method, js_namespace = bootstrap)]
72 fn to(this: &Carousel, index: u32);
73 #[wasm_bindgen(js_namespace = bootstrap)]
74 type Tooltip;
75 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
76 fn new(element: &Element, options: &JsValue) -> Tooltip;
77 #[wasm_bindgen(method, js_namespace = bootstrap)]
78 fn show(this: &Tooltip);
79 #[wasm_bindgen(method, js_namespace = bootstrap)]
80 fn hide(this: &Tooltip);
81 #[wasm_bindgen(method, js_namespace = bootstrap)]
82 fn toggle(this: &Tooltip);
83 #[wasm_bindgen(method, js_namespace = bootstrap)]
84 fn dispose(this: &Tooltip);
85 #[wasm_bindgen(js_namespace = bootstrap)]
86 type Popover;
87 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
88 fn new(element: &Element, options: &JsValue) -> Popover;
89 #[wasm_bindgen(method, js_namespace = bootstrap)]
90 fn show(this: &Popover);
91 #[wasm_bindgen(method, js_namespace = bootstrap)]
92 fn hide(this: &Popover);
93 #[wasm_bindgen(method, js_namespace = bootstrap)]
94 fn toggle(this: &Popover);
95 #[wasm_bindgen(method, js_namespace = bootstrap)]
96 fn dispose(this: &Popover);
97 #[wasm_bindgen(js_namespace = bootstrap)]
98 type ScrollSpy;
99 #[wasm_bindgen(constructor, js_namespace = bootstrap)]
100 fn new(element: &Element, options: &JsValue) -> ScrollSpy;
101 #[wasm_bindgen(method, js_namespace = bootstrap)]
102 fn refresh(this: &ScrollSpy);
103}
104pub struct BsModal {
105 modal: Modal,
106 element: Element,
107}
108impl BsModal {
109 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
110 let options = match options {
111 Some(opts) => opts,
112 None => &JsValue::NULL,
113 };
114 let modal = Modal::new(element, options);
115 BsModal {
116 modal,
117 element: element.clone(),
118 }
119 }
120 pub fn show(&self) {
121 self.modal.show();
122 }
123 pub fn hide(&self) {
124 self.modal.hide();
125 }
126 pub fn toggle(&self) {
127 self.modal.toggle();
128 }
129}
130impl Drop for BsModal {
131 fn drop(&mut self) {}
132}
133pub struct BsDropdown {
134 dropdown: Dropdown,
135 element: Element,
136}
137impl BsDropdown {
138 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
139 let options = match options {
140 Some(opts) => opts,
141 None => &JsValue::NULL,
142 };
143 let dropdown = Dropdown::new(element, options);
144 BsDropdown {
145 dropdown,
146 element: element.clone(),
147 }
148 }
149 pub fn show(&self) {
150 self.dropdown.show();
151 }
152 pub fn hide(&self) {
153 self.dropdown.hide();
154 }
155 pub fn toggle(&self) {
156 self.dropdown.toggle();
157 }
158}
159impl Drop for BsDropdown {
160 fn drop(&mut self) {}
161}
162pub struct BsAlert {
163 alert: Alert,
164 element: Element,
165}
166impl BsAlert {
167 pub fn new(element: &Element) -> Self {
168 let alert = Alert::new(element);
169 BsAlert {
170 alert,
171 element: element.clone(),
172 }
173 }
174 pub fn close(&self) {
175 self.alert.close();
176 }
177}
178impl Drop for BsAlert {
179 fn drop(&mut self) {}
180}
181pub struct BsCollapse {
182 collapse: Collapse,
183 element: Element,
184}
185impl BsCollapse {
186 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
187 let options = match options {
188 Some(opts) => opts,
189 None => &JsValue::NULL,
190 };
191 let collapse = Collapse::new(element, options);
192 BsCollapse {
193 collapse,
194 element: element.clone(),
195 }
196 }
197 pub fn show(&self) {
198 self.collapse.show();
199 }
200 pub fn hide(&self) {
201 self.collapse.hide();
202 }
203 pub fn toggle(&self) {
204 self.collapse.toggle();
205 }
206}
207impl Drop for BsCollapse {
208 fn drop(&mut self) {}
209}
210pub struct BsToast {
211 toast: Toast,
212 element: Element,
213}
214impl BsToast {
215 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
216 let options = match options {
217 Some(opts) => opts,
218 None => &JsValue::NULL,
219 };
220 let toast = Toast::new(element, options);
221 BsToast {
222 toast,
223 element: element.clone(),
224 }
225 }
226 pub fn show(&self) {
227 self.toast.show();
228 }
229 pub fn hide(&self) {
230 self.toast.hide();
231 }
232}
233impl Drop for BsToast {
234 fn drop(&mut self) {}
235}
236pub struct BsOffcanvas {
237 offcanvas: Offcanvas,
238 element: Element,
239}
240impl BsOffcanvas {
241 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
242 let options = match options {
243 Some(opts) => opts,
244 None => &JsValue::NULL,
245 };
246 let offcanvas = Offcanvas::new(element, options);
247 BsOffcanvas {
248 offcanvas,
249 element: element.clone(),
250 }
251 }
252 pub fn show(&self) {
253 self.offcanvas.show();
254 }
255 pub fn hide(&self) {
256 self.offcanvas.hide();
257 }
258 pub fn toggle(&self) {
259 self.offcanvas.toggle();
260 }
261}
262impl Drop for BsOffcanvas {
263 fn drop(&mut self) {}
264}
265pub struct BsCarousel {
266 carousel: Carousel,
267 element: Element,
268}
269impl BsCarousel {
270 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
271 let options = match options {
272 Some(opts) => opts,
273 None => &JsValue::NULL,
274 };
275 let carousel = Carousel::new(element, options);
276 BsCarousel {
277 carousel,
278 element: element.clone(),
279 }
280 }
281 pub fn cycle(&self) {
282 self.carousel.cycle();
283 }
284 pub fn pause(&self) {
285 self.carousel.pause();
286 }
287 pub fn prev(&self) {
288 self.carousel.prev();
289 }
290 pub fn next(&self) {
291 self.carousel.next();
292 }
293 pub fn to(&self, index: u32) {
294 self.carousel.to(index);
295 }
296}
297impl Drop for BsCarousel {
298 fn drop(&mut self) {}
299}
300pub struct BsTooltip {
301 tooltip: Tooltip,
302 element: Element,
303}
304impl BsTooltip {
305 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
306 let options = match options {
307 Some(opts) => opts,
308 None => &JsValue::NULL,
309 };
310 let tooltip = Tooltip::new(element, options);
311 BsTooltip {
312 tooltip,
313 element: element.clone(),
314 }
315 }
316 pub fn show(&self) {
317 self.tooltip.show();
318 }
319 pub fn hide(&self) {
320 self.tooltip.hide();
321 }
322 pub fn toggle(&self) {
323 self.tooltip.toggle();
324 }
325}
326impl Drop for BsTooltip {
327 fn drop(&mut self) {}
328}
329pub struct BsPopover {
330 popover: Popover,
331 element: Element,
332}
333impl BsPopover {
334 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
335 let options = match options {
336 Some(opts) => opts,
337 None => &JsValue::NULL,
338 };
339 let popover = Popover::new(element, options);
340 BsPopover {
341 popover,
342 element: element.clone(),
343 }
344 }
345 pub fn show(&self) {
346 self.popover.show();
347 }
348 pub fn hide(&self) {
349 self.popover.hide();
350 }
351 pub fn toggle(&self) {
352 self.popover.toggle();
353 }
354 pub fn dispose(&self) {
355 self.popover.dispose();
356 }
357}
358impl Drop for BsPopover {
359 fn drop(&mut self) {}
360}
361pub struct BsScrollSpy {
362 scrollspy: ScrollSpy,
363 element: Element,
364}
365impl BsScrollSpy {
366 pub fn new(element: &Element, options: Option<&JsValue>) -> Self {
367 let options = match options {
368 Some(opts) => opts,
369 None => &JsValue::NULL,
370 };
371 let scrollspy = ScrollSpy::new(element, options);
372 BsScrollSpy {
373 scrollspy,
374 element: element.clone(),
375 }
376 }
377 pub fn refresh(&self) {
378 self.scrollspy.refresh();
379 }
380}
381impl Drop for BsScrollSpy {
382 fn drop(&mut self) {}
383}