Browse Source

iOS support added

master
Christian Mueller 14 years ago
parent
commit
59f65fbfbc
  1. 10
      src-cljs/main.cljs
  2. 7
      src/NoteHub/views/css_generator.clj
  3. 4
      src/NoteHub/views/pages.clj

10
src-cljs/main.cljs

@ -16,11 +16,17 @@
[$id] [$id]
(anim ($ :body) {:scrollTop ((js->clj (.offset $id)) "top")} 500)) (anim ($ :body) {:scrollTop ((js->clj (.offset $id)) "top")} 500))
; try to detect iOS
(def ios-detected (.match (.-userAgent js/navigator) "(iPad|iPod|iPhone)"))
; set focus to the draft textarea (if there is one) ; set focus to the draft textarea (if there is one)
(when $draft (when $draft
(do (do
(val $draft "") (val $draft "")
(.focus $draft))) ; foces setting is impossible in iOS, so we border the field instead
(if ios-detected
(.addClass $draft "ui-border")
(.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.
(.keypress $draft (.keypress $draft
@ -40,6 +46,8 @@
(show $preview-start-line) (show $preview-start-line)
(scroll-to $preview-start-line))))))) (scroll-to $preview-start-line)))))))
; when the publish button is clicked, compute the hash of the entered text and
; provided session key and assign to the field session-value
(.click ($ :#publish-button) (.click ($ :#publish-button)
(fn [e] (fn [e]
(val ($ :#session-value) (val ($ :#session-value)

7
src/NoteHub/views/css_generator.clj

@ -71,6 +71,9 @@
:color link-hover) :color link-hover)
(rule "&:visited" (rule "&:visited"
:color link-visited)) :color link-visited))
(rule ".ui-border"
:border-radius :3px
:border [:1px :solid foreground])
(rule ".landing-button" (rule ".landing-button"
:box-shadow [0 :2px :5px :#aaa] :box-shadow [0 :2px :5px :#aaa]
:text-decoration :none :text-decoration :none
@ -146,6 +149,7 @@
:outline [:0px :none :transparent]) :outline [:0px :none :transparent])
(rule "textarea" (rule "textarea"
:width (px page-width) :width (px page-width)
:border-radius :5px
:font-family :Courier :font-family :Courier
:font-size :1em :font-size :1em
:border :none :border :none
@ -154,10 +158,9 @@
(rule ".hidden" (rule ".hidden"
:display :none) :display :none)
(rule ".button" (rule ".button"
:border-radius :3px :-webkit-appearance :none
helvetica-neue helvetica-neue
:cursor :pointer :cursor :pointer
:border [:1px :solid foreground]
:opacity 0.8 :opacity 0.8
:font-size :1em :font-size :1em
:background background) :background background)

4
src/NoteHub/views/pages.clj

@ -96,9 +96,9 @@
(text-area {:class :max-width} :draft (get-message :loading)) (text-area {:class :max-width} :draft (get-message :loading))
[:div#buttons.hidden [:div#buttons.hidden
(submit-button {:style "float: left" (submit-button {:style "float: left"
:class :button :class "button ui-border"
:id :publish-button} (get-message :publish)) :id :publish-button} (get-message :publish))
[:button#preview-button.button {:type :button [:button#preview-button.button.ui-border {:type :button
:style "float: right"} (get-message :preview)]])] :style "float: right"} (get-message :preview)]])]
[:div#preview-start-line.dashed-line.hidden] [:div#preview-start-line.dashed-line.hidden]
[:article#preview])) [:article#preview]))

Loading…
Cancel
Save