solidus_core 1.2.0.beta1 → 1.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/spree/exchange.rb +3 -2
- data/app/models/spree/stock/coordinator.rb +11 -0
- data/app/models/spree/stock/packer.rb +0 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/factories/country_factory.rb +14 -4
- data/spec/models/spree/address_spec.rb +2 -2
- data/spec/models/spree/stock/coordinator_spec.rb +113 -2
- data/spec/models/spree/stock/packer_spec.rb +4 -4
- metadata +2 -3
- data/vendor/assets/javascripts/jquery-migrate-1.0.0.js +0 -498
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef1fda7b796bd51ab9e01a449e5354a21efee3b9
|
4
|
+
data.tar.gz: c6a7a3dd7d508844576f5070ec54d05f491f229d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 579a5e3d9ab4ab281a4ffffac65d98d68069b965d0435908033dd492b5e0d26456ca26a90c033a8ce043a53a456052556a1f2ac713d33334c93688163dd4db88
|
7
|
+
data.tar.gz: 432c5b1f58a716abe1d8eac31b2028e7d748ecae28330800e5b6a186749b15d36cc2acee1b7622c9437918417d7fa9fbb830c5d46527ea3a1f4199a53855aff2
|
@@ -18,8 +18,9 @@ module Spree
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def perform!
|
21
|
-
|
22
|
-
|
21
|
+
begin
|
22
|
+
shipments = Spree::Stock::Coordinator.new(@order, @reimbursement_objects.map(&:build_exchange_inventory_unit)).shipments
|
23
|
+
rescue Spree::Order::InsufficientStock
|
23
24
|
raise UnableToCreateShipments.new("Could not generate shipments for all items. Out of stock?")
|
24
25
|
end
|
25
26
|
@order.shipments += shipments
|
@@ -20,6 +20,8 @@ module Spree
|
|
20
20
|
packages = build_packages(packages)
|
21
21
|
packages = prioritize_packages(packages)
|
22
22
|
packages = estimate_packages(packages)
|
23
|
+
validate_packages(packages)
|
24
|
+
packages
|
23
25
|
end
|
24
26
|
|
25
27
|
# Build packages for the inventory units that have preferred stock locations first
|
@@ -127,6 +129,15 @@ module Spree
|
|
127
129
|
packages
|
128
130
|
end
|
129
131
|
|
132
|
+
def validate_packages(packages)
|
133
|
+
desired_quantity = inventory_units.size
|
134
|
+
packaged_quantity = packages.sum(&:quantity)
|
135
|
+
if packaged_quantity != desired_quantity
|
136
|
+
raise Spree::Order::InsufficientStock,
|
137
|
+
"Was only able to package #{packaged_quantity} inventory units of #{desired_quantity} requested"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
130
141
|
def build_packer(stock_location, inventory_units)
|
131
142
|
Packer.new(stock_location, inventory_units, splitters(stock_location))
|
132
143
|
end
|
@@ -26,7 +26,6 @@ module Spree
|
|
26
26
|
next unless stock_item
|
27
27
|
|
28
28
|
on_hand, backordered = stock_item.fill_status(units.count)
|
29
|
-
raise Spree::Order::InsufficientStock unless on_hand > 0 || backordered > 0
|
30
29
|
package.add_multiple units.slice!(0, on_hand), :on_hand if on_hand > 0
|
31
30
|
package.add_multiple units.slice!(0, backordered), :backordered if backordered > 0
|
32
31
|
else
|
data/lib/spree/core/version.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
+
require 'carmen'
|
2
|
+
|
1
3
|
FactoryGirl.define do
|
2
4
|
factory :country, class: Spree::Country do
|
3
|
-
iso_name 'UNITED STATES'
|
4
|
-
name 'United States of America'
|
5
5
|
iso 'US'
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
transient do
|
8
|
+
carmen_country { Carmen::Country.coded(iso) || fail("Unknown country iso code: #{iso.inspect}") }
|
9
|
+
end
|
10
|
+
|
11
|
+
iso_name { carmen_country.name.upcase }
|
12
|
+
name { carmen_country.name }
|
13
|
+
iso3 { carmen_country.alpha_3_code }
|
14
|
+
numcode { carmen_country.numeric_code }
|
15
|
+
|
16
|
+
# FIXME: We should set states required, but it causes failing tests
|
17
|
+
# states_required { carmen_country.subregions? }
|
8
18
|
end
|
9
19
|
end
|
@@ -187,7 +187,7 @@ describe Spree::Address, :type => :model do
|
|
187
187
|
context '.factory' do
|
188
188
|
context 'with attributes that use setters defined in Address' do
|
189
189
|
let(:address_attributes) { attributes_for(:address, country_id: nil, country_iso: country.iso) }
|
190
|
-
let(:country) { create(:country, iso: '
|
190
|
+
let(:country) { create(:country, iso: 'ZW') }
|
191
191
|
|
192
192
|
it 'uses the setters' do
|
193
193
|
expect(subject.factory(address_attributes).country_id).to eq(country.id)
|
@@ -312,7 +312,7 @@ describe Spree::Address, :type => :model do
|
|
312
312
|
|
313
313
|
context '#country_iso=' do
|
314
314
|
let(:address) { build(:address, :country_id => nil) }
|
315
|
-
let(:country) { create(:country, iso: '
|
315
|
+
let(:country) { create(:country, iso: 'ZW') }
|
316
316
|
|
317
317
|
it 'sets the country to the country with the matching iso code' do
|
318
318
|
address.country_iso = country.iso
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Spree
|
4
4
|
module Stock
|
5
5
|
describe Coordinator, :type => :model do
|
6
|
-
let
|
6
|
+
let(:order) { create(:order_with_line_items, line_items_count: 2) }
|
7
7
|
|
8
8
|
subject { Coordinator.new(order) }
|
9
9
|
|
@@ -13,6 +13,7 @@ module Spree
|
|
13
13
|
expect(subject).to receive(:build_packages).ordered
|
14
14
|
expect(subject).to receive(:prioritize_packages).ordered
|
15
15
|
expect(subject).to receive(:estimate_packages).ordered
|
16
|
+
expect(subject).to receive(:validate_packages).ordered
|
16
17
|
subject.packages
|
17
18
|
end
|
18
19
|
|
@@ -91,9 +92,119 @@ module Spree
|
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
95
|
+
context "with no backordering" do
|
96
|
+
let!(:stock_location_1) { create(:stock_location, propagate_all_variants: false, active: true) }
|
97
|
+
|
98
|
+
let!(:variant) { create(:variant, track_inventory: true) }
|
99
|
+
|
100
|
+
before do
|
101
|
+
stock_item1 = variant.stock_items.create!(stock_location: stock_location_1, backorderable: false)
|
102
|
+
stock_item1.set_count_on_hand(location_1_inventory)
|
103
|
+
end
|
104
|
+
|
105
|
+
let!(:order) { create(:order) }
|
106
|
+
let!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 5) }
|
107
|
+
before { order.reload }
|
108
|
+
let(:packages) { subject.packages }
|
109
|
+
|
110
|
+
shared_examples "a fulfillable package" do
|
111
|
+
it "packages correctly" do
|
112
|
+
expect(packages).not_to be_empty
|
113
|
+
expect(packages.map(&:quantity).sum).to eq(5)
|
114
|
+
expect(packages.flat_map(&:contents).map(&:inventory_unit).uniq.size).to eq(5)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
shared_examples "an unfulfillable package" do
|
119
|
+
it "raises exception" do
|
120
|
+
expect{ packages }.to raise_error(Spree::Order::InsufficientStock)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'with no stock locations' do
|
125
|
+
let(:location_1_inventory) { 0 }
|
126
|
+
before { variant.stock_items.destroy_all }
|
127
|
+
it_behaves_like "an unfulfillable package"
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'with a single stock location' do
|
131
|
+
context "with no inventory" do
|
132
|
+
let(:location_1_inventory) { 0 }
|
133
|
+
it_behaves_like "an unfulfillable package"
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with insufficient inventory" do
|
137
|
+
let(:location_1_inventory) { 1 }
|
138
|
+
it_behaves_like "an unfulfillable package"
|
139
|
+
end
|
140
|
+
|
141
|
+
context "with sufficient inventory" do
|
142
|
+
let(:location_1_inventory) { 5 }
|
143
|
+
it_behaves_like "a fulfillable package"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'with two stock locations' do
|
148
|
+
let!(:stock_location_2) { create(:stock_location, propagate_all_variants: false, active: true) }
|
149
|
+
before do
|
150
|
+
stock_item2 = variant.stock_items.create!(stock_location: stock_location_2, backorderable: false)
|
151
|
+
stock_item2.set_count_on_hand(location_2_inventory)
|
152
|
+
end
|
153
|
+
|
154
|
+
context "with no inventory" do
|
155
|
+
let(:location_1_inventory) { 0 }
|
156
|
+
let(:location_2_inventory) { 0 }
|
157
|
+
it_behaves_like "an unfulfillable package"
|
158
|
+
end
|
159
|
+
|
160
|
+
context "with some but insufficient inventory in each location" do
|
161
|
+
let(:location_1_inventory) { 1 }
|
162
|
+
let(:location_2_inventory) { 1 }
|
163
|
+
it_behaves_like "an unfulfillable package"
|
164
|
+
end
|
165
|
+
|
166
|
+
context "has sufficient inventory in the first location" do
|
167
|
+
let(:location_1_inventory) { 5 }
|
168
|
+
let(:location_2_inventory) { 0 }
|
169
|
+
it_behaves_like "a fulfillable package"
|
170
|
+
end
|
171
|
+
|
172
|
+
context "has sufficient inventory in the second location" do
|
173
|
+
let(:location_1_inventory) { 0 }
|
174
|
+
let(:location_2_inventory) { 5 }
|
175
|
+
it_behaves_like "a fulfillable package"
|
176
|
+
end
|
177
|
+
|
178
|
+
context "with sufficient inventory only across both locations" do
|
179
|
+
let(:location_1_inventory) { 2 }
|
180
|
+
let(:location_2_inventory) { 3 }
|
181
|
+
before { pending "This is broken. The coordinator packages this incorrectly" }
|
182
|
+
it_behaves_like "a fulfillable package"
|
183
|
+
end
|
184
|
+
|
185
|
+
context "has sufficient inventory in the second location and some in the first" do
|
186
|
+
let(:location_1_inventory) { 2 }
|
187
|
+
let(:location_2_inventory) { 5 }
|
188
|
+
it_behaves_like "a fulfillable package"
|
189
|
+
end
|
190
|
+
|
191
|
+
context "has sufficient inventory in the first location and some in the second" do
|
192
|
+
let(:location_1_inventory) { 5 }
|
193
|
+
let(:location_2_inventory) { 2 }
|
194
|
+
it_behaves_like "a fulfillable package"
|
195
|
+
end
|
196
|
+
|
197
|
+
context "with sufficient inventory in both locations" do
|
198
|
+
let(:location_1_inventory) { 5 }
|
199
|
+
let(:location_2_inventory) { 5 }
|
200
|
+
it_behaves_like "a fulfillable package"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
94
205
|
context "build location configured packages" do
|
95
206
|
context "there are configured stock locations" do
|
96
|
-
let(:stock_location) { order.variants.first.stock_locations.first }
|
207
|
+
let!(:stock_location) { order.variants.first.stock_locations.first }
|
97
208
|
let!(:stock_location_2) { create(:stock_location) }
|
98
209
|
|
99
210
|
before do
|
@@ -41,11 +41,11 @@ module Spree
|
|
41
41
|
let(:packer) { Packer.new(stock_location, inventory_units) }
|
42
42
|
|
43
43
|
it "builds an empty package" do
|
44
|
-
expect(packer.default_package
|
44
|
+
expect(packer.default_package).to be_empty
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context "
|
48
|
+
context "none on hand and not backorderable" do
|
49
49
|
let(:packer) { Packer.new(stock_location, inventory_units) }
|
50
50
|
|
51
51
|
before do
|
@@ -53,8 +53,8 @@ module Spree
|
|
53
53
|
stock_location.stock_items.each { |si| si.set_count_on_hand(0) }
|
54
54
|
end
|
55
55
|
|
56
|
-
it "
|
57
|
-
expect
|
56
|
+
it "builds an empty package" do
|
57
|
+
expect(packer.default_package).to be_empty
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -1356,7 +1356,6 @@ files:
|
|
1356
1356
|
- spec/support/concerns/working_factories.rb
|
1357
1357
|
- spec/support/dummy_ability.rb
|
1358
1358
|
- spec/support/test_gateway.rb
|
1359
|
-
- vendor/assets/javascripts/jquery-migrate-1.0.0.js
|
1360
1359
|
- vendor/assets/javascripts/jquery.payment.js
|
1361
1360
|
- vendor/assets/javascripts/jsuri.js
|
1362
1361
|
- vendor/assets/stylesheets/normalize.css
|
@@ -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 );
|