creeper 1.0.9 → 2.0.0
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/.gitignore +1 -0
- data/.rvmrc +48 -0
- data/Gemfile +17 -1
- data/Guardfile +32 -0
- data/Rakefile +9 -1
- data/bin/creeper +10 -58
- data/bin/creeperctl +74 -0
- data/config.ru +18 -0
- data/creeper.gemspec +19 -9
- data/lib/creeper.rb +108 -413
- data/lib/creeper/beanstalk_connection.rb +35 -0
- data/lib/creeper/cli.rb +225 -0
- data/lib/creeper/client.rb +93 -0
- data/lib/creeper/core_ext.rb +54 -0
- data/lib/creeper/exception_handler.rb +30 -0
- data/lib/creeper/extensions/action_mailer.rb +33 -0
- data/lib/creeper/extensions/active_record.rb +30 -0
- data/lib/creeper/extensions/generic_proxy.rb +26 -0
- data/lib/creeper/fetch.rb +94 -0
- data/lib/creeper/legacy.rb +46 -0
- data/lib/creeper/logging.rb +46 -0
- data/lib/creeper/manager.rb +164 -0
- data/lib/creeper/middleware/chain.rb +100 -0
- data/lib/creeper/middleware/server/active_record.rb +13 -0
- data/lib/creeper/middleware/server/logging.rb +31 -0
- data/lib/creeper/middleware/server/retry_jobs.rb +79 -0
- data/lib/creeper/middleware/server/timeout.rb +21 -0
- data/lib/creeper/paginator.rb +31 -0
- data/lib/creeper/processor.rb +116 -0
- data/lib/creeper/rails.rb +21 -0
- data/lib/creeper/redis_connection.rb +28 -0
- data/lib/creeper/testing.rb +44 -0
- data/lib/creeper/util.rb +45 -0
- data/lib/creeper/version.rb +1 -1
- data/lib/creeper/web.rb +248 -0
- data/lib/creeper/worker.rb +62 -313
- data/spec/dummy/.gitignore +15 -0
- data/spec/dummy/Gemfile +51 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/work_controller.rb +71 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/mailers/user_mailer.rb +9 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/post.rb +8 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/user_mailer/greetings.html.erb +3 -0
- data/spec/dummy/app/views/work/index.html.erb +1 -0
- data/spec/dummy/app/workers/fast_worker.rb +10 -0
- data/spec/dummy/app/workers/hard_worker.rb +11 -0
- data/spec/dummy/app/workers/lazy_worker.rb +12 -0
- data/spec/dummy/app/workers/suicidal_worker.rb +33 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +68 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/creeper.yml +9 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/creeper.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +13 -0
- data/spec/dummy/db/migrate/20120123214055_create_posts.rb +10 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +241 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/lib/creeper/cli_spec.rb +208 -0
- data/spec/lib/creeper/client_spec.rb +110 -0
- data/spec/lib/creeper/exception_handler_spec.rb +110 -0
- data/spec/lib/creeper/processor_spec.rb +92 -0
- data/spec/lib/creeper/testing_spec.rb +105 -0
- data/spec/lib/creeper_spec.rb +54 -120
- data/spec/spec_helper.rb +81 -7
- data/spec/support/config.yml +9 -0
- data/spec/support/fake_env.rb +0 -0
- data/spec/support/workers/base_worker.rb +11 -0
- data/spec/support/workers/my_worker.rb +4 -0
- data/spec/support/workers/queued_worker.rb +5 -0
- data/spec/support/workers/real_worker.rb +10 -0
- data/web/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
- data/web/assets/images/bootstrap/glyphicons-halflings.png +0 -0
- data/web/assets/javascripts/application.js +49 -0
- data/web/assets/javascripts/vendor/bootstrap.js +12 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-alert.js +91 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-button.js +98 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-carousel.js +154 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-collapse.js +136 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-dropdown.js +92 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-modal.js +210 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-popover.js +95 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-scrollspy.js +125 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-tab.js +130 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-tooltip.js +270 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-transition.js +51 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-typeahead.js +271 -0
- data/web/assets/javascripts/vendor/jquery.js +9266 -0
- data/web/assets/javascripts/vendor/jquery.timeago.js +148 -0
- data/web/assets/stylesheets/application.css +6 -0
- data/web/assets/stylesheets/layout.css +26 -0
- data/web/assets/stylesheets/vendor/bootstrap-responsive.css +567 -0
- data/web/assets/stylesheets/vendor/bootstrap.css +3365 -0
- data/web/views/_paging.slim +15 -0
- data/web/views/_summary.slim +9 -0
- data/web/views/_workers.slim +14 -0
- data/web/views/index.slim +10 -0
- data/web/views/layout.slim +37 -0
- data/web/views/poll.slim +3 -0
- data/web/views/queue.slim +15 -0
- data/web/views/queues.slim +19 -0
- data/web/views/retries.slim +31 -0
- data/web/views/retry.slim +52 -0
- data/web/views/scheduled.slim +27 -0
- metadata +341 -23
- data/lib/creeper/celluloid_ext.rb +0 -42
- data/lib/creeper/creep.rb +0 -25
- data/lib/creeper/err_logger.rb +0 -37
- data/lib/creeper/launcher.rb +0 -44
- data/lib/creeper/out_logger.rb +0 -39
- data/spec/lib/creeper/session_spec.rb +0 -15
- data/spec/lib/creeper/worker_spec.rb +0 -21
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,84 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'spork'
|
|
3
|
+
#uncomment the following line to use spork with the debugger
|
|
4
|
+
#require 'spork/ext/ruby-debug'
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
Spork.prefork do
|
|
7
|
+
# Loading more in this block will cause your tests to run faster. However,
|
|
8
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
|
9
|
+
# need to restart spork for it take effect.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
|
|
12
|
+
require 'bundler/setup'
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
require 'pry'
|
|
15
|
+
|
|
16
|
+
require 'creeper'
|
|
17
|
+
require 'creeper/util'
|
|
18
|
+
|
|
19
|
+
Creeper.logger.level = Logger::ERROR
|
|
20
|
+
|
|
21
|
+
require 'creeper/beanstalk_connection'
|
|
22
|
+
BEANSTALK = Creeper::BeanstalkConnection.create
|
|
23
|
+
|
|
24
|
+
require 'creeper/redis_connection'
|
|
25
|
+
REDIS = Creeper::RedisConnection.create(url: "redis://localhost/15", namespace: 'creepy')
|
|
26
|
+
|
|
27
|
+
require 'rspec/autorun'
|
|
28
|
+
|
|
29
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
30
|
+
# in spec/support/ and its subdirectories.
|
|
31
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f}
|
|
32
|
+
|
|
33
|
+
RSpec.configure do |config|
|
|
34
|
+
# ## Mock Framework
|
|
35
|
+
#
|
|
36
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
37
|
+
#
|
|
38
|
+
# config.mock_with :mocha
|
|
39
|
+
# config.mock_with :flexmock
|
|
40
|
+
# config.mock_with :rr
|
|
41
|
+
config.mock_with :rspec
|
|
42
|
+
|
|
43
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
44
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
45
|
+
# the seed, which is printed after each run.
|
|
46
|
+
# --seed 1234
|
|
47
|
+
config.order = "random"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Spork.each_run do
|
|
53
|
+
# This code will be run each time you run your specs.
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# --- Instructions ---
|
|
58
|
+
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
|
|
59
|
+
# block.
|
|
60
|
+
#
|
|
61
|
+
# The Spork.prefork block is run only once when the spork server is started.
|
|
62
|
+
# You typically want to place most of your (slow) initializer code in here, in
|
|
63
|
+
# particular, require'ing any 3rd-party gems that you don't normally modify
|
|
64
|
+
# during development.
|
|
65
|
+
#
|
|
66
|
+
# The Spork.each_run block is run each time you run your specs. In case you
|
|
67
|
+
# need to load files that tend to change during development, require them here.
|
|
68
|
+
# With Rails, your application modules are loaded automatically, so sometimes
|
|
69
|
+
# this block can remain empty.
|
|
70
|
+
#
|
|
71
|
+
# Note: You can modify files loaded *from* the Spork.each_run block without
|
|
72
|
+
# restarting the spork server. However, this file itself will not be reloaded,
|
|
73
|
+
# so if you change any of the code inside the each_run block, you still need to
|
|
74
|
+
# restart the server. In general, if you have non-trivial code in this file,
|
|
75
|
+
# it's advisable to move it into a separate file so you can easily edit it
|
|
76
|
+
# without restarting spork. (For example, with RSpec, you could move
|
|
77
|
+
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
|
|
78
|
+
# spec/support/* files are require'd from inside the each_run block.)
|
|
79
|
+
#
|
|
80
|
+
# Any code that is left outside the two blocks will be run during preforking
|
|
81
|
+
# *and* during each_run -- that's probably not what you want.
|
|
82
|
+
#
|
|
83
|
+
# These instructions should self-destruct in 10 seconds. If they don't, feel
|
|
84
|
+
# free to delete them.
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//= require vendor/jquery
|
|
2
|
+
//= require vendor/jquery.timeago
|
|
3
|
+
//= require bootstrap
|
|
4
|
+
//= require_tree .
|
|
5
|
+
|
|
6
|
+
$(function() {
|
|
7
|
+
$.timeago.settings.allowFuture = true
|
|
8
|
+
$("time").timeago();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
$(function() {
|
|
12
|
+
$('.check_all').live('click', function() {
|
|
13
|
+
var checked = $(this).attr('checked');
|
|
14
|
+
if (checked == 'checked') {
|
|
15
|
+
$('input[type=checkbox]', $(this).closest('table')).attr('checked', checked);
|
|
16
|
+
} else {
|
|
17
|
+
$('input[type=checkbox]', $(this).closest('table')).removeAttr('checked');
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
$(function() {
|
|
23
|
+
$('a[name=poll]').data('polling', false);
|
|
24
|
+
|
|
25
|
+
$('a[name=poll]').on('click', function(e) {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
var pollLink = $(this);
|
|
28
|
+
if (pollLink.data('polling')) {
|
|
29
|
+
clearInterval(pollLink.data('interval'));
|
|
30
|
+
pollLink.text('Live Poll');
|
|
31
|
+
$('.poll-status').text('');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
var href = pollLink.attr('href');
|
|
35
|
+
pollLink.data('interval', setInterval(function() {
|
|
36
|
+
$.get(href, function(data) {
|
|
37
|
+
var responseHtml = $(data);
|
|
38
|
+
$('.hero-unit').replaceWith(responseHtml.find('.hero-unit'));
|
|
39
|
+
$('.workers').replaceWith(responseHtml.find('.workers'));
|
|
40
|
+
});
|
|
41
|
+
var currentTime = new Date();
|
|
42
|
+
$('.poll-status').text('Last polled at: ' + currentTime.getHours() + ':' + currentTime.getMinutes() + ':' + currentTime.getSeconds());
|
|
43
|
+
}, 2000));
|
|
44
|
+
$('.poll-status').text('Starting to poll...');
|
|
45
|
+
pollLink.text('Stop Polling');
|
|
46
|
+
}
|
|
47
|
+
pollLink.data('polling', !pollLink.data('polling'));
|
|
48
|
+
})
|
|
49
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//= require vendor/bootstrap/bootstrap-transition
|
|
2
|
+
//= require vendor/bootstrap/bootstrap-alert
|
|
3
|
+
//= require vendor/bootstrap/bootstrap-modal
|
|
4
|
+
//= require vendor/bootstrap/bootstrap-dropdown
|
|
5
|
+
//= require vendor/bootstrap/bootstrap-scrollspy
|
|
6
|
+
//= require vendor/bootstrap/bootstrap-tab
|
|
7
|
+
//= require vendor/bootstrap/bootstrap-tooltip
|
|
8
|
+
//= require vendor/bootstrap/bootstrap-popover
|
|
9
|
+
//= require vendor/bootstrap/bootstrap-button
|
|
10
|
+
//= require vendor/bootstrap/bootstrap-collapse
|
|
11
|
+
//= require vendor/bootstrap/bootstrap-carousel
|
|
12
|
+
//= require vendor/bootstrap/bootstrap-typeahead
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* ==========================================================
|
|
2
|
+
* bootstrap-alert.js v2.0.0
|
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
|
4
|
+
* ==========================================================
|
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* ========================================================== */
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
!function( $ ){
|
|
22
|
+
|
|
23
|
+
"use strict"
|
|
24
|
+
|
|
25
|
+
/* ALERT CLASS DEFINITION
|
|
26
|
+
* ====================== */
|
|
27
|
+
|
|
28
|
+
var dismiss = '[data-dismiss="alert"]'
|
|
29
|
+
, Alert = function ( el ) {
|
|
30
|
+
$(el).on('click', dismiss, this.close)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Alert.prototype = {
|
|
34
|
+
|
|
35
|
+
constructor: Alert
|
|
36
|
+
|
|
37
|
+
, close: function ( e ) {
|
|
38
|
+
var $this = $(this)
|
|
39
|
+
, selector = $this.attr('data-target')
|
|
40
|
+
, $parent
|
|
41
|
+
|
|
42
|
+
if (!selector) {
|
|
43
|
+
selector = $this.attr('href')
|
|
44
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
$parent = $(selector)
|
|
48
|
+
$parent.trigger('close')
|
|
49
|
+
|
|
50
|
+
e && e.preventDefault()
|
|
51
|
+
|
|
52
|
+
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
|
53
|
+
|
|
54
|
+
$parent.removeClass('in')
|
|
55
|
+
|
|
56
|
+
function removeElement() {
|
|
57
|
+
$parent.remove()
|
|
58
|
+
$parent.trigger('closed')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
$.support.transition && $parent.hasClass('fade') ?
|
|
62
|
+
$parent.on($.support.transition.end, removeElement) :
|
|
63
|
+
removeElement()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/* ALERT PLUGIN DEFINITION
|
|
70
|
+
* ======================= */
|
|
71
|
+
|
|
72
|
+
$.fn.alert = function ( option ) {
|
|
73
|
+
return this.each(function () {
|
|
74
|
+
var $this = $(this)
|
|
75
|
+
, data = $this.data('alert')
|
|
76
|
+
if (!data) $this.data('alert', (data = new Alert(this)))
|
|
77
|
+
if (typeof option == 'string') data[option].call($this)
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
$.fn.alert.Constructor = Alert
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
/* ALERT DATA-API
|
|
85
|
+
* ============== */
|
|
86
|
+
|
|
87
|
+
$(function () {
|
|
88
|
+
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
}( window.jQuery )
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* ============================================================
|
|
2
|
+
* bootstrap-button.js v2.0.0
|
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#buttons
|
|
4
|
+
* ============================================================
|
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* ============================================================ */
|
|
19
|
+
|
|
20
|
+
!function( $ ){
|
|
21
|
+
|
|
22
|
+
"use strict"
|
|
23
|
+
|
|
24
|
+
/* BUTTON PUBLIC CLASS DEFINITION
|
|
25
|
+
* ============================== */
|
|
26
|
+
|
|
27
|
+
var Button = function ( element, options ) {
|
|
28
|
+
this.$element = $(element)
|
|
29
|
+
this.options = $.extend({}, $.fn.button.defaults, options)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Button.prototype = {
|
|
33
|
+
|
|
34
|
+
constructor: Button
|
|
35
|
+
|
|
36
|
+
, setState: function ( state ) {
|
|
37
|
+
var d = 'disabled'
|
|
38
|
+
, $el = this.$element
|
|
39
|
+
, data = $el.data()
|
|
40
|
+
, val = $el.is('input') ? 'val' : 'html'
|
|
41
|
+
|
|
42
|
+
state = state + 'Text'
|
|
43
|
+
data.resetText || $el.data('resetText', $el[val]())
|
|
44
|
+
|
|
45
|
+
$el[val](data[state] || this.options[state])
|
|
46
|
+
|
|
47
|
+
// push to event loop to allow forms to submit
|
|
48
|
+
setTimeout(function () {
|
|
49
|
+
state == 'loadingText' ?
|
|
50
|
+
$el.addClass(d).attr(d, d) :
|
|
51
|
+
$el.removeClass(d).removeAttr(d)
|
|
52
|
+
}, 0)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
, toggle: function () {
|
|
56
|
+
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
|
57
|
+
|
|
58
|
+
$parent && $parent
|
|
59
|
+
.find('.active')
|
|
60
|
+
.removeClass('active')
|
|
61
|
+
|
|
62
|
+
this.$element.toggleClass('active')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
/* BUTTON PLUGIN DEFINITION
|
|
69
|
+
* ======================== */
|
|
70
|
+
|
|
71
|
+
$.fn.button = function ( option ) {
|
|
72
|
+
return this.each(function () {
|
|
73
|
+
var $this = $(this)
|
|
74
|
+
, data = $this.data('button')
|
|
75
|
+
, options = typeof option == 'object' && option
|
|
76
|
+
if (!data) $this.data('button', (data = new Button(this, options)))
|
|
77
|
+
if (option == 'toggle') data.toggle()
|
|
78
|
+
else if (option) data.setState(option)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$.fn.button.defaults = {
|
|
83
|
+
loadingText: 'loading...'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
$.fn.button.Constructor = Button
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/* BUTTON DATA-API
|
|
90
|
+
* =============== */
|
|
91
|
+
|
|
92
|
+
$(function () {
|
|
93
|
+
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
|
94
|
+
$(e.target).button('toggle')
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
}( window.jQuery )
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/* ==========================================================
|
|
2
|
+
* bootstrap-carousel.js v2.0.0
|
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#carousel
|
|
4
|
+
* ==========================================================
|
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* ========================================================== */
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
!function( $ ){
|
|
22
|
+
|
|
23
|
+
"use strict"
|
|
24
|
+
|
|
25
|
+
/* CAROUSEL CLASS DEFINITION
|
|
26
|
+
* ========================= */
|
|
27
|
+
|
|
28
|
+
var Carousel = function (element, options) {
|
|
29
|
+
this.$element = $(element)
|
|
30
|
+
this.options = $.extend({}, $.fn.carousel.defaults, options)
|
|
31
|
+
this.options.slide && this.slide(this.options.slide)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Carousel.prototype = {
|
|
35
|
+
|
|
36
|
+
cycle: function () {
|
|
37
|
+
this.interval = setInterval($.proxy(this.next, this), this.options.interval)
|
|
38
|
+
return this
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
, to: function (pos) {
|
|
42
|
+
var $active = this.$element.find('.active')
|
|
43
|
+
, children = $active.parent().children()
|
|
44
|
+
, activePos = children.index($active)
|
|
45
|
+
, that = this
|
|
46
|
+
|
|
47
|
+
if (pos > (children.length - 1) || pos < 0) return
|
|
48
|
+
|
|
49
|
+
if (this.sliding) {
|
|
50
|
+
return this.$element.one('slid', function () {
|
|
51
|
+
that.to(pos)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (activePos == pos) {
|
|
56
|
+
return this.pause().cycle()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
, pause: function () {
|
|
63
|
+
clearInterval(this.interval)
|
|
64
|
+
return this
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
, next: function () {
|
|
68
|
+
if (this.sliding) return
|
|
69
|
+
return this.slide('next')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
, prev: function () {
|
|
73
|
+
if (this.sliding) return
|
|
74
|
+
return this.slide('prev')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
, slide: function (type, next) {
|
|
78
|
+
var $active = this.$element.find('.active')
|
|
79
|
+
, $next = next || $active[type]()
|
|
80
|
+
, isCycling = this.interval
|
|
81
|
+
, direction = type == 'next' ? 'left' : 'right'
|
|
82
|
+
, fallback = type == 'next' ? 'first' : 'last'
|
|
83
|
+
, that = this
|
|
84
|
+
|
|
85
|
+
this.sliding = true
|
|
86
|
+
|
|
87
|
+
isCycling && this.pause()
|
|
88
|
+
|
|
89
|
+
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
|
|
90
|
+
|
|
91
|
+
if (!$.support.transition && this.$element.hasClass('slide')) {
|
|
92
|
+
this.$element.trigger('slide')
|
|
93
|
+
$active.removeClass('active')
|
|
94
|
+
$next.addClass('active')
|
|
95
|
+
this.sliding = false
|
|
96
|
+
this.$element.trigger('slid')
|
|
97
|
+
} else {
|
|
98
|
+
$next.addClass(type)
|
|
99
|
+
$next[0].offsetWidth // force reflow
|
|
100
|
+
$active.addClass(direction)
|
|
101
|
+
$next.addClass(direction)
|
|
102
|
+
this.$element.trigger('slide')
|
|
103
|
+
this.$element.one($.support.transition.end, function () {
|
|
104
|
+
$next.removeClass([type, direction].join(' ')).addClass('active')
|
|
105
|
+
$active.removeClass(['active', direction].join(' '))
|
|
106
|
+
that.sliding = false
|
|
107
|
+
setTimeout(function () { that.$element.trigger('slid') }, 0)
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
isCycling && this.cycle()
|
|
112
|
+
|
|
113
|
+
return this
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/* CAROUSEL PLUGIN DEFINITION
|
|
120
|
+
* ========================== */
|
|
121
|
+
|
|
122
|
+
$.fn.carousel = function ( option ) {
|
|
123
|
+
return this.each(function () {
|
|
124
|
+
var $this = $(this)
|
|
125
|
+
, data = $this.data('carousel')
|
|
126
|
+
, options = typeof option == 'object' && option
|
|
127
|
+
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
|
|
128
|
+
if (typeof option == 'number') data.to(option)
|
|
129
|
+
else if (typeof option == 'string' || (option = options.slide)) data[option]()
|
|
130
|
+
else data.cycle()
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
$.fn.carousel.defaults = {
|
|
135
|
+
interval: 5000
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
$.fn.carousel.Constructor = Carousel
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
/* CAROUSEL DATA-API
|
|
142
|
+
* ================= */
|
|
143
|
+
|
|
144
|
+
$(function () {
|
|
145
|
+
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
|
|
146
|
+
var $this = $(this), href
|
|
147
|
+
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
|
148
|
+
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
|
|
149
|
+
$target.carousel(options)
|
|
150
|
+
e.preventDefault()
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
}( window.jQuery )
|