Run 'cargo fmt' to format code (#489)
This commit is contained in:
committed by
Baptiste Gelez
parent
732f514da7
commit
b945d1f602
+30
-17
@@ -1,4 +1,4 @@
|
||||
#![recursion_limit="128"]
|
||||
#![recursion_limit = "128"]
|
||||
#![feature(decl_macro, proc_macro_hygiene, try_trait)]
|
||||
|
||||
extern crate gettext;
|
||||
@@ -9,7 +9,7 @@ extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate stdweb;
|
||||
|
||||
use stdweb::{web::{*, event::*}};
|
||||
use stdweb::web::{event::*, *};
|
||||
|
||||
init_i18n!("plume-front", en, fr);
|
||||
|
||||
@@ -20,9 +20,14 @@ compile_i18n!();
|
||||
lazy_static! {
|
||||
static ref CATALOG: gettext::Catalog = {
|
||||
let catalogs = include_i18n!();
|
||||
let lang = js!{ return navigator.language }.into_string().unwrap();
|
||||
let lang = js! { return navigator.language }.into_string().unwrap();
|
||||
let lang = lang.splitn(2, '-').next().unwrap_or("en");
|
||||
catalogs.iter().find(|(l, _)| l == &lang).unwrap_or(&catalogs[0]).clone().1
|
||||
catalogs
|
||||
.iter()
|
||||
.find(|(l, _)| l == &lang)
|
||||
.unwrap_or(&catalogs[0])
|
||||
.clone()
|
||||
.1
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,7 +35,8 @@ fn main() {
|
||||
menu();
|
||||
search();
|
||||
editor::init()
|
||||
.map_err(|e| console!(error, format!("Editor error: {:?}", e))).ok();
|
||||
.map_err(|e| console!(error, format!("Editor error: {:?}", e)))
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// Toggle menu on mobile device
|
||||
@@ -41,10 +47,14 @@ fn menu() {
|
||||
if let Some(button) = document().get_element_by_id("menu") {
|
||||
if let Some(menu) = document().get_element_by_id("content") {
|
||||
button.add_event_listener(|_: ClickEvent| {
|
||||
document().get_element_by_id("menu").map(|menu| menu.class_list().add("show"));
|
||||
document()
|
||||
.get_element_by_id("menu")
|
||||
.map(|menu| menu.class_list().add("show"));
|
||||
});
|
||||
menu.add_event_listener(|_: ClickEvent| {
|
||||
document().get_element_by_id("menu").map(|menu| menu.class_list().remove("show"));
|
||||
document()
|
||||
.get_element_by_id("menu")
|
||||
.map(|menu| menu.class_list().remove("show"));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -54,18 +64,21 @@ fn menu() {
|
||||
fn search() {
|
||||
if let Some(form) = document().get_element_by_id("form") {
|
||||
form.add_event_listener(|_: SubmitEvent| {
|
||||
document().query_selector_all("#form input").map(|inputs| {
|
||||
for input in inputs {
|
||||
js! {
|
||||
if (@{&input}.name === "") {
|
||||
@{&input}.name = @{&input}.id
|
||||
}
|
||||
if (@{&input}.name && !@{&input}.value) {
|
||||
@{&input}.name = "";
|
||||
document()
|
||||
.query_selector_all("#form input")
|
||||
.map(|inputs| {
|
||||
for input in inputs {
|
||||
js! {
|
||||
if (@{&input}.name === "") {
|
||||
@{&input}.name = @{&input}.id
|
||||
}
|
||||
if (@{&input}.name && !@{&input}.value) {
|
||||
@{&input}.name = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).ok();
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user