eligo-rails 0.0.1
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.
- data/Gemfile +4 -0
- data/Gemfile.lock +84 -0
- data/Rakefile +132 -0
- data/eligo-rails.gemspec +71 -0
- data/lib/eligo-rails.rb +8 -0
- data/spec/javascripts/shift_clickable_spec.coffee +132 -0
- data/spec/javascripts/support/jasmine.yml +75 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/vendor/assets/javascripts/shift_clickable.coffee +30 -0
- metadata +98 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
eligo (0.0.1)
|
5
|
+
jquery-rails (~> 1.0)
|
6
|
+
railties (~> 3.1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (3.1.3)
|
12
|
+
activemodel (= 3.1.3)
|
13
|
+
activesupport (= 3.1.3)
|
14
|
+
builder (~> 3.0.0)
|
15
|
+
erubis (~> 2.7.0)
|
16
|
+
i18n (~> 0.6)
|
17
|
+
rack (~> 1.3.5)
|
18
|
+
rack-cache (~> 1.1)
|
19
|
+
rack-mount (~> 0.8.2)
|
20
|
+
rack-test (~> 0.6.1)
|
21
|
+
sprockets (~> 2.0.3)
|
22
|
+
activemodel (3.1.3)
|
23
|
+
activesupport (= 3.1.3)
|
24
|
+
builder (~> 3.0.0)
|
25
|
+
i18n (~> 0.6)
|
26
|
+
activesupport (3.1.3)
|
27
|
+
multi_json (~> 1.0)
|
28
|
+
builder (3.0.0)
|
29
|
+
coffee-script (2.2.0)
|
30
|
+
coffee-script-source
|
31
|
+
execjs
|
32
|
+
coffee-script-source (1.2.0)
|
33
|
+
erubis (2.7.0)
|
34
|
+
execjs (1.2.13)
|
35
|
+
multi_json (~> 1.0)
|
36
|
+
hike (1.2.1)
|
37
|
+
i18n (0.6.0)
|
38
|
+
jasmine-core (1.1.0)
|
39
|
+
jasmine-headless-webkit (0.8.4)
|
40
|
+
coffee-script
|
41
|
+
jasmine-core (~> 1.1)
|
42
|
+
multi_json
|
43
|
+
rainbow
|
44
|
+
sprockets (~> 2)
|
45
|
+
jasmine-spec-extras (0.0.2)
|
46
|
+
jquery-rails (1.0.19)
|
47
|
+
railties (~> 3.0)
|
48
|
+
thor (~> 0.14)
|
49
|
+
json (1.6.4)
|
50
|
+
multi_json (1.0.4)
|
51
|
+
rack (1.3.6)
|
52
|
+
rack-cache (1.1)
|
53
|
+
rack (>= 0.4)
|
54
|
+
rack-mount (0.8.3)
|
55
|
+
rack (>= 1.0.0)
|
56
|
+
rack-ssl (1.3.2)
|
57
|
+
rack
|
58
|
+
rack-test (0.6.1)
|
59
|
+
rack (>= 1.0)
|
60
|
+
railties (3.1.3)
|
61
|
+
actionpack (= 3.1.3)
|
62
|
+
activesupport (= 3.1.3)
|
63
|
+
rack-ssl (~> 1.3.2)
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
rdoc (~> 3.4)
|
66
|
+
thor (~> 0.14.6)
|
67
|
+
rainbow (1.1.3)
|
68
|
+
rake (0.9.2.2)
|
69
|
+
rdoc (3.12)
|
70
|
+
json (~> 1.4)
|
71
|
+
sprockets (2.0.3)
|
72
|
+
hike (~> 1.2)
|
73
|
+
rack (~> 1.0)
|
74
|
+
tilt (~> 1.1, != 1.3.0)
|
75
|
+
thor (0.14.6)
|
76
|
+
tilt (1.3.3)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
ruby
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
eligo!
|
83
|
+
jasmine-headless-webkit (~> 0.8.4)
|
84
|
+
jasmine-spec-extras (~> 0.0.2)
|
data/Rakefile
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
|
47
|
+
begin
|
48
|
+
require 'jasmine'
|
49
|
+
load 'jasmine/tasks/jasmine.rake'
|
50
|
+
rescue LoadError
|
51
|
+
task :jasmine do
|
52
|
+
abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
task :default => :jasmine
|
57
|
+
|
58
|
+
#############################################################################
|
59
|
+
#
|
60
|
+
# Custom tasks (add your own tasks here)
|
61
|
+
#
|
62
|
+
#############################################################################
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
#############################################################################
|
67
|
+
#
|
68
|
+
# Packaging tasks
|
69
|
+
#
|
70
|
+
#############################################################################
|
71
|
+
|
72
|
+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
73
|
+
task :release => :build do
|
74
|
+
unless `git branch` =~ /^\* master$/
|
75
|
+
puts "You must be on the master branch to release!"
|
76
|
+
exit!
|
77
|
+
end
|
78
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
79
|
+
sh "git tag v#{version}"
|
80
|
+
sh "git push origin master"
|
81
|
+
sh "git push origin v#{version}"
|
82
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "Build #{gem_file} into the pkg directory"
|
86
|
+
task :build => :gemspec do
|
87
|
+
sh "mkdir -p pkg"
|
88
|
+
sh "gem build #{gemspec_file}"
|
89
|
+
sh "mv #{gem_file} pkg"
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Generate #{gemspec_file}"
|
93
|
+
task :gemspec => :validate do
|
94
|
+
# read spec file and split out manifest section
|
95
|
+
spec = File.read(gemspec_file)
|
96
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
97
|
+
|
98
|
+
# replace name version and date
|
99
|
+
replace_header(head, :name)
|
100
|
+
replace_header(head, :version)
|
101
|
+
replace_header(head, :date)
|
102
|
+
#comment this out if your rubyforge_project has a different name
|
103
|
+
replace_header(head, :rubyforge_project)
|
104
|
+
|
105
|
+
# determine file list from git ls-files
|
106
|
+
files = `git ls-files`.
|
107
|
+
split("\n").
|
108
|
+
sort.
|
109
|
+
reject { |file| file =~ /^\./ }.
|
110
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
111
|
+
map { |file| " #{file}" }.
|
112
|
+
join("\n")
|
113
|
+
|
114
|
+
# piece file back together and write
|
115
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
116
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
117
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
118
|
+
puts "Updated #{gemspec_file}"
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Validate #{gemspec_file}"
|
122
|
+
task :validate do
|
123
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
124
|
+
unless libfiles.empty?
|
125
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
126
|
+
exit!
|
127
|
+
end
|
128
|
+
unless Dir['VERSION*'].empty?
|
129
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
130
|
+
exit!
|
131
|
+
end
|
132
|
+
end
|
data/eligo-rails.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
## This is the rakegem gemspec template. Make sure you read and understand
|
2
|
+
## all of the comments. Some sections require modification, and others can
|
3
|
+
## be deleted if you don't need them. Once you understand the contents of
|
4
|
+
## this file, feel free to delete any comments that begin with two hash marks.
|
5
|
+
## You can find comprehensive Gem::Specification documentation, at
|
6
|
+
## http://docs.rubygems.org/read/chapter/20
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
+
s.rubygems_version = '1.3.5'
|
11
|
+
|
12
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
13
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
14
|
+
## the sub! line in the Rakefile
|
15
|
+
s.name = 'eligo-rails'
|
16
|
+
s.version = '0.0.1'
|
17
|
+
s.date = '2012-01-05'
|
18
|
+
|
19
|
+
## Make sure your summary is short. The description may be as long
|
20
|
+
## as you like.
|
21
|
+
s.summary = 'Add shift-click selection to a list of checkboxes.'
|
22
|
+
s.description = 'Add shift-click selection to a list of checkboxes.'
|
23
|
+
|
24
|
+
## List the primary authors. If there are a bunch of authors, it's probably
|
25
|
+
## better to set the email to an email list or something. If you don't have
|
26
|
+
## a custom homepage, consider using your GitHub URL or the like.
|
27
|
+
s.authors = ['Larry Marburger']
|
28
|
+
s.email = 'larry@marburger.cc'
|
29
|
+
s.homepage = 'http://github.com/lmarburger/eligo-rails'
|
30
|
+
|
31
|
+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
32
|
+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
33
|
+
s.require_paths = %w[lib]
|
34
|
+
|
35
|
+
## Specify any RDoc options here. You'll want to add your README and
|
36
|
+
## LICENSE files to the extra_rdoc_files list.
|
37
|
+
## s.rdoc_options = ["--charset=UTF-8"]
|
38
|
+
## s.extra_rdoc_files = %w[README LICENSE]
|
39
|
+
|
40
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
41
|
+
## that are needed for an end user to actually USE your code.
|
42
|
+
s.add_dependency 'railties', '~> 3.1.0'
|
43
|
+
s.add_dependency 'jquery-rails', '~> 1.0'
|
44
|
+
|
45
|
+
## List your development dependencies here. Development dependencies are
|
46
|
+
## those that are only needed during development
|
47
|
+
s.add_development_dependency 'jasmine-headless-webkit', '~> 0.8.4'
|
48
|
+
s.add_development_dependency 'jasmine-spec-extras', '~> 0.0.2'
|
49
|
+
|
50
|
+
## Leave this section as-is. It will be automatically generated from the
|
51
|
+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
52
|
+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
53
|
+
# = MANIFEST =
|
54
|
+
s.files = %w[
|
55
|
+
Gemfile
|
56
|
+
Gemfile.lock
|
57
|
+
Rakefile
|
58
|
+
eligo-rails.gemspec
|
59
|
+
lib/eligo-rails.rb
|
60
|
+
spec/javascripts/shift_clickable_spec.coffee
|
61
|
+
spec/javascripts/support/jasmine.yml
|
62
|
+
spec/javascripts/support/jasmine_config.rb
|
63
|
+
spec/javascripts/support/jasmine_runner.rb
|
64
|
+
vendor/assets/javascripts/shift_clickable.coffee
|
65
|
+
]
|
66
|
+
# = MANIFEST =
|
67
|
+
|
68
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
69
|
+
## matches what you actually use.
|
70
|
+
## s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
71
|
+
end
|
data/lib/eligo-rails.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
#= require jquery
|
2
|
+
#= require jasmine-jquery
|
3
|
+
#= require sinon
|
4
|
+
#= require jasmine-sinon
|
5
|
+
|
6
|
+
describe 'shiftClickable()', ->
|
7
|
+
|
8
|
+
deferExpect = (expectation) ->
|
9
|
+
waits 1
|
10
|
+
runs expectation
|
11
|
+
|
12
|
+
list = checkID = first = second = third = null
|
13
|
+
afterEach -> list.remove()
|
14
|
+
beforeEach ->
|
15
|
+
list = $ '<ul/>'
|
16
|
+
checkID = 1
|
17
|
+
first = createCheckbox()
|
18
|
+
second = createCheckbox()
|
19
|
+
third = createCheckbox()
|
20
|
+
list.shiftClickable()
|
21
|
+
|
22
|
+
shiftClickEvent = -> jQuery.Event 'click', shiftKey: true
|
23
|
+
createCheckbox = ->
|
24
|
+
$('<input type="checkbox">')
|
25
|
+
.attr('id', checkID++)
|
26
|
+
.appendTo($('<li/>').appendTo(list))
|
27
|
+
|
28
|
+
|
29
|
+
it 'is chainable', ->
|
30
|
+
shiftClickedList = list.shiftClickable()
|
31
|
+
expect(shiftClickedList).toEqual(list)
|
32
|
+
|
33
|
+
it 'simply checks checkboxes', ->
|
34
|
+
first.trigger 'click'
|
35
|
+
third.trigger 'click'
|
36
|
+
|
37
|
+
deferExpect ->
|
38
|
+
expect(first) .toBeChecked()
|
39
|
+
expect(third) .toBeChecked()
|
40
|
+
expect(second).not.toBeChecked()
|
41
|
+
|
42
|
+
it 'checks checkboxes between last and shift-clicked checkboxes', ->
|
43
|
+
first.trigger 'click'
|
44
|
+
third.trigger shiftClickEvent()
|
45
|
+
|
46
|
+
deferExpect ->
|
47
|
+
expect(first) .toBeChecked()
|
48
|
+
expect(second).toBeChecked()
|
49
|
+
expect(third) .toBeChecked()
|
50
|
+
|
51
|
+
it 'checks checkboxes below the shift-clicked checkbox', ->
|
52
|
+
third.trigger 'click'
|
53
|
+
first.trigger shiftClickEvent()
|
54
|
+
|
55
|
+
deferExpect ->
|
56
|
+
expect(first) .toBeChecked()
|
57
|
+
expect(second).toBeChecked()
|
58
|
+
expect(third) .toBeChecked()
|
59
|
+
|
60
|
+
it 'sets a default anchor', ->
|
61
|
+
second.trigger shiftClickEvent()
|
62
|
+
|
63
|
+
deferExpect ->
|
64
|
+
expect(first) .toBeChecked()
|
65
|
+
expect(second).toBeChecked()
|
66
|
+
|
67
|
+
it 'does not check checkboxes above the selected group', ->
|
68
|
+
second.trigger 'click'
|
69
|
+
third .trigger shiftClickEvent()
|
70
|
+
|
71
|
+
deferExpect ->
|
72
|
+
expect(second).toBeChecked()
|
73
|
+
expect(third) .toBeChecked()
|
74
|
+
expect(first) .not.toBeChecked()
|
75
|
+
|
76
|
+
it 'does not check checkboxes below the selected group', ->
|
77
|
+
first .trigger 'click'
|
78
|
+
second.trigger shiftClickEvent()
|
79
|
+
|
80
|
+
deferExpect ->
|
81
|
+
expect(first) .toBeChecked()
|
82
|
+
expect(second).toBeChecked()
|
83
|
+
expect(third) .not.toBeChecked()
|
84
|
+
|
85
|
+
it 'unchecks checkboxes between last and shift-clicked checkboxes', ->
|
86
|
+
group = [ third, second, first ]
|
87
|
+
checkbox.trigger 'click' for checkbox in group
|
88
|
+
third.trigger shiftClickEvent()
|
89
|
+
|
90
|
+
deferExpect ->
|
91
|
+
expect(first) .not.toBeChecked()
|
92
|
+
expect(second).not.toBeChecked()
|
93
|
+
expect(third) .not.toBeChecked()
|
94
|
+
|
95
|
+
it 'handles shift-clicks on appended checkboxes', ->
|
96
|
+
late = createCheckbox()
|
97
|
+
second.trigger 'click'
|
98
|
+
late .trigger shiftClickEvent()
|
99
|
+
|
100
|
+
deferExpect ->
|
101
|
+
expect(second).toBeChecked()
|
102
|
+
expect(third) .toBeChecked()
|
103
|
+
expect(late) .toBeChecked()
|
104
|
+
|
105
|
+
it 'checks appended checkboxes', ->
|
106
|
+
firstLate = createCheckbox()
|
107
|
+
secondLate = createCheckbox()
|
108
|
+
second .trigger 'click'
|
109
|
+
secondLate.trigger shiftClickEvent()
|
110
|
+
|
111
|
+
deferExpect ->
|
112
|
+
expect(second) .toBeChecked()
|
113
|
+
expect(third) .toBeChecked()
|
114
|
+
expect(firstLate) .toBeChecked()
|
115
|
+
expect(secondLate).toBeChecked()
|
116
|
+
|
117
|
+
it 'adjusts anchor to account for inserted checkboxes', ->
|
118
|
+
firstLate = createCheckbox()
|
119
|
+
secondLate = createCheckbox()
|
120
|
+
|
121
|
+
second.trigger 'click'
|
122
|
+
deferExpect ->
|
123
|
+
firstLate.add(secondLate).closest('li')
|
124
|
+
.insertBefore(second.closest('li'))
|
125
|
+
|
126
|
+
first.trigger shiftClickEvent()
|
127
|
+
|
128
|
+
deferExpect ->
|
129
|
+
expect(first) .toBeChecked()
|
130
|
+
expect(firstLate) .toBeChecked()
|
131
|
+
expect(secondLate).toBeChecked()
|
132
|
+
expect(second) .toBeChecked()
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# src_dir
|
2
|
+
#
|
3
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
4
|
+
# Default: project root
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_dir: public
|
9
|
+
#
|
10
|
+
src_dir: vendor/assets/javascripts
|
11
|
+
|
12
|
+
# src_files
|
13
|
+
#
|
14
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
15
|
+
# Default: []
|
16
|
+
#
|
17
|
+
# EXAMPLE:
|
18
|
+
#
|
19
|
+
# src_files:
|
20
|
+
# - lib/source1.js
|
21
|
+
# - lib/source2.js
|
22
|
+
# - dist/**/*.js
|
23
|
+
#
|
24
|
+
src_files:
|
25
|
+
- "**/*.coffee"
|
26
|
+
|
27
|
+
# stylesheets
|
28
|
+
#
|
29
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
30
|
+
# Default: []
|
31
|
+
#
|
32
|
+
# EXAMPLE:
|
33
|
+
#
|
34
|
+
# stylesheets:
|
35
|
+
# - css/style.css
|
36
|
+
# - stylesheets/*.css
|
37
|
+
#
|
38
|
+
stylesheets:
|
39
|
+
|
40
|
+
# spec_dir
|
41
|
+
#
|
42
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
43
|
+
# Default: spec/javascripts
|
44
|
+
#
|
45
|
+
# EXAMPLE:
|
46
|
+
#
|
47
|
+
# spec_dir: spec/javascripts
|
48
|
+
#
|
49
|
+
spec_dir: spec/javascripts
|
50
|
+
|
51
|
+
# helpers
|
52
|
+
#
|
53
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
54
|
+
# Default: ["helpers/**/*.js"]
|
55
|
+
#
|
56
|
+
# EXAMPLE:
|
57
|
+
#
|
58
|
+
# helpers:
|
59
|
+
# - helpers/**/*.js
|
60
|
+
#
|
61
|
+
helpers:
|
62
|
+
- helpers/**/*.coffee
|
63
|
+
|
64
|
+
# spec_files
|
65
|
+
#
|
66
|
+
# Return an array of filepaths relative to spec_dir to include.
|
67
|
+
# Default: ["**/*[sS]pec.js"]
|
68
|
+
#
|
69
|
+
# EXAMPLE:
|
70
|
+
#
|
71
|
+
# spec_files:
|
72
|
+
# - **/*[sS]pec.js
|
73
|
+
#
|
74
|
+
spec_files:
|
75
|
+
- "**/*_spec.coffee"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class Config
|
3
|
+
|
4
|
+
# Add your overrides or custom config code here
|
5
|
+
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
# Note - this is necessary for rspec2, which has removed the backtrace
|
11
|
+
module Jasmine
|
12
|
+
class SpecBuilder
|
13
|
+
def declare_spec(parent, spec)
|
14
|
+
me = self
|
15
|
+
example_name = spec["name"]
|
16
|
+
@spec_ids << spec["id"]
|
17
|
+
backtrace = @example_locations[parent.description + " " + example_name]
|
18
|
+
parent.it example_name, {} do
|
19
|
+
me.report_spec(spec["id"])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'jasmine'
|
5
|
+
jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
|
6
|
+
require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
|
7
|
+
if Jasmine::Dependencies.rspec2?
|
8
|
+
require 'rspec'
|
9
|
+
else
|
10
|
+
require 'spec'
|
11
|
+
end
|
12
|
+
|
13
|
+
jasmine_config = Jasmine::Config.new
|
14
|
+
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
15
|
+
|
16
|
+
should_stop = false
|
17
|
+
|
18
|
+
if Jasmine::Dependencies.rspec2?
|
19
|
+
RSpec.configuration.after(:suite) do
|
20
|
+
spec_builder.stop if should_stop
|
21
|
+
end
|
22
|
+
else
|
23
|
+
Spec::Runner.configure do |config|
|
24
|
+
config.after(:suite) do
|
25
|
+
spec_builder.stop if should_stop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
spec_builder.start
|
31
|
+
should_stop = true
|
32
|
+
spec_builder.declare_suites
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#= require jquery
|
2
|
+
|
3
|
+
$ = jQuery
|
4
|
+
$.fn.shiftClickable = ->
|
5
|
+
list = $ this
|
6
|
+
anchor = null
|
7
|
+
anchorIndex = -> anchor?.index() ? 0
|
8
|
+
|
9
|
+
shiftClick = (clicked) ->
|
10
|
+
[ first, last ] = [ anchorIndex(), clicked.index() ]
|
11
|
+
[ first, last ] = [ last, first ] if first > last
|
12
|
+
|
13
|
+
checked = clicked.find(':checkbox').prop('checked')
|
14
|
+
list.children('li')
|
15
|
+
.slice(first, last + 1)
|
16
|
+
.not(clicked)
|
17
|
+
.find(':checkbox')
|
18
|
+
.prop('checked', checked)
|
19
|
+
|
20
|
+
list.click (e) ->
|
21
|
+
clicked = $(e.target).closest('li')
|
22
|
+
|
23
|
+
# It seems WebKit triggers `change` before `click`, but I'm not too
|
24
|
+
# confident that all browsers must trigger events in exactly the same way.
|
25
|
+
# Defer setting the value to be sure the checkbox has its new value.
|
26
|
+
window.setTimeout(
|
27
|
+
->
|
28
|
+
shiftClick clicked if e.shiftKey
|
29
|
+
anchor = clicked
|
30
|
+
1)
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eligo-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Larry Marburger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: &70219192686260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70219192686260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: jquery-rails
|
27
|
+
requirement: &70219192685100 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70219192685100
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jasmine-headless-webkit
|
38
|
+
requirement: &70219192684400 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.8.4
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70219192684400
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jasmine-spec-extras
|
49
|
+
requirement: &70219192683480 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.2
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70219192683480
|
58
|
+
description: Add shift-click selection to a list of checkboxes.
|
59
|
+
email: larry@marburger.cc
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- Rakefile
|
67
|
+
- eligo-rails.gemspec
|
68
|
+
- lib/eligo-rails.rb
|
69
|
+
- spec/javascripts/shift_clickable_spec.coffee
|
70
|
+
- spec/javascripts/support/jasmine.yml
|
71
|
+
- spec/javascripts/support/jasmine_config.rb
|
72
|
+
- spec/javascripts/support/jasmine_runner.rb
|
73
|
+
- vendor/assets/javascripts/shift_clickable.coffee
|
74
|
+
homepage: http://github.com/lmarburger/eligo-rails
|
75
|
+
licenses: []
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.8.10
|
95
|
+
signing_key:
|
96
|
+
specification_version: 2
|
97
|
+
summary: Add shift-click selection to a list of checkboxes.
|
98
|
+
test_files: []
|