Skip to content

Commit eaba0e1

Browse files
committedAug 27, 2013
tabs
1 parent 3ad20f1 commit eaba0e1

File tree

6 files changed

+71
-27
lines changed

6 files changed

+71
-27
lines changed
 

‎externs.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var CodeMirror;
2+
function CodeMirror(){};
3+
CodeMirror.fromTextArea = {};
4+
CodeMirror.refresh = {};
5+
CodeMirror.getValue = {};
6+
CodeMirror.setValue = {};
7+
CodeMirror.setSize = {};
8+
var $;
9+
function $(){};
10+
$.on = {};

‎project.clj

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
:min-lein-version "2.0.0"
2323
:profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}}
2424
:ring {:handler cljsfiddle.handler/app}
25-
:cljsbuild {:builds [{:source-paths ["src/cljs"]
25+
:cljsbuild {:builds [{:id "dev"
26+
:source-paths ["src/cljs"]
2627
:compiler {:output-to "resources/public/js/app.js"
27-
:optimizations :whitespace
28-
:pretty-print true}}]})
28+
:optimizations :simple
29+
:pretty-print true}}
30+
{:id "prod"
31+
:source-paths ["src/cljs"]
32+
:compiler {:output-to "resources/public/js/app.js"
33+
:optimizations :advanced
34+
:static-fns true
35+
:externs ["externs.js"]}}]})

‎resources/public/favicon.ico

3.62 KB
Binary file not shown.

‎src/clj/cljsfiddle/gendeps.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
(optimize-ws (output-dir version))
3939
(println "done."))
4040

41-
;; (-main "2")
41+
;; (-main "1")
4242

4343

‎src/clj/cljsfiddle/views.clj

+32-19
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,46 @@
2828

2929
(defn main-view
3030
[fiddle user]
31-
(base [:hr {:style "margin-top:4px;margin-bottom:4px;"}]
32-
[:div.row
33-
[:div.col-lg-12
34-
[:button#run-btn.btn.btn-default {:type "Button"} "Run"] " "
35-
[:button#save-btn.btn.btn-default {:type "Button"} "Save"] " "
36-
[:button#recent-btn.btn.btn-default {:type "Button"} "Recent"] " "
37-
[:button#about-btn.btn.btn-default {:type "Button"} "About"] " "
38-
[:button#about-btn.btn.btn-default {:type "Button"} "Help"]
39-
[:span.pull-right (if user
40-
[:a {:href "/logout"} "Logout (" user ")"]
41-
[:a {:href github-login-url}
42-
"Login with github"])]]]
43-
[:hr {:style "margin-top:4px;margin-bottom:4px;"}]
31+
(base [:nav.navbar.navbar-default {:role "navigation"}
32+
[:div.navbar-header
33+
[:button.navbar-toggle {:type "button"
34+
:data-toggle "collapse"
35+
:data-target ".navbar-ex1-collapse"}
36+
[:span.sr-only "Toggle navigation"]
37+
[:span.icon-bar]
38+
[:span.icon-bar]
39+
[:span.icon-bar]]
40+
[:a.navbar-brand "CLJSFiddle"]]
41+
[:div.collapse.navbar-collapse.navbar-ex1-collapse
42+
[:ul.nav.navbar-nav
43+
[:li [:button#run-btn.btn.btn-default.navbar-btn {:type "button"} "Run"] " "]
44+
[:li [:button#save-btn.btn.btn-default.navbar-btn {:type "button"} "Save"] " "]
45+
[:li [:button#about-btn.btn.btn-default.navbar-btn {:type "button"} "About"]]]
46+
[:ul.nav.navbar-nav.navbar-right
47+
[:li (if user
48+
[:a {:href "/logout"} "Logout (" user ")"]
49+
[:a {:href github-login-url} "Login"])]]]]
4450
[:div.row
4551
[:div.col-lg-12
4652
[:div#alert]]]
4753
[:div.row
48-
[:div.col-lg-6 [:textarea#html-editor (escape-html (:fiddle/html fiddle))]]
49-
[:div.col-lg-6 [:textarea#css-editor (escape-html (:fiddle/css fiddle))]]]
50-
[:div.row
51-
[:div.col-lg-6 [:textarea#cljs-editor (escape-html (:fiddle/cljs fiddle))]]
54+
[:div.col-lg-6 [:ul.nav.nav-tabs
55+
[:li.active [:a {:href "#cljs-editor-tab" :data-toggle "tab"} "cljs"]]
56+
[:li [:a {:href "#html-editor-tab" :data-toggle "tab"} "html"]]
57+
[:li [:a {:href "#css-editor-tab" :data-toggle "tab"} "css"]]]
58+
[:div.tab-content
59+
[:div#cljs-editor-tab.tab-pane.active
60+
[:textarea#cljs-editor.tab-pane.active (escape-html (:fiddle/cljs fiddle))]]
61+
[:div#html-editor-tab.tab-pane
62+
[:textarea#html-editor.tab-pane (escape-html (:fiddle/html fiddle))]]
63+
[:div#css-editor-tab.tab-pane
64+
[:textarea#css-editor.tab-pane (escape-html (:fiddle/css fiddle))]]]]
5265
[:div.col-lg-6 [:iframe#result-frame {:seamless "seamless"
5366
:sandbox "allow-scripts"
5467
:width "100%"
55-
:style "border: 1px solid lightgray;height:260px;"}]]]
68+
:style "border: 1px solid lightgray;height:500px;"}]]]
5669
[:hr]
5770
[:div.row
5871
[:div.col-lg-12
5972
[:p.text-center {:style "margin-bottom: 10px;"}
60-
[:a {:href "http://www.cljsfiddle.net"} "cljsfiddle"] " © 2013 Jonas Enlund"]]]))
73+
[:a {:href "http://cljsfiddle.net"} "cljsfiddle.net"] " © 2013 Jonas Enlund"]]]))

‎src/cljs/cljsfiddle/core.cljs

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns cljsfiddle.core
22
(:require [clojure.string :as s]
33
[domina :as dom]
4+
[domina.css :as css]
45
[domina.events :as events]
56
[hylla.remote :as remote]))
67

@@ -34,16 +35,21 @@
3435
(defn alert-error [msg]
3536
(alert "danger" msg))
3637

37-
(defn init
38+
(defn ^:export init
3839
[]
40+
(alert-error "This is work-in-progress. Expect bugs/downtime and don't expect your saved work to be durable.")
41+
3942
(let [html-editor (code-mirror "html-editor" {:lineNumbers true})
4043
css-editor (code-mirror "css-editor" {:mode :css :lineNumbers true})
4144
cljs-editor (code-mirror "cljs-editor" {:mode :clojure :lineNumbers true})
4245
result-frame (domina/by-id "result-frame")
4346
run-btn (domina/by-id "run-btn")
4447
save-btn (domina/by-id "save-btn")]
45-
(.setSize html-editor "100%" "150px")
46-
(.setSize css-editor "100%" "150px")
48+
49+
(.setSize cljs-editor "100%" "455px")
50+
(.setSize html-editor "100%" "455px")
51+
(.setSize css-editor "100%" "455px")
52+
4753
(events/listen! run-btn :click
4854
(fn [e]
4955
(remote/post "/compiler/compile" {:src (.getValue cljs-editor)}
@@ -62,4 +68,12 @@
6268
(fn [res]
6369
(if (= (:status res) :success)
6470
(alert-success "Fiddle saved successfully!")
65-
(alert-error (:msg res)))))))))
71+
(alert-error (:msg res)))))))
72+
73+
(.on (js/$ "a[data-toggle=\"tab\"]")
74+
"shown.bs.tab"
75+
(fn [evt]
76+
(condp = (dom/attr (.-target evt) :href)
77+
"#cljs-editor-tab" (.refresh cljs-editor)
78+
"#html-editor-tab" (.refresh html-editor)
79+
"#css-editor-tab" (.refresh css-editor))))))

0 commit comments

Comments
 (0)
Please sign in to comment.