fay-jquery
jQuery bindings for Fay.
https://github.com/faylang/fay-jquery
LTS Haskell 8.24: | 0.6.1.0 |
Stackage Nightly 2017-06-26: | 0.6.1.0 |
Latest on Hackage: | 0.6.1.0 |
fay-jquery-0.6.1.0@sha256:25ee1ed2276608c69523d6ba1601d063029323d110c43eb0bfdc3d93c31ef870,887
Module documentation for 0.6.1.0
Fay jQuery
jQuery bindings for Fay. This project is experimental, but seems to work pretty well!
The short-term goals of this project are to help discover the real world requirements of Fay and to invite bikeshedding over the fay-jquery API. That means that names and types may change in rapid and annoying ways until conventions settle down.
The one consistent convention in the library is that the jQuery object on which methods operate is the last parameter to every function. This allows simple monadic composition:
{-# LANGUAGE RebindableSyntax, OverloadedStrings #-}
import Fay.Text (fromString)
import JQuery
import Prelude
(>=>) :: (a -> Fay b) -> (b -> Fay c) -> a -> Fay c
f >=> g = \x -> f x >>= g
makeSquare :: JQuery -> Fay JQuery
makeSquare = addClass "square" >=>
setWidth 400 >=>
setHeight 400
-- `ready` is the same as jQuery(document).ready(%1);
-- You generally need to wait for this event to fire before modifying the DOM.
main :: Fay ()
main = ready $ do
select "#elementToMakeSquare" >>= makeSquare
return ()
Usage
Install:
cabal install fay-text fay-jquery
Compile your file:
fay --package fay-jquery,fay-text MyFile.hs
Supported API calls
This binding is a work in progress. We’re adding calls by section of the jQuery docs. There is some overlap in the sections, but the following sections are (mostly) complete.
- Ajax
- Attributes
- Core
- CSS
- Effects (Basic, Fading)
- Manipulation
- Traversing
- Events
Still to do
- Data
- Deferred Object
- Effects (Custom, Sliding)
- Forms
- Internals
- Miscellaneous
- Offset
- Plugins
- Properties
- Utilities
Not Applicable
- Selectors
Changes
Changelog
0.6.1.0
- Add
currentTarget
thanks to Jelle Hermsen
0.6.0.3 (2015-01-05)
- Bug fix: Serialize ajax post bodies using JSON.stringify.
0.6.0.2 (2014-01-06)
- Bug fix: Force thunks on polymorphic arguments such as
a
inappend :: Selectable a => a -> JQuery -> Fay JQuery
. Previously only constant values would be passed to jQuery correctly for these arguments.
0.6.0.1 (2013-12-28)
- Fix typo in constraint, fixes build
0.6 (2013-12-26)
- Constrain more free type variables to
Selectable
- Change
getAttr :: Text -> JQuery -> Fay Text
toText -> JQuery -> Fay (Defined Text)
0.5 (2013-11-07)
- Add
Selectable
typeclass (with instances forText
,JQuery
andElement
.String
is not a valid instance.) select
andis
now acceptSelectable a => a
as the first argument.selectElement
,selectObject
,isJQuery
, andisElement
has been removed in favor ofselect
andis
.createJQuery :: Text -> a -> Fay JQuery
has been replaced byselectInContext :: (Selectable a, Selectable b) => a -> b -> Fay JQuery
isWith :: (Double -> Bool) -> JQuery -> Fay JQuery
has changed toisWith :: (Int -> Bool) -> JQuery -> Fay JQuery
- Updated usage instructions in README
Bug fixes:
is
now returnsBool
0.4.0.1 (2013-09-24)
- Fixed bug in definition of
clone
- Don’t define
fromIntegral
.
0.4 (2013-08-27)
- Updated to use fay-text, which fixes bugs in ajax FFI calls.