Wrap JS
This will prevent leaking variables, and will remove the possibility of Select2 not working well with other plugins which support AMD loaders. The `define` and `require` methods are now aliased under `$.Select2.amd` for use inside additional files, such as translations.
This commit is contained in:
parent
8e70642b87
commit
afbf30d09a
33
Gruntfile.js
33
Gruntfile.js
@ -78,7 +78,8 @@ module.exports = function (grunt) {
|
||||
paths: {
|
||||
almond: '../../vendor/almond-0.2.9',
|
||||
jquery: 'jquery.shim'
|
||||
}
|
||||
},
|
||||
wrap: grunt.file.readJSON('src/js/banner.json')
|
||||
}
|
||||
},
|
||||
'dist.full': {
|
||||
@ -91,7 +92,8 @@ module.exports = function (grunt) {
|
||||
paths: {
|
||||
almond: '../../vendor/almond-0.2.9',
|
||||
jquery: '../../vendor/jquery-2.1.0'
|
||||
}
|
||||
},
|
||||
wrap: grunt.file.readJSON('src/js/banner.json')
|
||||
}
|
||||
},
|
||||
'amd': {
|
||||
@ -103,7 +105,8 @@ module.exports = function (grunt) {
|
||||
include: includes,
|
||||
paths: {
|
||||
jquery: 'empty:'
|
||||
}
|
||||
},
|
||||
wrap: grunt.file.readJSON('src/js/banner.json')
|
||||
}
|
||||
},
|
||||
'amd.full': {
|
||||
@ -115,27 +118,9 @@ module.exports = function (grunt) {
|
||||
include: fullIncludes,
|
||||
paths: {
|
||||
jquery: 'empty:'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
concat: {
|
||||
'dist': {
|
||||
src: [
|
||||
'src/js/start.js',
|
||||
'dist/js/select2.js',
|
||||
'src/js/end.js'
|
||||
],
|
||||
dest: 'dist/js/select2.js'
|
||||
},
|
||||
'dist.full': {
|
||||
src: [
|
||||
'src/js/start.js',
|
||||
'dist/js/select2.full.js',
|
||||
'src/js/end.js'
|
||||
],
|
||||
dest: 'dist/js/select2.full.js'
|
||||
wrap: grunt.file.readJSON('src/js/banner.json')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -174,7 +159,7 @@ module.exports = function (grunt) {
|
||||
|
||||
grunt.registerTask('default', ['compile', 'test', 'minify']);
|
||||
|
||||
grunt.registerTask('compile', ['requirejs', 'sass:dev', 'concat']);
|
||||
grunt.registerTask('compile', ['requirejs', 'sass:dev']);
|
||||
grunt.registerTask('minify', ['uglify', 'sass:dist']);
|
||||
grunt.registerTask('test', ['qunit', 'jshint']);
|
||||
};
|
||||
|
3
dist/js/select2.amd.full.js
vendored
3
dist/js/select2.amd.full.js
vendored
@ -1,4 +1,4 @@
|
||||
define('select2/utils',[], function () {
|
||||
(function() {define('select2/utils',[], function () {
|
||||
var Utils = {};
|
||||
|
||||
Utils.Extend = function (ChildClass, SuperClass) {
|
||||
@ -1674,3 +1674,4 @@ define('jquery.select2',[
|
||||
return Select2;
|
||||
});
|
||||
|
||||
require('jquery.select2'); $.Select2 = $.Select2 || {}; $.Select2.amd = { define: define };}());
|
3
dist/js/select2.amd.js
vendored
3
dist/js/select2.amd.js
vendored
@ -1,4 +1,4 @@
|
||||
define('select2/utils',[], function () {
|
||||
(function() {define('select2/utils',[], function () {
|
||||
var Utils = {};
|
||||
|
||||
Utils.Extend = function (ChildClass, SuperClass) {
|
||||
@ -1674,3 +1674,4 @@ define('jquery.select2',[
|
||||
return Select2;
|
||||
});
|
||||
|
||||
require('jquery.select2'); $.Select2 = $.Select2 || {}; $.Select2.amd = { define: define };}());
|
6
dist/js/select2.full.js
vendored
6
dist/js/select2.full.js
vendored
@ -1,5 +1,4 @@
|
||||
|
||||
/**
|
||||
(function() {/**
|
||||
* @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
|
||||
* Available via the MIT or new BSD license.
|
||||
* see: http://github.com/jrburke/almond for details
|
||||
@ -11210,5 +11209,4 @@ define('jquery.select2',[
|
||||
return Select2;
|
||||
});
|
||||
|
||||
|
||||
require('jquery.select2');
|
||||
require('jquery.select2'); $.Select2 = $.Select2 || {}; $.Select2.amd = { define: define };}());
|
8
dist/js/select2.full.min.js
vendored
8
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
6
dist/js/select2.js
vendored
6
dist/js/select2.js
vendored
@ -1,5 +1,4 @@
|
||||
|
||||
/**
|
||||
(function() {/**
|
||||
* @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
|
||||
* Available via the MIT or new BSD license.
|
||||
* see: http://github.com/jrburke/almond for details
|
||||
@ -2103,5 +2102,4 @@ define('jquery.select2',[
|
||||
return Select2;
|
||||
});
|
||||
|
||||
|
||||
require('jquery.select2');
|
||||
require('jquery.select2'); $.Select2 = $.Select2 || {}; $.Select2.amd = { define: define };}());
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
4
src/js/banner.json
Normal file
4
src/js/banner.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"start": "(function() {",
|
||||
"end": "require('jquery.select2'); $.Select2 = $.Select2 || {}; $.Select2.amd = { define: define, require: require };}());"
|
||||
}
|
Loading…
Reference in New Issue
Block a user