File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ pub(crate) const A: &str = "a";
3535pub ( crate ) const CONTROLS : & str = "controls" ;
3636pub ( crate ) const LINK : & str = "link" ;
3737pub ( crate ) const WORK_HISTORY_SELECTOR : & str = ".work-history" ;
38+ pub ( crate ) const WORK_HISTORY_HASH : & str = "work-history" ;
3839pub ( crate ) const POOP : & str = "💩" ;
3940pub ( crate ) const CLASS : & str = "class" ;
4041pub ( crate ) const HASH : & str = "#" ;
Original file line number Diff line number Diff line change 1- < details class ='work-history '>
1+ < details class ='work-history ' id =' work-history ' >
22 < summary class ='link '> work history</ summary >
33 < ul >
44 < li >
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ use stdweb::unstable::TryInto;
33use stdweb:: web:: { document, Element } ;
44use stdweb:: web:: event:: ClickEvent ;
55
6- use crate :: constants:: WORK_HISTORY_SELECTOR ;
6+ use crate :: constants:: { WORK_HISTORY_HASH , WORK_HISTORY_SELECTOR } ;
7+ use crate :: util:: get_hash;
78
89fn scroll_into_view ( el : Element ) {
910 js ! { @( no_return)
@@ -17,11 +18,22 @@ fn scroll_into_view(el: Element) {
1718pub ( crate ) struct WorkHistory ;
1819
1920impl WorkHistory {
21+ fn open_from_hash ( details : Element ) {
22+ if get_hash ( ) == WORK_HISTORY_HASH {
23+ js ! { @( no_return)
24+ let details = @{ details} ;
25+ details. open = true ;
26+ }
27+ self :: scroll_into_view ( details) ;
28+ }
29+ }
30+
2031 pub ( crate ) fn new ( ) -> Self {
2132 let details = document ( )
2233 . query_selector ( WORK_HISTORY_SELECTOR )
2334 . unwrap ( )
2435 . unwrap ( ) ;
36+ Self :: open_from_hash ( details. clone ( ) ) ;
2537 let click_event = enclose ! ( ( details) move |_: ClickEvent | {
2638 let clone = details. clone( ) ;
2739 let is_open: bool = js!( return @{ & details} . open; )
You can’t perform that action at this time.
0 commit comments