atlas_assets 0.8.10 → 0.8.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +12 -12
- data/docs/_posts/2014-05-05-select.md +12 -1
- data/lib/assets/javascripts/views/select.coffee +16 -14
- data/lib/atlas_assets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWNmZjkyZDJlNTA4ZmMxYzQyNTg0NDdjMGQwMzkwOTJkYTg4MDE1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzNkNDExYTRkMjU0NzkyMmE1NjlkZTc0ZTUwOGI1NzNiYTVhYTRjMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTEyYmQ1ZWIzNGYzNmQ1MjAxNDhiYjI1ZDUwOTFmYjg3ZGZkNGViMGMyOTJl
|
10
|
+
MGJjMTczMDljOWYwMzkwNTIxMDRlNWE4OTJkYTRmMmJmYzk2OGQ4OTUwODE5
|
11
|
+
MTFlODQyMDJjY2E5OWYzNDYwNzdiNDA3ZmExZmYxZmQ1ZDcyYWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTg0Nzc3YTIyZmFmMTQ1OGUwNjRjMDg1YjBhMDkxYzRkYWUyMmJmOGUxYTQy
|
14
|
+
NmQyYzIxMTk0MGJmYzUyNTYzOGRkYTRiNjkzNmJhMmFhODExODc1MWYxODdl
|
15
|
+
MTZiNGE1MDdlY2YwMGI2M2FiODQ4MzlhOTUzZmI5YmIyYTJjNTA=
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
atlas_assets (0.8.
|
4
|
+
atlas_assets (0.8.10)
|
5
5
|
handlebars_assets (= 0.17.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
blankslate (2.1.2.4)
|
11
11
|
celluloid (0.16.0)
|
12
12
|
timers (~> 4.0.0)
|
13
|
-
classifier-reborn (2.0.
|
13
|
+
classifier-reborn (2.0.2)
|
14
14
|
fast-stemmer (~> 1.0)
|
15
15
|
coderay (1.0.9)
|
16
16
|
coffee-script (2.3.0)
|
@@ -23,9 +23,9 @@ GEM
|
|
23
23
|
eco-source
|
24
24
|
execjs
|
25
25
|
eco-source (1.1.0.rc.1)
|
26
|
-
execjs (2.2.
|
26
|
+
execjs (2.2.2)
|
27
27
|
fast-stemmer (1.0.2)
|
28
|
-
ffi (1.9.
|
28
|
+
ffi (1.9.6)
|
29
29
|
handlebars_assets (0.17.1)
|
30
30
|
execjs (>= 1.2.9)
|
31
31
|
multi_json
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
tilt
|
34
34
|
hike (1.2.3)
|
35
35
|
hitimes (1.2.2)
|
36
|
-
jekyll (2.
|
36
|
+
jekyll (2.5.1)
|
37
37
|
classifier-reborn (~> 2.0)
|
38
38
|
colorator (~> 0.1)
|
39
39
|
jekyll-coffeescript (~> 1.0)
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
redcarpet (~> 3.1)
|
49
49
|
safe_yaml (~> 1.0)
|
50
50
|
toml (~> 0.1.0)
|
51
|
-
jekyll-assets (0.
|
51
|
+
jekyll-assets (0.11.0)
|
52
52
|
jekyll (~> 2.0)
|
53
53
|
sass (~> 3.2)
|
54
54
|
sprockets (~> 2.10)
|
@@ -57,12 +57,12 @@ GEM
|
|
57
57
|
jekyll-coffeescript (1.0.1)
|
58
58
|
coffee-script (~> 2.2)
|
59
59
|
jekyll-gist (1.1.0)
|
60
|
-
jekyll-paginate (1.
|
60
|
+
jekyll-paginate (1.1.0)
|
61
61
|
jekyll-sass-converter (1.2.1)
|
62
62
|
sass (~> 3.2)
|
63
|
-
jekyll-watch (1.1.
|
63
|
+
jekyll-watch (1.1.2)
|
64
64
|
listen (~> 2.7)
|
65
|
-
kramdown (1.
|
65
|
+
kramdown (1.5.0)
|
66
66
|
liquid (2.6.1)
|
67
67
|
listen (2.7.11)
|
68
68
|
celluloid (>= 0.15.2)
|
@@ -87,10 +87,10 @@ GEM
|
|
87
87
|
rb-fsevent (0.9.4)
|
88
88
|
rb-inotify (0.9.5)
|
89
89
|
ffi (>= 0.5.0)
|
90
|
-
redcarpet (3.
|
90
|
+
redcarpet (3.2.0)
|
91
91
|
safe_yaml (1.0.4)
|
92
92
|
sass (3.2.19)
|
93
|
-
sprockets (2.12.
|
93
|
+
sprockets (2.12.3)
|
94
94
|
hike (~> 1.2)
|
95
95
|
multi_json (~> 1.0)
|
96
96
|
rack (~> 1.0)
|
@@ -103,7 +103,7 @@ GEM
|
|
103
103
|
tilt (1.4.1)
|
104
104
|
timers (4.0.1)
|
105
105
|
hitimes
|
106
|
-
toml (0.1.
|
106
|
+
toml (0.1.2)
|
107
107
|
parslet (~> 1.5.0)
|
108
108
|
yajl-ruby (1.1.0)
|
109
109
|
|
@@ -67,7 +67,9 @@ select2.on('change', function (model) {
|
|
67
67
|
|
68
68
|
You can also define a value that is different from the visible label, deactivate sorting of options and define a default option.
|
69
69
|
|
70
|
-
<div id="collection-example-b"></div>
|
70
|
+
<div id="collection-example-b"></div>
|
71
|
+
<a id="get-current-value" class="btn" href="#">Get current value</a>
|
72
|
+
<a id="get-current-model" class="btn" href="#">Get current model</a>
|
71
73
|
|
72
74
|
~~~js
|
73
75
|
var select2b = new classes.SelectView({
|
@@ -124,6 +126,15 @@ $('#collection-example-b').html(select2b.render().el)
|
|
124
126
|
select2b.on('change', function (model) {
|
125
127
|
$('#collection-example-b').append(model.get('label'))
|
126
128
|
})
|
129
|
+
$('#get-current-value').click(function(e){
|
130
|
+
e.preventDefault();
|
131
|
+
$('#collection-example-b').append(select2b.get_value() );
|
132
|
+
});
|
133
|
+
$('#get-current-model').click(function(e){
|
134
|
+
e.preventDefault();
|
135
|
+
console.log(select2b.get_model())
|
136
|
+
$('#collection-example-b').append(select2b.get_model().attributes.toString() );
|
137
|
+
});
|
127
138
|
|
128
139
|
</script>
|
129
140
|
|
@@ -20,19 +20,22 @@ class classes.SelectView extends Backbone.View
|
|
20
20
|
initialize: (options) ->
|
21
21
|
@rendered = false
|
22
22
|
|
23
|
-
@label
|
24
|
-
@value
|
25
|
-
@default_to= if options.default_to then options.default_to else false
|
26
|
-
@sort
|
27
|
-
@helper
|
23
|
+
@label = if options.label? then options.label else @defaults.label
|
24
|
+
@value = if options.value? then options.value else false
|
25
|
+
@default_to = if options.default_to? then options.default_to else false
|
26
|
+
@sort = if options.sort? then options.sort else @defaults.sort
|
27
|
+
@helper = options.helper if options.helper?
|
28
28
|
|
29
29
|
# The select view needs a collection.
|
30
30
|
if !@collection
|
31
31
|
@collection = @collection_from_values(options.values)
|
32
32
|
else if @collection.length > 0
|
33
33
|
t = @
|
34
|
-
@collection.each (model) ->
|
35
|
-
|
34
|
+
@collection.each (model) ->
|
35
|
+
t.set_model_attributes(model)
|
36
|
+
else
|
37
|
+
throw new Error "Select needs either a collection or an array of values"
|
38
|
+
|
36
39
|
@template = JST["templates/select"]
|
37
40
|
@listenTo(@collection, 'add', @add_model)
|
38
41
|
@listenTo(@collection, 'remove', @render)
|
@@ -50,12 +53,11 @@ class classes.SelectView extends Backbone.View
|
|
50
53
|
add_model: (m) ->
|
51
54
|
@set_model_attributes(m)
|
52
55
|
select_el = @$el.find('select').first()
|
53
|
-
value =
|
56
|
+
value = if m.get('value') then "value='#{m.get('value')}'" else ""
|
54
57
|
select_el.append("<option #{value}>#{m.get('label')}</option>")
|
55
58
|
|
56
59
|
sort_by_name = (a, b) ->
|
57
|
-
a.innerHTML.toLowerCase().localeCompare(b.innerHTML.toLowerCase())
|
58
|
-
|
60
|
+
a.innerHTML.trim().toLowerCase().localeCompare(b.innerHTML.trim().toLowerCase())
|
59
61
|
options = select_el.children().get()
|
60
62
|
options = options.sort(sort_by_name) if @sort
|
61
63
|
for opt in options
|
@@ -80,9 +82,9 @@ class classes.SelectView extends Backbone.View
|
|
80
82
|
|
81
83
|
@select.on('change', (v) ->
|
82
84
|
if t.value
|
83
|
-
selected_model = t.collection.find((model) -> model.get(t.value) is v.value)
|
85
|
+
selected_model = t.collection.find( (model) -> model.get(t.value) is v.value)
|
84
86
|
else
|
85
|
-
selected_model = t.collection.find((model) -> model.get(t.label) is v.value)
|
87
|
+
selected_model = t.collection.find( (model) -> model.get(t.label) is v.value)
|
86
88
|
|
87
89
|
t.trigger('change', selected_model)
|
88
90
|
)
|
@@ -90,8 +92,8 @@ class classes.SelectView extends Backbone.View
|
|
90
92
|
get_value: -> @select.value
|
91
93
|
get_model: ->
|
92
94
|
value = @select.value
|
93
|
-
if
|
94
|
-
@collection.find (model) => model.get('value') is value
|
95
|
+
if @value
|
96
|
+
@collection.find (model) => model.get('value') is value or model.get('label') is value
|
95
97
|
else
|
96
98
|
@collection.find (model) => model.get('label') is value
|
97
99
|
|
data/lib/atlas_assets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atlas_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rune Skjoldborg Madsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: handlebars_assets
|