make preview a link, remove js click event on preview
This commit is contained in:
parent
d68e6e0fd7
commit
3be5552fcf
3 changed files with 34 additions and 36 deletions
|
|
@ -110,6 +110,14 @@ blockquote.blockquote {
|
|||
display:none;
|
||||
}
|
||||
|
||||
a.preview-link {
|
||||
display: block;
|
||||
height: 100;
|
||||
width: 100;
|
||||
text-decoration: none;
|
||||
color: unset;
|
||||
}
|
||||
|
||||
.thread-subject {
|
||||
margin: auto;
|
||||
width: 50%;
|
||||
|
|
|
|||
|
|
@ -44,14 +44,6 @@ let render_time date_span =
|
|||
in
|
||||
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
|
||||
|
||||
(* make threads preview clickable to get to thread *)
|
||||
let preview_click thread_id _event =
|
||||
log "preview_click@\n";
|
||||
let url = Format.sprintf "/thread/%s" thread_id in
|
||||
let window = Jv.get Jv.global "window" in
|
||||
let location = Jv.get window "location" in
|
||||
ignore @@ Jv.set location "href" (Jv.of_string url)
|
||||
|
||||
let make_pretty _event =
|
||||
log "make pretty@\n";
|
||||
let document = Jv.get Jv.global "document" in
|
||||
|
|
@ -72,23 +64,7 @@ let make_pretty _event =
|
|||
@@ Jv.call el "addEventListener"
|
||||
[| Jv.of_string "click"; Jv.repr (image_click el) |]
|
||||
in
|
||||
List.iter add_click post_images;
|
||||
|
||||
log "make_pretty_catalog@\n";
|
||||
let previews =
|
||||
Jv.to_jv_list
|
||||
@@ Jv.call document "getElementsByClassName"
|
||||
[| Jv.of_string "thread-preview" |]
|
||||
in
|
||||
let add_preview_click el =
|
||||
let thread_id =
|
||||
Jv.to_string @@ Jv.call el "getAttribute" [| Jv.of_string "data-id" |]
|
||||
in
|
||||
ignore
|
||||
@@ Jv.call el "addEventListener"
|
||||
[| Jv.of_string "click"; Jv.repr (preview_click thread_id) |]
|
||||
in
|
||||
List.iter add_preview_click previews
|
||||
List.iter add_click post_images
|
||||
|
||||
(*make pretty after page load*)
|
||||
let () =
|
||||
|
|
|
|||
|
|
@ -103,11 +103,10 @@ let pp_post fmt t =
|
|||
~some:(fun thread_data -> thread_data.subject)
|
||||
thread_data_opt
|
||||
in
|
||||
let pp =
|
||||
(* put inside a link if its a preview *)
|
||||
let pp_inner_post fmt () =
|
||||
Format.fprintf fmt
|
||||
{|
|
||||
<div class="container">
|
||||
<div class="post" id="%s">
|
||||
<div class="thread-subject">
|
||||
%s
|
||||
</div>
|
||||
|
|
@ -115,12 +114,27 @@ let pp_post fmt t =
|
|||
%a
|
||||
<blockquote class="post-comment">%s</blockquote>
|
||||
%a
|
||||
</div>
|
||||
</div>
|
||||
|}
|
||||
id subject post_info_view () image_view () comment tags_view ()
|
||||
subject post_info_view () image_view () comment tags_view ()
|
||||
in
|
||||
pp
|
||||
if Option.is_some thread_data_opt then
|
||||
Format.fprintf fmt
|
||||
{|
|
||||
<div class="post" id="%s">
|
||||
<a class="preview-link" href="/thread/%s">
|
||||
%a
|
||||
</a>
|
||||
</div>
|
||||
|}
|
||||
id id pp_inner_post ()
|
||||
else
|
||||
Format.fprintf fmt
|
||||
{|
|
||||
<div class="post" id="%s">
|
||||
%a
|
||||
</div>
|
||||
|}
|
||||
id pp_inner_post ()
|
||||
|
||||
let view_post id =
|
||||
let* post = get_post id in
|
||||
|
|
@ -131,11 +145,11 @@ let pp_thread_preview fmt op =
|
|||
let thread_preview =
|
||||
Format.fprintf fmt
|
||||
{|
|
||||
<div class="thread-preview" data-id="%s" >
|
||||
<div class="thread-preview">
|
||||
%a
|
||||
</div>
|
||||
</div>
|
||||
|}
|
||||
post.id pp_post
|
||||
pp_post
|
||||
(Op (thread_data, post))
|
||||
in
|
||||
thread_preview
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue