chosen-rails 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chosen-rails.rb +6 -3
- data/lib/chosen-rails/engine.rb +3 -0
- data/lib/chosen-rails/engine3.rb +11 -0
- data/lib/chosen-rails/version.rb +2 -2
- data/vendor/assets/javascripts/chosen.jquery.coffee +18 -22
- data/vendor/assets/javascripts/chosen.proto.coffee +19 -23
- data/vendor/assets/javascripts/lib/abstract-chosen.coffee +6 -2
- data/vendor/assets/stylesheets/chosen.css.sass +12 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 627f993c355b60dd67a5f475a7e3049eab8ad08a
|
4
|
+
data.tar.gz: f5a266a53e616da1847ea1401caa18a99b77e785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09814cc265bbece45725638297abb5fc1285aed5c1cad288580c87c63f8c46a00acd371f31663f9aef273070653f2aea41c048a265cb615ce4f97da5c34bc58
|
7
|
+
data.tar.gz: 926cfe2150e8b4874e105ad800c2f663f71748cb25c2d1e402e9add3dbf1e8c00879608d9a3b5c9b1e1f9714ba5cc69c353bb88ef1050073cf3c3bd198010556
|
data/lib/chosen-rails.rb
CHANGED
@@ -2,10 +2,13 @@ require 'chosen-rails/version'
|
|
2
2
|
|
3
3
|
module Chosen
|
4
4
|
module Rails
|
5
|
-
|
6
|
-
|
7
|
-
else
|
5
|
+
case ::Rails.version.to_s
|
6
|
+
when /^4/
|
8
7
|
require 'chosen-rails/engine'
|
8
|
+
when /^3\.[12]/
|
9
|
+
require 'chosen-rails/engine3'
|
10
|
+
when /^3\.[0]/
|
11
|
+
require 'chosen-rails/railtie'
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
data/lib/chosen-rails/engine.rb
CHANGED
data/lib/chosen-rails/version.rb
CHANGED
@@ -44,9 +44,9 @@ class Chosen extends AbstractChosen
|
|
44
44
|
@container = ($ "<div />", container_props)
|
45
45
|
|
46
46
|
if @is_multiple
|
47
|
-
@container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"
|
47
|
+
@container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>'
|
48
48
|
else
|
49
|
-
@container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"
|
49
|
+
@container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
|
50
50
|
|
51
51
|
@form_field_jq.hide().after @container
|
52
52
|
@dropdown = @container.find('div.chzn-drop').first()
|
@@ -78,6 +78,7 @@ class Chosen extends AbstractChosen
|
|
78
78
|
@search_results.mouseup (evt) => this.search_results_mouseup(evt); return
|
79
79
|
@search_results.mouseover (evt) => this.search_results_mouseover(evt); return
|
80
80
|
@search_results.mouseout (evt) => this.search_results_mouseout(evt); return
|
81
|
+
@search_results.bind 'mousewheel DOMMouseScroll', (evt) => this.search_results_mousewheel(evt); return
|
81
82
|
|
82
83
|
@form_field_jq.bind "liszt:updated", (evt) => this.results_update_field(evt); return
|
83
84
|
@form_field_jq.bind "liszt:activate", (evt) => this.activate_field(evt); return
|
@@ -93,7 +94,6 @@ class Chosen extends AbstractChosen
|
|
93
94
|
else
|
94
95
|
@container.click (evt) => evt.preventDefault(); return # gobble click of anchor
|
95
96
|
|
96
|
-
|
97
97
|
search_field_disabled: ->
|
98
98
|
@is_disabled = @form_field_jq[0].disabled
|
99
99
|
if(@is_disabled)
|
@@ -125,6 +125,13 @@ class Chosen extends AbstractChosen
|
|
125
125
|
container_mouseup: (evt) ->
|
126
126
|
this.results_reset(evt) if evt.target.nodeName is "ABBR" and not @is_disabled
|
127
127
|
|
128
|
+
search_results_mousewheel: (evt) ->
|
129
|
+
delta = -evt.originalEvent?.wheelDelta or evt.originialEvent?.detail
|
130
|
+
if delta?
|
131
|
+
evt.preventDefault()
|
132
|
+
delta = delta * 40 if evt.type is 'DOMMouseScroll'
|
133
|
+
@search_results.scrollTop(delta + @search_results.scrollTop())
|
134
|
+
|
128
135
|
blur_test: (evt) ->
|
129
136
|
this.close_field() if not @active_field and @container.hasClass "chzn-container-active"
|
130
137
|
|
@@ -220,16 +227,15 @@ class Chosen extends AbstractChosen
|
|
220
227
|
@result_highlight = null
|
221
228
|
|
222
229
|
results_show: ->
|
223
|
-
if
|
224
|
-
|
225
|
-
|
226
|
-
this.result_do_highlight( @result_single_selected )
|
227
|
-
else if @max_selected_options <= @choices
|
230
|
+
if @result_single_selected?
|
231
|
+
this.result_do_highlight @result_single_selected
|
232
|
+
else if @is_multiple and @max_selected_options <= @choices
|
228
233
|
@form_field_jq.trigger("liszt:maxselected", {chosen: this})
|
229
234
|
return false
|
230
235
|
|
236
|
+
@container.addClass "chzn-with-drop"
|
231
237
|
@form_field_jq.trigger("liszt:showing_dropdown", {chosen: this})
|
232
|
-
|
238
|
+
|
233
239
|
@results_showing = true
|
234
240
|
|
235
241
|
@search_field.focus()
|
@@ -238,10 +244,11 @@ class Chosen extends AbstractChosen
|
|
238
244
|
this.winnow_results()
|
239
245
|
|
240
246
|
results_hide: ->
|
241
|
-
@selected_item.removeClass "chzn-single-with-drop" unless @is_multiple
|
242
247
|
this.result_clear_highlight()
|
248
|
+
|
249
|
+
@container.removeClass "chzn-with-drop"
|
243
250
|
@form_field_jq.trigger("liszt:hiding_dropdown", {chosen: this})
|
244
|
-
|
251
|
+
|
245
252
|
@results_showing = false
|
246
253
|
|
247
254
|
|
@@ -281,12 +288,6 @@ class Chosen extends AbstractChosen
|
|
281
288
|
search_results_mouseout: (evt) ->
|
282
289
|
this.result_clear_highlight() if $(evt.target).hasClass "active-result" or $(evt.target).parents('.active-result').first()
|
283
290
|
|
284
|
-
|
285
|
-
choices_click: (evt) ->
|
286
|
-
evt.preventDefault()
|
287
|
-
if( @active_field and not($(evt.target).hasClass "search-choice" or $(evt.target).parents('.search-choice').first) and not @results_showing )
|
288
|
-
this.results_show()
|
289
|
-
|
290
291
|
choice_build: (item) ->
|
291
292
|
if @is_multiple and @max_selected_options <= @choices
|
292
293
|
@form_field_jq.trigger("liszt:maxselected", {chosen: this})
|
@@ -570,8 +571,3 @@ class Chosen extends AbstractChosen
|
|
570
571
|
string
|
571
572
|
|
572
573
|
root.Chosen = Chosen
|
573
|
-
|
574
|
-
get_side_border_padding = (elmt) ->
|
575
|
-
side_border_padding = elmt.outerWidth() - elmt.width()
|
576
|
-
|
577
|
-
root.get_side_border_padding = get_side_border_padding
|
@@ -17,8 +17,8 @@ class Chosen extends AbstractChosen
|
|
17
17
|
super()
|
18
18
|
|
19
19
|
# HTML Templates
|
20
|
-
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"
|
21
|
-
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"
|
20
|
+
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
|
21
|
+
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>')
|
22
22
|
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
|
23
23
|
@choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>')
|
24
24
|
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
|
@@ -69,6 +69,8 @@ class Chosen extends AbstractChosen
|
|
69
69
|
@search_results.observe "mouseup", (evt) => this.search_results_mouseup(evt)
|
70
70
|
@search_results.observe "mouseover", (evt) => this.search_results_mouseover(evt)
|
71
71
|
@search_results.observe "mouseout", (evt) => this.search_results_mouseout(evt)
|
72
|
+
@search_results.observe "mousewheel", (evt) => this.search_results_mousewheel(evt)
|
73
|
+
@search_results.observe "DOMMouseScroll", (evt) => this.search_results_mousewheel(evt)
|
72
74
|
|
73
75
|
@form_field.observe "liszt:updated", (evt) => this.results_update_field(evt)
|
74
76
|
@form_field.observe "liszt:activate", (evt) => this.activate_field(evt)
|
@@ -114,6 +116,13 @@ class Chosen extends AbstractChosen
|
|
114
116
|
container_mouseup: (evt) ->
|
115
117
|
this.results_reset(evt) if evt.target.nodeName is "ABBR" and not @is_disabled
|
116
118
|
|
119
|
+
search_results_mousewheel: (evt) ->
|
120
|
+
delta = -evt.wheelDelta or evt.detail
|
121
|
+
if delta?
|
122
|
+
evt.preventDefault()
|
123
|
+
delta = delta * 40 if evt.type is 'DOMMouseScroll'
|
124
|
+
@search_results.scrollTop = delta + @search_results.scrollTop
|
125
|
+
|
117
126
|
blur_test: (evt) ->
|
118
127
|
this.close_field() if not @active_field and @container.hasClassName("chzn-container-active")
|
119
128
|
|
@@ -207,16 +216,15 @@ class Chosen extends AbstractChosen
|
|
207
216
|
@result_highlight = null
|
208
217
|
|
209
218
|
results_show: ->
|
210
|
-
if
|
211
|
-
@
|
212
|
-
|
213
|
-
this.result_do_highlight( @result_single_selected )
|
214
|
-
else if @max_selected_options <= @choices
|
219
|
+
if @result_single_selected?
|
220
|
+
this.result_do_highlight @result_single_selected
|
221
|
+
else if @is_multiple and @max_selected_options <= @choices
|
215
222
|
@form_field.fire("liszt:maxselected", {chosen: this})
|
216
223
|
return false
|
217
224
|
|
225
|
+
@container.addClassName "chzn-with-drop"
|
218
226
|
@form_field.fire("liszt:showing_dropdown", {chosen: this})
|
219
|
-
|
227
|
+
|
220
228
|
@results_showing = true
|
221
229
|
|
222
230
|
@search_field.focus()
|
@@ -225,10 +233,11 @@ class Chosen extends AbstractChosen
|
|
225
233
|
this.winnow_results()
|
226
234
|
|
227
235
|
results_hide: ->
|
228
|
-
@selected_item.removeClassName('chzn-single-with-drop') unless @is_multiple
|
229
236
|
this.result_clear_highlight()
|
237
|
+
|
238
|
+
@container.removeClassName "chzn-with-drop"
|
230
239
|
@form_field.fire("liszt:hiding_dropdown", {chosen: this})
|
231
|
-
|
240
|
+
|
232
241
|
@results_showing = false
|
233
242
|
|
234
243
|
|
@@ -268,12 +277,6 @@ class Chosen extends AbstractChosen
|
|
268
277
|
search_results_mouseout: (evt) ->
|
269
278
|
this.result_clear_highlight() if evt.target.hasClassName('active-result') or evt.target.up('.active-result')
|
270
279
|
|
271
|
-
|
272
|
-
choices_click: (evt) ->
|
273
|
-
evt.preventDefault()
|
274
|
-
if( @active_field and not(evt.target.hasClassName('search-choice') or evt.target.up('.search-choice')) and not @results_showing )
|
275
|
-
this.results_show()
|
276
|
-
|
277
280
|
choice_build: (item) ->
|
278
281
|
if @is_multiple and @max_selected_options <= @choices
|
279
282
|
@form_field.fire("liszt:maxselected", {chosen: this})
|
@@ -556,10 +559,3 @@ class Chosen extends AbstractChosen
|
|
556
559
|
@search_field.setStyle({'width': w + 'px'})
|
557
560
|
|
558
561
|
root.Chosen = Chosen
|
559
|
-
|
560
|
-
|
561
|
-
get_side_border_padding = (elmt) ->
|
562
|
-
layout = new Element.Layout(elmt)
|
563
|
-
side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right")
|
564
|
-
|
565
|
-
root.get_side_border_padding = get_side_border_padding
|
@@ -95,6 +95,10 @@ class AbstractChosen
|
|
95
95
|
else
|
96
96
|
this.results_show()
|
97
97
|
|
98
|
+
choices_click: (evt) ->
|
99
|
+
evt.preventDefault()
|
100
|
+
this.results_show() unless @results_showing
|
101
|
+
|
98
102
|
keyup_checker: (evt) ->
|
99
103
|
stroke = evt.which ? evt.keyCode
|
100
104
|
this.search_field_scale()
|
@@ -128,10 +132,10 @@ class AbstractChosen
|
|
128
132
|
|
129
133
|
container_width: ->
|
130
134
|
return @options.width if @options.width?
|
131
|
-
|
135
|
+
|
132
136
|
width = if window.getComputedStyle?
|
133
137
|
parseFloat window.getComputedStyle(@form_field).getPropertyValue('width')
|
134
|
-
else if jQuery?
|
138
|
+
else if jQuery? and @form_field_jq?
|
135
139
|
@form_field_jq.outerWidth()
|
136
140
|
else
|
137
141
|
@form_field.getWidth()
|
@@ -13,7 +13,7 @@
|
|
13
13
|
border-top: 0
|
14
14
|
position: absolute
|
15
15
|
top: 100%
|
16
|
-
left:
|
16
|
+
left: -9999px
|
17
17
|
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
18
18
|
-moz-box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
19
19
|
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
@@ -24,6 +24,8 @@
|
|
24
24
|
-webkit-box-sizing: border-box
|
25
25
|
-khtml-box-sizing: border-box
|
26
26
|
box-sizing: border-box
|
27
|
+
&.chzn-with-drop .chzn-drop
|
28
|
+
left: 0
|
27
29
|
|
28
30
|
/* @end
|
29
31
|
|
@@ -315,7 +317,7 @@
|
|
315
317
|
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3)
|
316
318
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3)
|
317
319
|
border: 1px solid #5897fb
|
318
|
-
|
320
|
+
&.chzn-with-drop .chzn-single
|
319
321
|
border: 1px solid #aaa
|
320
322
|
-webkit-box-shadow: 0 1px 0 #fff inset
|
321
323
|
-moz-box-shadow: 0 1px 0 #fff inset
|
@@ -384,13 +386,19 @@
|
|
384
386
|
.search-choice-close
|
385
387
|
left: 4px
|
386
388
|
right: auto
|
389
|
+
.chzn-search
|
390
|
+
left: 9999px
|
391
|
+
&.chzn-with-drop .chzn-search
|
392
|
+
left: 0px
|
393
|
+
.chzn-drop
|
394
|
+
left: 9999px
|
387
395
|
&.chzn-container-single .chzn-results
|
388
396
|
margin: 0 0 4px 4px
|
389
397
|
padding: 0 4px 0 0
|
390
398
|
.chzn-results .group-option
|
391
399
|
padding-left: 0
|
392
400
|
padding-right: 15px
|
393
|
-
&.chzn-container-active
|
401
|
+
&.chzn-container-active.chzn-with-drop .chzn-single div
|
394
402
|
border-right: none
|
395
403
|
.chzn-search input
|
396
404
|
background: white image-url('chosen-sprite.png') no-repeat -30px -20px
|
@@ -405,7 +413,7 @@
|
|
405
413
|
.chzn-container-single.chzn-rtl
|
406
414
|
.chzn-single div b
|
407
415
|
background-position: 6px 2px
|
408
|
-
|
416
|
+
&.chzn-with-drop .chzn-single div b
|
409
417
|
background-position: -12px 2px
|
410
418
|
|
411
419
|
/* @end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chosen-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tse-Ching Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- chosen-rails.gemspec
|
111
111
|
- lib/chosen-rails.rb
|
112
112
|
- lib/chosen-rails/engine.rb
|
113
|
+
- lib/chosen-rails/engine3.rb
|
113
114
|
- lib/chosen-rails/railtie.rb
|
114
115
|
- lib/chosen-rails/source_file.rb
|
115
116
|
- lib/chosen-rails/version.rb
|