Browse Source

minor improvements

master
Christian Mueller 12 years ago
parent
commit
2624222611
  1. 12
      src-cljs/main.cljs
  2. 2
      src/NoteHub/views/common.clj
  3. 11
      src/NoteHub/views/css.clj

12
src-cljs/main.cljs

@ -41,13 +41,13 @@
(.reset md5) (.reset md5)
; try to detect iOS ; try to detect iOS
(def ios-detected (.match (.-userAgent js/navigator) "(iPad|iPod|iPhone)")) (def ios-detected? (.match (.-userAgent js/navigator) "(iPad|iPod|iPhone)"))
(def timer nil) (def timer nil)
(def timerDelay (def timerDelay
; TODO: also test for Android ; TODO: also test for Android
(if ios-detected 800 400)) (if ios-detected? 800 400))
(defn update-preview (defn update-preview
"Updates the preview" "Updates the preview"
@ -55,6 +55,8 @@
(do (do
(js/clearTimeout timer) (js/clearTimeout timer)
(let [content (val $draft) (let [content (val $draft)
; the delay between the last typing and preview update is dynamic
; and increases with the length of the text
delay (Math/min timerDelay (* timerDelay (/ (count content) 400)))] delay (Math/min timerDelay (* timerDelay (/ (count content) 400)))]
(def timer (def timer
(js/setTimeout (js/setTimeout
@ -70,9 +72,9 @@
(if (= "update" (val $action)) (if (= "update" (val $action))
(update-preview) (update-preview)
(val $draft "")) (val $draft ""))
; foces setting is impossible in iOS, so we border the field instead ; focus setting is impossible in iOS, so we border the field instead
(if ios-detected (if ios-detected?
(set! (.-className $draft) (str (.-className $draft) "ui-border")) (set! (.-className $draft) (str (.-className $draft) " ui-border"))
(.focus $draft)))) (.focus $draft))))
; show the preview & publish buttons as soon as the user starts typing. ; show the preview & publish buttons as soon as the user starts typing.

2
src/NoteHub/views/common.clj

@ -1,7 +1,7 @@
(ns NoteHub.views.common (ns NoteHub.views.common
(:use (:use
[NoteHub.settings :only [get-message]] [NoteHub.settings :only [get-message]]
[NoteHub.views.css-generator] [NoteHub.views.css]
[noir.core :only [defpartial]] [noir.core :only [defpartial]]
[noir.options :only [dev-mode?]] [noir.options :only [dev-mode?]]
[hiccup.util :only [escape-html]] [hiccup.util :only [escape-html]]

11
src/NoteHub/views/css_generator.clj → src/NoteHub/views/css.clj

@ -1,4 +1,4 @@
(ns NoteHub.views.css-generator (ns NoteHub.views.css
(:use (:use
[cssgen] [cssgen]
[cssgen.types :only [px %]] [cssgen.types :only [px %]]
@ -93,12 +93,13 @@
:opacity 0.8 :opacity 0.8
:font-size :1em :font-size :1em
:background background) :background background)
(rule ".landing-button, table, tr, td, textarea, fieldset"
:border :none)
(rule ".landing-button" (rule ".landing-button"
:box-shadow [0 :2px :5px :#aaa] :box-shadow [0 :2px :5px :#aaa]
:text-decoration :none :text-decoration :none
:font-size :1.5em :font-size :1.5em
:background :#0a2 :background :#0a2
:border :none
:border-radius :10px :border-radius :10px
:padding :10px :padding :10px
helvetica-neue helvetica-neue
@ -126,8 +127,7 @@
(rule "& > td:first-child" (rule "& > td:first-child"
:text-align :right))) :text-align :right)))
(rule "table,tr,td" (rule "table,tr,td"
:margin 0 :margin 0)
:border :none)
(rule "td" (rule "td"
:padding :0.5em) :padding :0.5em)
(rule ".one-third-column" (rule ".one-third-column"
@ -174,14 +174,11 @@
:border-radius :5px :border-radius :5px
:font-family :Courier :font-family :Courier
:font-size :1em :font-size :1em
:border :none
:height :500px) :height :500px)
(rule ".hidden" (rule ".hidden"
:display :none) :display :none)
(rule ".central-element" (rule ".central-element"
central-element) central-element)
(rule "fieldset"
:border :none)
(rule "h1" (rule "h1"
:font-size :2em) :font-size :2em)
(rule "#dashed-line" (rule "#dashed-line"
Loading…
Cancel
Save