chosen-rails 1.3.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a00aed3e49a214127fe61ce7d78b31f490898af0
4
- data.tar.gz: 5849a7c7fd0b0bf95e5a282555771f30cd175fee
3
+ metadata.gz: 54b231f0aa24b8fc17fd9a9d54d8464bbfd05303
4
+ data.tar.gz: 467cff16f714c0c296cd038e3e859b070e6b1805
5
5
  SHA512:
6
- metadata.gz: 436778b889eb6341473da8452f60b33951d8415cbaf697322c63b799befc2ce37bbbce6910245e52624047cb7f2876ecea21c5ee4d57af64f9e2c8e9c0782222
7
- data.tar.gz: d2c4efc81e654f3957fc647ad58771e9629910b2a5e7ace3fd92504d456c063df3bd5dff44a833662c3b26d6c314454a72673019eb164fac72d1ca59dcb8ec95
6
+ metadata.gz: 32ff81721fc53de4f563c8aa3c61d75f6992d46f57053d523eb21de5a1b708df651656f5b1b76eedb086f98a10f5d2a44717c3589a77d05a062e5baf66e651ff
7
+ data.tar.gz: 13edc3f00dde02e5cf65c3aa38c198e1b9c5bd33baba537ec4890af3a7b8bdc073cb766e3252361adb46f8166feffa947c76fe4367cc0440b8894dff25d65347
@@ -1,6 +1,6 @@
1
1
  module Chosen
2
2
  module Rails
3
- VERSION = '1.3.0'
4
- CHOSEN_VERSION = '1.3.0'
3
+ VERSION = '1.4.1'
4
+ CHOSEN_VERSION = '1.4.1'
5
5
  end
6
6
  end
@@ -68,8 +68,8 @@ class Chosen extends AbstractChosen
68
68
  @form_field_jq.trigger("chosen:ready", {chosen: this})
69
69
 
70
70
  register_observers: ->
71
- @container.bind 'touchstart.chosen', (evt) => this.container_mousedown(evt); return
72
- @container.bind 'touchend.chosen', (evt) => this.container_mouseup(evt); return
71
+ @container.bind 'touchstart.chosen', (evt) => this.container_mousedown(evt); evt.preventDefault()
72
+ @container.bind 'touchend.chosen', (evt) => this.container_mouseup(evt); evt.preventDefault()
73
73
 
74
74
  @container.bind 'mousedown.chosen', (evt) => this.container_mousedown(evt); return
75
75
  @container.bind 'mouseup.chosen', (evt) => this.container_mouseup(evt); return
@@ -362,6 +362,9 @@ class Chosen extends AbstractChosen
362
362
 
363
363
  @form_field_jq.trigger "change", {'selected': @form_field.options[item.options_index].value} if @is_multiple || @form_field.selectedIndex != @current_selectedIndex
364
364
  @current_selectedIndex = @form_field.selectedIndex
365
+
366
+ evt.preventDefault()
367
+
365
368
  this.search_field_scale()
366
369
 
367
370
  single_set_selected_text: (text=@default_text) ->
@@ -398,7 +401,7 @@ class Chosen extends AbstractChosen
398
401
  @selected_item.addClass("chosen-single-with-deselect")
399
402
 
400
403
  get_search_text: ->
401
- if @search_field.val() is @default_text then "" else $('<div/>').text($.trim(@search_field.val())).html()
404
+ $('<div/>').text($.trim(@search_field.val())).html()
402
405
 
403
406
  winnow_results_set_highlight: ->
404
407
  selected_results = if not @is_multiple then @search_results.find(".result-selected.active-result") else []
@@ -51,8 +51,8 @@ class @Chosen extends AbstractChosen
51
51
  @form_field.fire("chosen:ready", {chosen: this})
52
52
 
53
53
  register_observers: ->
54
- @container.observe "touchstart", (evt) => this.container_mousedown(evt)
55
- @container.observe "touchend", (evt) => this.container_mouseup(evt)
54
+ @container.observe "touchstart", (evt) => this.container_mousedown(evt); evt.preventDefault()
55
+ @container.observe "touchend", (evt) => this.container_mouseup(evt); evt.preventDefault()
56
56
 
57
57
  @container.observe "mousedown", (evt) => this.container_mousedown(evt)
58
58
  @container.observe "mouseup", (evt) => this.container_mouseup(evt)
@@ -358,6 +358,8 @@ class @Chosen extends AbstractChosen
358
358
  @form_field.simulate("change") if typeof Event.simulate is 'function' && (@is_multiple || @form_field.selectedIndex != @current_selectedIndex)
359
359
  @current_selectedIndex = @form_field.selectedIndex
360
360
 
361
+ evt.preventDefault()
362
+
361
363
  this.search_field_scale()
362
364
 
363
365
  single_set_selected_text: (text=@default_text) ->
@@ -393,7 +395,7 @@ class @Chosen extends AbstractChosen
393
395
  @selected_item.addClassName("chosen-single-with-deselect")
394
396
 
395
397
  get_search_text: ->
396
- if @search_field.value is @default_text then "" else @search_field.value.strip().escapeHTML()
398
+ @search_field.value.strip().escapeHTML()
397
399
 
398
400
  winnow_results_set_highlight: ->
399
401
  if not @is_multiple
@@ -77,7 +77,7 @@ class AbstractChosen
77
77
  if data.selected and @is_multiple
78
78
  this.choice_build data
79
79
  else if data.selected and not @is_multiple
80
- this.single_set_selected_text(data.text)
80
+ this.single_set_selected_text(this.choice_label(data))
81
81
 
82
82
  content
83
83
 
@@ -97,6 +97,7 @@ class AbstractChosen
97
97
  option_el.style.cssText = option.style
98
98
  option_el.setAttribute("data-option-array-index", option.array_index)
99
99
  option_el.innerHTML = option.search_text
100
+ option_el.title = option.title if option.title
100
101
 
101
102
  this.outerHTML(option_el)
102
103
 
@@ -111,6 +112,7 @@ class AbstractChosen
111
112
  group_el = document.createElement("li")
112
113
  group_el.className = classes.join(" ")
113
114
  group_el.innerHTML = group.search_text
115
+ group_el.title = group.title if group.title
114
116
 
115
117
  this.outerHTML(group_el)
116
118
 
@@ -162,10 +164,10 @@ class AbstractChosen
162
164
  results_group = @results_data[option.group_array_index]
163
165
  results += 1 if results_group.active_options is 0 and results_group.search_match
164
166
  results_group.active_options += 1
165
-
166
- unless option.group and not @group_search
167
167
 
168
- option.search_text = if option.group then option.label else option.text
168
+ option.search_text = if option.group then option.label else option.html
169
+
170
+ unless option.group and not @group_search
169
171
  option.search_match = this.search_string_match(option.search_text, regex)
170
172
  results += 1 if option.search_match and not option.group
171
173
 
@@ -176,7 +178,7 @@ class AbstractChosen
176
178
  option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos)
177
179
 
178
180
  results_group.group_match = true if results_group?
179
-
181
+
180
182
  else if option.group_array_index? and @results_data[option.group_array_index].search_match
181
183
  option.search_match = true
182
184
 
@@ -210,7 +212,7 @@ class AbstractChosen
210
212
  @selected_option_count = 0
211
213
  for option in @form_field.options
212
214
  @selected_option_count += 1 if option.selected
213
-
215
+
214
216
  return @selected_option_count
215
217
 
216
218
  choices_click: (evt) ->
@@ -268,7 +270,7 @@ class AbstractChosen
268
270
  tmp.appendChild(element)
269
271
  tmp.innerHTML
270
272
 
271
- # class methods and variables ============================================================
273
+ # class methods and variables ============================================================
272
274
 
273
275
  @browser_is_supported: ->
274
276
  if window.navigator.appName == "Microsoft Internet Explorer"
@@ -16,6 +16,7 @@ class SelectParser
16
16
  array_index: group_position
17
17
  group: true
18
18
  label: this.escapeExpression(group.label)
19
+ title: group.title if group.title
19
20
  children: 0
20
21
  disabled: group.disabled,
21
22
  classes: group.className
@@ -32,6 +33,7 @@ class SelectParser
32
33
  value: option.value
33
34
  text: option.text
34
35
  html: option.innerHTML
36
+ title: option.title if option.title
35
37
  selected: option.selected
36
38
  disabled: if group_disabled is true then group_disabled else option.disabled
37
39
  group_array_index: group_position
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: 1.3.0
4
+ version: 1.4.1
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: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.2.2
160
+ rubygems_version: 2.4.6
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Integrate Chosen javascript library with Rails asset pipeline