Widgets only create script and style tags when necessary
This commit is contained in:
parent
2c0434c431
commit
0f1378a013
@ -398,7 +398,7 @@ jqueryDayFieldProfile = FieldProfile
|
|||||||
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
||||||
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"
|
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"
|
||||||
addStylesheetRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/cupertino/jquery-ui.css"
|
addStylesheetRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/cupertino/jquery-ui.css"
|
||||||
addHead [$hamlet|%script $$(function(){$$("#$name$").datepicker({dateFormat:'yy-mm-dd'})})|]
|
addJavaScript [$hamlet|$$(function(){$$("#$name$").datepicker({dateFormat:'yy-mm-dd'})});|]
|
||||||
, fpName = Nothing
|
, fpName = Nothing
|
||||||
, fpLabel = mempty
|
, fpLabel = mempty
|
||||||
, fpTooltip = mempty
|
, fpTooltip = mempty
|
||||||
@ -535,7 +535,7 @@ nicHtmlFieldProfile = FieldProfile
|
|||||||
|]
|
|]
|
||||||
, fpWidget = \name -> do
|
, fpWidget = \name -> do
|
||||||
addScriptRemote "http://js.nicedit.com/nicEdit-latest.js"
|
addScriptRemote "http://js.nicedit.com/nicEdit-latest.js"
|
||||||
addHead [$hamlet|%script bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("$name$")})|]
|
addJavaScript [$hamlet|bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("$name$")});|]
|
||||||
, fpName = Nothing
|
, fpName = Nothing
|
||||||
, fpLabel = mempty
|
, fpLabel = mempty
|
||||||
, fpTooltip = mempty
|
, fpTooltip = mempty
|
||||||
@ -787,7 +787,7 @@ jqueryAutocompleteFieldProfile src = FieldProfile
|
|||||||
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
||||||
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"
|
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"
|
||||||
addStylesheetRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/cupertino/jquery-ui.css"
|
addStylesheetRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/cupertino/jquery-ui.css"
|
||||||
addHead [$hamlet|%script $$(function(){$$("#$name$").autocomplete({source:"@src@",minLength:2})});|]
|
addJavaScript [$hamlet|$$(function(){$$("#$name$").autocomplete({source:"@src@",minLength:2})});|]
|
||||||
, fpName = Nothing
|
, fpName = Nothing
|
||||||
, fpLabel = mempty
|
, fpLabel = mempty
|
||||||
, fpTooltip = mempty
|
, fpTooltip = mempty
|
||||||
|
|||||||
@ -60,13 +60,13 @@ newtype Script url = Script { unScript :: Location url }
|
|||||||
newtype Stylesheet url = Stylesheet { unStylesheet :: Location url }
|
newtype Stylesheet url = Stylesheet { unStylesheet :: Location url }
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
newtype Title = Title { unTitle :: Html () }
|
newtype Title = Title { unTitle :: Html () }
|
||||||
newtype Style url = Style (Hamlet url)
|
newtype Style url = Style (Maybe (Hamlet url))
|
||||||
deriving Monoid
|
deriving Monoid
|
||||||
newtype Head url = Head (Hamlet url)
|
newtype Head url = Head (Hamlet url)
|
||||||
deriving Monoid
|
deriving Monoid
|
||||||
newtype Body url = Body (Hamlet url)
|
newtype Body url = Body (Hamlet url)
|
||||||
deriving Monoid
|
deriving Monoid
|
||||||
newtype JavaScript url = JavaScript (Hamlet url)
|
newtype JavaScript url = JavaScript (Maybe (Hamlet url))
|
||||||
deriving Monoid
|
deriving Monoid
|
||||||
|
|
||||||
newtype GWidget sub master a = GWidget (
|
newtype GWidget sub master a = GWidget (
|
||||||
@ -103,7 +103,7 @@ newIdent = GWidget $ lift $ lift $ lift $ lift $ lift $ lift $ lift $ do
|
|||||||
return $ "w" ++ show i'
|
return $ "w" ++ show i'
|
||||||
|
|
||||||
addStyle :: Hamlet (Route master) -> GWidget sub master ()
|
addStyle :: Hamlet (Route master) -> GWidget sub master ()
|
||||||
addStyle = GWidget . lift . lift . lift . lift . tell . Style
|
addStyle = GWidget . lift . lift . lift . lift . tell . Style . Just
|
||||||
|
|
||||||
addStylesheet :: Route master -> GWidget sub master ()
|
addStylesheet :: Route master -> GWidget sub master ()
|
||||||
addStylesheet = GWidget . lift . lift . lift . tell . toUnique . Stylesheet . Local
|
addStylesheet = GWidget . lift . lift . lift . tell . toUnique . Stylesheet . Local
|
||||||
@ -120,7 +120,8 @@ addScriptRemote =
|
|||||||
GWidget . lift . lift . tell . toUnique . Script . Remote
|
GWidget . lift . lift . tell . toUnique . Script . Remote
|
||||||
|
|
||||||
addJavaScript :: Hamlet (Route master) -> GWidget sub master ()
|
addJavaScript :: Hamlet (Route master) -> GWidget sub master ()
|
||||||
addJavaScript = GWidget . lift . lift . lift . lift . lift. tell . JavaScript
|
addJavaScript = GWidget . lift . lift . lift . lift . lift. tell
|
||||||
|
. JavaScript . Just
|
||||||
|
|
||||||
applyLayoutW :: (Eq (Route m), Yesod m)
|
applyLayoutW :: (Eq (Route m), Yesod m)
|
||||||
=> GWidget sub m () -> GHandler sub m RepHtml
|
=> GWidget sub m () -> GHandler sub m RepHtml
|
||||||
@ -150,8 +151,10 @@ $forall scripts s
|
|||||||
%script!src=^s^
|
%script!src=^s^
|
||||||
$forall stylesheets s
|
$forall stylesheets s
|
||||||
%link!rel=stylesheet!href=^s^
|
%link!rel=stylesheet!href=^s^
|
||||||
%style ^style^
|
$maybe style s
|
||||||
%script ^jscript^
|
%style ^s^
|
||||||
|
$maybe jscript j
|
||||||
|
%script ^j^
|
||||||
^head'^
|
^head'^
|
||||||
|]
|
|]
|
||||||
return $ PageContent title head'' body
|
return $ PageContent title head'' body
|
||||||
|
|||||||
@ -34,7 +34,6 @@ getRootR = applyLayoutW $ flip wrapWidget wrapper $ do
|
|||||||
|]
|
|]
|
||||||
addHead [$hamlet|%meta!keywords=haskell|]
|
addHead [$hamlet|%meta!keywords=haskell|]
|
||||||
|
|
||||||
-- FIXME add coolness to day and html below
|
|
||||||
handleFormR = do
|
handleFormR = do
|
||||||
(res, form, enctype) <- runFormPost $ (,,,,,,,)
|
(res, form, enctype) <- runFormPost $ (,,,,,,,)
|
||||||
<$> stringField (string "My Field") (string "Some tooltip info") Nothing
|
<$> stringField (string "My Field") (string "Some tooltip info") Nothing
|
||||||
@ -52,6 +51,7 @@ handleFormR = do
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
applyLayoutW $ do
|
applyLayoutW $ do
|
||||||
addStyle [$hamlet|\.tooltip{color:#666;font-style:italic}|]
|
addStyle [$hamlet|\.tooltip{color:#666;font-style:italic}|]
|
||||||
|
addStyle [$hamlet|textarea.html{width:300px;height:150px};|]
|
||||||
wrapWidget (fieldsToTable form) $ \h -> [$hamlet|
|
wrapWidget (fieldsToTable form) $ \h -> [$hamlet|
|
||||||
%form!method=post!enctype=$show.enctype$
|
%form!method=post!enctype=$show.enctype$
|
||||||
%table
|
%table
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user