jackpot 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.rvmrc.example +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +181 -0
- data/MIT-LICENSE +20 -0
- data/README.md +134 -0
- data/Rakefile +25 -0
- data/app/assets/images/jackpot/.gitkeep +0 -0
- data/app/assets/javascripts/jackpot/application.js +5 -0
- data/app/assets/javascripts/jackpot/bootstrap.js +32 -0
- data/app/assets/javascripts/jackpot/customers.js +2 -0
- data/app/assets/javascripts/jackpot/login.js +1 -0
- data/app/assets/javascripts/jackpot/payments.js +2 -0
- data/app/assets/javascripts/jackpot/subscriptions.js +2 -0
- data/app/assets/stylesheets/jackpot/application.css +9 -0
- data/app/assets/stylesheets/jackpot/customers.css +4 -0
- data/app/assets/stylesheets/jackpot/jackpot.css +10 -0
- data/app/controllers/jackpot/application_controller.rb +4 -0
- data/app/controllers/jackpot/customers_controller.rb +100 -0
- data/app/controllers/jackpot/payments_controller.rb +20 -0
- data/app/controllers/jackpot/subscriptions_controller.rb +86 -0
- data/app/helpers/jackpot/application_helper.rb +27 -0
- data/app/helpers/jackpot/customers_helper.rb +7 -0
- data/app/helpers/jackpot/subscriptions_helper.rb +4 -0
- data/app/models/jackpot/card.rb +29 -0
- data/app/models/jackpot/customer.rb +48 -0
- data/app/models/jackpot/gateway.rb +28 -0
- data/app/models/jackpot/payment.rb +33 -0
- data/app/models/jackpot/subscription.rb +13 -0
- data/app/models/jackpot/user.rb +25 -0
- data/app/views/jackpot/customers/_credit_card_form.html.erb +42 -0
- data/app/views/jackpot/customers/_form.html.erb +17 -0
- data/app/views/jackpot/customers/edit.html.erb +13 -0
- data/app/views/jackpot/customers/index.html.erb +30 -0
- data/app/views/jackpot/customers/new.html.erb +8 -0
- data/app/views/jackpot/customers/show.html.erb +32 -0
- data/app/views/jackpot/payments/create.html.erb +1 -0
- data/app/views/jackpot/payments/index.html.erb +25 -0
- data/app/views/jackpot/shared/_flash_messages.html.erb +6 -0
- data/app/views/jackpot/shared/_navigation.html.erb +5 -0
- data/app/views/jackpot/subscriptions/_form.html.erb +13 -0
- data/app/views/jackpot/subscriptions/edit.html.erb +6 -0
- data/app/views/jackpot/subscriptions/index.html.erb +29 -0
- data/app/views/jackpot/subscriptions/new.html.erb +4 -0
- data/app/views/jackpot/subscriptions/show.html.erb +23 -0
- data/app/views/layouts/devise.html.erb +22 -0
- data/app/views/layouts/jackpot/application.html.erb +39 -0
- data/config/initializers/jackpot_devise.rb +226 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20111221002616_create_jackpot_payments.rb +11 -0
- data/db/migrate/20111230014003_add_customer_information_to_jackpot_payments.rb +5 -0
- data/db/migrate/20120102223341_create_jackpot_subscriptions.rb +10 -0
- data/db/migrate/20120103211153_create_jackpot_customers.rb +11 -0
- data/db/migrate/20120104164830_add_credit_card_number_to_customer.rb +5 -0
- data/db/migrate/20120130173242_add_credit_card_information_to_customers.rb +7 -0
- data/db/migrate/20120208191815_add_billing_period_to_jackpot_subscriptions.rb +5 -0
- data/db/migrate/20120208191934_add_good_until_date_to_jackpot_customers.rb +6 -0
- data/db/migrate/20120209203542_add_subscription_and_customer_to_jackpot_payments.rb +8 -0
- data/db/migrate/20120209212043_rename_column_token_in_jackpot_payments.rb +5 -0
- data/db/migrate/20120210144038_devise_create_jackpot_users.rb +49 -0
- data/jackpot.gemspec +33 -0
- data/lib/jackpot.rb +23 -0
- data/lib/jackpot/configuration.rb +33 -0
- data/lib/jackpot/cron.rb +22 -0
- data/lib/jackpot/engine.rb +14 -0
- data/lib/jackpot/errors.rb +18 -0
- data/lib/jackpot/factory.rb +26 -0
- data/lib/jackpot/version.rb +3 -0
- data/lib/tasks/jackpot_tasks.rake +38 -0
- data/script/rails +6 -0
- data/spec/controllers/jackpot/customers_controller_spec.rb +170 -0
- data/spec/controllers/jackpot/payments_controller_spec.rb +47 -0
- data/spec/controllers/jackpot/subscriptions_controller_spec.rb +153 -0
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +51 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +17 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +32 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/jackpot.rb +13 -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 +3 -0
- data/spec/dummy/db/schema.rb +68 -0
- data/spec/dummy/lib/assets/.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 +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +5 -0
- data/spec/dummy/public/payment.html +36 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/vcr/Create_Customers_To_bill_monthly_my_customers_As_a_user_I_want_to_record_their_billing_information_/assigning_credit_card_information_to_customer.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_NEVER_persist_in_the_database_the_actual_card_number.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_NEVER_persist_in_the_database_the_verification_value.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_persist_in_the_database_the_ONLY_last_four_digits.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_persist_the_card_information.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_store_this_card_at_the_gateway.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/creates_a_new_payment.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/does_not_persist_credit_card_token_information.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/records_the_payment_transaction_id_for_future_reference.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/records_this_payment_information.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_customer_name/returns_its_customer_email.yml +96 -0
- data/spec/fixtures/vcr/jackpot/customer/updatecard.yml +34 -0
- data/spec/fixtures/vcr/jackpot/customer_expiration_date.yml +34 -0
- data/spec/fixtures/vcr/jackpot/receiving_payments.yml +96 -0
- data/spec/helpers/jackpot/customers_helper_spec.rb +16 -0
- data/spec/helpers/jackpot/subscriptions_helper_spec.rb +4 -0
- data/spec/lib/cron_spec.rb +39 -0
- data/spec/lib/factory_spec.rb +40 -0
- data/spec/models/jackpot/card_spec.rb +23 -0
- data/spec/models/jackpot/customer_spec.rb +140 -0
- data/spec/models/jackpot/gateway_spec.rb +22 -0
- data/spec/models/jackpot/payment_spec.rb +74 -0
- data/spec/models/jackpot/subscription_spec.rb +19 -0
- data/spec/requests/jackpot/jackpot_assign_subscription_to_customer_spec.rb +39 -0
- data/spec/requests/jackpot/jackpot_create_customer_spec.rb +73 -0
- data/spec/requests/jackpot/jackpot_create_subscriptions_spec.rb +27 -0
- data/spec/requests/jackpot/jackpot_receive_payments_spec.rb +34 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/support/active_merchant.rb +1 -0
- data/spec/support/capybara.rb +6 -0
- data/spec/support/devise.rb +21 -0
- data/spec/support/factories/jackpot_customers.rb +36 -0
- data/spec/support/factories/jackpot_payments.rb +7 -0
- data/spec/support/factories/jackpot_subscriptions.rb +9 -0
- data/spec/support/factories/jackpot_users.rb +9 -0
- data/spec/support/helpers.rb +16 -0
- data/spec/support/routes.rb +3 -0
- data/spec/support/vcr.rb +10 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +91 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +98 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +154 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +136 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +92 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +209 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +95 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +125 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +130 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +270 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +51 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +271 -0
- data/vendor/assets/stylesheets/twitter/bootstrap/bootstrap-responsive.css +567 -0
- data/vendor/assets/stylesheets/twitter/bootstrap/bootstrap.css.erb +3366 -0
- metadata +351 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-popover.js v2.0.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#popovers
|
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
|
+
var Popover = function ( element, options ) {
|
26
|
+
this.init('popover', element, options)
|
27
|
+
}
|
28
|
+
|
29
|
+
/* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
|
30
|
+
========================================== */
|
31
|
+
|
32
|
+
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
|
33
|
+
|
34
|
+
constructor: Popover
|
35
|
+
|
36
|
+
, setContent: function () {
|
37
|
+
var $tip = this.tip()
|
38
|
+
, title = this.getTitle()
|
39
|
+
, content = this.getContent()
|
40
|
+
|
41
|
+
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
|
42
|
+
$tip.find('.popover-content > *')[ $.type(content) == 'object' ? 'append' : 'html' ](content)
|
43
|
+
|
44
|
+
$tip.removeClass('fade top bottom left right in')
|
45
|
+
}
|
46
|
+
|
47
|
+
, hasContent: function () {
|
48
|
+
return this.getTitle() || this.getContent()
|
49
|
+
}
|
50
|
+
|
51
|
+
, getContent: function () {
|
52
|
+
var content
|
53
|
+
, $e = this.$element
|
54
|
+
, o = this.options
|
55
|
+
|
56
|
+
content = $e.attr('data-content')
|
57
|
+
|| (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
|
58
|
+
|
59
|
+
content = content.toString().replace(/(^\s*|\s*$)/, "")
|
60
|
+
|
61
|
+
return content
|
62
|
+
}
|
63
|
+
|
64
|
+
, tip: function() {
|
65
|
+
if (!this.$tip) {
|
66
|
+
this.$tip = $(this.options.template)
|
67
|
+
}
|
68
|
+
return this.$tip
|
69
|
+
}
|
70
|
+
|
71
|
+
})
|
72
|
+
|
73
|
+
|
74
|
+
/* POPOVER PLUGIN DEFINITION
|
75
|
+
* ======================= */
|
76
|
+
|
77
|
+
$.fn.popover = function ( option ) {
|
78
|
+
return this.each(function () {
|
79
|
+
var $this = $(this)
|
80
|
+
, data = $this.data('popover')
|
81
|
+
, options = typeof option == 'object' && option
|
82
|
+
if (!data) $this.data('popover', (data = new Popover(this, options)))
|
83
|
+
if (typeof option == 'string') data[option]()
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
$.fn.popover.Constructor = Popover
|
88
|
+
|
89
|
+
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
|
90
|
+
placement: 'right'
|
91
|
+
, content: ''
|
92
|
+
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
|
93
|
+
})
|
94
|
+
|
95
|
+
}( window.jQuery )
|
@@ -0,0 +1,125 @@
|
|
1
|
+
/* =============================================================
|
2
|
+
* bootstrap-scrollspy.js v2.0.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
|
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
|
+
/* SCROLLSPY CLASS DEFINITION
|
25
|
+
* ========================== */
|
26
|
+
|
27
|
+
function ScrollSpy( element, options) {
|
28
|
+
var process = $.proxy(this.process, this)
|
29
|
+
, $element = $(element).is('body') ? $(window) : $(element)
|
30
|
+
, href
|
31
|
+
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
|
32
|
+
this.$scrollElement = $element.on('scroll.scroll.data-api', process)
|
33
|
+
this.selector = (this.options.target
|
34
|
+
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
35
|
+
|| '') + ' .nav li > a'
|
36
|
+
this.$body = $('body').on('click.scroll.data-api', this.selector, process)
|
37
|
+
this.refresh()
|
38
|
+
this.process()
|
39
|
+
}
|
40
|
+
|
41
|
+
ScrollSpy.prototype = {
|
42
|
+
|
43
|
+
constructor: ScrollSpy
|
44
|
+
|
45
|
+
, refresh: function () {
|
46
|
+
this.targets = this.$body
|
47
|
+
.find(this.selector)
|
48
|
+
.map(function () {
|
49
|
+
var href = $(this).attr('href')
|
50
|
+
return /^#\w/.test(href) && $(href).length ? href : null
|
51
|
+
})
|
52
|
+
|
53
|
+
this.offsets = $.map(this.targets, function (id) {
|
54
|
+
return $(id).position().top
|
55
|
+
})
|
56
|
+
}
|
57
|
+
|
58
|
+
, process: function () {
|
59
|
+
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
|
60
|
+
, offsets = this.offsets
|
61
|
+
, targets = this.targets
|
62
|
+
, activeTarget = this.activeTarget
|
63
|
+
, i
|
64
|
+
|
65
|
+
for (i = offsets.length; i--;) {
|
66
|
+
activeTarget != targets[i]
|
67
|
+
&& scrollTop >= offsets[i]
|
68
|
+
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
|
69
|
+
&& this.activate( targets[i] )
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
, activate: function (target) {
|
74
|
+
var active
|
75
|
+
|
76
|
+
this.activeTarget = target
|
77
|
+
|
78
|
+
this.$body
|
79
|
+
.find(this.selector).parent('.active')
|
80
|
+
.removeClass('active')
|
81
|
+
|
82
|
+
active = this.$body
|
83
|
+
.find(this.selector + '[href="' + target + '"]')
|
84
|
+
.parent('li')
|
85
|
+
.addClass('active')
|
86
|
+
|
87
|
+
if ( active.parent('.dropdown-menu') ) {
|
88
|
+
active.closest('li.dropdown').addClass('active')
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
/* SCROLLSPY PLUGIN DEFINITION
|
96
|
+
* =========================== */
|
97
|
+
|
98
|
+
$.fn.scrollspy = function ( option ) {
|
99
|
+
return this.each(function () {
|
100
|
+
var $this = $(this)
|
101
|
+
, data = $this.data('scrollspy')
|
102
|
+
, options = typeof option == 'object' && option
|
103
|
+
if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
|
104
|
+
if (typeof option == 'string') data[option]()
|
105
|
+
})
|
106
|
+
}
|
107
|
+
|
108
|
+
$.fn.scrollspy.Constructor = ScrollSpy
|
109
|
+
|
110
|
+
$.fn.scrollspy.defaults = {
|
111
|
+
offset: 10
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
/* SCROLLSPY DATA-API
|
116
|
+
* ================== */
|
117
|
+
|
118
|
+
$(function () {
|
119
|
+
$('[data-spy="scroll"]').each(function () {
|
120
|
+
var $spy = $(this)
|
121
|
+
$spy.scrollspy($spy.data())
|
122
|
+
})
|
123
|
+
})
|
124
|
+
|
125
|
+
}( window.jQuery )
|
@@ -0,0 +1,130 @@
|
|
1
|
+
/* ========================================================
|
2
|
+
* bootstrap-tab.js v2.0.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
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
|
+
/* TAB CLASS DEFINITION
|
26
|
+
* ==================== */
|
27
|
+
|
28
|
+
var Tab = function ( element ) {
|
29
|
+
this.element = $(element)
|
30
|
+
}
|
31
|
+
|
32
|
+
Tab.prototype = {
|
33
|
+
|
34
|
+
constructor: Tab
|
35
|
+
|
36
|
+
, show: function () {
|
37
|
+
var $this = this.element
|
38
|
+
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
39
|
+
, selector = $this.attr('data-target')
|
40
|
+
, previous
|
41
|
+
, $target
|
42
|
+
|
43
|
+
if (!selector) {
|
44
|
+
selector = $this.attr('href')
|
45
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
46
|
+
}
|
47
|
+
|
48
|
+
if ( $this.parent('li').hasClass('active') ) return
|
49
|
+
|
50
|
+
previous = $ul.find('.active a').last()[0]
|
51
|
+
|
52
|
+
$this.trigger({
|
53
|
+
type: 'show'
|
54
|
+
, relatedTarget: previous
|
55
|
+
})
|
56
|
+
|
57
|
+
$target = $(selector)
|
58
|
+
|
59
|
+
this.activate($this.parent('li'), $ul)
|
60
|
+
this.activate($target, $target.parent(), function () {
|
61
|
+
$this.trigger({
|
62
|
+
type: 'shown'
|
63
|
+
, relatedTarget: previous
|
64
|
+
})
|
65
|
+
})
|
66
|
+
}
|
67
|
+
|
68
|
+
, activate: function ( element, container, callback) {
|
69
|
+
var $active = container.find('> .active')
|
70
|
+
, transition = callback
|
71
|
+
&& $.support.transition
|
72
|
+
&& $active.hasClass('fade')
|
73
|
+
|
74
|
+
function next() {
|
75
|
+
$active
|
76
|
+
.removeClass('active')
|
77
|
+
.find('> .dropdown-menu > .active')
|
78
|
+
.removeClass('active')
|
79
|
+
|
80
|
+
element.addClass('active')
|
81
|
+
|
82
|
+
if (transition) {
|
83
|
+
element[0].offsetWidth // reflow for transition
|
84
|
+
element.addClass('in')
|
85
|
+
} else {
|
86
|
+
element.removeClass('fade')
|
87
|
+
}
|
88
|
+
|
89
|
+
if ( element.parent('.dropdown-menu') ) {
|
90
|
+
element.closest('li.dropdown').addClass('active')
|
91
|
+
}
|
92
|
+
|
93
|
+
callback && callback()
|
94
|
+
}
|
95
|
+
|
96
|
+
transition ?
|
97
|
+
$active.one($.support.transition.end, next) :
|
98
|
+
next()
|
99
|
+
|
100
|
+
$active.removeClass('in')
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
/* TAB PLUGIN DEFINITION
|
106
|
+
* ===================== */
|
107
|
+
|
108
|
+
$.fn.tab = function ( option ) {
|
109
|
+
return this.each(function () {
|
110
|
+
var $this = $(this)
|
111
|
+
, data = $this.data('tab')
|
112
|
+
if (!data) $this.data('tab', (data = new Tab(this)))
|
113
|
+
if (typeof option == 'string') data[option]()
|
114
|
+
})
|
115
|
+
}
|
116
|
+
|
117
|
+
$.fn.tab.Constructor = Tab
|
118
|
+
|
119
|
+
|
120
|
+
/* TAB DATA-API
|
121
|
+
* ============ */
|
122
|
+
|
123
|
+
$(function () {
|
124
|
+
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
125
|
+
e.preventDefault()
|
126
|
+
$(this).tab('show')
|
127
|
+
})
|
128
|
+
})
|
129
|
+
|
130
|
+
}( window.jQuery )
|
@@ -0,0 +1,270 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-tooltip.js v2.0.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#tooltips
|
4
|
+
* Inspired by the original jQuery.tipsy by Jason Frame
|
5
|
+
* ===========================================================
|
6
|
+
* Copyright 2012 Twitter, Inc.
|
7
|
+
*
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
* you may not use this file except in compliance with the License.
|
10
|
+
* You may obtain a copy of the License at
|
11
|
+
*
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
*
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
* See the License for the specific language governing permissions and
|
18
|
+
* limitations under the License.
|
19
|
+
* ========================================================== */
|
20
|
+
|
21
|
+
!function( $ ) {
|
22
|
+
|
23
|
+
"use strict"
|
24
|
+
|
25
|
+
/* TOOLTIP PUBLIC CLASS DEFINITION
|
26
|
+
* =============================== */
|
27
|
+
|
28
|
+
var Tooltip = function ( element, options ) {
|
29
|
+
this.init('tooltip', element, options)
|
30
|
+
}
|
31
|
+
|
32
|
+
Tooltip.prototype = {
|
33
|
+
|
34
|
+
constructor: Tooltip
|
35
|
+
|
36
|
+
, init: function ( type, element, options ) {
|
37
|
+
var eventIn
|
38
|
+
, eventOut
|
39
|
+
|
40
|
+
this.type = type
|
41
|
+
this.$element = $(element)
|
42
|
+
this.options = this.getOptions(options)
|
43
|
+
this.enabled = true
|
44
|
+
|
45
|
+
if (this.options.trigger != 'manual') {
|
46
|
+
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
|
47
|
+
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
|
48
|
+
this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
|
49
|
+
this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
|
50
|
+
}
|
51
|
+
|
52
|
+
this.options.selector ?
|
53
|
+
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
|
54
|
+
this.fixTitle()
|
55
|
+
}
|
56
|
+
|
57
|
+
, getOptions: function ( options ) {
|
58
|
+
options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
|
59
|
+
|
60
|
+
if (options.delay && typeof options.delay == 'number') {
|
61
|
+
options.delay = {
|
62
|
+
show: options.delay
|
63
|
+
, hide: options.delay
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
return options
|
68
|
+
}
|
69
|
+
|
70
|
+
, enter: function ( e ) {
|
71
|
+
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
72
|
+
|
73
|
+
if (!self.options.delay || !self.options.delay.show) {
|
74
|
+
self.show()
|
75
|
+
} else {
|
76
|
+
self.hoverState = 'in'
|
77
|
+
setTimeout(function() {
|
78
|
+
if (self.hoverState == 'in') {
|
79
|
+
self.show()
|
80
|
+
}
|
81
|
+
}, self.options.delay.show)
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
, leave: function ( e ) {
|
86
|
+
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
87
|
+
|
88
|
+
if (!self.options.delay || !self.options.delay.hide) {
|
89
|
+
self.hide()
|
90
|
+
} else {
|
91
|
+
self.hoverState = 'out'
|
92
|
+
setTimeout(function() {
|
93
|
+
if (self.hoverState == 'out') {
|
94
|
+
self.hide()
|
95
|
+
}
|
96
|
+
}, self.options.delay.hide)
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
, show: function () {
|
101
|
+
var $tip
|
102
|
+
, inside
|
103
|
+
, pos
|
104
|
+
, actualWidth
|
105
|
+
, actualHeight
|
106
|
+
, placement
|
107
|
+
, tp
|
108
|
+
|
109
|
+
if (this.hasContent() && this.enabled) {
|
110
|
+
$tip = this.tip()
|
111
|
+
this.setContent()
|
112
|
+
|
113
|
+
if (this.options.animation) {
|
114
|
+
$tip.addClass('fade')
|
115
|
+
}
|
116
|
+
|
117
|
+
placement = typeof this.options.placement == 'function' ?
|
118
|
+
this.options.placement.call(this, $tip[0], this.$element[0]) :
|
119
|
+
this.options.placement
|
120
|
+
|
121
|
+
inside = /in/.test(placement)
|
122
|
+
|
123
|
+
$tip
|
124
|
+
.remove()
|
125
|
+
.css({ top: 0, left: 0, display: 'block' })
|
126
|
+
.appendTo(inside ? this.$element : document.body)
|
127
|
+
|
128
|
+
pos = this.getPosition(inside)
|
129
|
+
|
130
|
+
actualWidth = $tip[0].offsetWidth
|
131
|
+
actualHeight = $tip[0].offsetHeight
|
132
|
+
|
133
|
+
switch (inside ? placement.split(' ')[1] : placement) {
|
134
|
+
case 'bottom':
|
135
|
+
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
|
136
|
+
break
|
137
|
+
case 'top':
|
138
|
+
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
|
139
|
+
break
|
140
|
+
case 'left':
|
141
|
+
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
|
142
|
+
break
|
143
|
+
case 'right':
|
144
|
+
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
|
145
|
+
break
|
146
|
+
}
|
147
|
+
|
148
|
+
$tip
|
149
|
+
.css(tp)
|
150
|
+
.addClass(placement)
|
151
|
+
.addClass('in')
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
, setContent: function () {
|
156
|
+
var $tip = this.tip()
|
157
|
+
$tip.find('.tooltip-inner').html(this.getTitle())
|
158
|
+
$tip.removeClass('fade in top bottom left right')
|
159
|
+
}
|
160
|
+
|
161
|
+
, hide: function () {
|
162
|
+
var that = this
|
163
|
+
, $tip = this.tip()
|
164
|
+
|
165
|
+
$tip.removeClass('in')
|
166
|
+
|
167
|
+
function removeWithAnimation() {
|
168
|
+
var timeout = setTimeout(function () {
|
169
|
+
$tip.off($.support.transition.end).remove()
|
170
|
+
}, 500)
|
171
|
+
|
172
|
+
$tip.one($.support.transition.end, function () {
|
173
|
+
clearTimeout(timeout)
|
174
|
+
$tip.remove()
|
175
|
+
})
|
176
|
+
}
|
177
|
+
|
178
|
+
$.support.transition && this.$tip.hasClass('fade') ?
|
179
|
+
removeWithAnimation() :
|
180
|
+
$tip.remove()
|
181
|
+
}
|
182
|
+
|
183
|
+
, fixTitle: function () {
|
184
|
+
var $e = this.$element
|
185
|
+
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
|
186
|
+
$e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
, hasContent: function () {
|
191
|
+
return this.getTitle()
|
192
|
+
}
|
193
|
+
|
194
|
+
, getPosition: function (inside) {
|
195
|
+
return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
|
196
|
+
width: this.$element[0].offsetWidth
|
197
|
+
, height: this.$element[0].offsetHeight
|
198
|
+
})
|
199
|
+
}
|
200
|
+
|
201
|
+
, getTitle: function () {
|
202
|
+
var title
|
203
|
+
, $e = this.$element
|
204
|
+
, o = this.options
|
205
|
+
|
206
|
+
title = $e.attr('data-original-title')
|
207
|
+
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
|
208
|
+
|
209
|
+
title = title.toString().replace(/(^\s*|\s*$)/, "")
|
210
|
+
|
211
|
+
return title
|
212
|
+
}
|
213
|
+
|
214
|
+
, tip: function () {
|
215
|
+
return this.$tip = this.$tip || $(this.options.template)
|
216
|
+
}
|
217
|
+
|
218
|
+
, validate: function () {
|
219
|
+
if (!this.$element[0].parentNode) {
|
220
|
+
this.hide()
|
221
|
+
this.$element = null
|
222
|
+
this.options = null
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
, enable: function () {
|
227
|
+
this.enabled = true
|
228
|
+
}
|
229
|
+
|
230
|
+
, disable: function () {
|
231
|
+
this.enabled = false
|
232
|
+
}
|
233
|
+
|
234
|
+
, toggleEnabled: function () {
|
235
|
+
this.enabled = !this.enabled
|
236
|
+
}
|
237
|
+
|
238
|
+
, toggle: function () {
|
239
|
+
this[this.tip().hasClass('in') ? 'hide' : 'show']()
|
240
|
+
}
|
241
|
+
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
/* TOOLTIP PLUGIN DEFINITION
|
246
|
+
* ========================= */
|
247
|
+
|
248
|
+
$.fn.tooltip = function ( option ) {
|
249
|
+
return this.each(function () {
|
250
|
+
var $this = $(this)
|
251
|
+
, data = $this.data('tooltip')
|
252
|
+
, options = typeof option == 'object' && option
|
253
|
+
if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
|
254
|
+
if (typeof option == 'string') data[option]()
|
255
|
+
})
|
256
|
+
}
|
257
|
+
|
258
|
+
$.fn.tooltip.Constructor = Tooltip
|
259
|
+
|
260
|
+
$.fn.tooltip.defaults = {
|
261
|
+
animation: true
|
262
|
+
, delay: 0
|
263
|
+
, selector: false
|
264
|
+
, placement: 'top'
|
265
|
+
, trigger: 'hover'
|
266
|
+
, title: ''
|
267
|
+
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
|
268
|
+
}
|
269
|
+
|
270
|
+
}( window.jQuery )
|