This repository was archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathElement.purs
More file actions
84 lines (68 loc) · 3.29 KB
/
Element.purs
File metadata and controls
84 lines (68 loc) · 3.29 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
module DOM.Node.Element
( namespaceURI
, prefix
, localName
, tagName
, id
, setId
, className
, setClassName
, getElementsByTagName
, getElementsByTagNameNS
, getElementsByClassName
, setAttribute
, getAttribute
, removeAttribute
, matches
, closest
, scrollTop
, setScrollTop
, scrollLeft
, setScrollLeft
, scrollWidth
, scrollHeight
, clientTop
, clientLeft
, clientWidth
, clientHeight
) where
import Prelude
import Control.Monad.Eff (Eff)
import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe, toNullable)
import DOM (DOM)
import DOM.Node.Types (Element, HTMLCollection, ElementId)
namespaceURI :: Element -> Maybe String
namespaceURI = toMaybe <<< _namespaceURI
prefix :: Element -> Maybe String
prefix = toMaybe <<< _prefix
foreign import _namespaceURI :: Element -> Nullable String
foreign import _prefix :: Element -> Nullable String
foreign import localName :: Element -> String
foreign import tagName :: Element -> String
foreign import id :: forall eff. Element -> Eff (dom :: DOM | eff) ElementId
foreign import setId :: forall eff. ElementId -> Element -> Eff (dom :: DOM | eff) Unit
foreign import className :: forall eff. Element -> Eff (dom :: DOM | eff) String
foreign import setClassName :: forall eff. String -> Element -> Eff (dom :: DOM | eff) Unit
foreign import getElementsByTagName :: forall eff. String -> Element -> Eff (dom :: DOM | eff) HTMLCollection
getElementsByTagNameNS :: forall eff. Maybe String -> String -> Element -> Eff (dom :: DOM | eff) HTMLCollection
getElementsByTagNameNS = _getElementsByTagNameNS <<< toNullable
foreign import _getElementsByTagNameNS :: forall eff. Nullable String -> String -> Element -> Eff (dom :: DOM | eff) HTMLCollection
foreign import getElementsByClassName :: forall eff. String -> Element -> Eff (dom :: DOM | eff) HTMLCollection
foreign import setAttribute :: forall eff. String -> String -> Element -> Eff (dom :: DOM | eff) Unit
getAttribute :: forall eff. String -> Element -> Eff (dom :: DOM | eff) (Maybe String)
getAttribute attr = map toMaybe <<< _getAttribute attr
foreign import _getAttribute :: forall eff. String -> Element -> Eff (dom :: DOM | eff) (Nullable String)
foreign import removeAttribute :: forall eff. String -> Element -> Eff (dom :: DOM | eff) Unit
foreign import matches :: forall eff. String -> Element -> Eff (dom :: DOM | eff) Boolean
foreign import closest :: forall eff. String -> Element -> Eff (dom :: DOM | eff) (Nullable Element)
foreign import scrollTop :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import setScrollTop :: forall eff. Number -> Element -> Eff (dom :: DOM | eff) Unit
foreign import scrollLeft :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import setScrollLeft :: forall eff. Number -> Element -> Eff (dom :: DOM | eff) Unit
foreign import scrollWidth :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import scrollHeight :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import clientTop :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import clientLeft :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import clientWidth :: forall eff. Element -> Eff (dom :: DOM | eff) Number
foreign import clientHeight :: forall eff. Element -> Eff (dom :: DOM | eff) Number