mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-17 09:52:29 +01:00
Merge pull request #14852 from twbs/jquery-version-check
Add jQuery version check to existing jQuery presence check
This commit is contained in:
commit
9814256736
19
Gruntfile.js
19
Gruntfile.js
@ -37,8 +37,21 @@ module.exports = function (grunt) {
|
|||||||
' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
|
' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
|
||||||
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
|
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
|
||||||
' */\n',
|
' */\n',
|
||||||
// NOTE: This jqueryCheck code is duplicated in customizer.js; if making changes here, be sure to update the other copy too.
|
// NOTE: This jqueryCheck/jqueryVersionCheck code is duplicated in customizer.js;
|
||||||
jqueryCheck: 'if (typeof jQuery === \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n',
|
// if making changes here, be sure to update the other copy too.
|
||||||
|
jqueryCheck: [
|
||||||
|
'if (typeof jQuery === \'undefined\') {',
|
||||||
|
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\')',
|
||||||
|
'}\n'
|
||||||
|
].join('\n'),
|
||||||
|
jqueryVersionCheck: [
|
||||||
|
'+function ($) {',
|
||||||
|
' var version = $.fn.jquery.split(\' \')[0].split(\'.\')',
|
||||||
|
' if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {',
|
||||||
|
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery version 1.9.1 or higher\')',
|
||||||
|
' }',
|
||||||
|
'}(jQuery);\n\n'
|
||||||
|
].join('\n'),
|
||||||
|
|
||||||
// Task configuration.
|
// Task configuration.
|
||||||
clean: {
|
clean: {
|
||||||
@ -93,7 +106,7 @@ module.exports = function (grunt) {
|
|||||||
|
|
||||||
concat: {
|
concat: {
|
||||||
options: {
|
options: {
|
||||||
banner: '<%= banner %>\n<%= jqueryCheck %>',
|
banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>',
|
||||||
stripBanners: false
|
stripBanners: false
|
||||||
},
|
},
|
||||||
bootstrap: {
|
bootstrap: {
|
||||||
|
@ -33,6 +33,6 @@
|
|||||||
"test-infra"
|
"test-infra"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jquery": ">= 1.9.0"
|
"jquery": ">= 1.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,19 @@ window.onload = function () { // wait for load in a dumb way because B-0
|
|||||||
|
|
||||||
function generateJS(preamble) {
|
function generateJS(preamble) {
|
||||||
var $checked = $('#plugin-section input:checked')
|
var $checked = $('#plugin-section input:checked')
|
||||||
var jqueryCheck = 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap\'s JavaScript requires jQuery") }\n\n'
|
var jqueryCheck = [
|
||||||
|
'if (typeof jQuery === \'undefined\') {',
|
||||||
|
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\')',
|
||||||
|
'}\n'
|
||||||
|
].join('\n')
|
||||||
|
var jqueryVersionCheck = [
|
||||||
|
'+function ($) {',
|
||||||
|
' var version = $.fn.jquery.split(\' \')[0].split(\'.\')',
|
||||||
|
' if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {',
|
||||||
|
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery version 1.9.1 or higher\')',
|
||||||
|
' }',
|
||||||
|
'}(jQuery);\n\n'
|
||||||
|
].join('\n')
|
||||||
|
|
||||||
if (!$checked.length) return false
|
if (!$checked.length) return false
|
||||||
|
|
||||||
@ -329,7 +341,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
|
|||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
preamble = cw + preamble
|
preamble = cw + preamble
|
||||||
js = jqueryCheck + js
|
js = jqueryCheck + jqueryVersionCheck + js
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'bootstrap.js': preamble + js,
|
'bootstrap.js': preamble + js,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user