├── .gitignore ├── README.md ├── bower.json ├── LICENSE └── select2-shim.js /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # select2-es6-module-shim 2 | 3 | select2-es6-module-shim contains an ES6 module shim for select2 v4.0 4 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "select2-es6-module-shim", 3 | "version": "0.0.1", 4 | "authors": [ 5 | "pangratz " 6 | ], 7 | "description": "ES6 module shim for select2", 8 | "main": "select2-shim.js", 9 | "license": "MIT", 10 | "homepage": "https://github.com/pangratz/select2-es6-module-shim", 11 | "ignore": [ 12 | "**/.*", 13 | "node_modules", 14 | "bower_components", 15 | "test", 16 | "tests" 17 | ], 18 | "dependencies": { 19 | "select2": "~4.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Clemens Müller 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /select2-shim.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | /* globals define, jQuery */ 3 | 4 | function generateModule(name, values) { 5 | define(name, [], function() { 6 | 'use strict'; 7 | 8 | return values; 9 | }); 10 | } 11 | 12 | function camelCase(str) { 13 | return str.charAt(0).toUpperCase() + str.substr(1); 14 | } 15 | 16 | var shims = { 17 | 'select2': ['default:core', 'defaults', 'dropdown', 'options', 'results', 'utils'], 18 | 'select2/data': ['ajax', 'array', 'base', 'maximumInputLength', 'maximumSelectionLength', 'minimumInputLength', 'select', 'tags', 'tokenizer'], 19 | 'select2/dropdown': ['attachBody', 'attachContainer', 'closeOnSelect', 'hidePlaceholder', 'infiniteScroll', 'minimumResultsForSearch', 'search', 'selectOnClose'], 20 | 'select2/selection': ['allowClear', 'base', 'multiple', 'placeholder', 'search', 'single'] 21 | }; 22 | 23 | for (var moduleName in shims) { 24 | var values = {}; 25 | 26 | shims[moduleName].forEach(function(name) { 27 | var exportName = name; 28 | if (name.indexOf('default:') === 0) { 29 | name = name.slice('default:'.length); 30 | exportName = name; 31 | 32 | // export as default 33 | values['default'] = jQuery.fn.select2.amd.require(moduleName + '/' + name); 34 | } 35 | 36 | // export CamelCased version 37 | exportName = camelCase(exportName); 38 | values[exportName] = jQuery.fn.select2.amd.require(moduleName + '/' + name); 39 | }); 40 | 41 | generateModule(moduleName, values); 42 | } 43 | })(); 44 | --------------------------------------------------------------------------------