Permalink
Browse files

jquery mobile link options and docs

  • Loading branch information...
choptastic committed Aug 27, 2012
1 parent 0e15a52 commit 5a0040317a441e50442f3a2f41f9f084a7c98cf4
Showing with 22 additions and 14 deletions.
  1. +6 −2 doc/org-mode/elements/link.org
  2. +1 −1 include/wf.hrl
  3. +15 −11 src/elements/html/element_link.erl
@@ -1,4 +1,4 @@
-
+# vim: ts=3 sw=3 et ft=org
#+TITLE: Link Element Element
#+STYLE: <LINK href='../stylesheet.css' rel='stylesheet' type='text/css' />
#+AUTHOR: Rusty Klophaus (@rklophaus)
@@ -40,10 +40,14 @@
+ postback - (/Erlang term/) :: If set, clicking on the link will cause a Nitrogen postback with the supplied term.
+ + mobile_target - (/Boolean/) :: If set to false, this will work with jQuery Mobile to ensure that it skips using jQuery Mobile's automatic page transition loading system.
+
+ + mobile_dialog - (/Boolean/) :: If set to true, this will work with jQuery mobile to load the target URL in a [[http://jquerymobile.com/demos/1.1.1/docs/pages/page-dialogs.html][jQuery Mobile Dialog]].
+
** See Also
+ [[./base.html][base element]]
+ [[./button.html][button element]]
-
+ + [[../jquery_mobile_integration.html][jQuery Mobile Integration Guide]]
View
@@ -83,7 +83,7 @@
-record(strong, {?ELEMENT_BASE(element_strong), body="", text="", html_encode=true}).
-record(em, {?ELEMENT_BASE(element_em), body="", text="", html_encode=true}).
-record(value, {?ELEMENT_BASE(element_value), text="", html_encode=true}).
--record(link, {?ELEMENT_BASE(element_link), title = "", text="", body="", new=false, html_encode=true, mobile_target=false, url="javascript:", postback, delegate}).
+-record(link, {?ELEMENT_BASE(element_link), title = "", text="", body="", new=false, html_encode=true, mobile_target=false, mobile_dialog=false, url="javascript:", postback, delegate}).
-record(email_link, {?ELEMENT_BASE(element_email_link), title="",text="",body="",html_encode=true,email=""}).
-record(error, {?ELEMENT_BASE(element_error), text="", html_encode=true}).
-record(span, {?ELEMENT_BASE(element_span), body="", text="", html_encode=true}).
@@ -22,20 +22,14 @@ render_element(Record) ->
Record#link.body
],
- Target = case Record#link.new of
- false -> "";
- true -> "_blank";
- _ -> ""
- end,
+ Target = target(Record#link.new),
%% Basically, the default for mobile_target is to say nothing and let
%% jquery mobile use its default setting. Anything other than a boolean
%% will just treat it as blank
- DataFields = case Record#link.mobile_target of
- true -> [];
- false -> [{ajax,false}];
- _ -> []
- end,
+
+ DataFields1 = add_field(Record#link.mobile_target==false,{ajax,false},[]),
+ DataFields2 = add_field(Record#link.mobile_dialog==true,{rel,dialog},DataFields1),
wf_tags:emit_tag(a, Body, [
{id, Record#link.html_id},
@@ -44,5 +38,15 @@ render_element(Record) ->
{target, Target},
{style, Record#link.style},
{title, wf:html_encode(Record#link.title, Record#link.html_encode)},
- {data_fields, DataFields}
+ {data_fields, DataFields2}
]).
+
+target(New) ->
+ case New of
+ false -> "";
+ true -> "_blank";
+ _ -> ""
+ end.
+
+add_field(true,ToAdd,DataFields) -> [ToAdd | DataFields];
+add_field(_,_,DataFields) -> DataFields.

0 comments on commit 5a00403

Please sign in to comment.