eligo-rails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/eligo-rails.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'eligo-rails'
|
16
|
-
s.version = '0.0.
|
16
|
+
s.version = '0.0.3'
|
17
17
|
s.date = '2012-01-05'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
data/lib/eligo-rails.rb
CHANGED
@@ -48,6 +48,21 @@ describe 'shiftClickable()', ->
|
|
48
48
|
expect(second).toBeChecked()
|
49
49
|
expect(third) .toBeChecked()
|
50
50
|
|
51
|
+
it 'checks checkboxes when clicking parent list item', ->
|
52
|
+
first.closest('li').trigger 'click'
|
53
|
+
|
54
|
+
deferExpect ->
|
55
|
+
expect(first) .toBeChecked()
|
56
|
+
|
57
|
+
it 'checks checkboxes when shift-clicking parent list item', ->
|
58
|
+
first.trigger 'click'
|
59
|
+
third.closest('li').trigger shiftClickEvent()
|
60
|
+
|
61
|
+
deferExpect ->
|
62
|
+
expect(first) .toBeChecked()
|
63
|
+
expect(second).toBeChecked()
|
64
|
+
expect(third) .toBeChecked()
|
65
|
+
|
51
66
|
it 'triggers the change event on checkboxes', ->
|
52
67
|
first.trigger 'click'
|
53
68
|
spyOnEvent second, 'change'
|
@@ -5,21 +5,27 @@ $.fn.shiftClickable = ->
|
|
5
5
|
list = $ this
|
6
6
|
anchor = null
|
7
7
|
anchorIndex = -> anchor?.index() ? 0
|
8
|
+
checkboxSelector = 'input[type=checkbox]'
|
8
9
|
|
9
10
|
shiftClick = (clicked) ->
|
10
11
|
[ first, last ] = [ anchorIndex(), clicked.index() ]
|
11
12
|
[ first, last ] = [ last, first ] if first > last
|
12
13
|
|
13
|
-
checked = clicked.find(
|
14
|
+
checked = clicked.find(checkboxSelector).prop('checked')
|
14
15
|
list.children('li')
|
15
16
|
.slice(first, last + 1)
|
16
17
|
.not(clicked)
|
17
|
-
.find(
|
18
|
+
.find(checkboxSelector)
|
18
19
|
.prop('checked', checked)
|
19
20
|
.change()
|
20
21
|
|
21
22
|
list.click (e) ->
|
22
|
-
clicked = $
|
23
|
+
clicked = $ e.target
|
24
|
+
if clicked.is 'li'
|
25
|
+
clicked.find(checkboxSelector)
|
26
|
+
.trigger $.Event('click', shiftKey: e.shiftKey)
|
27
|
+
else
|
28
|
+
clicked = clicked.closest 'li'
|
23
29
|
|
24
30
|
# It seems WebKit triggers `change` before `click`, but I'm not too
|
25
31
|
# confident that all browsers must trigger events in exactly the same way.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eligo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70188917783640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70188917783640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jquery-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70188917782640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70188917782640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jasmine-headless-webkit
|
38
|
-
requirement: &
|
38
|
+
requirement: &70188917781460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.8.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70188917781460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jasmine-spec-extras
|
49
|
-
requirement: &
|
49
|
+
requirement: &70188917780220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 0.0.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70188917780220
|
58
58
|
description: Add shift-click selection to a list of checkboxes.
|
59
59
|
email: larry@marburger.cc
|
60
60
|
executables: []
|