|
|
|
@ -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,8 +72,8 @@ |
|
|
|
(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)))) |
|
|
|
|
|
|
|
|
|
|
|
|