spree_core 3.3.0.rc2 → 3.3.0.rc3
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.
- checksums.yaml +4 -4
- data/app/models/spree/order.rb +4 -0
- data/app/models/spree/payment_method/store_credit.rb +1 -1
- data/app/models/spree/preferences/store.rb +2 -2
- data/app/models/spree/store_credit.rb +1 -1
- data/app/models/spree/store_credit_event.rb +1 -1
- data/app/models/spree/tracker.rb +12 -6
- data/config/locales/en.yml +6 -6
- data/db/migrate/20170722102643_add_analytics_kind_to_spree_trackers.rb +5 -0
- data/db/migrate/20170727103056_rename_tracker_kind_field.rb +5 -0
- data/lib/spree/core/importer/order.rb +4 -4
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/factories/state_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tracker_factory.rb +1 -0
- metadata +4 -6
- data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +0 -19
- data/vendor/assets/javascripts/jquery-migrate-1.0.0.js +0 -498
- data/vendor/assets/stylesheets/normalize.css +0 -375
- data/vendor/assets/stylesheets/skeleton.css +0 -242
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6668d5ee08583dde8ee30f6c7de79e62a5b6084
|
|
4
|
+
data.tar.gz: 5d31cd7cae134239c4768c9e107c129a9702ffd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3edae0e8a5070fe74583a4f33b45689340943661e7bb16bef1ff2d09604aa90736be587367c0bbfc8d063132dabca53aaf48f98e631e50857f2b67b4bb2570a4
|
|
7
|
+
data.tar.gz: a029305f8e34985aecf4a4f2641c8d1e5401366501d765d2f83fa5053e743ca7ea99ca27e93e0a037ae5d68b72db27c433d2950b4e0f516ce0d308a169d610fe
|
data/app/models/spree/order.rb
CHANGED
|
@@ -117,7 +117,7 @@ module Spree
|
|
|
117
117
|
|
|
118
118
|
def handle_action(action, action_name, auth_code)
|
|
119
119
|
# Find first event with provided auth_code
|
|
120
|
-
store_credit = StoreCreditEvent.
|
|
120
|
+
store_credit = StoreCreditEvent.find_by(authorization_code: auth_code).try(:store_credit)
|
|
121
121
|
|
|
122
122
|
if store_credit.nil?
|
|
123
123
|
ActiveMerchant::Billing::Response.new(
|
|
@@ -40,7 +40,7 @@ module Spree::Preferences
|
|
|
40
40
|
# has been cleared from the cache
|
|
41
41
|
|
|
42
42
|
# does it exist in the database?
|
|
43
|
-
if preference = Spree::Preference.
|
|
43
|
+
if preference = Spree::Preference.find_by(key: key)
|
|
44
44
|
# it does exist
|
|
45
45
|
val = preference.value
|
|
46
46
|
else
|
|
@@ -81,7 +81,7 @@ module Spree::Preferences
|
|
|
81
81
|
def destroy(cache_key)
|
|
82
82
|
return unless should_persist?
|
|
83
83
|
|
|
84
|
-
preference = Spree::Preference.
|
|
84
|
+
preference = Spree::Preference.find_by(key: cache_key)
|
|
85
85
|
preference.destroy if preference
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -248,7 +248,7 @@ module Spree
|
|
|
248
248
|
def associate_credit_type
|
|
249
249
|
unless type_id
|
|
250
250
|
credit_type_name = category.try(:non_expiring?) ? 'Non-expiring' : 'Expiring'
|
|
251
|
-
self.credit_type = Spree::StoreCreditType.
|
|
251
|
+
self.credit_type = Spree::StoreCreditType.find_by(name: credit_type_name)
|
|
252
252
|
end
|
|
253
253
|
end
|
|
254
254
|
end
|
data/app/models/spree/tracker.rb
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
class Tracker < Spree::Base
|
|
3
|
+
TRACKING_ENGINES = %i(google_analytics segment).freeze
|
|
4
|
+
enum engine: TRACKING_ENGINES
|
|
5
|
+
|
|
3
6
|
after_commit :clear_cache
|
|
4
7
|
|
|
5
|
-
validates :analytics_id, presence: true, uniqueness: {
|
|
8
|
+
validates :analytics_id, presence: true, uniqueness: { scope: :engine, case_sensitive: false }
|
|
9
|
+
|
|
10
|
+
scope :active, -> { where(active: true) }
|
|
6
11
|
|
|
7
|
-
def self.current
|
|
8
|
-
tracker = Rails.cache.fetch("current_tracker") do
|
|
9
|
-
|
|
12
|
+
def self.current(engine = TRACKING_ENGINES.first)
|
|
13
|
+
tracker = Rails.cache.fetch("current_tracker/#{engine}") do
|
|
14
|
+
send(engine).active.first
|
|
10
15
|
end
|
|
11
16
|
tracker.analytics_id.present? ? tracker : nil if tracker
|
|
12
17
|
end
|
|
13
18
|
|
|
14
|
-
|
|
15
19
|
def clear_cache
|
|
16
|
-
|
|
20
|
+
TRACKING_ENGINES.each do |engine|
|
|
21
|
+
Rails.cache.delete("current_tracker/#{engine}")
|
|
22
|
+
end
|
|
17
23
|
end
|
|
18
24
|
end
|
|
19
25
|
end
|
data/config/locales/en.yml
CHANGED
|
@@ -96,8 +96,10 @@ en:
|
|
|
96
96
|
path: Path
|
|
97
97
|
starts_at: Starts At
|
|
98
98
|
usage_limit: Usage Limit
|
|
99
|
+
promotion_category: Promotion Category
|
|
99
100
|
spree/promotion_category:
|
|
100
101
|
name: Name
|
|
102
|
+
code: Code
|
|
101
103
|
spree/property:
|
|
102
104
|
name: Name
|
|
103
105
|
presentation: Presentation
|
|
@@ -476,6 +478,8 @@ en:
|
|
|
476
478
|
taxonomies: Taxonomies
|
|
477
479
|
taxons: Taxons
|
|
478
480
|
users: Users
|
|
481
|
+
return_authorizations: Return Authorizations
|
|
482
|
+
customer_returns: Customer Returns
|
|
479
483
|
order:
|
|
480
484
|
events:
|
|
481
485
|
approve: approve
|
|
@@ -513,6 +517,7 @@ en:
|
|
|
513
517
|
analytics_desc_list_2: Requires only a free Spree account to activate
|
|
514
518
|
analytics_desc_list_3: Absolutely no code to install
|
|
515
519
|
analytics_desc_list_4: It's completely free!
|
|
520
|
+
analytics_engine: Analytics Engine
|
|
516
521
|
analytics_trackers: Analytics Trackers
|
|
517
522
|
and: and
|
|
518
523
|
approve: approve
|
|
@@ -832,8 +837,6 @@ en:
|
|
|
832
837
|
items_to_be_reimbursed: Items to be reimbursed
|
|
833
838
|
items_reimbursed: Items reimbursed
|
|
834
839
|
jirafe: Jirafe
|
|
835
|
-
landing_page_rule:
|
|
836
|
-
path: Path
|
|
837
840
|
last_name: Last Name
|
|
838
841
|
last_name_begins_with: Last Name Begins With
|
|
839
842
|
learn_more: Learn More
|
|
@@ -1030,6 +1033,7 @@ en:
|
|
|
1030
1033
|
payment_processor_choose_banner_text: If you need help choosing a payment processor, please visit
|
|
1031
1034
|
payment_processor_choose_link: our payments page
|
|
1032
1035
|
payment_state: Payment State
|
|
1036
|
+
payment_identifier: Payment Identifier
|
|
1033
1037
|
payment_states:
|
|
1034
1038
|
balance_due: balance due
|
|
1035
1039
|
checkout: checkout
|
|
@@ -1113,9 +1117,6 @@ en:
|
|
|
1113
1117
|
item_total:
|
|
1114
1118
|
description: Order total meets these criteria
|
|
1115
1119
|
name: Item total
|
|
1116
|
-
landing_page:
|
|
1117
|
-
description: Customer must have visited the specified page
|
|
1118
|
-
name: Landing Page
|
|
1119
1120
|
one_use_per_user:
|
|
1120
1121
|
description: Only One Use Per User
|
|
1121
1122
|
name: One Use Per User
|
|
@@ -1158,7 +1159,6 @@ en:
|
|
|
1158
1159
|
reference: Reference
|
|
1159
1160
|
reference_contains: Reference Contains
|
|
1160
1161
|
refund: Refund
|
|
1161
|
-
refund_amount_must_be_greater_than_zero: Refund amount must be greater than zero
|
|
1162
1162
|
refund_reasons: Refund Reasons
|
|
1163
1163
|
refunded_amount: Refunded Amount
|
|
1164
1164
|
refunds: Refunds
|
|
@@ -54,7 +54,7 @@ module Spree
|
|
|
54
54
|
begin
|
|
55
55
|
shipment = order.shipments.build
|
|
56
56
|
shipment.tracking = s[:tracking]
|
|
57
|
-
shipment.stock_location = Spree::StockLocation.
|
|
57
|
+
shipment.stock_location = Spree::StockLocation.find_by(admin_name: s[:stock_location]) || Spree::StockLocation.find_by!(name: s[:stock_location])
|
|
58
58
|
inventory_units = create_inventory_units_from_order_and_params(order, s[:inventory_units])
|
|
59
59
|
|
|
60
60
|
inventory_units.each do |inventory_unit|
|
|
@@ -75,7 +75,7 @@ module Spree
|
|
|
75
75
|
|
|
76
76
|
shipment.save!
|
|
77
77
|
|
|
78
|
-
shipping_method = Spree::ShippingMethod.
|
|
78
|
+
shipping_method = Spree::ShippingMethod.find_by(name: s[:shipping_method]) || Spree::ShippingMethod.find_by!(admin_name: s[:shipping_method])
|
|
79
79
|
rate = shipment.shipping_rates.create!(shipping_method: shipping_method, cost: s[:cost])
|
|
80
80
|
|
|
81
81
|
shipment.selected_shipping_rate_id = rate.id
|
|
@@ -187,7 +187,7 @@ module Spree
|
|
|
187
187
|
# spree_wombat serializes payment state as status so imported orders should fall back to status field.
|
|
188
188
|
payment.state = p[:state] || p[:status] || 'completed'
|
|
189
189
|
payment.created_at = p[:created_at] if p[:created_at]
|
|
190
|
-
payment.payment_method = Spree::PaymentMethod.
|
|
190
|
+
payment.payment_method = Spree::PaymentMethod.find_by!(name: p[:payment_method])
|
|
191
191
|
payment.source = create_source_payment_from_params(p[:source], payment) if p[:source]
|
|
192
192
|
payment.save!
|
|
193
193
|
rescue Exception => e
|
|
@@ -218,7 +218,7 @@ module Spree
|
|
|
218
218
|
begin
|
|
219
219
|
sku = hash.delete(:sku)
|
|
220
220
|
unless hash[:variant_id].present?
|
|
221
|
-
hash[:variant_id] = Spree::Variant.active.
|
|
221
|
+
hash[:variant_id] = Spree::Variant.active.find_by!(sku: sku).id
|
|
222
222
|
end
|
|
223
223
|
hash
|
|
224
224
|
rescue ActiveRecord::RecordNotFound => e
|
data/lib/spree/core/version.rb
CHANGED
|
@@ -3,7 +3,7 @@ FactoryGirl.define do
|
|
|
3
3
|
sequence(:name) { |n| "STATE_NAME_#{n}" }
|
|
4
4
|
sequence(:abbr) { |n| "STATE_ABBR_#{n}" }
|
|
5
5
|
country do |country|
|
|
6
|
-
if usa = Spree::Country.
|
|
6
|
+
if usa = Spree::Country.find_by(numcode: 840)
|
|
7
7
|
country = usa
|
|
8
8
|
else
|
|
9
9
|
country.association(:country)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.3.0.
|
|
4
|
+
version: 3.3.0.rc3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Schofield
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemerchant
|
|
@@ -545,7 +545,6 @@ files:
|
|
|
545
545
|
- app/models/spree/zone_member.rb
|
|
546
546
|
- app/validators/db_maximum_length_validator.rb
|
|
547
547
|
- app/views/layouts/spree/base_mailer.html.erb
|
|
548
|
-
- app/views/spree/admin/orders/customer_details/_autocomplete.js.erb
|
|
549
548
|
- app/views/spree/order_mailer/_adjustment.html.erb
|
|
550
549
|
- app/views/spree/order_mailer/_subtotal.html.erb
|
|
551
550
|
- app/views/spree/order_mailer/_total.html.erb
|
|
@@ -834,6 +833,8 @@ files:
|
|
|
834
833
|
- db/migrate/20170331124513_add_index_to_spree_stock_items.rb
|
|
835
834
|
- db/migrate/20170331124924_add_index_to_spree_stock_movement.rb
|
|
836
835
|
- db/migrate/20170413211707_change_indexes_on_friendly_id_slugs.rb
|
|
836
|
+
- db/migrate/20170722102643_add_analytics_kind_to_spree_trackers.rb
|
|
837
|
+
- db/migrate/20170727103056_rename_tracker_kind_field.rb
|
|
837
838
|
- db/seeds.rb
|
|
838
839
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
|
839
840
|
- lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
|
|
@@ -961,11 +962,8 @@ files:
|
|
|
961
962
|
- lib/tasks/exchanges.rake
|
|
962
963
|
- script/rails
|
|
963
964
|
- spree_core.gemspec
|
|
964
|
-
- vendor/assets/javascripts/jquery-migrate-1.0.0.js
|
|
965
965
|
- vendor/assets/javascripts/jquery.payment.js
|
|
966
966
|
- vendor/assets/javascripts/jsuri.js
|
|
967
|
-
- vendor/assets/stylesheets/normalize.css
|
|
968
|
-
- vendor/assets/stylesheets/skeleton.css
|
|
969
967
|
homepage: http://spreecommerce.com
|
|
970
968
|
licenses:
|
|
971
969
|
- BSD-3-Clause
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script type='text/template' id='customer_autocomplete_template'>
|
|
2
|
-
<div class='customer-autocomplete-item'>
|
|
3
|
-
<div class='customer-details'>
|
|
4
|
-
<h5>{{customer.email}}</h5>
|
|
5
|
-
{{#if bill_address.firstname }}
|
|
6
|
-
<strong>{{t 'bill_address' }}</strong>
|
|
7
|
-
{{bill_address.firstname}} {{bill_address.lastname}}<br>
|
|
8
|
-
{{bill_address.address1}}, {{bill_address.address2}}<br>
|
|
9
|
-
{{bill_address.city}}<br>
|
|
10
|
-
{{#if bill_address.state_id }}
|
|
11
|
-
{{bill_address.state.name}}
|
|
12
|
-
{{else}}
|
|
13
|
-
{{bill_address.state_name}}
|
|
14
|
-
{{/if}}
|
|
15
|
-
{{bill_address.country.name}}
|
|
16
|
-
{{/if}}
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</script>
|
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* jQuery Migrate - v1.0.0 - 2013-01-14
|
|
3
|
-
* https://github.com/jquery/jquery-migrate
|
|
4
|
-
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
|
|
5
|
-
*/
|
|
6
|
-
(function( jQuery, window, undefined ) {
|
|
7
|
-
"use strict";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var warnedAbout = {};
|
|
11
|
-
|
|
12
|
-
// List of warnings already given; public read only
|
|
13
|
-
jQuery.migrateWarnings = [];
|
|
14
|
-
|
|
15
|
-
// Set to true to prevent console output; migrateWarnings still maintained
|
|
16
|
-
// jQuery.migrateMute = false;
|
|
17
|
-
|
|
18
|
-
// Forget any warnings we've already given; public
|
|
19
|
-
jQuery.migrateReset = function() {
|
|
20
|
-
warnedAbout = {};
|
|
21
|
-
jQuery.migrateWarnings.length = 0;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function migrateWarn( msg) {
|
|
25
|
-
if ( !warnedAbout[ msg ] ) {
|
|
26
|
-
warnedAbout[ msg ] = true;
|
|
27
|
-
jQuery.migrateWarnings.push( msg );
|
|
28
|
-
if ( window.console && console.warn && !jQuery.migrateMute ) {
|
|
29
|
-
console.warn( "JQMIGRATE: " + msg );
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function migrateWarnProp( obj, prop, value, msg ) {
|
|
35
|
-
if ( Object.defineProperty ) {
|
|
36
|
-
// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
|
|
37
|
-
// allow property to be overwritten in case some other plugin wants it
|
|
38
|
-
try {
|
|
39
|
-
Object.defineProperty( obj, prop, {
|
|
40
|
-
configurable: true,
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function() {
|
|
43
|
-
migrateWarn( msg );
|
|
44
|
-
return value;
|
|
45
|
-
},
|
|
46
|
-
set: function( newValue ) {
|
|
47
|
-
migrateWarn( msg );
|
|
48
|
-
value = newValue;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return;
|
|
52
|
-
} catch( err ) {
|
|
53
|
-
// IE8 is a dope about Object.defineProperty, can't warn there
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Non-ES5 (or broken) browser; just set the property
|
|
58
|
-
jQuery._definePropertyBroken = true;
|
|
59
|
-
obj[ prop ] = value;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if ( document.compatMode === "BackCompat" ) {
|
|
63
|
-
// jQuery has never supported or tested Quirks Mode
|
|
64
|
-
migrateWarn( "jQuery is not compatible with Quirks Mode" );
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var attrFn = {},
|
|
69
|
-
attr = jQuery.attr,
|
|
70
|
-
valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
|
|
71
|
-
function() { return null; },
|
|
72
|
-
valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
|
|
73
|
-
function() { return undefined; },
|
|
74
|
-
rnoType = /^(?:input|button)$/i,
|
|
75
|
-
rnoAttrNodeType = /^[238]$/,
|
|
76
|
-
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
|
|
77
|
-
ruseDefault = /^(?:checked|selected)$/i;
|
|
78
|
-
|
|
79
|
-
// jQuery.attrFn
|
|
80
|
-
migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" );
|
|
81
|
-
|
|
82
|
-
jQuery.attr = function( elem, name, value, pass ) {
|
|
83
|
-
var lowerName = name.toLowerCase(),
|
|
84
|
-
nType = elem && elem.nodeType;
|
|
85
|
-
|
|
86
|
-
if ( pass ) {
|
|
87
|
-
migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
|
|
88
|
-
if ( elem && !rnoAttrNodeType.test( nType ) && jQuery.isFunction( jQuery.fn[ name ] ) ) {
|
|
89
|
-
return jQuery( elem )[ name ]( value );
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Warn if user tries to set `type` since it breaks on IE 6/7/8
|
|
94
|
-
if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) ) {
|
|
95
|
-
migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Restore boolHook for boolean property/attribute synchronization
|
|
99
|
-
if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
|
|
100
|
-
jQuery.attrHooks[ lowerName ] = {
|
|
101
|
-
get: function( elem, name ) {
|
|
102
|
-
// Align boolean attributes with corresponding properties
|
|
103
|
-
// Fall back to attribute presence where some booleans are not supported
|
|
104
|
-
var attrNode,
|
|
105
|
-
property = jQuery.prop( elem, name );
|
|
106
|
-
return property === true || typeof property !== "boolean" &&
|
|
107
|
-
( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
|
|
108
|
-
|
|
109
|
-
name.toLowerCase() :
|
|
110
|
-
undefined;
|
|
111
|
-
},
|
|
112
|
-
set: function( elem, value, name ) {
|
|
113
|
-
var propName;
|
|
114
|
-
if ( value === false ) {
|
|
115
|
-
// Remove boolean attributes when set to false
|
|
116
|
-
jQuery.removeAttr( elem, name );
|
|
117
|
-
} else {
|
|
118
|
-
// value is true since we know at this point it's type boolean and not false
|
|
119
|
-
// Set boolean attributes to the same name and set the DOM property
|
|
120
|
-
propName = jQuery.propFix[ name ] || name;
|
|
121
|
-
if ( propName in elem ) {
|
|
122
|
-
// Only set the IDL specifically if it already exists on the element
|
|
123
|
-
elem[ propName ] = true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
elem.setAttribute( name, name.toLowerCase() );
|
|
127
|
-
}
|
|
128
|
-
return name;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// Warn only for attributes that can remain distinct from their properties post-1.9
|
|
133
|
-
if ( ruseDefault.test( lowerName ) ) {
|
|
134
|
-
migrateWarn( "jQuery.fn.attr(" + lowerName + ") may use property instead of attribute" );
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return attr.call( jQuery, elem, name, value );
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// attrHooks: value
|
|
142
|
-
jQuery.attrHooks.value = {
|
|
143
|
-
get: function( elem, name ) {
|
|
144
|
-
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
|
145
|
-
if ( nodeName === "button" ) {
|
|
146
|
-
return valueAttrGet.apply( this, arguments );
|
|
147
|
-
}
|
|
148
|
-
if ( nodeName !== "input" && nodeName !== "option" ) {
|
|
149
|
-
migrateWarn("property-based jQuery.fn.attr('value') is deprecated");
|
|
150
|
-
}
|
|
151
|
-
return name in elem ?
|
|
152
|
-
elem.value :
|
|
153
|
-
null;
|
|
154
|
-
},
|
|
155
|
-
set: function( elem, value ) {
|
|
156
|
-
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
|
157
|
-
if ( nodeName === "button" ) {
|
|
158
|
-
return valueAttrSet.apply( this, arguments );
|
|
159
|
-
}
|
|
160
|
-
if ( nodeName !== "input" && nodeName !== "option" ) {
|
|
161
|
-
migrateWarn("property-based jQuery.fn.attr('value', val) is deprecated");
|
|
162
|
-
}
|
|
163
|
-
// Does not return so that setAttribute is also used
|
|
164
|
-
elem.value = value;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var matched, browser,
|
|
170
|
-
oldInit = jQuery.fn.init,
|
|
171
|
-
// Note this does NOT include the # XSS fix from 1.7!
|
|
172
|
-
rquickExpr = /^(?:.*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;
|
|
173
|
-
|
|
174
|
-
// $(html) "looks like html" rule change
|
|
175
|
-
jQuery.fn.init = function( selector, context, rootjQuery ) {
|
|
176
|
-
var match;
|
|
177
|
-
|
|
178
|
-
if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
|
|
179
|
-
(match = rquickExpr.exec( selector )) && match[1] ) {
|
|
180
|
-
// This is an HTML string according to the "old" rules; is it still?
|
|
181
|
-
if ( selector.charAt( 0 ) !== "<" ) {
|
|
182
|
-
migrateWarn("$(html) HTML strings must start with '<' character");
|
|
183
|
-
}
|
|
184
|
-
// Now process using loose rules; let pre-1.8 play too
|
|
185
|
-
if ( context && context.context ) {
|
|
186
|
-
// jQuery object as context; parseHTML expects a DOM object
|
|
187
|
-
context = context.context;
|
|
188
|
-
}
|
|
189
|
-
if ( jQuery.parseHTML ) {
|
|
190
|
-
return oldInit.call( this, jQuery.parseHTML( jQuery.trim(selector), context, true ),
|
|
191
|
-
context, rootjQuery );
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return oldInit.apply( this, arguments );
|
|
195
|
-
};
|
|
196
|
-
jQuery.fn.init.prototype = jQuery.fn;
|
|
197
|
-
|
|
198
|
-
jQuery.uaMatch = function( ua ) {
|
|
199
|
-
ua = ua.toLowerCase();
|
|
200
|
-
|
|
201
|
-
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
|
202
|
-
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
|
203
|
-
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
|
204
|
-
/(msie) ([\w.]+)/.exec( ua ) ||
|
|
205
|
-
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
|
206
|
-
[];
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
browser: match[ 1 ] || "",
|
|
210
|
-
version: match[ 2 ] || "0"
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
matched = jQuery.uaMatch( navigator.userAgent );
|
|
215
|
-
browser = {};
|
|
216
|
-
|
|
217
|
-
if ( matched.browser ) {
|
|
218
|
-
browser[ matched.browser ] = true;
|
|
219
|
-
browser.version = matched.version;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Chrome is Webkit, but Webkit is also Safari.
|
|
223
|
-
if ( browser.chrome ) {
|
|
224
|
-
browser.webkit = true;
|
|
225
|
-
} else if ( browser.webkit ) {
|
|
226
|
-
browser.safari = true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
jQuery.browser = browser;
|
|
230
|
-
|
|
231
|
-
// Warn if the code tries to get jQuery.browser
|
|
232
|
-
migrateWarnProp( jQuery, "browser", browser, "jQuery.browser is deprecated" );
|
|
233
|
-
|
|
234
|
-
jQuery.sub = function() {
|
|
235
|
-
function jQuerySub( selector, context ) {
|
|
236
|
-
return new jQuerySub.fn.init( selector, context );
|
|
237
|
-
}
|
|
238
|
-
jQuery.extend( true, jQuerySub, this );
|
|
239
|
-
jQuerySub.superclass = this;
|
|
240
|
-
jQuerySub.fn = jQuerySub.prototype = this();
|
|
241
|
-
jQuerySub.fn.constructor = jQuerySub;
|
|
242
|
-
jQuerySub.sub = this.sub;
|
|
243
|
-
jQuerySub.fn.init = function init( selector, context ) {
|
|
244
|
-
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
|
|
245
|
-
context = jQuerySub( context );
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
|
249
|
-
};
|
|
250
|
-
jQuerySub.fn.init.prototype = jQuerySub.fn;
|
|
251
|
-
var rootjQuerySub = jQuerySub(document);
|
|
252
|
-
migrateWarn( "jQuery.sub() is deprecated" );
|
|
253
|
-
return jQuerySub;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var oldFnData = jQuery.fn.data;
|
|
258
|
-
|
|
259
|
-
jQuery.fn.data = function( name ) {
|
|
260
|
-
var ret, evt,
|
|
261
|
-
elem = this[0];
|
|
262
|
-
|
|
263
|
-
// Handles 1.7 which has this behavior and 1.8 which doesn't
|
|
264
|
-
if ( elem && name === "events" && arguments.length === 1 ) {
|
|
265
|
-
ret = jQuery.data( elem, name );
|
|
266
|
-
evt = jQuery._data( elem, name );
|
|
267
|
-
if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
|
|
268
|
-
migrateWarn("Use of jQuery.fn.data('events') is deprecated");
|
|
269
|
-
return evt;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return oldFnData.apply( this, arguments );
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
var rscriptType = /\/(java|ecma)script/i,
|
|
277
|
-
oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
|
|
278
|
-
oldFragment = jQuery.buildFragment;
|
|
279
|
-
|
|
280
|
-
jQuery.fn.andSelf = function() {
|
|
281
|
-
migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
|
|
282
|
-
return oldSelf.apply( this, arguments );
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
// Since jQuery.clean is used internally on older versions, we only shim if it's missing
|
|
286
|
-
if ( !jQuery.clean ) {
|
|
287
|
-
jQuery.clean = function( elems, context, fragment, scripts ) {
|
|
288
|
-
// Set context per 1.8 logic
|
|
289
|
-
context = context || document;
|
|
290
|
-
context = !context.nodeType && context[0] || context;
|
|
291
|
-
context = context.ownerDocument || context;
|
|
292
|
-
|
|
293
|
-
migrateWarn("jQuery.clean() is deprecated");
|
|
294
|
-
|
|
295
|
-
var i, elem, handleScript, jsTags,
|
|
296
|
-
ret = [];
|
|
297
|
-
|
|
298
|
-
jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
|
|
299
|
-
|
|
300
|
-
// Complex logic lifted directly from jQuery 1.8
|
|
301
|
-
if ( fragment ) {
|
|
302
|
-
// Special handling of each script element
|
|
303
|
-
handleScript = function( elem ) {
|
|
304
|
-
// Check if we consider it executable
|
|
305
|
-
if ( !elem.type || rscriptType.test( elem.type ) ) {
|
|
306
|
-
// Detach the script and store it in the scripts array (if provided) or the fragment
|
|
307
|
-
// Return truthy to indicate that it has been handled
|
|
308
|
-
return scripts ?
|
|
309
|
-
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
|
|
310
|
-
fragment.appendChild( elem );
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
for ( i = 0; (elem = ret[i]) != null; i++ ) {
|
|
315
|
-
// Check if we're done after handling an executable script
|
|
316
|
-
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
|
|
317
|
-
// Append to fragment and handle embedded scripts
|
|
318
|
-
fragment.appendChild( elem );
|
|
319
|
-
if ( typeof elem.getElementsByTagName !== "undefined" ) {
|
|
320
|
-
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
|
|
321
|
-
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
|
|
322
|
-
|
|
323
|
-
// Splice the scripts into ret after their former ancestor and advance our index beyond them
|
|
324
|
-
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
|
325
|
-
i += jsTags.length;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return ret;
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
jQuery.buildFragment = function( elems, context, scripts, selection ) {
|
|
336
|
-
var ret,
|
|
337
|
-
warning = "jQuery.buildFragment() is deprecated";
|
|
338
|
-
|
|
339
|
-
// Set context per 1.8 logic
|
|
340
|
-
context = context || document;
|
|
341
|
-
context = !context.nodeType && context[0] || context;
|
|
342
|
-
context = context.ownerDocument || context;
|
|
343
|
-
|
|
344
|
-
try {
|
|
345
|
-
ret = oldFragment.call( jQuery, elems, context, scripts, selection );
|
|
346
|
-
|
|
347
|
-
// jQuery < 1.8 required arrayish context; jQuery 1.9 fails on it
|
|
348
|
-
} catch( x ) {
|
|
349
|
-
ret = oldFragment.call( jQuery, elems, context.nodeType ? [ context ] : context[ 0 ], scripts, selection );
|
|
350
|
-
|
|
351
|
-
// Success from tweaking context means buildFragment was called by the user
|
|
352
|
-
migrateWarn( warning );
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// jQuery < 1.9 returned an object instead of the fragment itself
|
|
356
|
-
if ( !ret.fragment ) {
|
|
357
|
-
migrateWarnProp( ret, "fragment", ret, warning );
|
|
358
|
-
migrateWarnProp( ret, "cacheable", false, warning );
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return ret;
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
var eventAdd = jQuery.event.add,
|
|
365
|
-
eventRemove = jQuery.event.remove,
|
|
366
|
-
eventTrigger = jQuery.event.trigger,
|
|
367
|
-
oldToggle = jQuery.fn.toggle,
|
|
368
|
-
oldLive = jQuery.fn.live,
|
|
369
|
-
oldDie = jQuery.fn.die,
|
|
370
|
-
ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
|
|
371
|
-
rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
|
|
372
|
-
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
|
|
373
|
-
hoverHack = function( events ) {
|
|
374
|
-
if ( typeof( events ) != "string" || jQuery.event.special.hover ) {
|
|
375
|
-
return events;
|
|
376
|
-
}
|
|
377
|
-
if ( rhoverHack.test( events ) ) {
|
|
378
|
-
migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
|
|
379
|
-
}
|
|
380
|
-
return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
// Event props removed in 1.9, put them back if needed; no practical way to warn them
|
|
384
|
-
if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
|
|
385
|
-
jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
|
|
389
|
-
migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
|
|
390
|
-
|
|
391
|
-
// Support for 'hover' pseudo-event and ajax event warnings
|
|
392
|
-
jQuery.event.add = function( elem, types, handler, data, selector ){
|
|
393
|
-
if ( elem !== document && rajaxEvent.test( types ) ) {
|
|
394
|
-
migrateWarn( "AJAX events should be attached to document: " + types );
|
|
395
|
-
}
|
|
396
|
-
eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
|
|
397
|
-
};
|
|
398
|
-
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
|
|
399
|
-
eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
jQuery.fn.error = function() {
|
|
403
|
-
var args = Array.prototype.slice.call( arguments, 0);
|
|
404
|
-
migrateWarn("jQuery.fn.error() is deprecated");
|
|
405
|
-
args.splice( 0, 0, "error" );
|
|
406
|
-
if ( arguments.length ) {
|
|
407
|
-
return this.bind.apply( this, args );
|
|
408
|
-
}
|
|
409
|
-
// error event should not bubble to window, although it does pre-1.7
|
|
410
|
-
this.triggerHandler.apply( this, args );
|
|
411
|
-
return this;
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
jQuery.fn.toggle = function( fn, fn2 ) {
|
|
415
|
-
|
|
416
|
-
// Don't mess with animation or css toggles
|
|
417
|
-
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
|
|
418
|
-
return oldToggle.apply( this, arguments );
|
|
419
|
-
}
|
|
420
|
-
migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
|
|
421
|
-
|
|
422
|
-
// Save reference to arguments for access in closure
|
|
423
|
-
var args = arguments,
|
|
424
|
-
guid = fn.guid || jQuery.guid++,
|
|
425
|
-
i = 0,
|
|
426
|
-
toggler = function( event ) {
|
|
427
|
-
// Figure out which function to execute
|
|
428
|
-
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
|
429
|
-
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
|
430
|
-
|
|
431
|
-
// Make sure that clicks stop
|
|
432
|
-
event.preventDefault();
|
|
433
|
-
|
|
434
|
-
// and execute the function
|
|
435
|
-
return args[ lastToggle ].apply( this, arguments ) || false;
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
// link all the functions, so any of them can unbind this click handler
|
|
439
|
-
toggler.guid = guid;
|
|
440
|
-
while ( i < args.length ) {
|
|
441
|
-
args[ i++ ].guid = guid;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return this.click( toggler );
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
jQuery.fn.live = function( types, data, fn ) {
|
|
448
|
-
migrateWarn("jQuery.fn.live() is deprecated");
|
|
449
|
-
if ( oldLive ) {
|
|
450
|
-
return oldLive.apply( this, arguments );
|
|
451
|
-
}
|
|
452
|
-
jQuery( this.context ).on( types, this.selector, data, fn );
|
|
453
|
-
return this;
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
jQuery.fn.die = function( types, fn ) {
|
|
457
|
-
migrateWarn("jQuery.fn.die() is deprecated");
|
|
458
|
-
if ( oldDie ) {
|
|
459
|
-
return oldDie.apply( this, arguments );
|
|
460
|
-
}
|
|
461
|
-
jQuery( this.context ).off( types, this.selector || "**", fn );
|
|
462
|
-
return this;
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
// Turn global events into document-triggered events
|
|
466
|
-
jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
|
|
467
|
-
if ( !elem & !rajaxEvent.test( event ) ) {
|
|
468
|
-
migrateWarn( "Global events are undocumented and deprecated" );
|
|
469
|
-
}
|
|
470
|
-
return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
|
|
471
|
-
};
|
|
472
|
-
jQuery.each( ajaxEvents.split("|"),
|
|
473
|
-
function( _, name ) {
|
|
474
|
-
jQuery.event.special[ name ] = {
|
|
475
|
-
setup: function() {
|
|
476
|
-
var elem = this;
|
|
477
|
-
|
|
478
|
-
// The document needs no shimming; must be !== for oldIE
|
|
479
|
-
if ( elem !== document ) {
|
|
480
|
-
jQuery.event.add( document, name + "." + jQuery.guid, function() {
|
|
481
|
-
jQuery.event.trigger( name, null, elem, true );
|
|
482
|
-
});
|
|
483
|
-
jQuery._data( this, name, jQuery.guid++ );
|
|
484
|
-
}
|
|
485
|
-
return false;
|
|
486
|
-
},
|
|
487
|
-
teardown: function() {
|
|
488
|
-
if ( this !== document ) {
|
|
489
|
-
jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
|
|
490
|
-
}
|
|
491
|
-
return false;
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
);
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
})( jQuery, window );
|