Skip to content
Browse files

Remove Pinot & ClojureScript submodules; use CLJS compiler from offic…

…ial JAR.

TODO: fixup c2.layout namespace to not rely on now-absent Pinot functions.
  • Loading branch information...
1 parent b40eccf commit bd53d8661b3a266f5068892d8bfdef3ccc3b395e @lynaghk committed Feb 23, 2012
Showing with 58 additions and 68 deletions.
  1. +1 −4 .cake/config
  2. +0 −6 .gitmodules
  3. +2 −2 project.clj
  4. +55 −54 src/cljs/c2/layout.cljs
  5. +0 −1 vendor/clojurescript
  6. +0 −1 vendor/pinot
View
5 .cake/config
@@ -1,6 +1,3 @@
project.classpath = src/cljs\
:src/clj\
-:test/integration/\
-:vendor/clojurescript/src/clj\
-:vendor/clojurescript/src/cljs\
-:vendor/pinot/src
+:test/integration/
View
6 .gitmodules
@@ -1,6 +0,0 @@
-[submodule "vendor/clojurescript"]
- path = vendor/clojurescript
- url = git://github.com/clojure/clojurescript
-[submodule "vendor/pinot"]
- path = vendor/pinot
- url = git://github.com/lynaghk/pinot
View
4 project.clj
@@ -1,10 +1,10 @@
(defproject c2 "0.0.1-SNAPSHOT"
:description "Declarative data visualization in Clojure(Script)."
:dependencies [[org.clojure/clojure "1.3.0"]
- [com.google.javascript/closure-compiler "r1592"]
+ [org.clojure/clojurescript "0.0-927"]
+
[com.keminglabs/cassowary "0.1.0"]
- [goog-jar "1.0.0"] ;;Required for C2 because of its Pinot submodule dependency; will drop when new Pinot JAR is cut or C2 stops using Pinot all together.
[org.clojure/core.match "0.2.0-alpha9"]
[clj-iterate "0.95-SNAPSHOT"]]
View
109 src/cljs/c2/layout.cljs
@@ -2,66 +2,67 @@
(:refer-clojure :exclude [+ - =])
(:use-macros [c2.util :only [p half]])
(:use [c2.core :only [translate children select select-all]]
- [cassowary.core :only [+ - = cvar constrain! stay! simplex-solver]])
- (:require [pinot.dom :as dom]))
+ [cassowary.core :only [+ - = cvar constrain! stay! simplex-solver]]))
-(defn distribute! [selector]
- (let [solver (simplex-solver)
- spacing (cvar 0)
- nodes (dom/query selector)
- container (dom/parent (first nodes))
- container-height (js/parseFloat (dom/attr container :height))
- positions (map #(let [base {:top (cvar (dom/attr % :top))
- :left (cvar (dom/attr % :left))
- :height (cvar (dom/attr % :height))
- :width (cvar (dom/attr % :width))}
- bottom (cvar)
- right (cvar)]
+(comment
+ (defn distribute! [selector]
+ (let [solver (simplex-solver)
+ spacing (cvar 0)
+ nodes (dom/query selector)
+ container (dom/parent (first nodes))
+ container-height (js/parseFloat (dom/attr container :height))
+ positions (map #(let [base {:top (cvar (dom/attr % :top))
+ :left (cvar (dom/attr % :left))
+ :height (cvar (dom/attr % :height))
+ :width (cvar (dom/attr % :width))}
+ bottom (cvar)
+ right (cvar)]
- (doto solver
- (stay! (:height base))
- (stay! (:width base))
- (constrain! (= bottom (+ (:top base) (:height base))))
- (constrain! (= right (+ (:left base) (:width base)))))
- (merge base {:bottom bottom, :right right}))
- nodes)]
+ (doto solver
+ (stay! (:height base))
+ (stay! (:width base))
+ (constrain! (= bottom (+ (:top base) (:height base))))
+ (constrain! (= right (+ (:left base) (:width base)))))
+ (merge base {:bottom bottom, :right right}))
+ nodes)]
- ;;Constraints to distribute the elements across the entire height
- (constrain! solver (= 0 (:top (first positions))))
- (constrain! solver (= container-height
- (:bottom (last positions))))
+ ;;Constraints to distribute the elements across the entire height
+ (constrain! solver (= 0 (:top (first positions))))
+ (constrain! solver (= container-height
+ (:bottom (last positions))))
- (doseq [[t b] (partition 2 1 positions)]
- (constrain! solver (= (:top b) (+ (:bottom t) spacing))))
+ (doseq [[t b] (partition 2 1 positions)]
+ (constrain! solver (= (:top b) (+ (:bottom t) spacing))))
- (doseq [[node pos] (map vector nodes positions)]
- (dom/attr node (translate (.value (:left pos))
- (.value (:top pos)))))))
+ (doseq [[node pos] (map vector nodes positions)]
+ (dom/attr node (translate (.value (:left pos))
+ (.value (:top pos)))))))
-(defn grid [n ncol container-width]
- (let [sep-width (/ container-width (inc ncol))]
- {:positions (map (fn [idx]
- {:top (* sep-width (Math/floor (/ idx ncol)))
- :left (* sep-width (mod idx ncol))})
- (range n))
- :sep-width sep-width
- :container-width container-width
- :container-height (* sep-width (inc (Math/floor (/ n ncol))))}))
+ (defn grid [n ncol container-width]
+ (let [sep-width (/ container-width (inc ncol))]
+ {:positions (map (fn [idx]
+ {:top (* sep-width (Math/floor (/ idx ncol)))
+ :left (* sep-width (mod idx ncol))})
+ (range n))
+ :sep-width sep-width
+ :container-width container-width
+ :container-height (* sep-width (inc (Math/floor (/ n ncol))))}))
-(defn grid!
- "Positions objects in parent container to form a grid ncol items wide"
- [container ncol & {:keys [selector]}]
- (when-let [container (select container)]
- (let [nodes (if selector
- (select-all selector)
- (children container))
- container-width (js/parseFloat (dom/css container :width))
- sep-width (/ container-width (inc ncol))
- {:keys [positions container-height]} (grid (count nodes) ncol container-width)]
+ (defn grid!
+ "Positions objects in parent container to form a grid ncol items wide"
+ [container ncol & {:keys [selector]}]
+ (when-let [container (select container)]
+ (let [nodes (if selector
+ (select-all selector)
+ (children container))
+ container-width (js/parseFloat (dom/css container :width))
+ sep-width (/ container-width (inc ncol))
+ {:keys [positions container-height]} (grid (count nodes) ncol container-width)]
- ;;Position the nodes
- (doseq [[{:keys [top left]} node] (map vector positions nodes)]
- (dom/css node {:-webkit-transform (str "translate(" left "px" ", " top "px" ")")}))
+ ;;Position the nodes
+ (doseq [[{:keys [top left]} node] (map vector positions nodes)]
+ (dom/css node {:-webkit-transform (str "translate(" left "px" ", " top "px" ")")}))
- ;;Manually set container height according to the number of rows
- (dom/css container :height (str container-height "px")))))
+ ;;Manually set container height according to the number of rows
+ (dom/css container :height (str container-height "px")))))
+)
1 vendor/clojurescript
@@ -1 +0,0 @@
-Subproject commit 1028ca12f169322e31d7967d8c385165cf773665
1 vendor/pinot
@@ -1 +0,0 @@
-Subproject commit 16b2bf3feedee26661de2e0aaf6a28bc5dc955a0

0 comments on commit bd53d86

Please sign in to comment.
Something went wrong with that request. Please try again.