tao_form 0.2.3 → 1.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tao_form/components/select/multiple_result_component.rb +4 -6
- data/lib/tao_form/components/select/result_component.rb +4 -6
- data/lib/tao_form/components/select_component.rb +3 -7
- data/lib/tao_form/inputs/collection_select_input.rb +3 -1
- data/lib/tao_form/version.rb +1 -1
- data/lib/views/components/tao_form/components/select/_list.html.erb +1 -16
- data/lib/views/components/tao_form/components/select/_list_content.html.erb +16 -0
- data/lib/views/components/tao_form/components/select/_multiple_result.html.erb +1 -1
- metadata +12 -201
- data/lib/assets/icons/arrow_down.svg +0 -3
- data/lib/assets/icons/arrow_left.svg +0 -3
- data/lib/assets/icons/arrow_right.svg +0 -3
- data/lib/assets/icons/calendar.svg +0 -3
- data/lib/assets/icons/check.svg +0 -3
- data/lib/assets/icons/clock.svg +0 -3
- data/lib/assets/icons/search.svg +0 -3
- data/lib/assets/icons/success.svg +0 -3
- data/lib/assets/javascripts/tao/form/element.coffee +0 -16
- data/lib/assets/javascripts/tao/form/fields/checkbox.coffee +0 -15
- data/lib/assets/javascripts/tao/form/fields/index.coffee +0 -10
- data/lib/assets/javascripts/tao/form/fields/moment_picker/element.coffee +0 -38
- data/lib/assets/javascripts/tao/form/fields/moment_picker/index.coffee +0 -7
- data/lib/assets/javascripts/tao/form/fields/moment_picker/result.coffee +0 -25
- data/lib/assets/javascripts/tao/form/fields/moment_picker/segment_list.coffee +0 -14
- data/lib/assets/javascripts/tao/form/fields/radio.coffee +0 -14
- data/lib/assets/javascripts/tao/form/fields/select/element.coffee +0 -79
- data/lib/assets/javascripts/tao/form/fields/select/index.coffee +0 -8
- data/lib/assets/javascripts/tao/form/fields/select/list.coffee +0 -103
- data/lib/assets/javascripts/tao/form/fields/select/multiple_result.coffee +0 -41
- data/lib/assets/javascripts/tao/form/fields/select/result.coffee +0 -39
- data/lib/assets/javascripts/tao/form/fields/switch.coffee +0 -14
- data/lib/assets/javascripts/tao/form/index.coffee +0 -11
- data/lib/assets/javascripts/tao/form/mobile/element.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/checkbox.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/index.coffee +0 -10
- data/lib/assets/javascripts/tao/form/mobile/fields/moment_picker/element.coffee +0 -40
- data/lib/assets/javascripts/tao/form/mobile/fields/moment_picker/index.coffee +0 -7
- data/lib/assets/javascripts/tao/form/mobile/fields/moment_picker/result.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/moment_picker/segment_list.coffee +0 -24
- data/lib/assets/javascripts/tao/form/mobile/fields/radio.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/select/element.coffee +0 -74
- data/lib/assets/javascripts/tao/form/mobile/fields/select/index.coffee +0 -8
- data/lib/assets/javascripts/tao/form/mobile/fields/select/list.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/select/multiple_result.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/select/result.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/fields/switch.coffee +0 -5
- data/lib/assets/javascripts/tao/form/mobile/index.coffee +0 -11
- data/lib/assets/javascripts/tao/form/shared/element/base.coffee +0 -53
- data/lib/assets/javascripts/tao/form/shared/fields/checkbox.coffee +0 -31
- data/lib/assets/javascripts/tao/form/shared/fields/date_picker.coffee +0 -10
- data/lib/assets/javascripts/tao/form/shared/fields/date_range_picker.coffee +0 -75
- data/lib/assets/javascripts/tao/form/shared/fields/datetime_picker.coffee +0 -78
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/element/base.coffee +0 -70
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/result/base.coffee +0 -39
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segment_list/base.coffee +0 -88
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/base.coffee +0 -30
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/date_segment.coffee +0 -107
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/hour_segment.coffee +0 -28
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/index.coffee +0 -1
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/minute_segment.coffee +0 -28
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/month_segment.coffee +0 -46
- data/lib/assets/javascripts/tao/form/shared/fields/moment_picker/segments/year_segment.coffee +0 -57
- data/lib/assets/javascripts/tao/form/shared/fields/month_picker.coffee +0 -10
- data/lib/assets/javascripts/tao/form/shared/fields/radio.coffee +0 -23
- data/lib/assets/javascripts/tao/form/shared/fields/select/element/base.coffee +0 -132
- data/lib/assets/javascripts/tao/form/shared/fields/select/list/base.coffee +0 -97
- data/lib/assets/javascripts/tao/form/shared/fields/select/models/data_provider.coffee +0 -76
- data/lib/assets/javascripts/tao/form/shared/fields/select/models/index.coffee +0 -2
- data/lib/assets/javascripts/tao/form/shared/fields/select/models/option.coffee +0 -37
- data/lib/assets/javascripts/tao/form/shared/fields/select/multiple_result/base.coffee +0 -90
- data/lib/assets/javascripts/tao/form/shared/fields/select/result/base.coffee +0 -57
- data/lib/assets/javascripts/tao/form/shared/fields/switch.coffee +0 -23
- data/lib/assets/javascripts/tao/form/shared/fields/time_picker.coffee +0 -10
- data/lib/assets/javascripts/tao/form/shared/init.coffee +0 -23
- data/lib/assets/javascripts/tao/form/shared/mixins/checkable.coffee +0 -11
- data/lib/assets/javascripts/tao/ui/icons/form.coffee +0 -11
- data/lib/assets/stylesheets/tao/form/_globals.scss +0 -3
- data/lib/assets/stylesheets/tao/form/_mixins.scss +0 -28
- data/lib/assets/stylesheets/tao/form/_variables.scss +0 -3
- data/lib/assets/stylesheets/tao/form/fields/checkbox.scss +0 -36
- data/lib/assets/stylesheets/tao/form/fields/date_range_picker.scss +0 -20
- data/lib/assets/stylesheets/tao/form/fields/datetime_picker.scss +0 -22
- data/lib/assets/stylesheets/tao/form/fields/index.scss +0 -7
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/index.scss +0 -10
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/result.scss +0 -61
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/segment_list.scss +0 -53
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/segments/date_segment.scss +0 -17
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/segments/hour_segment.scss +0 -15
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/segments/minute_segment.scss +0 -17
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/segments/month_segment.scss +0 -15
- data/lib/assets/stylesheets/tao/form/fields/moment_picker/segments/year_segment.scss +0 -15
- data/lib/assets/stylesheets/tao/form/fields/radio.scss +0 -33
- data/lib/assets/stylesheets/tao/form/fields/select/index.scss +0 -14
- data/lib/assets/stylesheets/tao/form/fields/select/list.scss +0 -55
- data/lib/assets/stylesheets/tao/form/fields/select/multiple_result.scss +0 -76
- data/lib/assets/stylesheets/tao/form/fields/select/result.scss +0 -101
- data/lib/assets/stylesheets/tao/form/fields/switch.scss +0 -14
- data/lib/assets/stylesheets/tao/form/index.scss +0 -5
- data/lib/assets/stylesheets/tao/form/inputs/boolean.scss +0 -8
- data/lib/assets/stylesheets/tao/form/inputs/group.scss +0 -2
- data/lib/assets/stylesheets/tao/form/inputs/index.scss +0 -1
- data/lib/assets/stylesheets/tao/form/inputs/text.scss +0 -2
- data/lib/assets/stylesheets/tao/form/layouts/default.scss +0 -146
- data/lib/assets/stylesheets/tao/form/layouts/index.scss +0 -2
- data/lib/assets/stylesheets/tao/form/layouts/narrow.scss +0 -35
- data/lib/assets/stylesheets/tao/form/mobile/_globals.scss +0 -3
- data/lib/assets/stylesheets/tao/form/mobile/_mixins.scss +0 -22
- data/lib/assets/stylesheets/tao/form/mobile/_variables.scss +0 -3
- data/lib/assets/stylesheets/tao/form/mobile/fields/checkbox.scss +0 -2
- data/lib/assets/stylesheets/tao/form/mobile/fields/date_range_picker.scss +0 -18
- data/lib/assets/stylesheets/tao/form/mobile/fields/datetime_picker.scss +0 -18
- data/lib/assets/stylesheets/tao/form/mobile/fields/index.scss +0 -1
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/index.scss +0 -9
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/result.scss +0 -19
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/segment_list.scss +0 -52
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/segments/date_segment.scss +0 -14
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/segments/hour_segment.scss +0 -14
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/segments/minute_segment.scss +0 -14
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/segments/month_segment.scss +0 -14
- data/lib/assets/stylesheets/tao/form/mobile/fields/moment_picker/segments/year_segment.scss +0 -14
- data/lib/assets/stylesheets/tao/form/mobile/fields/radio.scss +0 -2
- data/lib/assets/stylesheets/tao/form/mobile/fields/select/index.scss +0 -80
- data/lib/assets/stylesheets/tao/form/mobile/fields/select/list.scss +0 -10
- data/lib/assets/stylesheets/tao/form/mobile/fields/select/multiple_result.scss +0 -12
- data/lib/assets/stylesheets/tao/form/mobile/fields/select/result.scss +0 -28
- data/lib/assets/stylesheets/tao/form/mobile/fields/switch.scss +0 -2
- data/lib/assets/stylesheets/tao/form/mobile/index.scss +0 -5
- data/lib/assets/stylesheets/tao/form/mobile/inputs/boolean.scss +0 -7
- data/lib/assets/stylesheets/tao/form/mobile/inputs/group.scss +0 -6
- data/lib/assets/stylesheets/tao/form/mobile/inputs/index.scss +0 -1
- data/lib/assets/stylesheets/tao/form/mobile/inputs/text.scss +0 -18
- data/lib/assets/stylesheets/tao/form/mobile/layout.scss +0 -137
- data/lib/assets/stylesheets/tao/form/mobile/reset.scss +0 -29
- data/lib/assets/stylesheets/tao/form/mobile/variables/_base.scss +0 -12
- data/lib/assets/stylesheets/tao/form/mobile/variables/_moment_picker.scss +0 -9
- data/lib/assets/stylesheets/tao/form/mobile/variables/_select.scss +0 -9
- data/lib/assets/stylesheets/tao/form/reset.scss +0 -31
- data/lib/assets/stylesheets/tao/form/shared/fields/_checkbox.scss +0 -61
- data/lib/assets/stylesheets/tao/form/shared/fields/_radio.scss +0 -53
- data/lib/assets/stylesheets/tao/form/shared/fields/_switch.scss +0 -56
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/_result.scss +0 -46
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/_segment_list.scss +0 -93
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/segments/_date_segment.scss +0 -56
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/segments/_hour_segment.scss +0 -35
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/segments/_minute_segment.scss +0 -23
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/segments/_month_segment.scss +0 -27
- data/lib/assets/stylesheets/tao/form/shared/fields/moment_picker/segments/_year_segment.scss +0 -27
- data/lib/assets/stylesheets/tao/form/shared/fields/select/_list.scss +0 -140
- data/lib/assets/stylesheets/tao/form/shared/fields/select/_multiple_result.scss +0 -50
- data/lib/assets/stylesheets/tao/form/shared/inputs/_boolean.scss +0 -5
- data/lib/assets/stylesheets/tao/form/shared/inputs/_group.scss +0 -25
- data/lib/assets/stylesheets/tao/form/shared/inputs/_text.scss +0 -35
- data/lib/assets/stylesheets/tao/form/variables/_base.scss +0 -15
- data/lib/assets/stylesheets/tao/form/variables/_moment_picker.scss +0 -9
- data/lib/assets/stylesheets/tao/form/variables/_select.scss +0 -10
- data/vendor/assets/javascripts/moment.js +0 -4463
- data/vendor/assets/javascripts/moment/zh-cn.js +0 -112
data/lib/assets/icons/search.svg
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
2
|
-
<path fill="#9B9B9B" fill-rule="evenodd" d="M16.6262932,16.0904129 L22.8402784,21.8382529 C23.0438968,22.0265968 23.0482516,22.3387618 22.8607428,22.5248371 L22.5286336,22.8544073 C22.3363174,23.0452534 22.0152795,23.0472113 21.8117305,22.8589237 L15.5610109,17.0768647 C14.0302194,18.2814309 12.0990251,19 10,19 C5.02943725,19 1,14.9705627 1,10 C1,5.02943725 5.02943725,1 10,1 C14.9705627,1 19,5.02943725 19,10 C19,12.3489613 18.1001192,14.4877442 16.6262932,16.0904129 Z M10,18 C14.418278,18 18,14.418278 18,10 C18,5.581722 14.418278,2 10,2 C5.581722,2 2,5.581722 2,10 C2,14.418278 5.581722,18 10,18 Z"/>
|
3
|
-
</svg>
|
@@ -1,3 +0,0 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
2
|
-
<path fill="#9B9B9B" fill-rule="evenodd" d="M12,23 C5.92486775,23 1,18.0751322 1,12 C1,5.92486775 5.92486775,1 12,1 C18.0751322,1 23,5.92486775 23,12 C23,18.0751322 18.0751322,23 12,23 Z M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M18.0734953,9.10417138 L11.0041681,16.1734985 C10.8122026,16.365464 10.4903696,16.3685474 10.2937708,16.1719486 L6.05597058,11.9341484 C5.8646839,11.7428617 5.85828819,11.4198835 6.05355034,11.2246214 C6.24310191,11.0350698 6.56254737,11.0265116 6.75429682,11.2182611 L10.6497444,15.1137087 L17.3604356,8.40301751 C17.5598374,8.20361571 17.8791035,8.20093212 18.0743656,8.39619427 C18.2639172,8.58574584 18.2692381,8.90842856 18.0734953,9.10417138 Z"/>
|
3
|
-
</svg>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/element/base
|
2
|
-
|
3
|
-
class Tao.Form.Element extends Tao.Form.ElementBase
|
4
|
-
|
5
|
-
_bind: ->
|
6
|
-
super
|
7
|
-
|
8
|
-
@on 'focus', '.input-field', (e) =>
|
9
|
-
$field = $ e.currentTarget
|
10
|
-
$field.closest('.form-input').addClass 'focus'
|
11
|
-
|
12
|
-
@on 'blur', '.input-field', (e) =>
|
13
|
-
$field = $ e.currentTarget
|
14
|
-
$field.closest('.form-input').removeClass 'focus'
|
15
|
-
|
16
|
-
TaoComponent.register Tao.Form.Element
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/checkbox
|
2
|
-
|
3
|
-
class Tao.Form.Checkbox extends Tao.Form.CheckboxBase
|
4
|
-
|
5
|
-
_bind: ->
|
6
|
-
super
|
7
|
-
|
8
|
-
@on 'keydown', '.checkbox-wrapper', (e) =>
|
9
|
-
return unless e.which == 13 && @field.is(':enabled')
|
10
|
-
@_toggleChecked()
|
11
|
-
@namespacedTrigger 'change'
|
12
|
-
|
13
|
-
false
|
14
|
-
|
15
|
-
TaoComponent.register Tao.Form.Checkbox
|
@@ -1,10 +0,0 @@
|
|
1
|
-
#= require ./checkbox
|
2
|
-
#= require ./switch
|
3
|
-
#= require ./radio
|
4
|
-
#= require ./select
|
5
|
-
#= require ./moment_picker
|
6
|
-
#= require tao/form/shared/fields/date_picker
|
7
|
-
#= require tao/form/shared/fields/time_picker
|
8
|
-
#= require tao/form/shared/fields/datetime_picker
|
9
|
-
#= require tao/form/shared/fields/month_picker
|
10
|
-
#= require tao/form/shared/fields/date_range_picker
|
@@ -1,38 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/moment_picker/element/base
|
2
|
-
|
3
|
-
class Tao.Form.MomentPicker.Element extends Tao.Form.MomentPicker.ElementBase
|
4
|
-
|
5
|
-
_bind: ->
|
6
|
-
super
|
7
|
-
|
8
|
-
@on 'tao:show', '.tao-moment-picker-segment-list', (e) =>
|
9
|
-
@_positionList()
|
10
|
-
|
11
|
-
_activeChanged: ->
|
12
|
-
@_unbindDocumentMousedown()
|
13
|
-
if @active
|
14
|
-
@segmentList.setMoment(@moment)
|
15
|
-
@_bindDocumentMousedown()
|
16
|
-
|
17
|
-
@result.active = @active
|
18
|
-
@segmentList.active = @active
|
19
|
-
|
20
|
-
_unbindDocumentMousedown: ->
|
21
|
-
$(document).off "mousedown.tao-moment-picker-#{@taoId}"
|
22
|
-
|
23
|
-
_bindDocumentMousedown: ->
|
24
|
-
$(document).on "mousedown.tao-moment-picker-#{@taoId}", (e) =>
|
25
|
-
return if $.contains(@, e.target) && !(@multiple && @result == e.target)
|
26
|
-
@active = false
|
27
|
-
@_unbindDocumentMousedown()
|
28
|
-
|
29
|
-
_positionList: ->
|
30
|
-
rect = @getBoundingClientRect()
|
31
|
-
offsetToWindowTop = rect.top
|
32
|
-
offsetToWindowBottom = $(window).height() - rect.bottom
|
33
|
-
listHeight = @segmentList.jq.outerHeight()
|
34
|
-
|
35
|
-
@segmentList.direction = if offsetToWindowBottom < listHeight && offsetToWindowTop > offsetToWindowBottom
|
36
|
-
'up'
|
37
|
-
else
|
38
|
-
'down'
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/moment_picker/result/base
|
2
|
-
|
3
|
-
class Tao.Form.MomentPicker.Result extends Tao.Form.MomentPicker.ResultBase
|
4
|
-
|
5
|
-
@attribute 'active', type: 'boolean'
|
6
|
-
|
7
|
-
_connected: ->
|
8
|
-
super
|
9
|
-
@jq.attr('tabindex', '0') unless @disabled
|
10
|
-
|
11
|
-
_bind: ->
|
12
|
-
super
|
13
|
-
|
14
|
-
@on 'click', '.link-clear', (e) =>
|
15
|
-
return if @disabled
|
16
|
-
@clear() && @namespacedTrigger('clear')
|
17
|
-
false
|
18
|
-
|
19
|
-
_disabledChanged: ->
|
20
|
-
if @disabled
|
21
|
-
@jq.removeAttr 'tabindex'
|
22
|
-
else
|
23
|
-
@jq.attr 'tabindex', '0'
|
24
|
-
|
25
|
-
TaoComponent.register Tao.Form.MomentPicker.Result
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/moment_picker/segment_list/base
|
2
|
-
|
3
|
-
MomentPicker = Tao.Form.MomentPicker
|
4
|
-
|
5
|
-
class MomentPicker.SegmentList extends MomentPicker.SegmentListBase
|
6
|
-
|
7
|
-
@attribute 'active', type: 'boolean', observe: true
|
8
|
-
|
9
|
-
@attribute 'direction', default: 'down'
|
10
|
-
|
11
|
-
_activeChanged: ->
|
12
|
-
@namespacedTrigger('show') if @active
|
13
|
-
|
14
|
-
TaoComponent.register Tao.Form.MomentPicker.SegmentList
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/radio
|
2
|
-
|
3
|
-
class Tao.Form.Radio extends Tao.Form.RadioBase
|
4
|
-
|
5
|
-
_bind: ->
|
6
|
-
super
|
7
|
-
|
8
|
-
@on 'keydown', '.radio-wrapper', (e) =>
|
9
|
-
return unless e.which == 13 && @field.is(':enabled')
|
10
|
-
@_toggleChecked()
|
11
|
-
@namespacedTrigger 'change'
|
12
|
-
false
|
13
|
-
|
14
|
-
TaoComponent.register Tao.Form.Radio
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/select/element/base
|
2
|
-
|
3
|
-
class Tao.Form.Select.Element extends Tao.Form.Select.ElementBase
|
4
|
-
|
5
|
-
_disconnected: ->
|
6
|
-
super
|
7
|
-
@_unbindDocumentMousedown()
|
8
|
-
|
9
|
-
_bindResultEvents: ->
|
10
|
-
super
|
11
|
-
|
12
|
-
@on 'tao:enterPress', '.select-result', (e) =>
|
13
|
-
if @active
|
14
|
-
if @selectOption @list.highlightedOption
|
15
|
-
@namespacedTrigger 'change', @selectedOption
|
16
|
-
else
|
17
|
-
@active = true
|
18
|
-
null
|
19
|
-
|
20
|
-
@on 'tao:arrowPress', '.select-result', (e, direction) =>
|
21
|
-
if @active
|
22
|
-
if direction == 'up'
|
23
|
-
@list.highlightPrevOption()
|
24
|
-
else
|
25
|
-
@list.highlightNextOption()
|
26
|
-
else
|
27
|
-
@active = true
|
28
|
-
null
|
29
|
-
|
30
|
-
_bindListEvents: ->
|
31
|
-
super
|
32
|
-
|
33
|
-
@on 'tao:select', '.select-list', (e, option) =>
|
34
|
-
@active = false
|
35
|
-
null
|
36
|
-
|
37
|
-
@on 'tao:show', '.select-list', (e) =>
|
38
|
-
@_positionList()
|
39
|
-
|
40
|
-
@on 'tao:cancel', '.select-list', (e) =>
|
41
|
-
@active = false
|
42
|
-
null
|
43
|
-
|
44
|
-
_activeChanged: ->
|
45
|
-
@list.active = @active
|
46
|
-
@result.active = @active
|
47
|
-
|
48
|
-
@_unbindDocumentMousedown()
|
49
|
-
if @active
|
50
|
-
@_bindDocumentMousedown()
|
51
|
-
else
|
52
|
-
@result.focus()
|
53
|
-
|
54
|
-
_unbindDocumentMousedown: ->
|
55
|
-
$(document).off "mousedown.tao-select-#{@taoId}"
|
56
|
-
|
57
|
-
_bindDocumentMousedown: ->
|
58
|
-
$(document).on "mousedown.tao-select-#{@taoId}", (e) =>
|
59
|
-
return if $.contains(@, e.target) && !(@multiple && @result == e.target)
|
60
|
-
@active = false
|
61
|
-
@_unbindDocumentMousedown()
|
62
|
-
|
63
|
-
_positionList: ->
|
64
|
-
rect = @getBoundingClientRect()
|
65
|
-
offsetToWindowTop = rect.top
|
66
|
-
offsetToWindowBottom = $(window).height() - rect.bottom
|
67
|
-
|
68
|
-
@list.setMaxHeight false
|
69
|
-
@reflow()
|
70
|
-
listHeight = @list.jq.outerHeight()
|
71
|
-
|
72
|
-
if offsetToWindowBottom < listHeight && offsetToWindowTop > offsetToWindowBottom
|
73
|
-
@list.setMaxHeight offsetToWindowTop - 20
|
74
|
-
@list.direction = 'up'
|
75
|
-
else
|
76
|
-
@list.setMaxHeight offsetToWindowBottom - 20
|
77
|
-
@list.direction = 'down'
|
78
|
-
|
79
|
-
TaoComponent.register Tao.Form.Select.Element
|
@@ -1,103 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/select/list/base
|
2
|
-
|
3
|
-
class Tao.Form.Select.List extends Tao.Form.Select.ListBase
|
4
|
-
|
5
|
-
@attribute 'active', type: 'boolean', observe: true
|
6
|
-
|
7
|
-
@attribute 'direction', default: 'down'
|
8
|
-
|
9
|
-
_connected: ->
|
10
|
-
super
|
11
|
-
|
12
|
-
@highlightedOption = null
|
13
|
-
|
14
|
-
_bind: ->
|
15
|
-
super
|
16
|
-
|
17
|
-
@on 'keydown', '.search-field', (e) =>
|
18
|
-
if e.which == 13
|
19
|
-
@namespacedTrigger('select', [@highlightedOption]) if @highlightedOption
|
20
|
-
false
|
21
|
-
else if e.which == 27
|
22
|
-
@namespacedTrigger 'cancel'
|
23
|
-
false
|
24
|
-
else if e.which == 38
|
25
|
-
@highlightPrevOption()
|
26
|
-
false
|
27
|
-
else if e.which == 40
|
28
|
-
@highlightNextOption()
|
29
|
-
false
|
30
|
-
|
31
|
-
@on 'mouseenter', '.option', (e) =>
|
32
|
-
$option = $ e.currentTarget
|
33
|
-
@highlightOption $option
|
34
|
-
null
|
35
|
-
|
36
|
-
_activeChanged: ->
|
37
|
-
if @active
|
38
|
-
@namespacedTrigger 'show'
|
39
|
-
@searchField.focus() if @searchable
|
40
|
-
@_refreshScrollPosition()
|
41
|
-
else
|
42
|
-
@reset()
|
43
|
-
|
44
|
-
_refreshScrollPosition: ->
|
45
|
-
return unless @active
|
46
|
-
|
47
|
-
@reflow()
|
48
|
-
|
49
|
-
$list = @jq.find('.list-wrapper')
|
50
|
-
if @direction == 'up'
|
51
|
-
$list.scrollTop $list[0].scrollHeight
|
52
|
-
else
|
53
|
-
$list.scrollTop 0
|
54
|
-
|
55
|
-
setOptions: (options, totalSize) ->
|
56
|
-
super
|
57
|
-
if @options.length > 0
|
58
|
-
@highlightFirstOption()
|
59
|
-
else
|
60
|
-
@highlightedOption = null
|
61
|
-
|
62
|
-
setMaxHeight: (maxHeight) ->
|
63
|
-
maxHeight = if maxHeight
|
64
|
-
searchHeight = if @searchable then @jq.find('.search-input').outerHeight() else 0
|
65
|
-
optionHeight = @jq.find('.options-list .option:first').outerHeight()
|
66
|
-
Math.floor((maxHeight - searchHeight) / optionHeight) * optionHeight
|
67
|
-
else
|
68
|
-
''
|
69
|
-
|
70
|
-
@jq.find('.list-wrapper').css
|
71
|
-
maxHeight: maxHeight
|
72
|
-
|
73
|
-
highlightNextOption: ->
|
74
|
-
if @highlightedOption
|
75
|
-
method = if @direction == 'up' then 'prev' else 'next'
|
76
|
-
$option = @jq.find(".option[data-value='#{@highlightedOption.value}']")[method]('.option')
|
77
|
-
@highlightOption($option) if $option.length > 0
|
78
|
-
else
|
79
|
-
@highlightFirstOption()
|
80
|
-
|
81
|
-
highlightPrevOption: ->
|
82
|
-
if @highlightedOption
|
83
|
-
method = if @direction == 'up' then 'next' else 'prev'
|
84
|
-
$option = @jq.find(".option[data-value='#{@highlightedOption.value}']")[method]('.option')
|
85
|
-
@highlightOption($option) if $option.length > 0
|
86
|
-
else
|
87
|
-
@highlightFirstOption()
|
88
|
-
|
89
|
-
highlightFirstOption: ->
|
90
|
-
@highlightOption @jq.find('.option:first')
|
91
|
-
|
92
|
-
highlightOption: (option) ->
|
93
|
-
if option instanceof Option
|
94
|
-
$option = @jq.find(".option[data-value='#{option.value}']")
|
95
|
-
else
|
96
|
-
$option = option
|
97
|
-
|
98
|
-
return false unless $option && !$option.hasClass('highlighted')
|
99
|
-
$option.addClass('highlighted')
|
100
|
-
.siblings('.option').removeClass('highlighted')
|
101
|
-
@highlightedOption = $option.data 'option'
|
102
|
-
|
103
|
-
TaoComponent.register Tao.Form.Select.List
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/select/multiple_result/base
|
2
|
-
|
3
|
-
class Tao.Form.Select.MultipleResult extends Tao.Form.Select.MultipleResultBase
|
4
|
-
|
5
|
-
@attribute 'active', type: 'boolean'
|
6
|
-
|
7
|
-
_connected: ->
|
8
|
-
super
|
9
|
-
@linkAdd = @jq.find '.link-add'
|
10
|
-
@linkAdd.attr('tabindex', '0') unless @disabled
|
11
|
-
|
12
|
-
_bind: ->
|
13
|
-
super
|
14
|
-
|
15
|
-
@on 'click', '.link-add', (e) =>
|
16
|
-
return if @disabled
|
17
|
-
@namespacedTrigger 'activeClick'
|
18
|
-
false
|
19
|
-
|
20
|
-
@on 'keydown', '.link-add', (e) =>
|
21
|
-
return if @disabled
|
22
|
-
if e.which == 13
|
23
|
-
@namespacedTrigger 'enterPress'
|
24
|
-
false
|
25
|
-
else if e.which == 38
|
26
|
-
@namespacedTrigger 'arrowPress', ['up']
|
27
|
-
false
|
28
|
-
else if e.which == 40
|
29
|
-
@namespacedTrigger 'arrowPress', ['down']
|
30
|
-
false
|
31
|
-
|
32
|
-
_disabledChanged: ->
|
33
|
-
if @disabled
|
34
|
-
@linkAdd.removeAttr 'tabindex'
|
35
|
-
else
|
36
|
-
@linkAdd.attr 'tabindex', '0'
|
37
|
-
|
38
|
-
focus: ->
|
39
|
-
@linkAdd.focus()
|
40
|
-
|
41
|
-
TaoComponent.register Tao.Form.Select.MultipleResult
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/select/result/base
|
2
|
-
|
3
|
-
class Tao.Form.Select.Result extends Tao.Form.Select.ResultBase
|
4
|
-
|
5
|
-
@attribute 'active', type: 'boolean'
|
6
|
-
|
7
|
-
_connected: ->
|
8
|
-
super
|
9
|
-
@jq.attr('tabindex', '0') unless @disabled
|
10
|
-
|
11
|
-
_bind: ->
|
12
|
-
super
|
13
|
-
|
14
|
-
@on 'click', (e) =>
|
15
|
-
return if @disabled
|
16
|
-
@namespacedTrigger 'activeClick'
|
17
|
-
|
18
|
-
@on 'keydown', (e) =>
|
19
|
-
return if @disabled
|
20
|
-
if e.which == 13
|
21
|
-
@namespacedTrigger 'enterPress'
|
22
|
-
false
|
23
|
-
else if e.which == 8 || e.which == 46
|
24
|
-
@clearSelected() && @namespacedTrigger('clear')
|
25
|
-
false
|
26
|
-
else if e.which == 38
|
27
|
-
@namespacedTrigger 'arrowPress', ['up']
|
28
|
-
false
|
29
|
-
else if e.which == 40
|
30
|
-
@namespacedTrigger 'arrowPress', ['down']
|
31
|
-
false
|
32
|
-
|
33
|
-
_disabledChanged: ->
|
34
|
-
if @disabled
|
35
|
-
@jq.removeAttr 'tabindex'
|
36
|
-
else
|
37
|
-
@jq.attr 'tabindex', '0'
|
38
|
-
|
39
|
-
TaoComponent.register Tao.Form.Select.Result
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#= require tao/form/shared/fields/switch
|
2
|
-
|
3
|
-
class Tao.Form.Switch extends Tao.Form.SwitchBase
|
4
|
-
|
5
|
-
_bind: ->
|
6
|
-
super
|
7
|
-
|
8
|
-
@on 'keydown', '.switch-wrapper', (e) =>
|
9
|
-
return unless e.which == 13 && @field.is(':enabled')
|
10
|
-
@_toggleChecked()
|
11
|
-
@namespacedTrigger 'change'
|
12
|
-
false
|
13
|
-
|
14
|
-
TaoComponent.register Tao.Form.Switch
|