sortablelabel-js 2.1 → 2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4fb0f60698d0d20dbfc51b2763fb9d78ee540e4
4
- data.tar.gz: 9492f92c37457a49d7d98f87772a3a218599fcca
3
+ metadata.gz: c65f7a5079171fc4ef7f2cd422425f139e6b351b
4
+ data.tar.gz: 9abaaa646f8d8bf2ef89925ffea110d40e64cc5f
5
5
  SHA512:
6
- metadata.gz: 0f9b50dd7b03f40d8e75d7502a6de6fc04f714c1b1a147b7c96bcf28b39efe1f1da32483bd10a3dd331f182087b222dc3824c362c04a4e8182132a5693d2c25b
7
- data.tar.gz: c3df6e1948d309bc1d976f98a4b832a01eb36138e9610d5edbf966fc9a53ec728f3d4d429d8ebac5990c45a893bca646e279b331ab00925a3717ea8b668fb749
6
+ metadata.gz: 7719e1dcaea286c9129f7b3a747a0b6afecbb22e9440b28a409428b34f61cbf455a1ae7210cfc546a62302f161640371be506563a17433b24a0794cb16f55fe4
7
+ data.tar.gz: 3ed548f4f3bb6fd66c41adee6a31b653caf179aaf0afadcbcb236282ba62051b47068a04445d38b81e3a2eb50224ff1b0063530fda317182d5ef6088de0bc2c9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sortablelabel-js (2.1)
4
+ sortablelabel-js (2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  module Sortablelabel
2
2
  module Js
3
- VERSION = "2.1"
3
+ VERSION = "2.2"
4
4
  end
5
5
  end
@@ -30,38 +30,41 @@ class @SortableLabel
30
30
  if typeof(@stop_callback) == 'function'
31
31
  @stop_callback.call(@target)
32
32
  )
33
-
34
- if !@target.hasClass("sortable-label-#{@targetId}")
35
- @target.addClass("sortable-label-#{@targetId}")
36
-
37
- @target.on('sortableLabel:refresh', =>
38
- @target.sortable("enable")
39
- @calStepLable()
40
- )
33
+
34
+ @target.each((_, element)=>
35
+ target = $(element)
36
+ if !target.hasClass("sortable-label-#{@targetId}")
37
+ target.addClass("sortable-label-#{@targetId}")
38
+
39
+ target.on('sortableLabel:refresh', =>
40
+ target.sortable("enable")
41
+ @calStepLable()
42
+ )
41
43
 
42
- if @options['nestedTarget']
43
- @options['nestedTarget'].call(@target)
44
+ if @options['nestedTarget']
45
+ @options['nestedTarget'].call(@target)
44
46
 
45
- @target.sortable(
46
- items: @options['sortableItem']
47
- placeholder: "ui-state-highlight"
48
- start: (event, ui)->
49
- $(this).find('.ui-state-highlight').css('height', $(ui.item).css('height'))
50
- stop: =>
51
- @calStepLable()
52
- if typeof(@stop_callback) == 'function'
53
- @stop_callback.call(@target)
54
- )
47
+ target.sortable(
48
+ items: @options['sortableItem']
49
+ placeholder: "ui-state-highlight"
50
+ start: (event, ui)->
51
+ $(this).find('.ui-state-highlight').css('height', $(ui.item).css('height'))
52
+ stop: =>
53
+ @calStepLable()
54
+ if typeof(@stop_callback) == 'function'
55
+ @stop_callback.call(@target)
56
+ )
55
57
 
56
- @target.on('sortableLabel:disable', =>
57
- @target.sortable('disable')
58
- )
58
+ target.on('sortableLabel:disable', =>
59
+ target.sortable('disable')
60
+ )
61
+ )
59
62
 
60
63
  # 1. ascending sort if all position fields are not provided
61
64
  # 2. ascending sort field elements which part of them are no provided position
62
65
  initSortByPosition: () ->
63
66
  _option = @options
64
- @target.each((i, sub_target) ->
67
+ @target.each((_, sub_target) ->
65
68
  all_fields = $(sub_target).find(_option['sortableItem'])
66
69
  _positionTarget = _option['positionTarget']
67
70
  all_remain_fields_info = []
@@ -71,7 +74,7 @@ class @SortableLabel
71
74
  if all_fields.length > 0
72
75
 
73
76
  # get the maxinum_position
74
- all_fields.each((index, field_item) ->
77
+ all_fields.each((_, field_item) ->
75
78
  _position = $(field_item).find(_positionTarget).val()
76
79
  if _position && _position != '' && typeof _position != 'undefined'
77
80
  _position = parseInt(_position, 10)
@@ -80,7 +83,7 @@ class @SortableLabel
80
83
  )
81
84
 
82
85
  # in case that new added field position value is initialized as null or '' or undefined
83
- all_fields.each((index, field_item) ->
86
+ all_fields.each((_, field_item) ->
84
87
  _position = $(field_item).find(_positionTarget).val()
85
88
  if !_position || _position == '' || typeof _position != 'undefined'
86
89
  maxium_position += 1
@@ -88,7 +91,7 @@ class @SortableLabel
88
91
  )
89
92
 
90
93
  # filter removed fields and remain fields
91
- all_fields.each((index, field_item) ->
94
+ all_fields.each((_, field_item) ->
92
95
  _position = $(field_item).find(_positionTarget).val()
93
96
  _is_removed = $(field_item).find(_option['removeField']).val()
94
97
  if _is_removed == "false" || _is_removed == false
@@ -132,11 +135,11 @@ class @SortableLabel
132
135
  all_remain_fields_info[key].position = key + 1
133
136
 
134
137
  _target = $(sub_target)
135
- all_remain_fields_info.forEach((item, index) ->
138
+ all_remain_fields_info.forEach((item, _) ->
136
139
  _target.append(item.j_element)
137
140
  )
138
141
 
139
- all_removed_fields_info.forEach((item, index) ->
142
+ all_removed_fields_info.forEach((item, _) ->
140
143
  _target.append(item.j_element)
141
144
  )
142
145
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sortablelabel-js
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.1'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - BenZhang