rocketjob_mission_control 3.0.0.rc1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +10 -6
- data/app/assets/javascripts/rocket_job_mission_control/application.js +4 -3
- data/app/assets/javascripts/rocket_job_mission_control/base.js +12 -0
- data/app/assets/javascripts/rocket_job_mission_control/datatable.js +40 -0
- data/app/assets/javascripts/rocket_job_mission_control/dirmon_entries.js +16 -0
- data/app/assets/javascripts/rocket_job_mission_control/selectize.js +6 -0
- data/app/controllers/rocket_job_mission_control/active_workers_controller.rb +16 -5
- data/app/controllers/rocket_job_mission_control/application_controller.rb +2 -0
- data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +47 -67
- data/app/controllers/rocket_job_mission_control/jobs_controller.rb +113 -19
- data/app/controllers/rocket_job_mission_control/servers_controller.rb +71 -28
- data/app/datatables/rocket_job_mission_control/abstract_datatable.rb +3 -3
- data/app/datatables/rocket_job_mission_control/active_workers_datatable.rb +8 -14
- data/app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb +7 -15
- data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +128 -13
- data/app/datatables/rocket_job_mission_control/servers_datatable.rb +13 -15
- data/app/helpers/rocket_job_mission_control/application_helper.rb +58 -0
- data/app/helpers/rocket_job_mission_control/jobs_helper.rb +15 -7
- data/app/helpers/rocket_job_mission_control/servers_helper.rb +1 -1
- data/app/models/rocket_job_mission_control/job_sanitizer.rb +47 -0
- data/app/models/rocket_job_mission_control/query.rb +24 -18
- data/app/views/layouts/rocket_job_mission_control/application.html.erb +43 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_flash.html.erb +20 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_header.html.erb +45 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.erb +12 -0
- data/app/views/rocket_job_mission_control/active_workers/index.html.erb +40 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_form.html.erb +60 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.erb +38 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.erb +17 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/edit.html.erb +4 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/index.html.erb +33 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/new.html.erb +8 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/show.html.erb +29 -0
- data/app/views/rocket_job_mission_control/jobs/_pagination.html.erb +26 -0
- data/app/views/rocket_job_mission_control/jobs/_sidebar.html.erb +32 -0
- data/app/views/rocket_job_mission_control/jobs/_status.html.erb +42 -0
- data/app/views/rocket_job_mission_control/jobs/edit.html.erb +32 -0
- data/app/views/rocket_job_mission_control/jobs/exception.html.erb +19 -0
- data/app/views/rocket_job_mission_control/jobs/exceptions.html.erb +40 -0
- data/app/views/rocket_job_mission_control/jobs/index.html.erb +33 -0
- data/app/views/rocket_job_mission_control/jobs/show.html.erb +68 -0
- data/app/views/rocket_job_mission_control/servers/_sidebar.html.erb +31 -0
- data/app/views/rocket_job_mission_control/servers/index.html.erb +56 -0
- data/config/locales/en.yml +3 -10
- data/config/routes.rb +20 -17
- data/lib/rocket_job_mission_control/engine.rb +10 -0
- data/lib/rocket_job_mission_control/version.rb +1 -1
- data/test/compare_hashes.rb +17 -0
- data/test/controllers/rocket_job_mission_control/application_controller_test.rb +49 -0
- data/test/controllers/rocket_job_mission_control/dirmon_entries_controller_test.rb +417 -0
- data/test/controllers/rocket_job_mission_control/jobs_controller_test.rb +363 -0
- data/test/controllers/rocket_job_mission_control/servers_controller_test.rb +251 -0
- data/test/helpers/rocket_job_mission_control/application_helper_test.rb +54 -0
- data/test/helpers/rocket_job_mission_control/jobs_helper_test.rb +85 -0
- data/test/helpers/rocket_job_mission_control/pagination_helper_test.rb +23 -0
- data/test/helpers/rocket_job_mission_control/servers_helper_test.rb +64 -0
- data/test/helpers/rocket_job_mission_control/slices_helper_test.rb +30 -0
- data/test/models/rocket_job_mission_control/job_sanitizer_test.rb +92 -0
- data/test/models/rocket_job_mission_control/query_test.rb +136 -0
- data/test/test_helper.rb +23 -0
- metadata +75 -175
- data/app/assets/javascripts/rocket_job_mission_control/base.js.coffee +0 -11
- data/app/assets/javascripts/rocket_job_mission_control/datatable.js.coffee +0 -33
- data/app/assets/javascripts/rocket_job_mission_control/dirmon_entries.js.coffee +0 -13
- data/app/assets/javascripts/rocket_job_mission_control/selectize.js.coffee +0 -5
- data/app/assets/stylesheets/rocket_job_mission_control/jquery.bootstrap-touchspin.scss +0 -45
- data/app/controllers/rocket_job_mission_control/dirmon_entries/index_filters_controller.rb +0 -45
- data/app/controllers/rocket_job_mission_control/jobs/failures_controller.rb +0 -30
- data/app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb +0 -90
- data/app/controllers/rocket_job_mission_control/servers/index_filters_controller.rb +0 -49
- data/app/datatables/rocket_job_mission_control/completed_jobs_datatable.rb +0 -27
- data/app/datatables/rocket_job_mission_control/interrupted_jobs_datatable.rb +0 -26
- data/app/datatables/rocket_job_mission_control/queued_jobs_datatable.rb +0 -23
- data/app/datatables/rocket_job_mission_control/running_jobs_datatable.rb +0 -47
- data/app/datatables/rocket_job_mission_control/scheduled_jobs_datatable.rb +0 -31
- data/app/models/job_failures.rb +0 -20
- data/app/models/job_sanitizer.rb +0 -17
- data/app/views/layouts/rocket_job_mission_control/application.html.haml +0 -45
- data/app/views/layouts/rocket_job_mission_control/partials/_header.html.haml +0 -32
- data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.haml +0 -11
- data/app/views/rocket_job_mission_control/active_workers/index.html.haml +0 -24
- data/app/views/rocket_job_mission_control/dirmon_entries/_form.html.haml +0 -37
- data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +0 -30
- data/app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.haml +0 -27
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +0 -23
- data/app/views/rocket_job_mission_control/dirmon_entries/edit.html.haml +0 -4
- data/app/views/rocket_job_mission_control/dirmon_entries/index.html.haml +0 -18
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/disabled.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/enabled.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/failed.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/pending.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/new.html.haml +0 -6
- data/app/views/rocket_job_mission_control/dirmon_entries/show.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/_sidebar.html.haml +0 -28
- data/app/views/rocket_job_mission_control/jobs/_status.html.haml +0 -45
- data/app/views/rocket_job_mission_control/jobs/edit.html.haml +0 -34
- data/app/views/rocket_job_mission_control/jobs/exceptions.html.haml +0 -29
- data/app/views/rocket_job_mission_control/jobs/failures/_pagination.html.haml +0 -16
- data/app/views/rocket_job_mission_control/jobs/failures/index.html.haml +0 -32
- data/app/views/rocket_job_mission_control/jobs/index.html.haml +0 -25
- data/app/views/rocket_job_mission_control/jobs/index_filters/aborted.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/index_filters/completed.html.haml +0 -24
- data/app/views/rocket_job_mission_control/jobs/index_filters/failed.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/index_filters/paused.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/index_filters/queued.html.haml +0 -24
- data/app/views/rocket_job_mission_control/jobs/index_filters/running.html.haml +0 -25
- data/app/views/rocket_job_mission_control/jobs/index_filters/scheduled.html.haml +0 -24
- data/app/views/rocket_job_mission_control/jobs/show.html.haml +0 -51
- data/app/views/rocket_job_mission_control/servers/_actions.html.haml +0 -9
- data/app/views/rocket_job_mission_control/servers/_sidebar.html.haml +0 -20
- data/app/views/rocket_job_mission_control/servers/index.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/paused.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/running.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/starting.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/stopping.html.haml +0 -37
- data/spec/controllers/application_controller_spec.rb +0 -47
- data/spec/controllers/dirmon_entries/index_filters_controller_spec.rb +0 -77
- data/spec/controllers/dirmon_entries_controller_spec.rb +0 -383
- data/spec/controllers/jobs/failures_controller_spec.rb +0 -82
- data/spec/controllers/jobs/index_filters_controller_spec.rb +0 -66
- data/spec/controllers/jobs_controller_spec.rb +0 -172
- data/spec/controllers/workers/index_filters_controller_spec.rb +0 -59
- data/spec/controllers/workers_controller_spec.rb +0 -125
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/mongoid.yml +0 -88
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config/symmetric-encryption.yml +0 -8
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -118933
- data/spec/helpers/application_helper_spec.rb +0 -58
- data/spec/helpers/jobs_helper_spec.rb +0 -35
- data/spec/helpers/pagination_helper_spec.rb +0 -21
- data/spec/helpers/servers_helper_spec.rb +0 -16
- data/spec/helpers/slices_helper_spec.rb +0 -33
- data/spec/models/job_failures_spec.rb +0 -14
- data/spec/models/job_sanitizer_spec.rb +0 -16
- data/spec/rails_helper.rb +0 -47
- data/spec/spec_helper.rb +0 -84
- data/vendor/assets/javascripts/jquery.bootstrap-touchspin.js +0 -686
- data/vendor/assets/javascripts/prism.js +0 -6
- data/vendor/assets/stylesheets/jquery.bootstrap-touchspin.css +0 -45
- data/vendor/assets/stylesheets/prism.scss +0 -160
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
class ::TheJobClass < OpenStruct;
|
5
|
-
end
|
6
|
-
|
7
|
-
describe ApplicationHelper, type: :helper do
|
8
|
-
before do
|
9
|
-
helper.extend(RocketJobMissionControl::ApplicationHelper)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#state_icon' do
|
13
|
-
RocketJobMissionControl::ApplicationHelper::STATE_ICON_MAP.each do |state, expected_class|
|
14
|
-
context "when the job state is #{state}" do
|
15
|
-
it 'returns the correct class' do
|
16
|
-
expect(helper.state_icon(state)).to eq("#{expected_class} #{state}")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#pretty_print_array_or_hash' do
|
23
|
-
let(:arguments) { [42, "muad'dib"] }
|
24
|
-
let(:helper_output) { helper.pretty_print_array_or_hash(arguments) }
|
25
|
-
|
26
|
-
context 'when arguments is a simple array' do
|
27
|
-
it 'returns a string with spacing and line breaks' do
|
28
|
-
expect(helper_output).to eq("[<br /> 42,<br /> \"muad'dib\"<br />]")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when arguments is an array with complex data' do
|
33
|
-
let(:arguments) {
|
34
|
-
[
|
35
|
-
42,
|
36
|
-
{
|
37
|
-
crew: ['leela', 'fry', 'bender'],
|
38
|
-
created_at: '1999-03-28',
|
39
|
-
}
|
40
|
-
]
|
41
|
-
}
|
42
|
-
|
43
|
-
it 'returns a string with spacing and line breaks' do
|
44
|
-
expected_output = "[<br /> 42,<br /> {<br /> \"crew\": [<br /> \"leela\",<br /> \"fry\",<br /> \"bender\"<br /> ],<br /> \"created_at\": \"1999-03-28\"<br /> }<br />]"
|
45
|
-
expect(helper_output).to eq(expected_output)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "when arguments isn't an array or hash" do
|
50
|
-
let(:arguments) { 42 }
|
51
|
-
|
52
|
-
it 'returns the arguments' do
|
53
|
-
expect(helper_output).to eq(arguments)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
class ::TheJobClass < OpenStruct;
|
5
|
-
end
|
6
|
-
|
7
|
-
RSpec.describe JobsHelper, type: :helper do
|
8
|
-
before do
|
9
|
-
helper.extend(RocketJobMissionControl::ApplicationHelper)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#job_action_link' do
|
13
|
-
let(:action) { 'abort' }
|
14
|
-
let(:http_method) { :patch }
|
15
|
-
let(:path) { "/jobs/42/#{action}" }
|
16
|
-
let(:action_link) { helper.job_action_link(action, path, http_method) }
|
17
|
-
|
18
|
-
it 'uses the action as the label' do
|
19
|
-
expect(action_link).to match(/>abort<\/a>/)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'links to the correct url' do
|
23
|
-
expect(action_link).to match(/href="\/jobs\/42\/abort\"/)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'adds prompt for confirmation' do
|
27
|
-
expect(action_link).to match(/data-confirm="Are you sure you want to abort this job\?"/)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'uses correct http method' do
|
31
|
-
expect(action_link).to match(/data-method="patch"/)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.describe PaginationHelper, type: :helper do
|
5
|
-
describe '#page_nav_disabled_class' do
|
6
|
-
|
7
|
-
context 'when the current position equals the boundary' do
|
8
|
-
it 'returns disabled' do
|
9
|
-
expect(helper.page_nav_disabled_class(0, 0)).to eq('disabled')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when the current position is NOT equal to the boundary' do
|
14
|
-
it 'returns blank' do
|
15
|
-
expect(helper.page_nav_disabled_class(4, 0)).to be_blank
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.describe ServersHelper, type: :helper do
|
5
|
-
describe '#server_card_class' do
|
6
|
-
context 'when the server is a zombie' do
|
7
|
-
let(:server) { spy(zombie?: true) }
|
8
|
-
|
9
|
-
it 'returns the correct class' do
|
10
|
-
expect(helper.server_card_class(server)).to eq('callout-zombie')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.describe SlicesHelper, type: :helper do
|
5
|
-
before do
|
6
|
-
helper.extend(RocketJobMissionControl::ApplicationHelper)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#display_slice_info' do
|
10
|
-
let(:slice) { {id: 42, name: 'test'} }
|
11
|
-
|
12
|
-
context "when encrypted" do
|
13
|
-
it { expect(helper.display_slice_info(slice, true)).to eq('encrypted') }
|
14
|
-
end
|
15
|
-
|
16
|
-
context "when unencrypted" do
|
17
|
-
before do
|
18
|
-
allow(helper).to receive(:pretty_print_array_or_hash)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "does not return 'encrypted'" do
|
22
|
-
expect(helper.display_slice_info(slice, false)).to_not eq('encrypted')
|
23
|
-
end
|
24
|
-
|
25
|
-
it "displays the slice info" do
|
26
|
-
helper.display_slice_info(slice, false)
|
27
|
-
expect(helper).to have_received(:pretty_print_array_or_hash).with(slice.to_a)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe JobFailures do
|
4
|
-
describe '#job' do
|
5
|
-
before do
|
6
|
-
allow(RocketJob::Job).to receive(:find)
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'looks up the job' do
|
10
|
-
described_class.new(42).job
|
11
|
-
expect(RocketJob::Job).to have_received(:find).with(42)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe JobSanitizer do
|
4
|
-
describe '#sanitize' do
|
5
|
-
it "replaces blank string in log_level with nil" do
|
6
|
-
params = { job: { log_level: '' } }
|
7
|
-
sanitized = { job: { log_level: nil } }
|
8
|
-
expect(JobSanitizer.new(params).sanitize).to eq(sanitized)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "leaves valid log_levels alone" do
|
12
|
-
params = { job: { log_level: :warn } }
|
13
|
-
expect(JobSanitizer.new(params).sanitize).to eq(params)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/spec/rails_helper.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
ENV['RAILS_ENV'] ||= 'test'
|
3
|
-
require_relative 'spec_helper'
|
4
|
-
require_relative 'dummy/config/environment'
|
5
|
-
|
6
|
-
require 'rspec/rails'
|
7
|
-
# Add additional requires below this line. Rails is not loaded until this point!
|
8
|
-
|
9
|
-
# Requires supporting ruby files with custom matchers and macros, etc, in
|
10
|
-
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
11
|
-
# run as spec files by default. This means that files in spec/support that end
|
12
|
-
# in _spec.rb will both be required and run as specs, causing the specs to be
|
13
|
-
# run twice. It is recommended that you do not name files matching this glob to
|
14
|
-
# end with _spec.rb. You can configure this pattern with the --pattern
|
15
|
-
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
16
|
-
#
|
17
|
-
# The following line is provided for convenience purposes. It has the downside
|
18
|
-
# of increasing the boot-up time by auto-requiring all files in the support
|
19
|
-
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
20
|
-
# require only the support files necessary.
|
21
|
-
#
|
22
|
-
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
23
|
-
|
24
|
-
RSpec.configure do |config|
|
25
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
26
|
-
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
27
|
-
|
28
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
29
|
-
# examples within a transaction, remove the following line or assign false
|
30
|
-
# instead of true.
|
31
|
-
config.use_transactional_fixtures = true
|
32
|
-
|
33
|
-
# RSpec Rails can automatically mix in different behaviours to your tests
|
34
|
-
# based on their file location, for example enabling you to call `get` and
|
35
|
-
# `post` in specs under `spec/controllers`.
|
36
|
-
#
|
37
|
-
# You can disable this behaviour by removing the line below, and instead
|
38
|
-
# explicitly tag your specs with their type, e.g.:
|
39
|
-
#
|
40
|
-
# RSpec.describe UsersController, :type => :controller do
|
41
|
-
# # ...
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# The different available types are documented in the features, such as in
|
45
|
-
# https://relishapp.com/rspec/rspec-rails/docs
|
46
|
-
config.infer_spec_type_from_file_location!
|
47
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'rocketjob'
|
2
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
3
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
4
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
5
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
6
|
-
# a separate helper file that requires the additional dependencies and performs
|
7
|
-
# the additional setup, and require it from the spec files that actually need
|
8
|
-
# it.
|
9
|
-
#
|
10
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
11
|
-
# users commonly want.
|
12
|
-
#
|
13
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
14
|
-
RSpec.configure do |config|
|
15
|
-
# rspec-expectations config goes here. You can use an alternate
|
16
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
17
|
-
# assertions if you prefer.
|
18
|
-
config.expect_with :rspec do |expectations|
|
19
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
20
|
-
# and `failure_message` of custom matchers include text for helper methods
|
21
|
-
# defined using `chain`, e.g.:
|
22
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
23
|
-
# # => "be bigger than 2 and smaller than 4"
|
24
|
-
# ...rather than:
|
25
|
-
# # => "be bigger than 2"
|
26
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
27
|
-
end
|
28
|
-
|
29
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
30
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
31
|
-
config.mock_with :rspec do |mocks|
|
32
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
33
|
-
# a real object. This is generally recommended, and will default to
|
34
|
-
# `true` in RSpec 4.
|
35
|
-
mocks.verify_partial_doubles = true
|
36
|
-
end
|
37
|
-
|
38
|
-
# The settings below are suggested to provide a good initial experience
|
39
|
-
# with RSpec, but feel free to customize to your heart's content.
|
40
|
-
=begin
|
41
|
-
# These two settings work together to allow you to limit a spec run
|
42
|
-
# to individual examples or groups you care about by tagging them with
|
43
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
44
|
-
# get run.
|
45
|
-
config.filter_run :focus
|
46
|
-
config.run_all_when_everything_filtered = true
|
47
|
-
|
48
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
49
|
-
# recommended. For more details, see:
|
50
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
51
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
52
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
53
|
-
config.disable_monkey_patching!
|
54
|
-
|
55
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
56
|
-
# file, and it's useful to allow more verbose output when running an
|
57
|
-
# individual spec file.
|
58
|
-
if config.files_to_run.one?
|
59
|
-
# Use the documentation formatter for detailed output,
|
60
|
-
# unless a formatter has already been configured
|
61
|
-
# (e.g. via a command-line flag).
|
62
|
-
config.default_formatter = 'doc'
|
63
|
-
end
|
64
|
-
|
65
|
-
# Print the 10 slowest examples and example groups at the
|
66
|
-
# end of the spec run, to help surface which specs are running
|
67
|
-
# particularly slow.
|
68
|
-
config.profile_examples = 10
|
69
|
-
|
70
|
-
# Run specs in random order to surface order dependencies. If you find an
|
71
|
-
# order dependency and want to debug it, you can fix the order by providing
|
72
|
-
# the seed, which is printed after each run.
|
73
|
-
# --seed 1234
|
74
|
-
config.order = :random
|
75
|
-
|
76
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
77
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
78
|
-
# test failures related to randomization by passing the same `--seed` value
|
79
|
-
# as the one that triggered the failure.
|
80
|
-
Kernel.srand config.seed
|
81
|
-
=end
|
82
|
-
end
|
83
|
-
|
84
|
-
RocketJob::Config.load!('test', 'spec/dummy/config/mongoid.yml', 'spec/dummy/config/symmetric-encryption.yml')
|
@@ -1,686 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Bootstrap TouchSpin - v3.0.1
|
3
|
-
* A mobile and touch friendly input spinner component for Bootstrap 3.
|
4
|
-
* http://www.virtuosoft.eu/code/bootstrap-touchspin/
|
5
|
-
*
|
6
|
-
* Made by István Ujj-Mészáros
|
7
|
-
* Under Apache License v2.0 License
|
8
|
-
*/
|
9
|
-
(function($) {
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var _currentSpinnerId = 0;
|
13
|
-
|
14
|
-
function _scopedEventName(name, id) {
|
15
|
-
return name + '.touchspin_' + id;
|
16
|
-
}
|
17
|
-
|
18
|
-
function _scopeEventNames(names, id) {
|
19
|
-
return $.map(names, function(name) {
|
20
|
-
return _scopedEventName(name, id);
|
21
|
-
});
|
22
|
-
}
|
23
|
-
|
24
|
-
$.fn.TouchSpin = function(options) {
|
25
|
-
|
26
|
-
if (options === 'destroy') {
|
27
|
-
this.each(function() {
|
28
|
-
var originalinput = $(this),
|
29
|
-
originalinput_data = originalinput.data();
|
30
|
-
$(document).off(_scopeEventNames([
|
31
|
-
'mouseup',
|
32
|
-
'touchend',
|
33
|
-
'touchcancel',
|
34
|
-
'mousemove',
|
35
|
-
'touchmove',
|
36
|
-
'scroll',
|
37
|
-
'scrollstart'], originalinput_data.spinnerid).join(' '));
|
38
|
-
});
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
|
42
|
-
var defaults = {
|
43
|
-
min: 0,
|
44
|
-
max: 100,
|
45
|
-
initval: '',
|
46
|
-
step: 1,
|
47
|
-
decimals: 0,
|
48
|
-
stepinterval: 100,
|
49
|
-
forcestepdivisibility: 'round', // none | floor | round | ceil
|
50
|
-
stepintervaldelay: 500,
|
51
|
-
verticalbuttons: false,
|
52
|
-
verticalupclass: 'glyphicon glyphicon-chevron-up',
|
53
|
-
verticaldownclass: 'glyphicon glyphicon-chevron-down',
|
54
|
-
prefix: '',
|
55
|
-
postfix: '',
|
56
|
-
prefix_extraclass: '',
|
57
|
-
postfix_extraclass: '',
|
58
|
-
booster: true,
|
59
|
-
boostat: 10,
|
60
|
-
maxboostedstep: false,
|
61
|
-
mousewheel: true,
|
62
|
-
buttondown_class: 'btn btn-default',
|
63
|
-
buttonup_class: 'btn btn-default',
|
64
|
-
buttondown_txt: '-',
|
65
|
-
buttonup_txt: '+'
|
66
|
-
};
|
67
|
-
|
68
|
-
var attributeMap = {
|
69
|
-
min: 'min',
|
70
|
-
max: 'max',
|
71
|
-
initval: 'init-val',
|
72
|
-
step: 'step',
|
73
|
-
decimals: 'decimals',
|
74
|
-
stepinterval: 'step-interval',
|
75
|
-
verticalbuttons: 'vertical-buttons',
|
76
|
-
verticalupclass: 'vertical-up-class',
|
77
|
-
verticaldownclass: 'vertical-down-class',
|
78
|
-
forcestepdivisibility: 'force-step-divisibility',
|
79
|
-
stepintervaldelay: 'step-interval-delay',
|
80
|
-
prefix: 'prefix',
|
81
|
-
postfix: 'postfix',
|
82
|
-
prefix_extraclass: 'prefix-extra-class',
|
83
|
-
postfix_extraclass: 'postfix-extra-class',
|
84
|
-
booster: 'booster',
|
85
|
-
boostat: 'boostat',
|
86
|
-
maxboostedstep: 'max-boosted-step',
|
87
|
-
mousewheel: 'mouse-wheel',
|
88
|
-
buttondown_class: 'button-down-class',
|
89
|
-
buttonup_class: 'button-up-class',
|
90
|
-
buttondown_txt: 'button-down-txt',
|
91
|
-
buttonup_txt: 'button-up-txt'
|
92
|
-
};
|
93
|
-
|
94
|
-
return this.each(function() {
|
95
|
-
|
96
|
-
var settings,
|
97
|
-
originalinput = $(this),
|
98
|
-
originalinput_data = originalinput.data(),
|
99
|
-
container,
|
100
|
-
elements,
|
101
|
-
value,
|
102
|
-
downSpinTimer,
|
103
|
-
upSpinTimer,
|
104
|
-
downDelayTimeout,
|
105
|
-
upDelayTimeout,
|
106
|
-
spincount = 0,
|
107
|
-
spinning = false;
|
108
|
-
|
109
|
-
init();
|
110
|
-
|
111
|
-
|
112
|
-
function init() {
|
113
|
-
if (originalinput.data('alreadyinitialized')) {
|
114
|
-
return;
|
115
|
-
}
|
116
|
-
|
117
|
-
originalinput.data('alreadyinitialized', true);
|
118
|
-
_currentSpinnerId += 1;
|
119
|
-
originalinput.data('spinnerid', _currentSpinnerId);
|
120
|
-
|
121
|
-
|
122
|
-
if (!originalinput.is('input')) {
|
123
|
-
console.log('Must be an input.');
|
124
|
-
return;
|
125
|
-
}
|
126
|
-
|
127
|
-
_initSettings();
|
128
|
-
_setInitval();
|
129
|
-
_checkValue();
|
130
|
-
_buildHtml();
|
131
|
-
_initElements();
|
132
|
-
_hideEmptyPrefixPostfix();
|
133
|
-
_bindEvents();
|
134
|
-
_bindEventsInterface();
|
135
|
-
elements.input.css('display', 'block');
|
136
|
-
}
|
137
|
-
|
138
|
-
function _setInitval() {
|
139
|
-
if (settings.initval !== '' && originalinput.val() === '') {
|
140
|
-
originalinput.val(settings.initval);
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
function changeSettings(newsettings) {
|
145
|
-
_updateSettings(newsettings);
|
146
|
-
_checkValue();
|
147
|
-
|
148
|
-
var value = elements.input.val();
|
149
|
-
|
150
|
-
if (value !== '') {
|
151
|
-
value = Number(elements.input.val());
|
152
|
-
elements.input.val(value.toFixed(settings.decimals));
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
function _initSettings() {
|
157
|
-
settings = $.extend({}, defaults, originalinput_data, _parseAttributes(), options);
|
158
|
-
}
|
159
|
-
|
160
|
-
function _parseAttributes() {
|
161
|
-
var data = {};
|
162
|
-
$.each(attributeMap, function(key, value) {
|
163
|
-
var attrName = 'bts-' + value + '';
|
164
|
-
if (originalinput.is('[data-' + attrName + ']')) {
|
165
|
-
data[key] = originalinput.data(attrName);
|
166
|
-
}
|
167
|
-
});
|
168
|
-
return data;
|
169
|
-
}
|
170
|
-
|
171
|
-
function _updateSettings(newsettings) {
|
172
|
-
settings = $.extend({}, settings, newsettings);
|
173
|
-
}
|
174
|
-
|
175
|
-
function _buildHtml() {
|
176
|
-
var initval = originalinput.val(),
|
177
|
-
parentelement = originalinput.parent();
|
178
|
-
|
179
|
-
if (initval !== '') {
|
180
|
-
initval = Number(initval).toFixed(settings.decimals);
|
181
|
-
}
|
182
|
-
|
183
|
-
originalinput.data('initvalue', initval).val(initval);
|
184
|
-
originalinput.addClass('form-control');
|
185
|
-
|
186
|
-
if (parentelement.hasClass('input-group')) {
|
187
|
-
_advanceInputGroup(parentelement);
|
188
|
-
}
|
189
|
-
else {
|
190
|
-
_buildInputGroup();
|
191
|
-
}
|
192
|
-
}
|
193
|
-
|
194
|
-
function _advanceInputGroup(parentelement) {
|
195
|
-
parentelement.addClass('bootstrap-touchspin');
|
196
|
-
|
197
|
-
var prev = originalinput.prev(),
|
198
|
-
next = originalinput.next();
|
199
|
-
|
200
|
-
var downhtml,
|
201
|
-
uphtml,
|
202
|
-
prefixhtml = '<span class="input-group-addon bootstrap-touchspin-prefix">' + settings.prefix + '</span>',
|
203
|
-
postfixhtml = '<span class="input-group-addon bootstrap-touchspin-postfix">' + settings.postfix + '</span>';
|
204
|
-
|
205
|
-
if (prev.hasClass('input-group-btn')) {
|
206
|
-
downhtml = '<button class="' + settings.buttondown_class + ' bootstrap-touchspin-down" type="button">' + settings.buttondown_txt + '</button>';
|
207
|
-
prev.append(downhtml);
|
208
|
-
}
|
209
|
-
else {
|
210
|
-
downhtml = '<span class="input-group-btn"><button class="' + settings.buttondown_class + ' bootstrap-touchspin-down" type="button">' + settings.buttondown_txt + '</button></span>';
|
211
|
-
$(downhtml).insertBefore(originalinput);
|
212
|
-
}
|
213
|
-
|
214
|
-
if (next.hasClass('input-group-btn')) {
|
215
|
-
uphtml = '<button class="' + settings.buttonup_class + ' bootstrap-touchspin-up" type="button">' + settings.buttonup_txt + '</button>';
|
216
|
-
next.prepend(uphtml);
|
217
|
-
}
|
218
|
-
else {
|
219
|
-
uphtml = '<span class="input-group-btn"><button class="' + settings.buttonup_class + ' bootstrap-touchspin-up" type="button">' + settings.buttonup_txt + '</button></span>';
|
220
|
-
$(uphtml).insertAfter(originalinput);
|
221
|
-
}
|
222
|
-
|
223
|
-
$(prefixhtml).insertBefore(originalinput);
|
224
|
-
$(postfixhtml).insertAfter(originalinput);
|
225
|
-
|
226
|
-
container = parentelement;
|
227
|
-
}
|
228
|
-
|
229
|
-
function _buildInputGroup() {
|
230
|
-
var html;
|
231
|
-
|
232
|
-
if (settings.verticalbuttons) {
|
233
|
-
html = '<div class="input-group bootstrap-touchspin"><span class="input-group-addon bootstrap-touchspin-prefix">' + settings.prefix + '</span><span class="input-group-addon bootstrap-touchspin-postfix">' + settings.postfix + '</span><span class="input-group-btn-vertical"><button class="' + settings.buttondown_class + ' bootstrap-touchspin-up" type="button"><i class="' + settings.verticalupclass + '"></i></button><button class="' + settings.buttonup_class + ' bootstrap-touchspin-down" type="button"><i class="' + settings.verticaldownclass + '"></i></button></span></div>';
|
234
|
-
}
|
235
|
-
else {
|
236
|
-
html = '<div class="input-group bootstrap-touchspin"><span class="input-group-btn"><button class="' + settings.buttondown_class + ' bootstrap-touchspin-down" type="button">' + settings.buttondown_txt + '</button></span><span class="input-group-addon bootstrap-touchspin-prefix">' + settings.prefix + '</span><span class="input-group-addon bootstrap-touchspin-postfix">' + settings.postfix + '</span><span class="input-group-btn"><button class="' + settings.buttonup_class + ' bootstrap-touchspin-up" type="button">' + settings.buttonup_txt + '</button></span></div>';
|
237
|
-
}
|
238
|
-
|
239
|
-
container = $(html).insertBefore(originalinput);
|
240
|
-
|
241
|
-
$('.bootstrap-touchspin-prefix', container).after(originalinput);
|
242
|
-
|
243
|
-
if (originalinput.hasClass('input-sm')) {
|
244
|
-
container.addClass('input-group-sm');
|
245
|
-
}
|
246
|
-
else if (originalinput.hasClass('input-lg')) {
|
247
|
-
container.addClass('input-group-lg');
|
248
|
-
}
|
249
|
-
}
|
250
|
-
|
251
|
-
function _initElements() {
|
252
|
-
elements = {
|
253
|
-
down: $('.bootstrap-touchspin-down', container),
|
254
|
-
up: $('.bootstrap-touchspin-up', container),
|
255
|
-
input: $('input', container),
|
256
|
-
prefix: $('.bootstrap-touchspin-prefix', container).addClass(settings.prefix_extraclass),
|
257
|
-
postfix: $('.bootstrap-touchspin-postfix', container).addClass(settings.postfix_extraclass)
|
258
|
-
};
|
259
|
-
}
|
260
|
-
|
261
|
-
function _hideEmptyPrefixPostfix() {
|
262
|
-
if (settings.prefix === '') {
|
263
|
-
elements.prefix.hide();
|
264
|
-
}
|
265
|
-
|
266
|
-
if (settings.postfix === '') {
|
267
|
-
elements.postfix.hide();
|
268
|
-
}
|
269
|
-
}
|
270
|
-
|
271
|
-
function _bindEvents() {
|
272
|
-
originalinput.on('keydown', function(ev) {
|
273
|
-
var code = ev.keyCode || ev.which;
|
274
|
-
|
275
|
-
if (code === 38) {
|
276
|
-
if (spinning !== 'up') {
|
277
|
-
upOnce();
|
278
|
-
startUpSpin();
|
279
|
-
}
|
280
|
-
ev.preventDefault();
|
281
|
-
}
|
282
|
-
else if (code === 40) {
|
283
|
-
if (spinning !== 'down') {
|
284
|
-
downOnce();
|
285
|
-
startDownSpin();
|
286
|
-
}
|
287
|
-
ev.preventDefault();
|
288
|
-
}
|
289
|
-
});
|
290
|
-
|
291
|
-
originalinput.on('keyup', function(ev) {
|
292
|
-
var code = ev.keyCode || ev.which;
|
293
|
-
|
294
|
-
if (code === 38) {
|
295
|
-
stopSpin();
|
296
|
-
}
|
297
|
-
else if (code === 40) {
|
298
|
-
stopSpin();
|
299
|
-
}
|
300
|
-
});
|
301
|
-
|
302
|
-
originalinput.on('blur', function() {
|
303
|
-
_checkValue();
|
304
|
-
});
|
305
|
-
|
306
|
-
elements.down.on('keydown', function(ev) {
|
307
|
-
var code = ev.keyCode || ev.which;
|
308
|
-
|
309
|
-
if (code === 32 || code === 13) {
|
310
|
-
if (spinning !== 'down') {
|
311
|
-
downOnce();
|
312
|
-
startDownSpin();
|
313
|
-
}
|
314
|
-
ev.preventDefault();
|
315
|
-
}
|
316
|
-
});
|
317
|
-
|
318
|
-
elements.down.on('keyup', function(ev) {
|
319
|
-
var code = ev.keyCode || ev.which;
|
320
|
-
|
321
|
-
if (code === 32 || code === 13) {
|
322
|
-
stopSpin();
|
323
|
-
}
|
324
|
-
});
|
325
|
-
|
326
|
-
elements.up.on('keydown', function(ev) {
|
327
|
-
var code = ev.keyCode || ev.which;
|
328
|
-
|
329
|
-
if (code === 32 || code === 13) {
|
330
|
-
if (spinning !== 'up') {
|
331
|
-
upOnce();
|
332
|
-
startUpSpin();
|
333
|
-
}
|
334
|
-
ev.preventDefault();
|
335
|
-
}
|
336
|
-
});
|
337
|
-
|
338
|
-
elements.up.on('keyup', function(ev) {
|
339
|
-
var code = ev.keyCode || ev.which;
|
340
|
-
|
341
|
-
if (code === 32 || code === 13) {
|
342
|
-
stopSpin();
|
343
|
-
}
|
344
|
-
});
|
345
|
-
|
346
|
-
elements.down.on('mousedown.touchspin', function(ev) {
|
347
|
-
elements.down.off('touchstart.touchspin'); // android 4 workaround
|
348
|
-
|
349
|
-
if (originalinput.is(':disabled')) {
|
350
|
-
return;
|
351
|
-
}
|
352
|
-
|
353
|
-
downOnce();
|
354
|
-
startDownSpin();
|
355
|
-
|
356
|
-
ev.preventDefault();
|
357
|
-
ev.stopPropagation();
|
358
|
-
});
|
359
|
-
|
360
|
-
elements.down.on('touchstart.touchspin', function(ev) {
|
361
|
-
elements.down.off('mousedown.touchspin'); // android 4 workaround
|
362
|
-
|
363
|
-
if (originalinput.is(':disabled')) {
|
364
|
-
return;
|
365
|
-
}
|
366
|
-
|
367
|
-
downOnce();
|
368
|
-
startDownSpin();
|
369
|
-
|
370
|
-
ev.preventDefault();
|
371
|
-
ev.stopPropagation();
|
372
|
-
});
|
373
|
-
|
374
|
-
elements.up.on('mousedown.touchspin', function(ev) {
|
375
|
-
elements.up.off('touchstart.touchspin'); // android 4 workaround
|
376
|
-
|
377
|
-
if (originalinput.is(':disabled')) {
|
378
|
-
return;
|
379
|
-
}
|
380
|
-
|
381
|
-
upOnce();
|
382
|
-
startUpSpin();
|
383
|
-
|
384
|
-
ev.preventDefault();
|
385
|
-
ev.stopPropagation();
|
386
|
-
});
|
387
|
-
|
388
|
-
elements.up.on('touchstart.touchspin', function(ev) {
|
389
|
-
elements.up.off('mousedown.touchspin'); // android 4 workaround
|
390
|
-
|
391
|
-
if (originalinput.is(':disabled')) {
|
392
|
-
return;
|
393
|
-
}
|
394
|
-
|
395
|
-
upOnce();
|
396
|
-
startUpSpin();
|
397
|
-
|
398
|
-
ev.preventDefault();
|
399
|
-
ev.stopPropagation();
|
400
|
-
});
|
401
|
-
|
402
|
-
elements.up.on('mouseout touchleave touchend touchcancel', function(ev) {
|
403
|
-
if (!spinning) {
|
404
|
-
return;
|
405
|
-
}
|
406
|
-
|
407
|
-
ev.stopPropagation();
|
408
|
-
stopSpin();
|
409
|
-
});
|
410
|
-
|
411
|
-
elements.down.on('mouseout touchleave touchend touchcancel', function(ev) {
|
412
|
-
if (!spinning) {
|
413
|
-
return;
|
414
|
-
}
|
415
|
-
|
416
|
-
ev.stopPropagation();
|
417
|
-
stopSpin();
|
418
|
-
});
|
419
|
-
|
420
|
-
elements.down.on('mousemove touchmove', function(ev) {
|
421
|
-
if (!spinning) {
|
422
|
-
return;
|
423
|
-
}
|
424
|
-
|
425
|
-
ev.stopPropagation();
|
426
|
-
ev.preventDefault();
|
427
|
-
});
|
428
|
-
|
429
|
-
elements.up.on('mousemove touchmove', function(ev) {
|
430
|
-
if (!spinning) {
|
431
|
-
return;
|
432
|
-
}
|
433
|
-
|
434
|
-
ev.stopPropagation();
|
435
|
-
ev.preventDefault();
|
436
|
-
});
|
437
|
-
|
438
|
-
$(document).on(_scopeEventNames(['mouseup', 'touchend', 'touchcancel'], _currentSpinnerId).join(' '), function(ev) {
|
439
|
-
if (!spinning) {
|
440
|
-
return;
|
441
|
-
}
|
442
|
-
|
443
|
-
ev.preventDefault();
|
444
|
-
stopSpin();
|
445
|
-
});
|
446
|
-
|
447
|
-
$(document).on(_scopeEventNames(['mousemove', 'touchmove', 'scroll', 'scrollstart'], _currentSpinnerId).join(' '), function(ev) {
|
448
|
-
if (!spinning) {
|
449
|
-
return;
|
450
|
-
}
|
451
|
-
|
452
|
-
ev.preventDefault();
|
453
|
-
stopSpin();
|
454
|
-
});
|
455
|
-
|
456
|
-
originalinput.on('mousewheel DOMMouseScroll', function(ev) {
|
457
|
-
if (!settings.mousewheel || !originalinput.is(':focus')) {
|
458
|
-
return;
|
459
|
-
}
|
460
|
-
|
461
|
-
var delta = ev.originalEvent.wheelDelta || -ev.originalEvent.deltaY || -ev.originalEvent.detail;
|
462
|
-
|
463
|
-
ev.stopPropagation();
|
464
|
-
ev.preventDefault();
|
465
|
-
|
466
|
-
if (delta < 0) {
|
467
|
-
downOnce();
|
468
|
-
}
|
469
|
-
else {
|
470
|
-
upOnce();
|
471
|
-
}
|
472
|
-
});
|
473
|
-
}
|
474
|
-
|
475
|
-
function _bindEventsInterface() {
|
476
|
-
originalinput.on('touchspin.uponce', function() {
|
477
|
-
stopSpin();
|
478
|
-
upOnce();
|
479
|
-
});
|
480
|
-
|
481
|
-
originalinput.on('touchspin.downonce', function() {
|
482
|
-
stopSpin();
|
483
|
-
downOnce();
|
484
|
-
});
|
485
|
-
|
486
|
-
originalinput.on('touchspin.startupspin', function() {
|
487
|
-
startUpSpin();
|
488
|
-
});
|
489
|
-
|
490
|
-
originalinput.on('touchspin.startdownspin', function() {
|
491
|
-
startDownSpin();
|
492
|
-
});
|
493
|
-
|
494
|
-
originalinput.on('touchspin.stopspin', function() {
|
495
|
-
stopSpin();
|
496
|
-
});
|
497
|
-
|
498
|
-
originalinput.on('touchspin.updatesettings', function(e, newsettings) {
|
499
|
-
changeSettings(newsettings);
|
500
|
-
});
|
501
|
-
}
|
502
|
-
|
503
|
-
function _forcestepdivisibility(value) {
|
504
|
-
switch (settings.forcestepdivisibility) {
|
505
|
-
case 'round':
|
506
|
-
return (Math.round(value / settings.step) * settings.step).toFixed(settings.decimals);
|
507
|
-
case 'floor':
|
508
|
-
return (Math.floor(value / settings.step) * settings.step).toFixed(settings.decimals);
|
509
|
-
case 'ceil':
|
510
|
-
return (Math.ceil(value / settings.step) * settings.step).toFixed(settings.decimals);
|
511
|
-
default:
|
512
|
-
return value;
|
513
|
-
}
|
514
|
-
}
|
515
|
-
|
516
|
-
function _checkValue() {
|
517
|
-
var val, parsedval, returnval;
|
518
|
-
|
519
|
-
val = originalinput.val();
|
520
|
-
|
521
|
-
if (val === '') {
|
522
|
-
return;
|
523
|
-
}
|
524
|
-
|
525
|
-
if (settings.decimals > 0 && val === '.') {
|
526
|
-
return;
|
527
|
-
}
|
528
|
-
|
529
|
-
parsedval = parseFloat(val);
|
530
|
-
|
531
|
-
if (isNaN(parsedval)) {
|
532
|
-
parsedval = 0;
|
533
|
-
}
|
534
|
-
|
535
|
-
returnval = parsedval;
|
536
|
-
|
537
|
-
if (parsedval.toString() !== val) {
|
538
|
-
returnval = parsedval;
|
539
|
-
}
|
540
|
-
|
541
|
-
if (parsedval < settings.min) {
|
542
|
-
returnval = settings.min;
|
543
|
-
}
|
544
|
-
|
545
|
-
if (parsedval > settings.max) {
|
546
|
-
returnval = settings.max;
|
547
|
-
}
|
548
|
-
|
549
|
-
returnval = _forcestepdivisibility(returnval);
|
550
|
-
|
551
|
-
if (Number(val).toString() !== returnval.toString()) {
|
552
|
-
originalinput.val(returnval);
|
553
|
-
originalinput.trigger('change');
|
554
|
-
}
|
555
|
-
}
|
556
|
-
|
557
|
-
function _getBoostedStep() {
|
558
|
-
if (!settings.booster) {
|
559
|
-
return settings.step;
|
560
|
-
}
|
561
|
-
else {
|
562
|
-
var boosted = Math.pow(2, Math.floor(spincount / settings.boostat)) * settings.step;
|
563
|
-
|
564
|
-
if (settings.maxboostedstep) {
|
565
|
-
if (boosted > settings.maxboostedstep) {
|
566
|
-
boosted = settings.maxboostedstep;
|
567
|
-
value = Math.round((value / boosted)) * boosted;
|
568
|
-
}
|
569
|
-
}
|
570
|
-
|
571
|
-
return Math.max(settings.step, boosted);
|
572
|
-
}
|
573
|
-
}
|
574
|
-
|
575
|
-
function upOnce() {
|
576
|
-
_checkValue();
|
577
|
-
|
578
|
-
value = parseFloat(elements.input.val());
|
579
|
-
if (isNaN(value)) {
|
580
|
-
value = 0;
|
581
|
-
}
|
582
|
-
|
583
|
-
var initvalue = value,
|
584
|
-
boostedstep = _getBoostedStep();
|
585
|
-
|
586
|
-
value = value + boostedstep;
|
587
|
-
|
588
|
-
if (value > settings.max) {
|
589
|
-
value = settings.max;
|
590
|
-
originalinput.trigger('touchspin.on.max');
|
591
|
-
stopSpin();
|
592
|
-
}
|
593
|
-
|
594
|
-
elements.input.val(Number(value).toFixed(settings.decimals));
|
595
|
-
|
596
|
-
if (initvalue !== value) {
|
597
|
-
originalinput.trigger('change');
|
598
|
-
}
|
599
|
-
}
|
600
|
-
|
601
|
-
function downOnce() {
|
602
|
-
_checkValue();
|
603
|
-
|
604
|
-
value = parseFloat(elements.input.val());
|
605
|
-
if (isNaN(value)) {
|
606
|
-
value = 0;
|
607
|
-
}
|
608
|
-
|
609
|
-
var initvalue = value,
|
610
|
-
boostedstep = _getBoostedStep();
|
611
|
-
|
612
|
-
value = value - boostedstep;
|
613
|
-
|
614
|
-
if (value < settings.min) {
|
615
|
-
value = settings.min;
|
616
|
-
originalinput.trigger('touchspin.on.min');
|
617
|
-
stopSpin();
|
618
|
-
}
|
619
|
-
|
620
|
-
elements.input.val(value.toFixed(settings.decimals));
|
621
|
-
|
622
|
-
if (initvalue !== value) {
|
623
|
-
originalinput.trigger('change');
|
624
|
-
}
|
625
|
-
}
|
626
|
-
|
627
|
-
function startDownSpin() {
|
628
|
-
stopSpin();
|
629
|
-
|
630
|
-
spincount = 0;
|
631
|
-
spinning = 'down';
|
632
|
-
|
633
|
-
originalinput.trigger('touchspin.on.startspin');
|
634
|
-
originalinput.trigger('touchspin.on.startdownspin');
|
635
|
-
|
636
|
-
downDelayTimeout = setTimeout(function() {
|
637
|
-
downSpinTimer = setInterval(function() {
|
638
|
-
spincount++;
|
639
|
-
downOnce();
|
640
|
-
}, settings.stepinterval);
|
641
|
-
}, settings.stepintervaldelay);
|
642
|
-
}
|
643
|
-
|
644
|
-
function startUpSpin() {
|
645
|
-
stopSpin();
|
646
|
-
|
647
|
-
spincount = 0;
|
648
|
-
spinning = 'up';
|
649
|
-
|
650
|
-
originalinput.trigger('touchspin.on.startspin');
|
651
|
-
originalinput.trigger('touchspin.on.startupspin');
|
652
|
-
|
653
|
-
upDelayTimeout = setTimeout(function() {
|
654
|
-
upSpinTimer = setInterval(function() {
|
655
|
-
spincount++;
|
656
|
-
upOnce();
|
657
|
-
}, settings.stepinterval);
|
658
|
-
}, settings.stepintervaldelay);
|
659
|
-
}
|
660
|
-
|
661
|
-
function stopSpin() {
|
662
|
-
clearTimeout(downDelayTimeout);
|
663
|
-
clearTimeout(upDelayTimeout);
|
664
|
-
clearInterval(downSpinTimer);
|
665
|
-
clearInterval(upSpinTimer);
|
666
|
-
|
667
|
-
switch (spinning) {
|
668
|
-
case 'up':
|
669
|
-
originalinput.trigger('touchspin.on.stopupspin');
|
670
|
-
originalinput.trigger('touchspin.on.stopspin');
|
671
|
-
break;
|
672
|
-
case 'down':
|
673
|
-
originalinput.trigger('touchspin.on.stopdownspin');
|
674
|
-
originalinput.trigger('touchspin.on.stopspin');
|
675
|
-
break;
|
676
|
-
}
|
677
|
-
|
678
|
-
spincount = 0;
|
679
|
-
spinning = false;
|
680
|
-
}
|
681
|
-
|
682
|
-
});
|
683
|
-
|
684
|
-
};
|
685
|
-
|
686
|
-
})(jQuery);
|