Commits

Brian McKenna  committed 159b6fe

Remove function

  • Participants
  • Parent commits 8283223

Comments (0)

Files changed (1)

File src/climacs/editor.cljs

             [goog.events :as events]
             [goog.style :as style]))
 
-(defn call [o f & args]
-  (let [a (to-array args)]
-    (js* "~{f}.apply(~{o}, ~{a})")))
-
 ; Editor
 
 (def field (goog.editor/Field. "editor"))
 
-(call field (.makeEditable field))
+(. field (makeEditable))
 
-(def iframe (call field (.getEditableIframe field)))
+(def iframe (. field (getEditableIframe)))
 (def iframe-doc (. iframe contentDocument))
 (def iframe-body (. iframe-doc body))
 (def iframe-html (. iframe-body parentNode))
    "color" "#FFF"}))
 
 (defn upload-file [e]
-  (js* "console.log(~{})" (call e (.getBrowserEvent e))))
+  (js* "console.log(~{})" (. e (getBrowserEvent))))
 
 (events/listen
  (events/FileDropHandler. iframe-html)
 ; Editor plugin
 
 (defn Climacs []
-  (call (js* "this") goog.editor/Plugin))
+  (. goog.editor/Plugin (call (js* "this"))))
 
 (goog.inherits Climacs goog.editor/Plugin)
 
 (defn set-token-color [sel tkn end color]
   (let [node (aget (.childNodes iframe-body) 0)
         start (.pos tkn)
-        range (call iframe-doc (.createRange iframe-doc))]
-    (call sel (.removeAllRanges sel))
-    (call range (.setStart range) node start)
-    (call range (.setEnd range) node end)
-    (call sel (.addRange sel) range)
-    (call iframe-doc (.execCommand iframe-doc) "ForeColor" false color)))
+        range (. iframe-doc (createRange))]
+    (. sel (removeAllRanges))
+    (. range (setStart node start))
+    (. range (setEnd node end))
+    (. sel (addRange range))
+    (. iframe-doc (execCommand "ForeColor" false color))))
 
 (defn highlight-token [sel tkn end]
   (set-token-color
      "#FFF")))
 
 (defn get-selection []
-  (call iframe-doc (.getSelection iframe-doc)))
+  (. iframe-doc (getSelection)))
 
 (defn highlight-content []
   (let [t (goog.global.tokenizer (get-content))
 (set! (.. Climacs prototype handleKeyUp)
       (fn [e]
         (let [sel (get-selection)
-              range (call sel (.getRangeAt sel) 0)
+              range (. sel (getRangeAt 0))
               prev-start-node (.startContainer range)
               prev-end-node (.endContainer range)
               prev-start-pos (.startOffset range)
               prev-end-pos (.endOffset range)]
 
-          (call field (.setHtml field) false (get-content))
+          (. field (setHtml false (get-content)))
           (try*
            (highlight-content)
            (catch e))
                 nodes-pos (get-range-nodes start end)
                 start-node-pos (first nodes-pos)
                 end-node-pos (second nodes-pos)
-                range (call iframe-doc (.createRange iframe-doc))]
+                range (. iframe-doc (createRange))]
 
-            (call sel (.removeAllRanges sel))
-            (call range (.setStart range) (:node start-node-pos) (:pos start-node-pos))
-            (call range (.setEnd range) (:node end-node-pos) (:pos end-node-pos))
-            (call sel (.addRange sel) range)))))
+            (. sel (removeAllRanges))
+            (. range (setStart (:node start-node-pos) (:pos start-node-pos)))
+            (. range (setEnd (:node end-node-pos) (:pos end-node-pos)))
+            (. sel (addRange range))))))
 
 (set! (.. Climacs prototype handleKeyboardShortcut)
       (fn [e key modifier]
           \j (run-field)
           nil)))
 
-(call field (.registerPlugin field) (Climacs.))
+(. field (registerPlugin (Climacs.)))