File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ You can set `Pace.options` before bringing in the file:
2020Pace = {
2121 options: {
2222 // Disable the 'elements' source
23- elements: false
23+ elements: false ,
24+
25+ theme: ' barber-shop'
2426 }
2527}
2628```
@@ -41,6 +43,19 @@ define(['pace'], function(pace){
4143});
4244```
4345
46+ Themes
47+ ------
48+
49+ Pace includes a bunch of themes to get you started. Specify the theme of your choice as
50+ an option, and include the appropriate css file.
51+
52+ You can specify the theme as an option, but to keep things simple, we also support
53+ specifying it as a seperate data attribute:
54+
55+ ``` html
56+ <script data-pace-theme =' barber-shop' src =' pace.js' ></script >
57+ ```
58+
4459Collectors
4560----------
4661
Original file line number Diff line number Diff line change @@ -78,10 +78,15 @@ extend = (out, sources...) ->
7878 out[key] = val
7979 out
8080
81- getOptionsFromDOM = ->
82- el = document .querySelector ' [data-pace-options]'
83- data = el .getAttribute ' data-pace-options'
81+ getFromDOM = (key = ' options' , json = true ) ->
82+ el = document .querySelector " [data-pace-#{ key } ]"
83+
84+ return unless el
85+
86+ data = el .getAttribute " data-pace-#{ key } "
8487
88+ return data if not json
89+
8590 try
8691 return JSON .parse data
8792 catch e
@@ -90,7 +95,10 @@ getOptionsFromDOM = ->
9095window .Pace ?= {}
9196Pace .options ?= {}
9297
93- options = extend Pace ? .options , getOptionsFromDOM (), defaultOptions
98+ options = extend Pace ? .options , getFromDOM (), defaultOptions
99+
100+ if domTheme = getFromDOM (' theme' , false )
101+ options .theme = domTheme
94102
95103class Bar
96104 constructor : ->
You can’t perform that action at this time.
0 commit comments