Run cargo fmt on plume-front (#515)

When `editor-improvements` was merged it was not run, because Travis was still used, but now it makes Circle CI fail on master.
This commit is contained in:
Baptiste Gelez 2019-04-06 18:57:25 +01:00 committed by GitHub
parent 12c2078c89
commit 1bc2684af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 66 additions and 49 deletions

View File

@ -111,7 +111,9 @@ pub fn init() -> Result<(), EditorError> {
window().local_storage().remove("basic-editor");
window().history().go(0).ok(); // refresh
});
editor_button.append_child(&document().create_text_node(&i18n!(CATALOG, "Open the rich text editor")));
editor_button.append_child(
&document().create_text_node(&i18n!(CATALOG, "Open the rich text editor")),
);
editor.insert_before(&editor_button, &title_label).ok();
return Ok(());
}
@ -170,7 +172,8 @@ fn init_editor() -> Result<(), EditorError> {
}), 0);
}));
document().get_element_by_id("publish")?.add_event_listener(mv!(title, subtitle, content, old_ed => move |_: ClickEvent| {
document().get_element_by_id("publish")?.add_event_listener(
mv!(title, subtitle, content, old_ed => move |_: ClickEvent| {
let popup = document().get_element_by_id("publish-popup").or_else(||
init_popup(&title, &subtitle, &content, &old_ed).ok()
).unwrap();
@ -180,7 +183,8 @@ fn init_editor() -> Result<(), EditorError> {
popup.class_list().add("show").unwrap();
bg.class_list().add("show").unwrap();
}));
}),
);
show_errors();
setup_close_button();
@ -191,7 +195,10 @@ fn init_editor() -> Result<(), EditorError> {
fn setup_close_button() {
if let Some(button) = document().get_element_by_id("close-editor") {
button.add_event_listener(|_: ClickEvent| {
window().local_storage().insert("basic-editor", "true").unwrap();
window()
.local_storage()
.insert("basic-editor", "true")
.unwrap();
window().history().go(0).unwrap(); // Refresh the page
});
}
@ -202,10 +209,18 @@ fn show_errors() {
let list = document().create_element("header").unwrap();
list.class_list().add("messages").unwrap();
for error in document().query_selector_all("p.error").unwrap() {
error.parent_element().unwrap().remove_child(&error).unwrap();
error
.parent_element()
.unwrap()
.remove_child(&error)
.unwrap();
list.append_child(&error);
}
header.parent_element().unwrap().insert_before(&list, &header.next_sibling().unwrap()).unwrap();
header
.parent_element()
.unwrap()
.insert_before(&list, &header.next_sibling().unwrap())
.unwrap();
}
}
@ -259,7 +274,8 @@ fn init_popup(
@{&button}.value = @{i18n!(CATALOG, "Publish")};
};
button.append_child(&document().create_text_node(&i18n!(CATALOG, "Publish")));
button.add_event_listener(mv!(title, subtitle, content, old_ed => move |_: ClickEvent| {
button.add_event_listener(
mv!(title, subtitle, content, old_ed => move |_: ClickEvent| {
title.focus(); // Remove the placeholder before publishing
set_value("title", title.inner_text());
subtitle.focus();
@ -292,7 +308,8 @@ fn init_popup(
js! {
@{&old_ed}.submit();
};
}));
}),
);
popup.append_child(&button);
document().body()?.append_child(&popup);