Paste server written in Haskell. Fork of Hpaste, fully freedom and privacy respecting and generally improved. At the time of writing there's an instance at <http://paste.rel4tion.org>.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aoqmo
SSH:
git clone USERNAME@vervis.peers.community:aoqmo
Branches
Tags
Extra.hs
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | {-# OPTIONS -Wall -fno-warn-orphans -fno-warn-name-shadowing -fno-warn-unused-do-bind #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
module HJScript.Objects.JQuery.Extra where
import HJScript
import HJScript.Objects.JQuery
import qualified HJScript.Objects.Math as Math
import Prelude hiding ((++),max)
-- | jQuery selector.
j :: String -> JObject JQuery
j = selectExpr . string
-- | Set the width of a DOM element.
setWidth :: IsJQuery o => Exp Int -> o -> HJScript ()
setWidth w o = do
runExp $ methodCall "width" w o
-- | Set the text of a DOM element.
setText :: IsJQuery o => Exp String -> o -> HJScript ()
setText w o = do
runExp $ methodCall "text" w o
-- | Append an element to another.
append :: IsJQuery o => Exp a -> o -> HJScript ()
append w o = do
runExp $ methodCall "append" w o
-- | Prepend an element before another.
prepend :: IsJQuery o => Exp a -> o -> HJScript ()
prepend w o = do
runExp $ methodCall "prepend" w o
-- | Add a class to an object.
addClass :: IsJQuery o => String -> o -> HJScript ()
addClass w o = do
runExp $ methodCall "addClass" (string w) o
-- | Does an object have a class?
hasClass :: IsJQuery o => String -> o -> JBool
hasClass w o = do
methodCall "hasClass" (string w) o
-- | Remove a class from an object.
removeClass :: IsJQuery o => String -> o -> HJScript ()
removeClass w o = do
runExp $ methodCall "removeClass" (string w) o
-- | Set the width of a DOM element.
css' :: IsJQuery o => String -> String -> o -> HJScript ()
css' key value o = do
runExp $ methodCall "css" (string key,string value) o
-- | Set the width of a DOM element.
css :: IsJQuery o => String -> String -> o -> HJScript ()
css key value o = do
runExp $ methodCall "css" (string key,string value) o
-- | Get the width of a DOM element.
getWidth :: IsJQuery o => o -> Exp Int
getWidth o = do
methodCall "width" () o
-- | Get siblings of an elements.
siblings :: IsJQuery o => String -> o -> JObject JQuery
siblings q o = do
methodCall "siblings" (string q) o
-- | When toggling by clicking, run these events on this object.
toggle :: IsJQuery o => HJScript JBool -> HJScript JBool -> o -> HJScript ()
toggle on off query = do
fnon <- function $ \() -> on
fnoff <- function $ \() -> off
runExp $ methodCall "toggle" (fnon,fnoff) query
-- | When toggling by hover, run these events on this object.
hover :: IsJQuery o => HJScript JBool -> HJScript JBool -> o -> HJScript ()
hover on off query = do
fnon <- function $ \() -> on
fnoff <- function $ \() -> off
runExp $ methodCall "hover" (fnon,fnoff) query
-- | For each object in a jQuery selection.
each :: IsJQuery o => HJScript JBool -> o -> HJScript ()
each script query = do
fn <- function $ \() -> script
runExp $ methodCall "each" fn query
-- | The jQuery 'this' object.
this' :: JObject JQuery
this' = selectExpr (this :: JObject JQuery)
-- | Parent of a jQuery object.
parent :: IsJQuery o => o -> JObject JQuery
parent o = callMethod "parent" () o
-- | Max.
mathMax :: Exp a -> Exp a -> Exp a
mathMax a b = callMethod "max" (a,b) Math.Math
-- | Simple instance so we can use number literals and simple
-- | arithmetic.
instance Num (Exp Int) where
a + b = a .+. b
a * b = a .*. b
abs = undefined
signum = undefined
fromInteger = int . fromIntegral
instance Eq (Exp Int)
class (IsDeref o) => IsJQuery o
instance IsJQuery (JObject JQuery)
instance IsClass (Var JQuery)
instance IsJQuery (Var JQuery)
|