├── .bowerrc ├── .coveralls.yml ├── .gitignore ├── LICENSE ├── README.md ├── bower.json ├── demo ├── demo.all.js ├── demo.all.js.map ├── demo.all.min.js ├── demo.html ├── demo.js ├── demo.vue ├── issue7.all.js ├── issue7.html ├── issue7.js └── webpack.config.js ├── dist ├── vue-select.js ├── vue-select.js.map └── vue-select.min.js ├── gulpfile.js ├── karma.conf.js ├── package.json ├── screenshot.png ├── src ├── value-text-matcher.js └── vue-select.js ├── test └── specs │ ├── i18n │ └── zh-CN.json │ └── vue-select.js └── webpack.config.js /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "lib" 3 | } 4 | -------------------------------------------------------------------------------- /.coveralls.yml: -------------------------------------------------------------------------------- 1 | repo_token: fv7fpdRYNi8lFMhWQ9Ce9chRxyMrNa1ey -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /lib 2 | /coverage 3 | /node_modules 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Haixing Hu 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-select 2 | 3 | [![Build Status](https://circleci.com/gh/Haixing-Hu/vue-select/tree/master.svg?style=shield)](https://circleci.com/gh/Haixing-Hu/vue-select/tree/master) 4 | [![Coverage Status](https://coveralls.io/repos/Haixing-Hu/vue-select/badge.svg?branch=master&service=github)](https://coveralls.io/github/Haixing-Hu/vue-select?branch=master) 5 | [![bitHound Score](https://www.bithound.io/github/Haixing-Hu/vue-select/badges/score.svg)](https://www.bithound.io/github/Haixing-Hu/vue-select) 6 | [![Dependency Status](https://david-dm.org/Haixing-Hu/vue-select.svg)](https://david-dm.org/Haixing-Hu/vue-select) 7 | [![devDependency Status](https://david-dm.org/Haixing-Hu/vue-select/dev-status.svg)](https://david-dm.org/Haixing-Hu/vue-select#info=devDependencies) 8 | 9 | A Vue.js component implementing the select control with the [jQuery select2 plugin](https://github.com/select2/select2). 10 | 11 | # Demo 12 | 13 | The demo page is [HERE](http://haixing-hu.github.io/vue-select/demo.html). 14 | 15 | ![Screenshot](screenshot.png) 16 | 17 | # Requirements 18 | 19 | - [Vue.js](https://github.com/yyx990803/vue) `^1.0.24` 20 | - [JQuery](https://github.com/jquery/jquery) `^2.2.4` 21 | - [Select2](https://github.com/select2/select2) `^4.0.3` 22 | 23 | # Instllation 24 | 25 | ## npm 26 | 27 | ```shell 28 | $ npm install vue-select2 29 | ``` 30 | 31 | ## bower 32 | 33 | ```shell 34 | $ bower install vue-select 35 | ``` 36 | 37 | # Usage 38 | 39 | The HTML snippets are as follows: 40 | 41 | ```html 42 |
43 |
44 |
45 | 48 |
49 | 50 | 51 |
52 |
53 |

54 | Selected Result: {{result1}} 55 |

56 |
57 |
58 |
59 | 62 |
63 | 66 | 67 |
68 |
69 |

70 | Selected Result: {{result2}} 71 |

72 |
73 |
74 |
75 | 78 |
79 | 82 | 83 |
84 |
85 |

86 | Selected Result: {{result3}} 87 |

88 |
89 |
90 |
91 |
92 | ``` 93 | 94 | The Javascript snippets are as follows: 95 | 96 | ```javascript 97 | var vm = new Vue({ 98 | el: "#app", 99 | components: { 100 | "vue-select": require("vue-select") 101 | }, 102 | data: { 103 | options1: [ 104 | "value1", 105 | "value2", 106 | "value3" 107 | ], 108 | options2: [{ 109 | text: "name1", 110 | value: "value1" 111 | }, { 112 | text: "name2", 113 | value: "value2" 114 | }, { 115 | text: "name3", 116 | value: "value3" 117 | }], 118 | options3: [{ 119 | label: "group1", 120 | options: [{ 121 | text: "name1", 122 | value: "value1" 123 | }, { 124 | text: "name2", 125 | value: "value2" 126 | }, { 127 | text: "name3", 128 | value: "value3" 129 | }] 130 | }, { 131 | label: "group2", 132 | options: [{ 133 | text: "name4", 134 | value: "value4" 135 | }, { 136 | text: "name5", 137 | value: "value5" 138 | }, { 139 | text: "name6", 140 | value: "value6" 141 | }] 142 | }], 143 | result1: "", 144 | result2: "", 145 | result3: "" 146 | } 147 | }); 148 | ``` 149 | 150 | # Component Properties 151 | 152 | ## `options` 153 | 154 | The array of options of the selection control. It could be 155 | 156 | - an array of strings, e.g., `['opt1', 'opt2']`; or 157 | - an array of objects specifying the text and value of each option, e.g., 158 | `[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]`; or 159 | - an array of objects specifying the option group, e.g. 160 | ``` 161 | [{ 162 | label: 'group1', 163 | options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}] 164 | }, { 165 | label: 'group2', 166 | options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}] 167 | }] 168 | ``` 169 | 170 | ## `model` 171 | 172 | The model bind to the control, which must be a two way binding variable. 173 | 174 | Note that the value of model could be set to `null`, and in that case the 175 | selection will be set to nothing. Also, if the selection is set to nothing 176 | (that is, the user delete the text in the input box of the selector), the 177 | value of the model will be set to `null` instead of an empty string. 178 | 179 | ## `searchable` 180 | 181 | The optional flag indicates whether to show the search box. The default value is 182 | false. 183 | 184 | ## `multiple` 185 | 186 | The optional flag indicates whether to use a multiple select control. The default 187 | value is false. 188 | 189 | ## `language` 190 | 191 | The optional code of language used by the 192 | [select2](https://github.com/select2/select2) plugin. 193 | 194 | The supported languages are exactly the same as the supported languages of the 195 | [select2](https://github.com/select2/select2) plugin. In order to use the 196 | supported language, you must also include the corresponding "i18n" js file of 197 | the [select2](https://github.com/select2/select2) plugin in your HTML file. 198 | 199 | Note that the language code passed to this property could be a locale code 200 | consists of a language code and a country code, e.g., `"en-US"`. The component 201 | will automatically convert the locale code to the language code supported by 202 | the [select2](https://github.com/select2/select2) plugin. Since some languages 203 | have different variants in different country or region, e.g., `"zh-CN"` for the 204 | simplified Chinese and `"zh-TW"` for the traditional Chinese, it's recommended 205 | to use the locale code in the form of `"[language]-[country]"`. 206 | 207 | If this property is not set, and the [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) 208 | plugin is used, the component will use the language code `$language` provided 209 | by the [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin; otherwise, the 210 | component will use the default value `"en-US"`. 211 | 212 | ## `theme` 213 | 214 | The optional name of the theme of the [select2](https://github.com/select2/select2) 215 | plugin. Default value is `'bootstrap'`. 216 | 217 | Note that in order to use the bootstrap theme, you must include the CSS file 218 | from the [select2-bootstrap-theme](https://github.com/select2/select2-bootstrap-theme/) project. 219 | And it's very important that the above CSS file must be included AFTER the 220 | CSS file of the bootstrap. 221 | 222 | The following is the correct order for including CSS files: 223 | 224 | ```html 225 | 226 | 227 | 228 | ``` 229 | 230 | Check the [demo page](http://haixing-hu.github.io/vue-select/demo.html) for details. 231 | 232 | ## `name` 233 | 234 | The optional name of the selection control. 235 | 236 | # API 237 | 238 | ## `control` 239 | 240 | This property is a reference to the JQuery selection of the base select 241 | control. It could be used to call the APIs of 242 | [select2](https://github.com/select2/select2) plugin. For example, 243 | `select.control.val(val)` will set the value of the select to the 244 | specified value, where `select` is the reference to the `vue-select` 245 | component. 246 | 247 | # Contributing 248 | 249 | - Fork it ! 250 | - Create your top branch from `dev`: `git branch my-new-topic origin/dev` 251 | - Commit your changes: `git commit -am 'Add some topic'` 252 | - Push to the branch: `git push origin my-new-topic` 253 | - Submit a pull request to `dev` branch of `Haixing-Hu/vue-select` repository ! 254 | 255 | # Building and Testing 256 | 257 | First you should install all depended NPM packages. The NPM packages are used 258 | for building and testing this package. 259 | 260 | ```shell 261 | $ npm install 262 | ``` 263 | 264 | Then install all depended bower packages. The bower packages are depended by 265 | this packages. 266 | 267 | ```shell 268 | $ bower install 269 | ``` 270 | 271 | Now you can build the project. 272 | ```shell 273 | $ gulp build 274 | ``` 275 | 276 | The following command will test the project. 277 | ```shell 278 | $ gulp test 279 | ``` 280 | 281 | The following command will perform the test and generate a coverage report. 282 | ```shell 283 | $ gulp test:coverage 284 | ``` 285 | 286 | The following command will perform the test, generate a coverage report, and 287 | upload the coverage report to [coveralls.io](https://coveralls.io/). 288 | ```shell 289 | $ gulp test:coveralls 290 | ``` 291 | 292 | You can also run `bower install` and `gulp build` together with the following 293 | command: 294 | ```shell 295 | npm run build 296 | ``` 297 | 298 | Or run `bower install` and `gulp test:coveralls` together with the following 299 | command: 300 | ```shell 301 | npm run test 302 | ``` 303 | 304 | # License 305 | 306 | [The MIT License](http://opensource.org/licenses/MIT) 307 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-select", 3 | "description": "A Vue.js component implementing the select control with the jQuery select2 plugin.", 4 | "version": "0.3.1", 5 | "keywords": [ 6 | "Vue.js", 7 | "component", 8 | "select", 9 | "jquery.select2" 10 | ], 11 | "authors": [ 12 | "Haixing Hu" 13 | ], 14 | "homepage": "https://github.com/Haixing-Hu/vue-select", 15 | "license": "MIT", 16 | "repository": { 17 | "type": "git", 18 | "url": "git@github.com:Haixing-Hu/vue-select.git" 19 | }, 20 | "main": [ 21 | "src/vue-select.js" 22 | ], 23 | "ignore": [ 24 | "lib", 25 | "coverage", 26 | "node_modules" 27 | ], 28 | "dependencies": { 29 | "vue": "^1.0.24", 30 | "select2": "^4.0.3" 31 | }, 32 | "devDependencies": { 33 | "bootstrap": "^3.3.6", 34 | "jquery": "^2.2.4", 35 | "select2-bootstrap-theme": "^0.1.0-beta.7", 36 | "vue-i18n-plugin": "^0.2.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demo/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Demo of vue-select 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Demo of vue-select

14 |
15 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /demo/demo.js: -------------------------------------------------------------------------------- 1 | var Vue = require("vue"); 2 | 3 | var vm = new Vue({ 4 | components: { 5 | "demo": require("./demo.vue") 6 | }, 7 | data: { 8 | result1: null, 9 | result2: "value2", 10 | result3: "value6", 11 | result4: ["value1", "value2"] 12 | } 13 | }); 14 | 15 | vm.$mount("#app"); 16 | -------------------------------------------------------------------------------- /demo/demo.vue: -------------------------------------------------------------------------------- 1 | 69 | 70 | -------------------------------------------------------------------------------- /demo/issue7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Demo of vue-select 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Demo of Issue #7

14 |
15 |
16 |
17 |
18 |

19 | Selected: {{val}} 20 |

21 |
22 |
23 |
24 |
25 | 26 | 27 |
28 |
29 |
30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /demo/issue7.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import VueSelect from "../src/vue-select.js"; 3 | 4 | var vm = new Vue({ 5 | components: { 6 | "vue-select": VueSelect 7 | }, 8 | data: { 9 | opt: ['foo','bar','baz', 'yep'], 10 | val: "foo" 11 | } 12 | }); 13 | 14 | vm.$mount("#app"); 15 | -------------------------------------------------------------------------------- /demo/webpack.config.js: -------------------------------------------------------------------------------- 1 | // Configuration file of webpack 2 | var path = require("path"); 3 | var webpack = require("webpack"); 4 | var BowerWebpackPlugin = require("bower-webpack-plugin"); 5 | var pkg = require("../package.json"); 6 | var dirs = pkg.configs.directories; 7 | var version = process.env.VERSION || pkg.version; 8 | var banner = pkg.name + " v" + version + "\n" + 9 | "(c) " + new Date().getFullYear() + 10 | " " + pkg.author.name + "\n" + 11 | "Released under the " + pkg.license + " License."; 12 | var VueLoader = require('vue-loader'); 13 | 14 | module.exports = { 15 | entry: { 16 | "demo": path.join(__dirname, "demo.js"), 17 | "issue7": path.join(__dirname, "issue7.js"), 18 | }, 19 | module: { 20 | loaders: [ 21 | { test: /\.vue$/, loader: "vue" }, 22 | { 23 | test: /\.js$/, 24 | // excluding some local linked packages. 25 | // for normal use cases only node_modules is needed. 26 | exclude: /node_modules|vue\/dist|vue-router\/|vue-loader\/|vue-hot-reload-api\//, 27 | loader: 'babel' 28 | } 29 | ] 30 | }, 31 | vue: { 32 | loaders: { 33 | html: "raw" // use raw-loader to process HTML 34 | } 35 | }, 36 | babel: { 37 | presets: ['es2015'], 38 | plugins: ['transform-runtime'] 39 | }, 40 | resolve: { 41 | root: [__dirname], 42 | modulesDirectories: [ "lib" ] 43 | }, 44 | plugins: [ 45 | // new webpack.optimize.DedupePlugin(), 46 | new BowerWebpackPlugin({ 47 | modulesDirectories: [ "lib" ], 48 | manifestFiles: "bower.json", 49 | includes: /.*/, 50 | excludes: [], 51 | searchResolveModulesDirectories: true 52 | }), 53 | new webpack.BannerPlugin(banner) 54 | ], 55 | output: { 56 | path: __dirname, 57 | filename: "[name].all.js", 58 | sourceMapFilename: "[file].map" 59 | }, 60 | }; 61 | -------------------------------------------------------------------------------- /dist/vue-select.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * vue-select2 v0.2.6 3 | * (c) 2016 Haixing Hu 4 | * Released under the MIT License. 5 | */ 6 | /******/ (function(modules) { // webpackBootstrap 7 | /******/ // The module cache 8 | /******/ var installedModules = {}; 9 | /******/ 10 | /******/ // The require function 11 | /******/ function __webpack_require__(moduleId) { 12 | /******/ 13 | /******/ // Check if module is in cache 14 | /******/ if(installedModules[moduleId]) 15 | /******/ return installedModules[moduleId].exports; 16 | /******/ 17 | /******/ // Create a new module (and put it into the cache) 18 | /******/ var module = installedModules[moduleId] = { 19 | /******/ exports: {}, 20 | /******/ id: moduleId, 21 | /******/ loaded: false 22 | /******/ }; 23 | /******/ 24 | /******/ // Execute the module function 25 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 26 | /******/ 27 | /******/ // Flag the module as loaded 28 | /******/ module.loaded = true; 29 | /******/ 30 | /******/ // Return the exports of the module 31 | /******/ return module.exports; 32 | /******/ } 33 | /******/ 34 | /******/ 35 | /******/ // expose the modules object (__webpack_modules__) 36 | /******/ __webpack_require__.m = modules; 37 | /******/ 38 | /******/ // expose the module cache 39 | /******/ __webpack_require__.c = installedModules; 40 | /******/ 41 | /******/ // __webpack_public_path__ 42 | /******/ __webpack_require__.p = ""; 43 | /******/ 44 | /******/ // Load entry module and return exports 45 | /******/ return __webpack_require__(0); 46 | /******/ }) 47 | /************************************************************************/ 48 | /******/ ([ 49 | /* 0 */ 50 | /***/ function(module, exports, __webpack_require__) { 51 | 52 | /** 53 | * The default language used by this component. 54 | */ 55 | var DEFAULT_LANGUAGE = "en-US"; 56 | 57 | /** 58 | * A bootstrap style selection (combobox) control using the select2 plugin. 59 | * 60 | * @param options 61 | * the array of options of the selection control. It could be an array of 62 | * strings, e.g., "['opt1', 'opt2']"; or an array of objects specifying 63 | * the text and value of each option, e.g., 64 | * "[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]"; 65 | * or it could be an array of objects specifying the option group, e.g. 66 | * "[{label: 'group1', options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]}, 67 | * {label: 'group2', options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}]}]". 68 | * @param model 69 | * the model bind to the control, which must be a two way binding variable. 70 | * @param searchable 71 | * the optional flag indicates whether to show the search box. Default value 72 | * is false. 73 | * @param matchValue 74 | * the optional flag indicates whether the searching should match both the 75 | * texts and values of options. Default value is true. 76 | * @param language 77 | * the optional code of language used by the select2 plugin. If it is not set, 78 | * and the [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin is used, 79 | * the component will use the language code `$language` provided by the 80 | * [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin; otherwise, the 81 | * component will use the default value "en-US". 82 | * @param theme 83 | * the optional name of the theme of the select2. Default value is "bootstrap". 84 | * @param name 85 | * the optional name of the selection control. 86 | * @author Haixing Hu 87 | */ 88 | module.exports = { 89 | replace: true, 90 | inherit: false, 91 | template: "", 98 | props: { 99 | options: { 100 | type: Array, 101 | required: true 102 | }, 103 | model: { 104 | required: true, 105 | twoWay: true 106 | }, 107 | searchable: { 108 | type: Boolean, 109 | required: false, 110 | default: false 111 | }, 112 | matchValue: { 113 | type: Boolean, 114 | required: false, 115 | default: true 116 | }, 117 | name: { 118 | type: String, 119 | required: false, 120 | default: "" 121 | }, 122 | language: { 123 | type: String, 124 | required: false, 125 | default: "" 126 | }, 127 | theme: { 128 | type: String, 129 | required: false, 130 | default: "bootstrap" 131 | } 132 | }, 133 | data: function() { 134 | return { 135 | optionsType: "unknown" 136 | } 137 | }, 138 | beforeCompile: function() { 139 | this.isChanging = false; 140 | this.control = null; 141 | this.optionsType = this.getOptionsType(); 142 | }, 143 | watch: { 144 | "options": function(val, oldVal) { 145 | //console.debug("options.change"); 146 | this.optionsType = this.getOptionsType(); 147 | var found = this.inOptions(this.model); 148 | var newValue = (found ? this.model : null); 149 | this.control.removeData("data"); // remove the cached options data 150 | // note that setting the model will automatically changed in the "change" 151 | // event of the select2 control 152 | this.control.val(newValue).trigger("change"); 153 | }, 154 | "model": function(val, oldVal) { 155 | //console.debug("model.change"); 156 | if (! this.isChanging) { 157 | this.isChanging = true; 158 | this.control.val(val).trigger("change"); 159 | this.isChanging = false; 160 | } 161 | } 162 | }, 163 | ready: function() { 164 | var language = this.language; 165 | if (language === null || language === "") { 166 | if (this.$language) { 167 | language = this.$language; 168 | } else { 169 | language = DEFAULT_LANGUAGE; 170 | } 171 | } 172 | var args = { 173 | theme: this.theme, 174 | language: this.getLanguageCode(language) 175 | }; 176 | if (! this.searchable) { 177 | args.minimumResultsForSearch = Infinity; // hide the search box 178 | } else { 179 | if (this.matchValue) { 180 | args.matcher = __webpack_require__(1); 181 | } 182 | } 183 | this.control = $(this.$el); 184 | this.control.select2(args); 185 | var me = this; 186 | this.control.on("change", function(e) { 187 | //console.debug("control.change"); 188 | if (! me.isChanging) { 189 | me.isChanging = true; 190 | me.model = me.control.val(); 191 | me.$nextTick(function () { 192 | me.isChanging = false; 193 | }); 194 | } 195 | }); 196 | }, 197 | methods: { 198 | 199 | /** 200 | * Gets the type of the `options` property of this component. 201 | * 202 | * The `options` property of this component may have the following types: 203 | * - "values": the `options` is an array of strings, e.g., `[value1, value2, value3]`; 204 | * - "options": the `options` is an array of options, e.g., `[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]`; 205 | * - "groups": the `options` is an array of option groups, e.g., 206 | * `[{label: 'group1', options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]}, 207 | * {label: 'group2', options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}]}]`; 208 | * 209 | * @param options 210 | * the new options. 211 | * @return 212 | * the string representing the type of the `options` property of this 213 | * component. 214 | */ 215 | getOptionsType: function() { 216 | if (this.options.length === 0) { 217 | return "values"; 218 | } 219 | var el = this.options[0]; 220 | if (typeof el == "string" || el instanceof String) { 221 | return "values"; 222 | } else if (typeof el.text !== "undefined") { 223 | return "options"; 224 | } else if (typeof el.label !== "undefined") { 225 | return "groups"; 226 | } else { 227 | return "unknown"; 228 | } 229 | }, 230 | 231 | /** 232 | * Tests whether a specified value exists in the options. 233 | * 234 | * @param value 235 | * the value to test. 236 | * @return 237 | * true if the specified value exists in the options; false otherwise. 238 | */ 239 | inOptions: function(value) { 240 | var type = this.getOptionsType(); 241 | var list = this.options; 242 | var i, j; 243 | switch (type) { 244 | case "values": 245 | for (i = 0; i < list.length; ++i) { 246 | if (value === list[i]) { 247 | return true; 248 | } 249 | } 250 | break; 251 | case "options": 252 | for (i = 0; i < list.length; ++i) { 253 | if (value === list[i].value) { 254 | return true; 255 | } 256 | } 257 | break; 258 | case "groups": 259 | for (i = 0; i < list.length; ++i) { 260 | var options = list[i].options; 261 | for (j = 0; j < options.length; ++j) { 262 | if (value === options[j].value) { 263 | return true; 264 | } 265 | } 266 | } 267 | break; 268 | default: 269 | break; 270 | } 271 | return false; 272 | }, 273 | 274 | /** 275 | * Gets the language code from the "language-country" locale code. 276 | * 277 | * The function will strip the language code before the first "-" of a 278 | * locale code. For example, pass "en-US" will returns "en". But for some 279 | * special locales, the function reserves the locale code. For example, 280 | * the "zh-CN" for the simplified Chinese and the "zh-TW" for the 281 | * traditional Chinese. 282 | * 283 | * @param locale 284 | * A locale code. 285 | * @return 286 | * the language code of the locale. 287 | */ 288 | getLanguageCode: function(locale) { 289 | if (locale === null || locale.length === 0) { 290 | return "en"; 291 | } 292 | if (locale.length <= 2) { 293 | return locale; 294 | } else { 295 | switch (locale) { 296 | case "pt-BR": 297 | case "zh-CN": 298 | case "zh-TW": 299 | return locale; 300 | default: 301 | // reserve only the first two letters language code 302 | return locale.substr(0, 2); 303 | } 304 | } 305 | } 306 | } 307 | }; 308 | 309 | 310 | /***/ }, 311 | /* 1 */ 312 | /***/ function(module, exports) { 313 | 314 | 315 | var DIACRITICS = { 316 | '\u24B6': 'A', 317 | '\uFF21': 'A', 318 | '\u00C0': 'A', 319 | '\u00C1': 'A', 320 | '\u00C2': 'A', 321 | '\u1EA6': 'A', 322 | '\u1EA4': 'A', 323 | '\u1EAA': 'A', 324 | '\u1EA8': 'A', 325 | '\u00C3': 'A', 326 | '\u0100': 'A', 327 | '\u0102': 'A', 328 | '\u1EB0': 'A', 329 | '\u1EAE': 'A', 330 | '\u1EB4': 'A', 331 | '\u1EB2': 'A', 332 | '\u0226': 'A', 333 | '\u01E0': 'A', 334 | '\u00C4': 'A', 335 | '\u01DE': 'A', 336 | '\u1EA2': 'A', 337 | '\u00C5': 'A', 338 | '\u01FA': 'A', 339 | '\u01CD': 'A', 340 | '\u0200': 'A', 341 | '\u0202': 'A', 342 | '\u1EA0': 'A', 343 | '\u1EAC': 'A', 344 | '\u1EB6': 'A', 345 | '\u1E00': 'A', 346 | '\u0104': 'A', 347 | '\u023A': 'A', 348 | '\u2C6F': 'A', 349 | '\uA732': 'AA', 350 | '\u00C6': 'AE', 351 | '\u01FC': 'AE', 352 | '\u01E2': 'AE', 353 | '\uA734': 'AO', 354 | '\uA736': 'AU', 355 | '\uA738': 'AV', 356 | '\uA73A': 'AV', 357 | '\uA73C': 'AY', 358 | '\u24B7': 'B', 359 | '\uFF22': 'B', 360 | '\u1E02': 'B', 361 | '\u1E04': 'B', 362 | '\u1E06': 'B', 363 | '\u0243': 'B', 364 | '\u0182': 'B', 365 | '\u0181': 'B', 366 | '\u24B8': 'C', 367 | '\uFF23': 'C', 368 | '\u0106': 'C', 369 | '\u0108': 'C', 370 | '\u010A': 'C', 371 | '\u010C': 'C', 372 | '\u00C7': 'C', 373 | '\u1E08': 'C', 374 | '\u0187': 'C', 375 | '\u023B': 'C', 376 | '\uA73E': 'C', 377 | '\u24B9': 'D', 378 | '\uFF24': 'D', 379 | '\u1E0A': 'D', 380 | '\u010E': 'D', 381 | '\u1E0C': 'D', 382 | '\u1E10': 'D', 383 | '\u1E12': 'D', 384 | '\u1E0E': 'D', 385 | '\u0110': 'D', 386 | '\u018B': 'D', 387 | '\u018A': 'D', 388 | '\u0189': 'D', 389 | '\uA779': 'D', 390 | '\u01F1': 'DZ', 391 | '\u01C4': 'DZ', 392 | '\u01F2': 'Dz', 393 | '\u01C5': 'Dz', 394 | '\u24BA': 'E', 395 | '\uFF25': 'E', 396 | '\u00C8': 'E', 397 | '\u00C9': 'E', 398 | '\u00CA': 'E', 399 | '\u1EC0': 'E', 400 | '\u1EBE': 'E', 401 | '\u1EC4': 'E', 402 | '\u1EC2': 'E', 403 | '\u1EBC': 'E', 404 | '\u0112': 'E', 405 | '\u1E14': 'E', 406 | '\u1E16': 'E', 407 | '\u0114': 'E', 408 | '\u0116': 'E', 409 | '\u00CB': 'E', 410 | '\u1EBA': 'E', 411 | '\u011A': 'E', 412 | '\u0204': 'E', 413 | '\u0206': 'E', 414 | '\u1EB8': 'E', 415 | '\u1EC6': 'E', 416 | '\u0228': 'E', 417 | '\u1E1C': 'E', 418 | '\u0118': 'E', 419 | '\u1E18': 'E', 420 | '\u1E1A': 'E', 421 | '\u0190': 'E', 422 | '\u018E': 'E', 423 | '\u24BB': 'F', 424 | '\uFF26': 'F', 425 | '\u1E1E': 'F', 426 | '\u0191': 'F', 427 | '\uA77B': 'F', 428 | '\u24BC': 'G', 429 | '\uFF27': 'G', 430 | '\u01F4': 'G', 431 | '\u011C': 'G', 432 | '\u1E20': 'G', 433 | '\u011E': 'G', 434 | '\u0120': 'G', 435 | '\u01E6': 'G', 436 | '\u0122': 'G', 437 | '\u01E4': 'G', 438 | '\u0193': 'G', 439 | '\uA7A0': 'G', 440 | '\uA77D': 'G', 441 | '\uA77E': 'G', 442 | '\u24BD': 'H', 443 | '\uFF28': 'H', 444 | '\u0124': 'H', 445 | '\u1E22': 'H', 446 | '\u1E26': 'H', 447 | '\u021E': 'H', 448 | '\u1E24': 'H', 449 | '\u1E28': 'H', 450 | '\u1E2A': 'H', 451 | '\u0126': 'H', 452 | '\u2C67': 'H', 453 | '\u2C75': 'H', 454 | '\uA78D': 'H', 455 | '\u24BE': 'I', 456 | '\uFF29': 'I', 457 | '\u00CC': 'I', 458 | '\u00CD': 'I', 459 | '\u00CE': 'I', 460 | '\u0128': 'I', 461 | '\u012A': 'I', 462 | '\u012C': 'I', 463 | '\u0130': 'I', 464 | '\u00CF': 'I', 465 | '\u1E2E': 'I', 466 | '\u1EC8': 'I', 467 | '\u01CF': 'I', 468 | '\u0208': 'I', 469 | '\u020A': 'I', 470 | '\u1ECA': 'I', 471 | '\u012E': 'I', 472 | '\u1E2C': 'I', 473 | '\u0197': 'I', 474 | '\u24BF': 'J', 475 | '\uFF2A': 'J', 476 | '\u0134': 'J', 477 | '\u0248': 'J', 478 | '\u24C0': 'K', 479 | '\uFF2B': 'K', 480 | '\u1E30': 'K', 481 | '\u01E8': 'K', 482 | '\u1E32': 'K', 483 | '\u0136': 'K', 484 | '\u1E34': 'K', 485 | '\u0198': 'K', 486 | '\u2C69': 'K', 487 | '\uA740': 'K', 488 | '\uA742': 'K', 489 | '\uA744': 'K', 490 | '\uA7A2': 'K', 491 | '\u24C1': 'L', 492 | '\uFF2C': 'L', 493 | '\u013F': 'L', 494 | '\u0139': 'L', 495 | '\u013D': 'L', 496 | '\u1E36': 'L', 497 | '\u1E38': 'L', 498 | '\u013B': 'L', 499 | '\u1E3C': 'L', 500 | '\u1E3A': 'L', 501 | '\u0141': 'L', 502 | '\u023D': 'L', 503 | '\u2C62': 'L', 504 | '\u2C60': 'L', 505 | '\uA748': 'L', 506 | '\uA746': 'L', 507 | '\uA780': 'L', 508 | '\u01C7': 'LJ', 509 | '\u01C8': 'Lj', 510 | '\u24C2': 'M', 511 | '\uFF2D': 'M', 512 | '\u1E3E': 'M', 513 | '\u1E40': 'M', 514 | '\u1E42': 'M', 515 | '\u2C6E': 'M', 516 | '\u019C': 'M', 517 | '\u24C3': 'N', 518 | '\uFF2E': 'N', 519 | '\u01F8': 'N', 520 | '\u0143': 'N', 521 | '\u00D1': 'N', 522 | '\u1E44': 'N', 523 | '\u0147': 'N', 524 | '\u1E46': 'N', 525 | '\u0145': 'N', 526 | '\u1E4A': 'N', 527 | '\u1E48': 'N', 528 | '\u0220': 'N', 529 | '\u019D': 'N', 530 | '\uA790': 'N', 531 | '\uA7A4': 'N', 532 | '\u01CA': 'NJ', 533 | '\u01CB': 'Nj', 534 | '\u24C4': 'O', 535 | '\uFF2F': 'O', 536 | '\u00D2': 'O', 537 | '\u00D3': 'O', 538 | '\u00D4': 'O', 539 | '\u1ED2': 'O', 540 | '\u1ED0': 'O', 541 | '\u1ED6': 'O', 542 | '\u1ED4': 'O', 543 | '\u00D5': 'O', 544 | '\u1E4C': 'O', 545 | '\u022C': 'O', 546 | '\u1E4E': 'O', 547 | '\u014C': 'O', 548 | '\u1E50': 'O', 549 | '\u1E52': 'O', 550 | '\u014E': 'O', 551 | '\u022E': 'O', 552 | '\u0230': 'O', 553 | '\u00D6': 'O', 554 | '\u022A': 'O', 555 | '\u1ECE': 'O', 556 | '\u0150': 'O', 557 | '\u01D1': 'O', 558 | '\u020C': 'O', 559 | '\u020E': 'O', 560 | '\u01A0': 'O', 561 | '\u1EDC': 'O', 562 | '\u1EDA': 'O', 563 | '\u1EE0': 'O', 564 | '\u1EDE': 'O', 565 | '\u1EE2': 'O', 566 | '\u1ECC': 'O', 567 | '\u1ED8': 'O', 568 | '\u01EA': 'O', 569 | '\u01EC': 'O', 570 | '\u00D8': 'O', 571 | '\u01FE': 'O', 572 | '\u0186': 'O', 573 | '\u019F': 'O', 574 | '\uA74A': 'O', 575 | '\uA74C': 'O', 576 | '\u01A2': 'OI', 577 | '\uA74E': 'OO', 578 | '\u0222': 'OU', 579 | '\u24C5': 'P', 580 | '\uFF30': 'P', 581 | '\u1E54': 'P', 582 | '\u1E56': 'P', 583 | '\u01A4': 'P', 584 | '\u2C63': 'P', 585 | '\uA750': 'P', 586 | '\uA752': 'P', 587 | '\uA754': 'P', 588 | '\u24C6': 'Q', 589 | '\uFF31': 'Q', 590 | '\uA756': 'Q', 591 | '\uA758': 'Q', 592 | '\u024A': 'Q', 593 | '\u24C7': 'R', 594 | '\uFF32': 'R', 595 | '\u0154': 'R', 596 | '\u1E58': 'R', 597 | '\u0158': 'R', 598 | '\u0210': 'R', 599 | '\u0212': 'R', 600 | '\u1E5A': 'R', 601 | '\u1E5C': 'R', 602 | '\u0156': 'R', 603 | '\u1E5E': 'R', 604 | '\u024C': 'R', 605 | '\u2C64': 'R', 606 | '\uA75A': 'R', 607 | '\uA7A6': 'R', 608 | '\uA782': 'R', 609 | '\u24C8': 'S', 610 | '\uFF33': 'S', 611 | '\u1E9E': 'S', 612 | '\u015A': 'S', 613 | '\u1E64': 'S', 614 | '\u015C': 'S', 615 | '\u1E60': 'S', 616 | '\u0160': 'S', 617 | '\u1E66': 'S', 618 | '\u1E62': 'S', 619 | '\u1E68': 'S', 620 | '\u0218': 'S', 621 | '\u015E': 'S', 622 | '\u2C7E': 'S', 623 | '\uA7A8': 'S', 624 | '\uA784': 'S', 625 | '\u24C9': 'T', 626 | '\uFF34': 'T', 627 | '\u1E6A': 'T', 628 | '\u0164': 'T', 629 | '\u1E6C': 'T', 630 | '\u021A': 'T', 631 | '\u0162': 'T', 632 | '\u1E70': 'T', 633 | '\u1E6E': 'T', 634 | '\u0166': 'T', 635 | '\u01AC': 'T', 636 | '\u01AE': 'T', 637 | '\u023E': 'T', 638 | '\uA786': 'T', 639 | '\uA728': 'TZ', 640 | '\u24CA': 'U', 641 | '\uFF35': 'U', 642 | '\u00D9': 'U', 643 | '\u00DA': 'U', 644 | '\u00DB': 'U', 645 | '\u0168': 'U', 646 | '\u1E78': 'U', 647 | '\u016A': 'U', 648 | '\u1E7A': 'U', 649 | '\u016C': 'U', 650 | '\u00DC': 'U', 651 | '\u01DB': 'U', 652 | '\u01D7': 'U', 653 | '\u01D5': 'U', 654 | '\u01D9': 'U', 655 | '\u1EE6': 'U', 656 | '\u016E': 'U', 657 | '\u0170': 'U', 658 | '\u01D3': 'U', 659 | '\u0214': 'U', 660 | '\u0216': 'U', 661 | '\u01AF': 'U', 662 | '\u1EEA': 'U', 663 | '\u1EE8': 'U', 664 | '\u1EEE': 'U', 665 | '\u1EEC': 'U', 666 | '\u1EF0': 'U', 667 | '\u1EE4': 'U', 668 | '\u1E72': 'U', 669 | '\u0172': 'U', 670 | '\u1E76': 'U', 671 | '\u1E74': 'U', 672 | '\u0244': 'U', 673 | '\u24CB': 'V', 674 | '\uFF36': 'V', 675 | '\u1E7C': 'V', 676 | '\u1E7E': 'V', 677 | '\u01B2': 'V', 678 | '\uA75E': 'V', 679 | '\u0245': 'V', 680 | '\uA760': 'VY', 681 | '\u24CC': 'W', 682 | '\uFF37': 'W', 683 | '\u1E80': 'W', 684 | '\u1E82': 'W', 685 | '\u0174': 'W', 686 | '\u1E86': 'W', 687 | '\u1E84': 'W', 688 | '\u1E88': 'W', 689 | '\u2C72': 'W', 690 | '\u24CD': 'X', 691 | '\uFF38': 'X', 692 | '\u1E8A': 'X', 693 | '\u1E8C': 'X', 694 | '\u24CE': 'Y', 695 | '\uFF39': 'Y', 696 | '\u1EF2': 'Y', 697 | '\u00DD': 'Y', 698 | '\u0176': 'Y', 699 | '\u1EF8': 'Y', 700 | '\u0232': 'Y', 701 | '\u1E8E': 'Y', 702 | '\u0178': 'Y', 703 | '\u1EF6': 'Y', 704 | '\u1EF4': 'Y', 705 | '\u01B3': 'Y', 706 | '\u024E': 'Y', 707 | '\u1EFE': 'Y', 708 | '\u24CF': 'Z', 709 | '\uFF3A': 'Z', 710 | '\u0179': 'Z', 711 | '\u1E90': 'Z', 712 | '\u017B': 'Z', 713 | '\u017D': 'Z', 714 | '\u1E92': 'Z', 715 | '\u1E94': 'Z', 716 | '\u01B5': 'Z', 717 | '\u0224': 'Z', 718 | '\u2C7F': 'Z', 719 | '\u2C6B': 'Z', 720 | '\uA762': 'Z', 721 | '\u24D0': 'a', 722 | '\uFF41': 'a', 723 | '\u1E9A': 'a', 724 | '\u00E0': 'a', 725 | '\u00E1': 'a', 726 | '\u00E2': 'a', 727 | '\u1EA7': 'a', 728 | '\u1EA5': 'a', 729 | '\u1EAB': 'a', 730 | '\u1EA9': 'a', 731 | '\u00E3': 'a', 732 | '\u0101': 'a', 733 | '\u0103': 'a', 734 | '\u1EB1': 'a', 735 | '\u1EAF': 'a', 736 | '\u1EB5': 'a', 737 | '\u1EB3': 'a', 738 | '\u0227': 'a', 739 | '\u01E1': 'a', 740 | '\u00E4': 'a', 741 | '\u01DF': 'a', 742 | '\u1EA3': 'a', 743 | '\u00E5': 'a', 744 | '\u01FB': 'a', 745 | '\u01CE': 'a', 746 | '\u0201': 'a', 747 | '\u0203': 'a', 748 | '\u1EA1': 'a', 749 | '\u1EAD': 'a', 750 | '\u1EB7': 'a', 751 | '\u1E01': 'a', 752 | '\u0105': 'a', 753 | '\u2C65': 'a', 754 | '\u0250': 'a', 755 | '\uA733': 'aa', 756 | '\u00E6': 'ae', 757 | '\u01FD': 'ae', 758 | '\u01E3': 'ae', 759 | '\uA735': 'ao', 760 | '\uA737': 'au', 761 | '\uA739': 'av', 762 | '\uA73B': 'av', 763 | '\uA73D': 'ay', 764 | '\u24D1': 'b', 765 | '\uFF42': 'b', 766 | '\u1E03': 'b', 767 | '\u1E05': 'b', 768 | '\u1E07': 'b', 769 | '\u0180': 'b', 770 | '\u0183': 'b', 771 | '\u0253': 'b', 772 | '\u24D2': 'c', 773 | '\uFF43': 'c', 774 | '\u0107': 'c', 775 | '\u0109': 'c', 776 | '\u010B': 'c', 777 | '\u010D': 'c', 778 | '\u00E7': 'c', 779 | '\u1E09': 'c', 780 | '\u0188': 'c', 781 | '\u023C': 'c', 782 | '\uA73F': 'c', 783 | '\u2184': 'c', 784 | '\u24D3': 'd', 785 | '\uFF44': 'd', 786 | '\u1E0B': 'd', 787 | '\u010F': 'd', 788 | '\u1E0D': 'd', 789 | '\u1E11': 'd', 790 | '\u1E13': 'd', 791 | '\u1E0F': 'd', 792 | '\u0111': 'd', 793 | '\u018C': 'd', 794 | '\u0256': 'd', 795 | '\u0257': 'd', 796 | '\uA77A': 'd', 797 | '\u01F3': 'dz', 798 | '\u01C6': 'dz', 799 | '\u24D4': 'e', 800 | '\uFF45': 'e', 801 | '\u00E8': 'e', 802 | '\u00E9': 'e', 803 | '\u00EA': 'e', 804 | '\u1EC1': 'e', 805 | '\u1EBF': 'e', 806 | '\u1EC5': 'e', 807 | '\u1EC3': 'e', 808 | '\u1EBD': 'e', 809 | '\u0113': 'e', 810 | '\u1E15': 'e', 811 | '\u1E17': 'e', 812 | '\u0115': 'e', 813 | '\u0117': 'e', 814 | '\u00EB': 'e', 815 | '\u1EBB': 'e', 816 | '\u011B': 'e', 817 | '\u0205': 'e', 818 | '\u0207': 'e', 819 | '\u1EB9': 'e', 820 | '\u1EC7': 'e', 821 | '\u0229': 'e', 822 | '\u1E1D': 'e', 823 | '\u0119': 'e', 824 | '\u1E19': 'e', 825 | '\u1E1B': 'e', 826 | '\u0247': 'e', 827 | '\u025B': 'e', 828 | '\u01DD': 'e', 829 | '\u24D5': 'f', 830 | '\uFF46': 'f', 831 | '\u1E1F': 'f', 832 | '\u0192': 'f', 833 | '\uA77C': 'f', 834 | '\u24D6': 'g', 835 | '\uFF47': 'g', 836 | '\u01F5': 'g', 837 | '\u011D': 'g', 838 | '\u1E21': 'g', 839 | '\u011F': 'g', 840 | '\u0121': 'g', 841 | '\u01E7': 'g', 842 | '\u0123': 'g', 843 | '\u01E5': 'g', 844 | '\u0260': 'g', 845 | '\uA7A1': 'g', 846 | '\u1D79': 'g', 847 | '\uA77F': 'g', 848 | '\u24D7': 'h', 849 | '\uFF48': 'h', 850 | '\u0125': 'h', 851 | '\u1E23': 'h', 852 | '\u1E27': 'h', 853 | '\u021F': 'h', 854 | '\u1E25': 'h', 855 | '\u1E29': 'h', 856 | '\u1E2B': 'h', 857 | '\u1E96': 'h', 858 | '\u0127': 'h', 859 | '\u2C68': 'h', 860 | '\u2C76': 'h', 861 | '\u0265': 'h', 862 | '\u0195': 'hv', 863 | '\u24D8': 'i', 864 | '\uFF49': 'i', 865 | '\u00EC': 'i', 866 | '\u00ED': 'i', 867 | '\u00EE': 'i', 868 | '\u0129': 'i', 869 | '\u012B': 'i', 870 | '\u012D': 'i', 871 | '\u00EF': 'i', 872 | '\u1E2F': 'i', 873 | '\u1EC9': 'i', 874 | '\u01D0': 'i', 875 | '\u0209': 'i', 876 | '\u020B': 'i', 877 | '\u1ECB': 'i', 878 | '\u012F': 'i', 879 | '\u1E2D': 'i', 880 | '\u0268': 'i', 881 | '\u0131': 'i', 882 | '\u24D9': 'j', 883 | '\uFF4A': 'j', 884 | '\u0135': 'j', 885 | '\u01F0': 'j', 886 | '\u0249': 'j', 887 | '\u24DA': 'k', 888 | '\uFF4B': 'k', 889 | '\u1E31': 'k', 890 | '\u01E9': 'k', 891 | '\u1E33': 'k', 892 | '\u0137': 'k', 893 | '\u1E35': 'k', 894 | '\u0199': 'k', 895 | '\u2C6A': 'k', 896 | '\uA741': 'k', 897 | '\uA743': 'k', 898 | '\uA745': 'k', 899 | '\uA7A3': 'k', 900 | '\u24DB': 'l', 901 | '\uFF4C': 'l', 902 | '\u0140': 'l', 903 | '\u013A': 'l', 904 | '\u013E': 'l', 905 | '\u1E37': 'l', 906 | '\u1E39': 'l', 907 | '\u013C': 'l', 908 | '\u1E3D': 'l', 909 | '\u1E3B': 'l', 910 | '\u017F': 'l', 911 | '\u0142': 'l', 912 | '\u019A': 'l', 913 | '\u026B': 'l', 914 | '\u2C61': 'l', 915 | '\uA749': 'l', 916 | '\uA781': 'l', 917 | '\uA747': 'l', 918 | '\u01C9': 'lj', 919 | '\u24DC': 'm', 920 | '\uFF4D': 'm', 921 | '\u1E3F': 'm', 922 | '\u1E41': 'm', 923 | '\u1E43': 'm', 924 | '\u0271': 'm', 925 | '\u026F': 'm', 926 | '\u24DD': 'n', 927 | '\uFF4E': 'n', 928 | '\u01F9': 'n', 929 | '\u0144': 'n', 930 | '\u00F1': 'n', 931 | '\u1E45': 'n', 932 | '\u0148': 'n', 933 | '\u1E47': 'n', 934 | '\u0146': 'n', 935 | '\u1E4B': 'n', 936 | '\u1E49': 'n', 937 | '\u019E': 'n', 938 | '\u0272': 'n', 939 | '\u0149': 'n', 940 | '\uA791': 'n', 941 | '\uA7A5': 'n', 942 | '\u01CC': 'nj', 943 | '\u24DE': 'o', 944 | '\uFF4F': 'o', 945 | '\u00F2': 'o', 946 | '\u00F3': 'o', 947 | '\u00F4': 'o', 948 | '\u1ED3': 'o', 949 | '\u1ED1': 'o', 950 | '\u1ED7': 'o', 951 | '\u1ED5': 'o', 952 | '\u00F5': 'o', 953 | '\u1E4D': 'o', 954 | '\u022D': 'o', 955 | '\u1E4F': 'o', 956 | '\u014D': 'o', 957 | '\u1E51': 'o', 958 | '\u1E53': 'o', 959 | '\u014F': 'o', 960 | '\u022F': 'o', 961 | '\u0231': 'o', 962 | '\u00F6': 'o', 963 | '\u022B': 'o', 964 | '\u1ECF': 'o', 965 | '\u0151': 'o', 966 | '\u01D2': 'o', 967 | '\u020D': 'o', 968 | '\u020F': 'o', 969 | '\u01A1': 'o', 970 | '\u1EDD': 'o', 971 | '\u1EDB': 'o', 972 | '\u1EE1': 'o', 973 | '\u1EDF': 'o', 974 | '\u1EE3': 'o', 975 | '\u1ECD': 'o', 976 | '\u1ED9': 'o', 977 | '\u01EB': 'o', 978 | '\u01ED': 'o', 979 | '\u00F8': 'o', 980 | '\u01FF': 'o', 981 | '\u0254': 'o', 982 | '\uA74B': 'o', 983 | '\uA74D': 'o', 984 | '\u0275': 'o', 985 | '\u01A3': 'oi', 986 | '\u0223': 'ou', 987 | '\uA74F': 'oo', 988 | '\u24DF': 'p', 989 | '\uFF50': 'p', 990 | '\u1E55': 'p', 991 | '\u1E57': 'p', 992 | '\u01A5': 'p', 993 | '\u1D7D': 'p', 994 | '\uA751': 'p', 995 | '\uA753': 'p', 996 | '\uA755': 'p', 997 | '\u24E0': 'q', 998 | '\uFF51': 'q', 999 | '\u024B': 'q', 1000 | '\uA757': 'q', 1001 | '\uA759': 'q', 1002 | '\u24E1': 'r', 1003 | '\uFF52': 'r', 1004 | '\u0155': 'r', 1005 | '\u1E59': 'r', 1006 | '\u0159': 'r', 1007 | '\u0211': 'r', 1008 | '\u0213': 'r', 1009 | '\u1E5B': 'r', 1010 | '\u1E5D': 'r', 1011 | '\u0157': 'r', 1012 | '\u1E5F': 'r', 1013 | '\u024D': 'r', 1014 | '\u027D': 'r', 1015 | '\uA75B': 'r', 1016 | '\uA7A7': 'r', 1017 | '\uA783': 'r', 1018 | '\u24E2': 's', 1019 | '\uFF53': 's', 1020 | '\u00DF': 's', 1021 | '\u015B': 's', 1022 | '\u1E65': 's', 1023 | '\u015D': 's', 1024 | '\u1E61': 's', 1025 | '\u0161': 's', 1026 | '\u1E67': 's', 1027 | '\u1E63': 's', 1028 | '\u1E69': 's', 1029 | '\u0219': 's', 1030 | '\u015F': 's', 1031 | '\u023F': 's', 1032 | '\uA7A9': 's', 1033 | '\uA785': 's', 1034 | '\u1E9B': 's', 1035 | '\u24E3': 't', 1036 | '\uFF54': 't', 1037 | '\u1E6B': 't', 1038 | '\u1E97': 't', 1039 | '\u0165': 't', 1040 | '\u1E6D': 't', 1041 | '\u021B': 't', 1042 | '\u0163': 't', 1043 | '\u1E71': 't', 1044 | '\u1E6F': 't', 1045 | '\u0167': 't', 1046 | '\u01AD': 't', 1047 | '\u0288': 't', 1048 | '\u2C66': 't', 1049 | '\uA787': 't', 1050 | '\uA729': 'tz', 1051 | '\u24E4': 'u', 1052 | '\uFF55': 'u', 1053 | '\u00F9': 'u', 1054 | '\u00FA': 'u', 1055 | '\u00FB': 'u', 1056 | '\u0169': 'u', 1057 | '\u1E79': 'u', 1058 | '\u016B': 'u', 1059 | '\u1E7B': 'u', 1060 | '\u016D': 'u', 1061 | '\u00FC': 'u', 1062 | '\u01DC': 'u', 1063 | '\u01D8': 'u', 1064 | '\u01D6': 'u', 1065 | '\u01DA': 'u', 1066 | '\u1EE7': 'u', 1067 | '\u016F': 'u', 1068 | '\u0171': 'u', 1069 | '\u01D4': 'u', 1070 | '\u0215': 'u', 1071 | '\u0217': 'u', 1072 | '\u01B0': 'u', 1073 | '\u1EEB': 'u', 1074 | '\u1EE9': 'u', 1075 | '\u1EEF': 'u', 1076 | '\u1EED': 'u', 1077 | '\u1EF1': 'u', 1078 | '\u1EE5': 'u', 1079 | '\u1E73': 'u', 1080 | '\u0173': 'u', 1081 | '\u1E77': 'u', 1082 | '\u1E75': 'u', 1083 | '\u0289': 'u', 1084 | '\u24E5': 'v', 1085 | '\uFF56': 'v', 1086 | '\u1E7D': 'v', 1087 | '\u1E7F': 'v', 1088 | '\u028B': 'v', 1089 | '\uA75F': 'v', 1090 | '\u028C': 'v', 1091 | '\uA761': 'vy', 1092 | '\u24E6': 'w', 1093 | '\uFF57': 'w', 1094 | '\u1E81': 'w', 1095 | '\u1E83': 'w', 1096 | '\u0175': 'w', 1097 | '\u1E87': 'w', 1098 | '\u1E85': 'w', 1099 | '\u1E98': 'w', 1100 | '\u1E89': 'w', 1101 | '\u2C73': 'w', 1102 | '\u24E7': 'x', 1103 | '\uFF58': 'x', 1104 | '\u1E8B': 'x', 1105 | '\u1E8D': 'x', 1106 | '\u24E8': 'y', 1107 | '\uFF59': 'y', 1108 | '\u1EF3': 'y', 1109 | '\u00FD': 'y', 1110 | '\u0177': 'y', 1111 | '\u1EF9': 'y', 1112 | '\u0233': 'y', 1113 | '\u1E8F': 'y', 1114 | '\u00FF': 'y', 1115 | '\u1EF7': 'y', 1116 | '\u1E99': 'y', 1117 | '\u1EF5': 'y', 1118 | '\u01B4': 'y', 1119 | '\u024F': 'y', 1120 | '\u1EFF': 'y', 1121 | '\u24E9': 'z', 1122 | '\uFF5A': 'z', 1123 | '\u017A': 'z', 1124 | '\u1E91': 'z', 1125 | '\u017C': 'z', 1126 | '\u017E': 'z', 1127 | '\u1E93': 'z', 1128 | '\u1E95': 'z', 1129 | '\u01B6': 'z', 1130 | '\u0225': 'z', 1131 | '\u0240': 'z', 1132 | '\u2C6C': 'z', 1133 | '\uA763': 'z', 1134 | '\u0386': '\u0391', 1135 | '\u0388': '\u0395', 1136 | '\u0389': '\u0397', 1137 | '\u038A': '\u0399', 1138 | '\u03AA': '\u0399', 1139 | '\u038C': '\u039F', 1140 | '\u038E': '\u03A5', 1141 | '\u03AB': '\u03A5', 1142 | '\u038F': '\u03A9', 1143 | '\u03AC': '\u03B1', 1144 | '\u03AD': '\u03B5', 1145 | '\u03AE': '\u03B7', 1146 | '\u03AF': '\u03B9', 1147 | '\u03CA': '\u03B9', 1148 | '\u0390': '\u03B9', 1149 | '\u03CC': '\u03BF', 1150 | '\u03CD': '\u03C5', 1151 | '\u03CB': '\u03C5', 1152 | '\u03B0': '\u03C5', 1153 | '\u03C9': '\u03C9', 1154 | '\u03C2': '\u03C3' 1155 | }; 1156 | 1157 | 1158 | function stripDiacritics (text) { 1159 | // Used 'uni range + named function' from http://jsperf.com/diacritics/18 1160 | function match(a) { 1161 | return DIACRITICS[a] || a; 1162 | } 1163 | return text.replace(/[^\u0000-\u007E]/g, match); 1164 | } 1165 | 1166 | // The following matcher is a modification version of the default matcher 1167 | // of select2 1168 | module.exports = matcher = function(params, data) { 1169 | // Always return the object if there is nothing to compare 1170 | if ($.trim(params.term) === '') { 1171 | return data; 1172 | } 1173 | 1174 | // Do a recursive check for options with children 1175 | if (data.children && data.children.length > 0) { 1176 | // Clone the data object if there are children 1177 | // This is required as we modify the object to remove any non-matches 1178 | var match = $.extend(true, {}, data); 1179 | 1180 | // Check each child of the option 1181 | for (var c = data.children.length - 1; c >= 0; c--) { 1182 | var child = data.children[c]; 1183 | 1184 | var matches = matcher(params, child); 1185 | 1186 | // If there wasn't a match, remove the object in the array 1187 | if (matches == null) { 1188 | match.children.splice(c, 1); 1189 | } 1190 | } 1191 | 1192 | // If any children matched, return the new object 1193 | if (match.children.length > 0) { 1194 | return match; 1195 | } 1196 | 1197 | // If there were no matching children, check just the plain object 1198 | return matcher(params, match); 1199 | } 1200 | 1201 | var original = stripDiacritics(data.text).toUpperCase(); 1202 | var term = stripDiacritics(params.term).toUpperCase(); 1203 | 1204 | // Check if the text contains the term 1205 | if (original.indexOf(term) > -1) { 1206 | return data; 1207 | } 1208 | 1209 | // add by Haixing Hu: also match the value of an option 1210 | if (data.id) { 1211 | var originalValue = stripDiacritics(data.id).toUpperCase(); 1212 | if (originalValue.indexOf(term) > -1) { 1213 | return data; 1214 | } 1215 | } 1216 | 1217 | // If it doesn't contain the term, don't return anything 1218 | return null; 1219 | } 1220 | 1221 | /***/ } 1222 | /******/ ]); 1223 | //# sourceMappingURL=vue-select.js.map -------------------------------------------------------------------------------- /dist/vue-select.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap 4b33c9b1ba403aec0760","webpack:///./src/vue-select.js","webpack:///./src/value-text-matcher.js"],"names":[],"mappings":";;;;;;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yCAAwC;AACxC;AACA,UAAS,6BAA6B,GAAG,6BAA6B;AACtE;AACA,UAAS,4BAA4B,6BAA6B,GAAG,6BAA6B,EAAE;AACpG,UAAS,4BAA4B,6BAA6B,GAAG,6BAA6B,EAAE;AACpG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAgE;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gGAA+F,KAAK;AACpG,uGAAsG,UAAU;AAChH;AACA,4EAA2E,UAAU;AACrF;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,uCAAsC;AACtC;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA8C;AAC9C,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,MAAK;AACL,IAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,oEAAmE,6BAA6B,GAAG,6BAA6B;AAChI;AACA,aAAY,4BAA4B,6BAA6B,GAAG,6BAA6B,EAAE;AACvG,aAAY,4BAA4B,6BAA6B,GAAG,6BAA6B,EAAE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA,QAAO;AACP;AACA,QAAO;AACP;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,6DAA4D;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA,sBAAqB,oBAAoB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kCAAiC;;AAEjC;AACA,2CAA0C,QAAQ;AAClD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,E","file":"vue-select.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 4b33c9b1ba403aec0760\n **/","/**\n * The default language used by this component.\n */\nvar DEFAULT_LANGUAGE = \"en-US\";\n\n/**\n * A bootstrap style selection (combobox) control using the select2 plugin.\n *\n * @param options\n * the array of options of the selection control. It could be an array of\n * strings, e.g., \"['opt1', 'opt2']\"; or an array of objects specifying\n * the text and value of each option, e.g.,\n * \"[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]\";\n * or it could be an array of objects specifying the option group, e.g.\n * \"[{label: 'group1', options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]},\n * {label: 'group2', options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}]}]\".\n * @param model\n * the model bind to the control, which must be a two way binding variable.\n * @param searchable\n * the optional flag indicates whether to show the search box. Default value\n * is false.\n * @param matchValue\n * the optional flag indicates whether the searching should match both the\n * texts and values of options. Default value is true.\n * @param language\n * the optional code of language used by the select2 plugin. If it is not set,\n * and the [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin is used,\n * the component will use the language code `$language` provided by the\n * [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin; otherwise, the\n * component will use the default value \"en-US\".\n * @param theme\n * the optional name of the theme of the select2. Default value is \"bootstrap\".\n * @param name\n * the optional name of the selection control.\n * @author Haixing Hu\n */\nmodule.exports = {\n replace: true,\n inherit: false,\n template: \"\",\n props: {\n options: {\n type: Array,\n required: true\n },\n model: {\n required: true,\n twoWay: true\n },\n searchable: {\n type: Boolean,\n required: false,\n default: false\n },\n matchValue: {\n type: Boolean,\n required: false,\n default: true\n },\n name: {\n type: String,\n required: false,\n default: \"\"\n },\n language: {\n type: String,\n required: false,\n default: \"\"\n },\n theme: {\n type: String,\n required: false,\n default: \"bootstrap\"\n }\n },\n data: function() {\n return {\n optionsType: \"unknown\"\n }\n },\n beforeCompile: function() {\n this.isChanging = false;\n this.control = null;\n this.optionsType = this.getOptionsType();\n },\n watch: {\n \"options\": function(val, oldVal) {\n //console.debug(\"options.change\");\n this.optionsType = this.getOptionsType();\n var found = this.inOptions(this.model);\n var newValue = (found ? this.model : null);\n this.control.removeData(\"data\"); // remove the cached options data\n // note that setting the model will automatically changed in the \"change\"\n // event of the select2 control\n this.control.val(newValue).trigger(\"change\");\n },\n \"model\": function(val, oldVal) {\n //console.debug(\"model.change\");\n if (! this.isChanging) {\n this.isChanging = true;\n this.control.val(val).trigger(\"change\");\n this.isChanging = false;\n }\n }\n },\n ready: function() {\n var language = this.language;\n if (language === null || language === \"\") {\n if (this.$language) {\n language = this.$language;\n } else {\n language = DEFAULT_LANGUAGE;\n }\n }\n var args = {\n theme: this.theme,\n language: this.getLanguageCode(language)\n };\n if (! this.searchable) {\n args.minimumResultsForSearch = Infinity; // hide the search box\n } else {\n if (this.matchValue) {\n args.matcher = require(\"./value-text-matcher.js\");\n }\n }\n this.control = $(this.$el);\n this.control.select2(args);\n var me = this;\n this.control.on(\"change\", function(e) {\n //console.debug(\"control.change\");\n if (! me.isChanging) {\n me.isChanging = true;\n me.model = me.control.val();\n me.$nextTick(function () {\n me.isChanging = false;\n });\n }\n });\n },\n methods: {\n\n /**\n * Gets the type of the `options` property of this component.\n *\n * The `options` property of this component may have the following types:\n * - \"values\": the `options` is an array of strings, e.g., `[value1, value2, value3]`;\n * - \"options\": the `options` is an array of options, e.g., `[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]`;\n * - \"groups\": the `options` is an array of option groups, e.g.,\n * `[{label: 'group1', options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]},\n * {label: 'group2', options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}]}]`;\n *\n * @param options\n * the new options.\n * @return\n * the string representing the type of the `options` property of this\n * component.\n */\n getOptionsType: function() {\n if (this.options.length === 0) {\n return \"values\";\n }\n var el = this.options[0];\n if (typeof el == \"string\" || el instanceof String) {\n return \"values\";\n } else if (typeof el.text !== \"undefined\") {\n return \"options\";\n } else if (typeof el.label !== \"undefined\") {\n return \"groups\";\n } else {\n return \"unknown\";\n }\n },\n\n /**\n * Tests whether a specified value exists in the options.\n *\n * @param value\n * the value to test.\n * @return\n * true if the specified value exists in the options; false otherwise.\n */\n inOptions: function(value) {\n var type = this.getOptionsType();\n var list = this.options;\n var i, j;\n switch (type) {\n case \"values\":\n for (i = 0; i < list.length; ++i) {\n if (value === list[i]) {\n return true;\n }\n }\n break;\n case \"options\":\n for (i = 0; i < list.length; ++i) {\n if (value === list[i].value) {\n return true;\n }\n }\n break;\n case \"groups\":\n for (i = 0; i < list.length; ++i) {\n var options = list[i].options;\n for (j = 0; j < options.length; ++j) {\n if (value === options[j].value) {\n return true;\n }\n }\n }\n break;\n default:\n break;\n }\n return false;\n },\n\n /**\n * Gets the language code from the \"language-country\" locale code.\n *\n * The function will strip the language code before the first \"-\" of a\n * locale code. For example, pass \"en-US\" will returns \"en\". But for some\n * special locales, the function reserves the locale code. For example,\n * the \"zh-CN\" for the simplified Chinese and the \"zh-TW\" for the\n * traditional Chinese.\n *\n * @param locale\n * A locale code.\n * @return\n * the language code of the locale.\n */\n getLanguageCode: function(locale) {\n if (locale === null || locale.length === 0) {\n return \"en\";\n }\n if (locale.length <= 2) {\n return locale;\n } else {\n switch (locale) {\n case \"pt-BR\":\n case \"zh-CN\":\n case \"zh-TW\":\n return locale;\n default:\n // reserve only the first two letters language code\n return locale.substr(0, 2);\n }\n }\n }\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/vue-select.js\n ** module id = 0\n ** module chunks = 0\n **/","\nvar DIACRITICS = {\n '\\u24B6': 'A',\n '\\uFF21': 'A',\n '\\u00C0': 'A',\n '\\u00C1': 'A',\n '\\u00C2': 'A',\n '\\u1EA6': 'A',\n '\\u1EA4': 'A',\n '\\u1EAA': 'A',\n '\\u1EA8': 'A',\n '\\u00C3': 'A',\n '\\u0100': 'A',\n '\\u0102': 'A',\n '\\u1EB0': 'A',\n '\\u1EAE': 'A',\n '\\u1EB4': 'A',\n '\\u1EB2': 'A',\n '\\u0226': 'A',\n '\\u01E0': 'A',\n '\\u00C4': 'A',\n '\\u01DE': 'A',\n '\\u1EA2': 'A',\n '\\u00C5': 'A',\n '\\u01FA': 'A',\n '\\u01CD': 'A',\n '\\u0200': 'A',\n '\\u0202': 'A',\n '\\u1EA0': 'A',\n '\\u1EAC': 'A',\n '\\u1EB6': 'A',\n '\\u1E00': 'A',\n '\\u0104': 'A',\n '\\u023A': 'A',\n '\\u2C6F': 'A',\n '\\uA732': 'AA',\n '\\u00C6': 'AE',\n '\\u01FC': 'AE',\n '\\u01E2': 'AE',\n '\\uA734': 'AO',\n '\\uA736': 'AU',\n '\\uA738': 'AV',\n '\\uA73A': 'AV',\n '\\uA73C': 'AY',\n '\\u24B7': 'B',\n '\\uFF22': 'B',\n '\\u1E02': 'B',\n '\\u1E04': 'B',\n '\\u1E06': 'B',\n '\\u0243': 'B',\n '\\u0182': 'B',\n '\\u0181': 'B',\n '\\u24B8': 'C',\n '\\uFF23': 'C',\n '\\u0106': 'C',\n '\\u0108': 'C',\n '\\u010A': 'C',\n '\\u010C': 'C',\n '\\u00C7': 'C',\n '\\u1E08': 'C',\n '\\u0187': 'C',\n '\\u023B': 'C',\n '\\uA73E': 'C',\n '\\u24B9': 'D',\n '\\uFF24': 'D',\n '\\u1E0A': 'D',\n '\\u010E': 'D',\n '\\u1E0C': 'D',\n '\\u1E10': 'D',\n '\\u1E12': 'D',\n '\\u1E0E': 'D',\n '\\u0110': 'D',\n '\\u018B': 'D',\n '\\u018A': 'D',\n '\\u0189': 'D',\n '\\uA779': 'D',\n '\\u01F1': 'DZ',\n '\\u01C4': 'DZ',\n '\\u01F2': 'Dz',\n '\\u01C5': 'Dz',\n '\\u24BA': 'E',\n '\\uFF25': 'E',\n '\\u00C8': 'E',\n '\\u00C9': 'E',\n '\\u00CA': 'E',\n '\\u1EC0': 'E',\n '\\u1EBE': 'E',\n '\\u1EC4': 'E',\n '\\u1EC2': 'E',\n '\\u1EBC': 'E',\n '\\u0112': 'E',\n '\\u1E14': 'E',\n '\\u1E16': 'E',\n '\\u0114': 'E',\n '\\u0116': 'E',\n '\\u00CB': 'E',\n '\\u1EBA': 'E',\n '\\u011A': 'E',\n '\\u0204': 'E',\n '\\u0206': 'E',\n '\\u1EB8': 'E',\n '\\u1EC6': 'E',\n '\\u0228': 'E',\n '\\u1E1C': 'E',\n '\\u0118': 'E',\n '\\u1E18': 'E',\n '\\u1E1A': 'E',\n '\\u0190': 'E',\n '\\u018E': 'E',\n '\\u24BB': 'F',\n '\\uFF26': 'F',\n '\\u1E1E': 'F',\n '\\u0191': 'F',\n '\\uA77B': 'F',\n '\\u24BC': 'G',\n '\\uFF27': 'G',\n '\\u01F4': 'G',\n '\\u011C': 'G',\n '\\u1E20': 'G',\n '\\u011E': 'G',\n '\\u0120': 'G',\n '\\u01E6': 'G',\n '\\u0122': 'G',\n '\\u01E4': 'G',\n '\\u0193': 'G',\n '\\uA7A0': 'G',\n '\\uA77D': 'G',\n '\\uA77E': 'G',\n '\\u24BD': 'H',\n '\\uFF28': 'H',\n '\\u0124': 'H',\n '\\u1E22': 'H',\n '\\u1E26': 'H',\n '\\u021E': 'H',\n '\\u1E24': 'H',\n '\\u1E28': 'H',\n '\\u1E2A': 'H',\n '\\u0126': 'H',\n '\\u2C67': 'H',\n '\\u2C75': 'H',\n '\\uA78D': 'H',\n '\\u24BE': 'I',\n '\\uFF29': 'I',\n '\\u00CC': 'I',\n '\\u00CD': 'I',\n '\\u00CE': 'I',\n '\\u0128': 'I',\n '\\u012A': 'I',\n '\\u012C': 'I',\n '\\u0130': 'I',\n '\\u00CF': 'I',\n '\\u1E2E': 'I',\n '\\u1EC8': 'I',\n '\\u01CF': 'I',\n '\\u0208': 'I',\n '\\u020A': 'I',\n '\\u1ECA': 'I',\n '\\u012E': 'I',\n '\\u1E2C': 'I',\n '\\u0197': 'I',\n '\\u24BF': 'J',\n '\\uFF2A': 'J',\n '\\u0134': 'J',\n '\\u0248': 'J',\n '\\u24C0': 'K',\n '\\uFF2B': 'K',\n '\\u1E30': 'K',\n '\\u01E8': 'K',\n '\\u1E32': 'K',\n '\\u0136': 'K',\n '\\u1E34': 'K',\n '\\u0198': 'K',\n '\\u2C69': 'K',\n '\\uA740': 'K',\n '\\uA742': 'K',\n '\\uA744': 'K',\n '\\uA7A2': 'K',\n '\\u24C1': 'L',\n '\\uFF2C': 'L',\n '\\u013F': 'L',\n '\\u0139': 'L',\n '\\u013D': 'L',\n '\\u1E36': 'L',\n '\\u1E38': 'L',\n '\\u013B': 'L',\n '\\u1E3C': 'L',\n '\\u1E3A': 'L',\n '\\u0141': 'L',\n '\\u023D': 'L',\n '\\u2C62': 'L',\n '\\u2C60': 'L',\n '\\uA748': 'L',\n '\\uA746': 'L',\n '\\uA780': 'L',\n '\\u01C7': 'LJ',\n '\\u01C8': 'Lj',\n '\\u24C2': 'M',\n '\\uFF2D': 'M',\n '\\u1E3E': 'M',\n '\\u1E40': 'M',\n '\\u1E42': 'M',\n '\\u2C6E': 'M',\n '\\u019C': 'M',\n '\\u24C3': 'N',\n '\\uFF2E': 'N',\n '\\u01F8': 'N',\n '\\u0143': 'N',\n '\\u00D1': 'N',\n '\\u1E44': 'N',\n '\\u0147': 'N',\n '\\u1E46': 'N',\n '\\u0145': 'N',\n '\\u1E4A': 'N',\n '\\u1E48': 'N',\n '\\u0220': 'N',\n '\\u019D': 'N',\n '\\uA790': 'N',\n '\\uA7A4': 'N',\n '\\u01CA': 'NJ',\n '\\u01CB': 'Nj',\n '\\u24C4': 'O',\n '\\uFF2F': 'O',\n '\\u00D2': 'O',\n '\\u00D3': 'O',\n '\\u00D4': 'O',\n '\\u1ED2': 'O',\n '\\u1ED0': 'O',\n '\\u1ED6': 'O',\n '\\u1ED4': 'O',\n '\\u00D5': 'O',\n '\\u1E4C': 'O',\n '\\u022C': 'O',\n '\\u1E4E': 'O',\n '\\u014C': 'O',\n '\\u1E50': 'O',\n '\\u1E52': 'O',\n '\\u014E': 'O',\n '\\u022E': 'O',\n '\\u0230': 'O',\n '\\u00D6': 'O',\n '\\u022A': 'O',\n '\\u1ECE': 'O',\n '\\u0150': 'O',\n '\\u01D1': 'O',\n '\\u020C': 'O',\n '\\u020E': 'O',\n '\\u01A0': 'O',\n '\\u1EDC': 'O',\n '\\u1EDA': 'O',\n '\\u1EE0': 'O',\n '\\u1EDE': 'O',\n '\\u1EE2': 'O',\n '\\u1ECC': 'O',\n '\\u1ED8': 'O',\n '\\u01EA': 'O',\n '\\u01EC': 'O',\n '\\u00D8': 'O',\n '\\u01FE': 'O',\n '\\u0186': 'O',\n '\\u019F': 'O',\n '\\uA74A': 'O',\n '\\uA74C': 'O',\n '\\u01A2': 'OI',\n '\\uA74E': 'OO',\n '\\u0222': 'OU',\n '\\u24C5': 'P',\n '\\uFF30': 'P',\n '\\u1E54': 'P',\n '\\u1E56': 'P',\n '\\u01A4': 'P',\n '\\u2C63': 'P',\n '\\uA750': 'P',\n '\\uA752': 'P',\n '\\uA754': 'P',\n '\\u24C6': 'Q',\n '\\uFF31': 'Q',\n '\\uA756': 'Q',\n '\\uA758': 'Q',\n '\\u024A': 'Q',\n '\\u24C7': 'R',\n '\\uFF32': 'R',\n '\\u0154': 'R',\n '\\u1E58': 'R',\n '\\u0158': 'R',\n '\\u0210': 'R',\n '\\u0212': 'R',\n '\\u1E5A': 'R',\n '\\u1E5C': 'R',\n '\\u0156': 'R',\n '\\u1E5E': 'R',\n '\\u024C': 'R',\n '\\u2C64': 'R',\n '\\uA75A': 'R',\n '\\uA7A6': 'R',\n '\\uA782': 'R',\n '\\u24C8': 'S',\n '\\uFF33': 'S',\n '\\u1E9E': 'S',\n '\\u015A': 'S',\n '\\u1E64': 'S',\n '\\u015C': 'S',\n '\\u1E60': 'S',\n '\\u0160': 'S',\n '\\u1E66': 'S',\n '\\u1E62': 'S',\n '\\u1E68': 'S',\n '\\u0218': 'S',\n '\\u015E': 'S',\n '\\u2C7E': 'S',\n '\\uA7A8': 'S',\n '\\uA784': 'S',\n '\\u24C9': 'T',\n '\\uFF34': 'T',\n '\\u1E6A': 'T',\n '\\u0164': 'T',\n '\\u1E6C': 'T',\n '\\u021A': 'T',\n '\\u0162': 'T',\n '\\u1E70': 'T',\n '\\u1E6E': 'T',\n '\\u0166': 'T',\n '\\u01AC': 'T',\n '\\u01AE': 'T',\n '\\u023E': 'T',\n '\\uA786': 'T',\n '\\uA728': 'TZ',\n '\\u24CA': 'U',\n '\\uFF35': 'U',\n '\\u00D9': 'U',\n '\\u00DA': 'U',\n '\\u00DB': 'U',\n '\\u0168': 'U',\n '\\u1E78': 'U',\n '\\u016A': 'U',\n '\\u1E7A': 'U',\n '\\u016C': 'U',\n '\\u00DC': 'U',\n '\\u01DB': 'U',\n '\\u01D7': 'U',\n '\\u01D5': 'U',\n '\\u01D9': 'U',\n '\\u1EE6': 'U',\n '\\u016E': 'U',\n '\\u0170': 'U',\n '\\u01D3': 'U',\n '\\u0214': 'U',\n '\\u0216': 'U',\n '\\u01AF': 'U',\n '\\u1EEA': 'U',\n '\\u1EE8': 'U',\n '\\u1EEE': 'U',\n '\\u1EEC': 'U',\n '\\u1EF0': 'U',\n '\\u1EE4': 'U',\n '\\u1E72': 'U',\n '\\u0172': 'U',\n '\\u1E76': 'U',\n '\\u1E74': 'U',\n '\\u0244': 'U',\n '\\u24CB': 'V',\n '\\uFF36': 'V',\n '\\u1E7C': 'V',\n '\\u1E7E': 'V',\n '\\u01B2': 'V',\n '\\uA75E': 'V',\n '\\u0245': 'V',\n '\\uA760': 'VY',\n '\\u24CC': 'W',\n '\\uFF37': 'W',\n '\\u1E80': 'W',\n '\\u1E82': 'W',\n '\\u0174': 'W',\n '\\u1E86': 'W',\n '\\u1E84': 'W',\n '\\u1E88': 'W',\n '\\u2C72': 'W',\n '\\u24CD': 'X',\n '\\uFF38': 'X',\n '\\u1E8A': 'X',\n '\\u1E8C': 'X',\n '\\u24CE': 'Y',\n '\\uFF39': 'Y',\n '\\u1EF2': 'Y',\n '\\u00DD': 'Y',\n '\\u0176': 'Y',\n '\\u1EF8': 'Y',\n '\\u0232': 'Y',\n '\\u1E8E': 'Y',\n '\\u0178': 'Y',\n '\\u1EF6': 'Y',\n '\\u1EF4': 'Y',\n '\\u01B3': 'Y',\n '\\u024E': 'Y',\n '\\u1EFE': 'Y',\n '\\u24CF': 'Z',\n '\\uFF3A': 'Z',\n '\\u0179': 'Z',\n '\\u1E90': 'Z',\n '\\u017B': 'Z',\n '\\u017D': 'Z',\n '\\u1E92': 'Z',\n '\\u1E94': 'Z',\n '\\u01B5': 'Z',\n '\\u0224': 'Z',\n '\\u2C7F': 'Z',\n '\\u2C6B': 'Z',\n '\\uA762': 'Z',\n '\\u24D0': 'a',\n '\\uFF41': 'a',\n '\\u1E9A': 'a',\n '\\u00E0': 'a',\n '\\u00E1': 'a',\n '\\u00E2': 'a',\n '\\u1EA7': 'a',\n '\\u1EA5': 'a',\n '\\u1EAB': 'a',\n '\\u1EA9': 'a',\n '\\u00E3': 'a',\n '\\u0101': 'a',\n '\\u0103': 'a',\n '\\u1EB1': 'a',\n '\\u1EAF': 'a',\n '\\u1EB5': 'a',\n '\\u1EB3': 'a',\n '\\u0227': 'a',\n '\\u01E1': 'a',\n '\\u00E4': 'a',\n '\\u01DF': 'a',\n '\\u1EA3': 'a',\n '\\u00E5': 'a',\n '\\u01FB': 'a',\n '\\u01CE': 'a',\n '\\u0201': 'a',\n '\\u0203': 'a',\n '\\u1EA1': 'a',\n '\\u1EAD': 'a',\n '\\u1EB7': 'a',\n '\\u1E01': 'a',\n '\\u0105': 'a',\n '\\u2C65': 'a',\n '\\u0250': 'a',\n '\\uA733': 'aa',\n '\\u00E6': 'ae',\n '\\u01FD': 'ae',\n '\\u01E3': 'ae',\n '\\uA735': 'ao',\n '\\uA737': 'au',\n '\\uA739': 'av',\n '\\uA73B': 'av',\n '\\uA73D': 'ay',\n '\\u24D1': 'b',\n '\\uFF42': 'b',\n '\\u1E03': 'b',\n '\\u1E05': 'b',\n '\\u1E07': 'b',\n '\\u0180': 'b',\n '\\u0183': 'b',\n '\\u0253': 'b',\n '\\u24D2': 'c',\n '\\uFF43': 'c',\n '\\u0107': 'c',\n '\\u0109': 'c',\n '\\u010B': 'c',\n '\\u010D': 'c',\n '\\u00E7': 'c',\n '\\u1E09': 'c',\n '\\u0188': 'c',\n '\\u023C': 'c',\n '\\uA73F': 'c',\n '\\u2184': 'c',\n '\\u24D3': 'd',\n '\\uFF44': 'd',\n '\\u1E0B': 'd',\n '\\u010F': 'd',\n '\\u1E0D': 'd',\n '\\u1E11': 'd',\n '\\u1E13': 'd',\n '\\u1E0F': 'd',\n '\\u0111': 'd',\n '\\u018C': 'd',\n '\\u0256': 'd',\n '\\u0257': 'd',\n '\\uA77A': 'd',\n '\\u01F3': 'dz',\n '\\u01C6': 'dz',\n '\\u24D4': 'e',\n '\\uFF45': 'e',\n '\\u00E8': 'e',\n '\\u00E9': 'e',\n '\\u00EA': 'e',\n '\\u1EC1': 'e',\n '\\u1EBF': 'e',\n '\\u1EC5': 'e',\n '\\u1EC3': 'e',\n '\\u1EBD': 'e',\n '\\u0113': 'e',\n '\\u1E15': 'e',\n '\\u1E17': 'e',\n '\\u0115': 'e',\n '\\u0117': 'e',\n '\\u00EB': 'e',\n '\\u1EBB': 'e',\n '\\u011B': 'e',\n '\\u0205': 'e',\n '\\u0207': 'e',\n '\\u1EB9': 'e',\n '\\u1EC7': 'e',\n '\\u0229': 'e',\n '\\u1E1D': 'e',\n '\\u0119': 'e',\n '\\u1E19': 'e',\n '\\u1E1B': 'e',\n '\\u0247': 'e',\n '\\u025B': 'e',\n '\\u01DD': 'e',\n '\\u24D5': 'f',\n '\\uFF46': 'f',\n '\\u1E1F': 'f',\n '\\u0192': 'f',\n '\\uA77C': 'f',\n '\\u24D6': 'g',\n '\\uFF47': 'g',\n '\\u01F5': 'g',\n '\\u011D': 'g',\n '\\u1E21': 'g',\n '\\u011F': 'g',\n '\\u0121': 'g',\n '\\u01E7': 'g',\n '\\u0123': 'g',\n '\\u01E5': 'g',\n '\\u0260': 'g',\n '\\uA7A1': 'g',\n '\\u1D79': 'g',\n '\\uA77F': 'g',\n '\\u24D7': 'h',\n '\\uFF48': 'h',\n '\\u0125': 'h',\n '\\u1E23': 'h',\n '\\u1E27': 'h',\n '\\u021F': 'h',\n '\\u1E25': 'h',\n '\\u1E29': 'h',\n '\\u1E2B': 'h',\n '\\u1E96': 'h',\n '\\u0127': 'h',\n '\\u2C68': 'h',\n '\\u2C76': 'h',\n '\\u0265': 'h',\n '\\u0195': 'hv',\n '\\u24D8': 'i',\n '\\uFF49': 'i',\n '\\u00EC': 'i',\n '\\u00ED': 'i',\n '\\u00EE': 'i',\n '\\u0129': 'i',\n '\\u012B': 'i',\n '\\u012D': 'i',\n '\\u00EF': 'i',\n '\\u1E2F': 'i',\n '\\u1EC9': 'i',\n '\\u01D0': 'i',\n '\\u0209': 'i',\n '\\u020B': 'i',\n '\\u1ECB': 'i',\n '\\u012F': 'i',\n '\\u1E2D': 'i',\n '\\u0268': 'i',\n '\\u0131': 'i',\n '\\u24D9': 'j',\n '\\uFF4A': 'j',\n '\\u0135': 'j',\n '\\u01F0': 'j',\n '\\u0249': 'j',\n '\\u24DA': 'k',\n '\\uFF4B': 'k',\n '\\u1E31': 'k',\n '\\u01E9': 'k',\n '\\u1E33': 'k',\n '\\u0137': 'k',\n '\\u1E35': 'k',\n '\\u0199': 'k',\n '\\u2C6A': 'k',\n '\\uA741': 'k',\n '\\uA743': 'k',\n '\\uA745': 'k',\n '\\uA7A3': 'k',\n '\\u24DB': 'l',\n '\\uFF4C': 'l',\n '\\u0140': 'l',\n '\\u013A': 'l',\n '\\u013E': 'l',\n '\\u1E37': 'l',\n '\\u1E39': 'l',\n '\\u013C': 'l',\n '\\u1E3D': 'l',\n '\\u1E3B': 'l',\n '\\u017F': 'l',\n '\\u0142': 'l',\n '\\u019A': 'l',\n '\\u026B': 'l',\n '\\u2C61': 'l',\n '\\uA749': 'l',\n '\\uA781': 'l',\n '\\uA747': 'l',\n '\\u01C9': 'lj',\n '\\u24DC': 'm',\n '\\uFF4D': 'm',\n '\\u1E3F': 'm',\n '\\u1E41': 'm',\n '\\u1E43': 'm',\n '\\u0271': 'm',\n '\\u026F': 'm',\n '\\u24DD': 'n',\n '\\uFF4E': 'n',\n '\\u01F9': 'n',\n '\\u0144': 'n',\n '\\u00F1': 'n',\n '\\u1E45': 'n',\n '\\u0148': 'n',\n '\\u1E47': 'n',\n '\\u0146': 'n',\n '\\u1E4B': 'n',\n '\\u1E49': 'n',\n '\\u019E': 'n',\n '\\u0272': 'n',\n '\\u0149': 'n',\n '\\uA791': 'n',\n '\\uA7A5': 'n',\n '\\u01CC': 'nj',\n '\\u24DE': 'o',\n '\\uFF4F': 'o',\n '\\u00F2': 'o',\n '\\u00F3': 'o',\n '\\u00F4': 'o',\n '\\u1ED3': 'o',\n '\\u1ED1': 'o',\n '\\u1ED7': 'o',\n '\\u1ED5': 'o',\n '\\u00F5': 'o',\n '\\u1E4D': 'o',\n '\\u022D': 'o',\n '\\u1E4F': 'o',\n '\\u014D': 'o',\n '\\u1E51': 'o',\n '\\u1E53': 'o',\n '\\u014F': 'o',\n '\\u022F': 'o',\n '\\u0231': 'o',\n '\\u00F6': 'o',\n '\\u022B': 'o',\n '\\u1ECF': 'o',\n '\\u0151': 'o',\n '\\u01D2': 'o',\n '\\u020D': 'o',\n '\\u020F': 'o',\n '\\u01A1': 'o',\n '\\u1EDD': 'o',\n '\\u1EDB': 'o',\n '\\u1EE1': 'o',\n '\\u1EDF': 'o',\n '\\u1EE3': 'o',\n '\\u1ECD': 'o',\n '\\u1ED9': 'o',\n '\\u01EB': 'o',\n '\\u01ED': 'o',\n '\\u00F8': 'o',\n '\\u01FF': 'o',\n '\\u0254': 'o',\n '\\uA74B': 'o',\n '\\uA74D': 'o',\n '\\u0275': 'o',\n '\\u01A3': 'oi',\n '\\u0223': 'ou',\n '\\uA74F': 'oo',\n '\\u24DF': 'p',\n '\\uFF50': 'p',\n '\\u1E55': 'p',\n '\\u1E57': 'p',\n '\\u01A5': 'p',\n '\\u1D7D': 'p',\n '\\uA751': 'p',\n '\\uA753': 'p',\n '\\uA755': 'p',\n '\\u24E0': 'q',\n '\\uFF51': 'q',\n '\\u024B': 'q',\n '\\uA757': 'q',\n '\\uA759': 'q',\n '\\u24E1': 'r',\n '\\uFF52': 'r',\n '\\u0155': 'r',\n '\\u1E59': 'r',\n '\\u0159': 'r',\n '\\u0211': 'r',\n '\\u0213': 'r',\n '\\u1E5B': 'r',\n '\\u1E5D': 'r',\n '\\u0157': 'r',\n '\\u1E5F': 'r',\n '\\u024D': 'r',\n '\\u027D': 'r',\n '\\uA75B': 'r',\n '\\uA7A7': 'r',\n '\\uA783': 'r',\n '\\u24E2': 's',\n '\\uFF53': 's',\n '\\u00DF': 's',\n '\\u015B': 's',\n '\\u1E65': 's',\n '\\u015D': 's',\n '\\u1E61': 's',\n '\\u0161': 's',\n '\\u1E67': 's',\n '\\u1E63': 's',\n '\\u1E69': 's',\n '\\u0219': 's',\n '\\u015F': 's',\n '\\u023F': 's',\n '\\uA7A9': 's',\n '\\uA785': 's',\n '\\u1E9B': 's',\n '\\u24E3': 't',\n '\\uFF54': 't',\n '\\u1E6B': 't',\n '\\u1E97': 't',\n '\\u0165': 't',\n '\\u1E6D': 't',\n '\\u021B': 't',\n '\\u0163': 't',\n '\\u1E71': 't',\n '\\u1E6F': 't',\n '\\u0167': 't',\n '\\u01AD': 't',\n '\\u0288': 't',\n '\\u2C66': 't',\n '\\uA787': 't',\n '\\uA729': 'tz',\n '\\u24E4': 'u',\n '\\uFF55': 'u',\n '\\u00F9': 'u',\n '\\u00FA': 'u',\n '\\u00FB': 'u',\n '\\u0169': 'u',\n '\\u1E79': 'u',\n '\\u016B': 'u',\n '\\u1E7B': 'u',\n '\\u016D': 'u',\n '\\u00FC': 'u',\n '\\u01DC': 'u',\n '\\u01D8': 'u',\n '\\u01D6': 'u',\n '\\u01DA': 'u',\n '\\u1EE7': 'u',\n '\\u016F': 'u',\n '\\u0171': 'u',\n '\\u01D4': 'u',\n '\\u0215': 'u',\n '\\u0217': 'u',\n '\\u01B0': 'u',\n '\\u1EEB': 'u',\n '\\u1EE9': 'u',\n '\\u1EEF': 'u',\n '\\u1EED': 'u',\n '\\u1EF1': 'u',\n '\\u1EE5': 'u',\n '\\u1E73': 'u',\n '\\u0173': 'u',\n '\\u1E77': 'u',\n '\\u1E75': 'u',\n '\\u0289': 'u',\n '\\u24E5': 'v',\n '\\uFF56': 'v',\n '\\u1E7D': 'v',\n '\\u1E7F': 'v',\n '\\u028B': 'v',\n '\\uA75F': 'v',\n '\\u028C': 'v',\n '\\uA761': 'vy',\n '\\u24E6': 'w',\n '\\uFF57': 'w',\n '\\u1E81': 'w',\n '\\u1E83': 'w',\n '\\u0175': 'w',\n '\\u1E87': 'w',\n '\\u1E85': 'w',\n '\\u1E98': 'w',\n '\\u1E89': 'w',\n '\\u2C73': 'w',\n '\\u24E7': 'x',\n '\\uFF58': 'x',\n '\\u1E8B': 'x',\n '\\u1E8D': 'x',\n '\\u24E8': 'y',\n '\\uFF59': 'y',\n '\\u1EF3': 'y',\n '\\u00FD': 'y',\n '\\u0177': 'y',\n '\\u1EF9': 'y',\n '\\u0233': 'y',\n '\\u1E8F': 'y',\n '\\u00FF': 'y',\n '\\u1EF7': 'y',\n '\\u1E99': 'y',\n '\\u1EF5': 'y',\n '\\u01B4': 'y',\n '\\u024F': 'y',\n '\\u1EFF': 'y',\n '\\u24E9': 'z',\n '\\uFF5A': 'z',\n '\\u017A': 'z',\n '\\u1E91': 'z',\n '\\u017C': 'z',\n '\\u017E': 'z',\n '\\u1E93': 'z',\n '\\u1E95': 'z',\n '\\u01B6': 'z',\n '\\u0225': 'z',\n '\\u0240': 'z',\n '\\u2C6C': 'z',\n '\\uA763': 'z',\n '\\u0386': '\\u0391',\n '\\u0388': '\\u0395',\n '\\u0389': '\\u0397',\n '\\u038A': '\\u0399',\n '\\u03AA': '\\u0399',\n '\\u038C': '\\u039F',\n '\\u038E': '\\u03A5',\n '\\u03AB': '\\u03A5',\n '\\u038F': '\\u03A9',\n '\\u03AC': '\\u03B1',\n '\\u03AD': '\\u03B5',\n '\\u03AE': '\\u03B7',\n '\\u03AF': '\\u03B9',\n '\\u03CA': '\\u03B9',\n '\\u0390': '\\u03B9',\n '\\u03CC': '\\u03BF',\n '\\u03CD': '\\u03C5',\n '\\u03CB': '\\u03C5',\n '\\u03B0': '\\u03C5',\n '\\u03C9': '\\u03C9',\n '\\u03C2': '\\u03C3'\n};\n\n\nfunction stripDiacritics (text) {\n // Used 'uni range + named function' from http://jsperf.com/diacritics/18\n function match(a) {\n return DIACRITICS[a] || a;\n }\n return text.replace(/[^\\u0000-\\u007E]/g, match);\n}\n\n// The following matcher is a modification version of the default matcher\n// of select2\nmodule.exports = matcher = function(params, data) {\n // Always return the object if there is nothing to compare\n if ($.trim(params.term) === '') {\n return data;\n }\n\n // Do a recursive check for options with children\n if (data.children && data.children.length > 0) {\n // Clone the data object if there are children\n // This is required as we modify the object to remove any non-matches\n var match = $.extend(true, {}, data);\n\n // Check each child of the option\n for (var c = data.children.length - 1; c >= 0; c--) {\n var child = data.children[c];\n\n var matches = matcher(params, child);\n\n // If there wasn't a match, remove the object in the array\n if (matches == null) {\n match.children.splice(c, 1);\n }\n }\n\n // If any children matched, return the new object\n if (match.children.length > 0) {\n return match;\n }\n\n // If there were no matching children, check just the plain object\n return matcher(params, match);\n }\n\n var original = stripDiacritics(data.text).toUpperCase();\n var term = stripDiacritics(params.term).toUpperCase();\n\n // Check if the text contains the term\n if (original.indexOf(term) > -1) {\n return data;\n }\n\n // add by Haixing Hu: also match the value of an option\n if (data.id) {\n var originalValue = stripDiacritics(data.id).toUpperCase();\n if (originalValue.indexOf(term) > -1) {\n return data;\n }\n }\n\n // If it doesn't contain the term, don't return anything\n return null;\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/value-text-matcher.js\n ** module id = 1\n ** module chunks = 0\n **/"],"sourceRoot":""} -------------------------------------------------------------------------------- /dist/vue-select.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * vue-select2 v0.2.6 3 | * (c) 2016 Haixing Hu 4 | * Released under the MIT License. 5 | */ 6 | !function(e){function t(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){var n="en-US";e.exports={replace:!0,inherit:!1,template:"",props:{options:{type:Array,required:!0},model:{required:!0,twoWay:!0},searchable:{type:Boolean,required:!1,"default":!1},matchValue:{type:Boolean,required:!1,"default":!0},name:{type:String,required:!1,"default":""},language:{type:String,required:!1,"default":""},theme:{type:String,required:!1,"default":"bootstrap"}},data:function(){return{optionsType:"unknown"}},beforeCompile:function(){this.isChanging=!1,this.control=null,this.optionsType=this.getOptionsType()},watch:{options:function(e,t){this.optionsType=this.getOptionsType();var o=this.inOptions(this.model),n=o?this.model:null;this.control.removeData("data"),this.control.val(n).trigger("change")},model:function(e,t){this.isChanging||(this.isChanging=!0,this.control.val(e).trigger("change"),this.isChanging=!1)}},ready:function(){var e=this.language;null!==e&&""!==e||(e=this.$language?this.$language:n);var t={theme:this.theme,language:this.getLanguageCode(e)};this.searchable?this.matchValue&&(t.matcher=o(1)):t.minimumResultsForSearch=1/0,this.control=$(this.$el),this.control.select2(t);var i=this;this.control.on("change",function(e){i.isChanging||(i.isChanging=!0,i.model=i.control.val(),i.$nextTick(function(){i.isChanging=!1}))})},methods:{getOptionsType:function(){if(0===this.options.length)return"values";var e=this.options[0];return"string"==typeof e||e instanceof String?"values":"undefined"!=typeof e.text?"options":"undefined"!=typeof e.label?"groups":"unknown"},inOptions:function(e){var t,o,n=this.getOptionsType(),i=this.options;switch(n){case"values":for(t=0;t0){for(var n=$.extend(!0,{},t),i=t.children.length-1;i>=0;i--){var r=t.children[i],a=matcher(e,r);null==a&&n.children.splice(i,1)}return n.children.length>0?n:matcher(e,n)}var u=o(t.text).toUpperCase(),s=o(e.term).toUpperCase();if(u.indexOf(s)>-1)return t;if(t.id){var l=o(t.id).toUpperCase();if(l.indexOf(s)>-1)return t}return null}}]); -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | // Gulp building scripts 2 | var gulp = require("gulp"); 3 | var del = require("del"); 4 | var gutil = require("gulp-util"); 5 | var webpack = require("webpack"); 6 | var webpackConfig = require("./webpack.config.js"); 7 | var runSequence = require("run-sequence"); 8 | var Server = require('karma').Server; 9 | var pkg = require("./package.json"); 10 | var dirs = pkg.configs.directories; 11 | 12 | // --------------------------------------------------------------------- 13 | // | Helper tasks | 14 | // --------------------------------------------------------------------- 15 | 16 | gulp.task("clean", function (done) { 17 | del([ dirs.dist, dirs.coverage ]); 18 | done(); 19 | }); 20 | 21 | gulp.task("webpack-dev", function(done) { 22 | // modify some webpack config options 23 | var webpackDevConfig = Object.create(webpackConfig); 24 | webpackDevConfig.devtool = "sourcemap"; 25 | webpackDevConfig.debug = true; 26 | // create a single instance of the compiler to allow caching 27 | var webpackDevCompiler = webpack(webpackDevConfig); 28 | // run webpack 29 | webpackDevCompiler.run(function(err, stats) { 30 | if(err) throw new gutil.PluginError("webpack:build-dev", err); 31 | gutil.log("[webpack:build-dev]", stats.toString({ 32 | colors: true 33 | })); 34 | done(); 35 | }); 36 | }); 37 | 38 | gulp.task("webpack", function(done) { 39 | // modify some webpack config options 40 | var webpackProdConfig = Object.create(webpackConfig); 41 | webpackProdConfig.plugins.push(new webpack.DefinePlugin({ 42 | "process.env": { 43 | // This has effect on the react lib size 44 | "NODE_ENV": JSON.stringify("production") 45 | } 46 | }), new webpack.optimize.UglifyJsPlugin()); 47 | webpackProdConfig.output.filename = "[name].min.js"; 48 | // run webpack 49 | webpack(webpackProdConfig, function(err, stats) { 50 | if(err) throw new gutil.PluginError("webpack:build", err); 51 | gutil.log("[webpack:build]", stats.toString({ 52 | colors: true 53 | })); 54 | done(); 55 | }); 56 | }); 57 | 58 | gulp.task('test', function(done) { 59 | // Be sure to return the stream 60 | new Server({ 61 | configFile: __dirname + '/karma.conf.js', 62 | singleRun: true 63 | }, done).start(); 64 | }); 65 | 66 | gulp.task('test:coverage', function(done) { 67 | // Be sure to return the stream 68 | process.env.TEST_TYPE = "coverage"; 69 | new Server({ 70 | configFile: __dirname + '/karma.conf.js', 71 | singleRun: true 72 | }, done).start(); 73 | }); 74 | 75 | gulp.task('test:coveralls', function(done) { 76 | // Be sure to return the stream 77 | process.env.TEST_TYPE = "coveralls"; 78 | new Server({ 79 | configFile: __dirname + '/karma.conf.js', 80 | singleRun: true 81 | }, done).start(); 82 | }); 83 | 84 | // --------------------------------------------------------------------- 85 | // | Main tasks | 86 | // --------------------------------------------------------------------- 87 | 88 | gulp.task("build-dev", function (done) { 89 | runSequence( 90 | "clean", 91 | "test:coverage", 92 | "webpack-dev", 93 | done); 94 | }); 95 | 96 | gulp.task("build", function (done) { 97 | runSequence( 98 | "clean", 99 | "test:coveralls", 100 | "webpack-dev", 101 | "webpack", 102 | done); 103 | }); 104 | 105 | gulp.task("default", ["build"]); -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | var VueLoader = require('vue-loader'); 3 | 4 | module.exports = function (config) { 5 | var settings = { 6 | // base path that will be used to resolve all patterns (eg. files, exclude) 7 | basePath: '', 8 | 9 | // frameworks to use 10 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 11 | frameworks: ['mocha'], 12 | 13 | // list of files / patterns to load in the browser 14 | files: [ 15 | "./lib/jquery/dist/jquery.min.js", 16 | "./lib/select2/dist/js/select2.min.js", 17 | "./test/specs/**/*.js", 18 | { 19 | pattern: "./test/specs/i18n/*.json", 20 | watched: false, 21 | included: false, 22 | served: true 23 | } 24 | ], 25 | 26 | // list of files to exclude 27 | exclude: [ 28 | ], 29 | 30 | // preprocess matching files before serving them to the browser 31 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 32 | preprocessors: { 33 | "./test/**/*.js": ['webpack', 'sourcemap'], 34 | "./demo/**/*.vue": ['webpack', 'sourcemap'], 35 | "./src/**/*.js": ['webpack', 'sourcemap'] 36 | }, 37 | 38 | webpack: { 39 | devtool: 'inline-source-map', 40 | module: { 41 | loaders: [{ 42 | test: /\.vue$/, loader: "vue" 43 | }], 44 | postLoaders: [{ 45 | test: /\.js$/, 46 | exclude: /test|node_modules|lib|value-text-matcher.js/, 47 | loader: 'istanbul-instrumenter' 48 | }] 49 | }, 50 | vue: { 51 | loaders: { 52 | html: "raw" // use raw-loader to process HTML 53 | } 54 | } 55 | }, 56 | 57 | webpackMiddleware: { 58 | noInfo: true 59 | }, 60 | 61 | // test results reporter to use 62 | // possible values: 'dots', 'progress' 63 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 64 | /* 65 | reporters: [ 66 | 'mocha', 'coverage' 67 | ], 68 | 69 | coverageReporter: { 70 | reporters: [{ 71 | type: 'html', dir: '../coverage' 72 | }, { 73 | type: 'lcov', dir: '../coverage' 74 | }, { 75 | type: 'text-summary', dir: '../coverage' 76 | }] 77 | }, 78 | */ 79 | 80 | // web server port 81 | port: 9876, 82 | 83 | // enable / disable colors in the output (reporters and logs) 84 | colors: true, 85 | 86 | // level of logging 87 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 88 | logLevel: config.LOG_INFO, 89 | 90 | // enable / disable watching file and executing tests whenever any file changes 91 | autoWatch: true, 92 | 93 | // Continuous Integration mode 94 | // if true, Karma captures browsers, runs the tests and exits 95 | singleRun: true 96 | }; 97 | 98 | switch (process.env.TEST_TYPE) { 99 | case 'coverage': 100 | settings.browsers = ['PhantomJS']; 101 | settings.reporters = ['coverage']; 102 | settings.coverageReporter = { 103 | reporters: [{ 104 | type: 'text-summary', dir: "./coverage" 105 | }, { 106 | type: 'html', dir: "./coverage" 107 | }] 108 | }; 109 | break; 110 | case 'coveralls': 111 | settings.browsers = ['PhantomJS']; 112 | settings.reporters = ['coverage', 'coveralls']; 113 | settings.coverageReporter = { 114 | reporters: [{ 115 | type: 'text-summary', dir: "./coverage" 116 | }, { 117 | type: 'lcov', 118 | dir: "./coverage" 119 | }] 120 | }; 121 | break; 122 | case 'sauce': 123 | var batch = process.env.SAUCE || 'batch1'; 124 | var sauce = require('./sauce')[batch]; 125 | settings.sauceLabs = sauce.sauceLabs; 126 | settings.captureTimeout = sauce.captureTimeout; 127 | settings.customLaunchers = sauce.customLaunchers; 128 | settings.browsers = sauce.browsers; 129 | settings.reporters = sauce.reporters; 130 | break; 131 | case 'browser': 132 | settings.browsers = ['Chrome', 'Safari', 'Firefox']; 133 | settings.reporters = ['progress']; 134 | break; 135 | default: 136 | settings.browsers = ['PhantomJS']; 137 | settings.reporters = ['mocha']; 138 | break; 139 | } 140 | 141 | config.set(settings); 142 | }; 143 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-select2", 3 | "description": "A Vue.js component implementing the select control with the jQuery select2 plugin.", 4 | "version": "0.3.1", 5 | "author": { 6 | "name": "Haixing Hu", 7 | "email": "starfish.hu@gmail.com" 8 | }, 9 | "homepage": "https://github.com/Haixing-Hu/vue-select", 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git@github.com:Haixing-Hu/vue-select.git" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/Haixing-Hu/vue-select/issues" 17 | }, 18 | "main": "dist/vue-select.min.js", 19 | "configs": { 20 | "directories": { 21 | "dist": "dist", 22 | "src": "src", 23 | "test": "test", 24 | "coverage": "coverage" 25 | } 26 | }, 27 | "scripts": { 28 | "build": "bower install && gulp build", 29 | "test": "bower install && gulp test:coveralls", 30 | "coverage": "bower install && gulp test:coverage", 31 | "coveralls": "bower install && gulp test:coveralls", 32 | "ci": "bower install && gulp test:coveralls && gulp build" 33 | }, 34 | "engines": { 35 | "node": ">=0.10.0" 36 | }, 37 | "devDependencies": { 38 | "bower": "^1.7.9", 39 | "bower-update-all": "^0.1.2", 40 | "del": "^2.2.0", 41 | "run-sequence": "^1.2.1", 42 | "bower-webpack-plugin": "^0.1.9", 43 | "gulp": "^3.9.1", 44 | "gulp-util": "^3.0.7", 45 | "webpack": "^1.13.1", 46 | "mocha": "^2.5.3", 47 | "karma": "^0.13.22", 48 | "karma-chrome-launcher": "^1.0.1", 49 | "karma-safari-launcher": "^1.0.0", 50 | "karma-firefox-launcher": "^1.0.0", 51 | "karma-phantomjs-launcher": "^1.0.0", 52 | "karma-sauce-launcher": "^1.0.0", 53 | "karma-mocha": "^1.0.1", 54 | "karma-mocha-reporter": "^2.0.4", 55 | "karma-coverage": "^1.0.0", 56 | "karma-coveralls": "^1.1.2", 57 | "karma-sourcemap-loader": "^0.3.7", 58 | "karma-webpack": "^1.7.0", 59 | "phantomjs-prebuilt": "^2.1.7", 60 | "istanbul": "^0.4.3", 61 | "istanbul-instrumenter-loader": "^0.2.0", 62 | "vue": "^1.0.24", 63 | "vue-loader": "^8.5.2", 64 | "vue-html-loader": "^1.2.2", 65 | "vue-style-loader": "^1.0.0", 66 | "vue-hot-reload-api": "^1.2.0", 67 | "raw-loader": "^0.5.1", 68 | "html-loader": "^0.4.3", 69 | "css-loader": "^0.23.1", 70 | "file-loader": "^0.8.5", 71 | "babel-loader": "^6.2.4", 72 | "babel-core": "^6.8.0", 73 | "babel-plugin-transform-runtime": "^6.8.0", 74 | "babel-runtime": "^6.0.0", 75 | "babel-preset-es2015": "^6.6.0", 76 | "jquery": "^2.2.4" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Haixing-Hu/vue-select/6bdc2179857a60108f10792e2599b4feec9c5ef3/screenshot.png -------------------------------------------------------------------------------- /src/value-text-matcher.js: -------------------------------------------------------------------------------- 1 | 2 | var DIACRITICS = { 3 | '\u24B6': 'A', 4 | '\uFF21': 'A', 5 | '\u00C0': 'A', 6 | '\u00C1': 'A', 7 | '\u00C2': 'A', 8 | '\u1EA6': 'A', 9 | '\u1EA4': 'A', 10 | '\u1EAA': 'A', 11 | '\u1EA8': 'A', 12 | '\u00C3': 'A', 13 | '\u0100': 'A', 14 | '\u0102': 'A', 15 | '\u1EB0': 'A', 16 | '\u1EAE': 'A', 17 | '\u1EB4': 'A', 18 | '\u1EB2': 'A', 19 | '\u0226': 'A', 20 | '\u01E0': 'A', 21 | '\u00C4': 'A', 22 | '\u01DE': 'A', 23 | '\u1EA2': 'A', 24 | '\u00C5': 'A', 25 | '\u01FA': 'A', 26 | '\u01CD': 'A', 27 | '\u0200': 'A', 28 | '\u0202': 'A', 29 | '\u1EA0': 'A', 30 | '\u1EAC': 'A', 31 | '\u1EB6': 'A', 32 | '\u1E00': 'A', 33 | '\u0104': 'A', 34 | '\u023A': 'A', 35 | '\u2C6F': 'A', 36 | '\uA732': 'AA', 37 | '\u00C6': 'AE', 38 | '\u01FC': 'AE', 39 | '\u01E2': 'AE', 40 | '\uA734': 'AO', 41 | '\uA736': 'AU', 42 | '\uA738': 'AV', 43 | '\uA73A': 'AV', 44 | '\uA73C': 'AY', 45 | '\u24B7': 'B', 46 | '\uFF22': 'B', 47 | '\u1E02': 'B', 48 | '\u1E04': 'B', 49 | '\u1E06': 'B', 50 | '\u0243': 'B', 51 | '\u0182': 'B', 52 | '\u0181': 'B', 53 | '\u24B8': 'C', 54 | '\uFF23': 'C', 55 | '\u0106': 'C', 56 | '\u0108': 'C', 57 | '\u010A': 'C', 58 | '\u010C': 'C', 59 | '\u00C7': 'C', 60 | '\u1E08': 'C', 61 | '\u0187': 'C', 62 | '\u023B': 'C', 63 | '\uA73E': 'C', 64 | '\u24B9': 'D', 65 | '\uFF24': 'D', 66 | '\u1E0A': 'D', 67 | '\u010E': 'D', 68 | '\u1E0C': 'D', 69 | '\u1E10': 'D', 70 | '\u1E12': 'D', 71 | '\u1E0E': 'D', 72 | '\u0110': 'D', 73 | '\u018B': 'D', 74 | '\u018A': 'D', 75 | '\u0189': 'D', 76 | '\uA779': 'D', 77 | '\u01F1': 'DZ', 78 | '\u01C4': 'DZ', 79 | '\u01F2': 'Dz', 80 | '\u01C5': 'Dz', 81 | '\u24BA': 'E', 82 | '\uFF25': 'E', 83 | '\u00C8': 'E', 84 | '\u00C9': 'E', 85 | '\u00CA': 'E', 86 | '\u1EC0': 'E', 87 | '\u1EBE': 'E', 88 | '\u1EC4': 'E', 89 | '\u1EC2': 'E', 90 | '\u1EBC': 'E', 91 | '\u0112': 'E', 92 | '\u1E14': 'E', 93 | '\u1E16': 'E', 94 | '\u0114': 'E', 95 | '\u0116': 'E', 96 | '\u00CB': 'E', 97 | '\u1EBA': 'E', 98 | '\u011A': 'E', 99 | '\u0204': 'E', 100 | '\u0206': 'E', 101 | '\u1EB8': 'E', 102 | '\u1EC6': 'E', 103 | '\u0228': 'E', 104 | '\u1E1C': 'E', 105 | '\u0118': 'E', 106 | '\u1E18': 'E', 107 | '\u1E1A': 'E', 108 | '\u0190': 'E', 109 | '\u018E': 'E', 110 | '\u24BB': 'F', 111 | '\uFF26': 'F', 112 | '\u1E1E': 'F', 113 | '\u0191': 'F', 114 | '\uA77B': 'F', 115 | '\u24BC': 'G', 116 | '\uFF27': 'G', 117 | '\u01F4': 'G', 118 | '\u011C': 'G', 119 | '\u1E20': 'G', 120 | '\u011E': 'G', 121 | '\u0120': 'G', 122 | '\u01E6': 'G', 123 | '\u0122': 'G', 124 | '\u01E4': 'G', 125 | '\u0193': 'G', 126 | '\uA7A0': 'G', 127 | '\uA77D': 'G', 128 | '\uA77E': 'G', 129 | '\u24BD': 'H', 130 | '\uFF28': 'H', 131 | '\u0124': 'H', 132 | '\u1E22': 'H', 133 | '\u1E26': 'H', 134 | '\u021E': 'H', 135 | '\u1E24': 'H', 136 | '\u1E28': 'H', 137 | '\u1E2A': 'H', 138 | '\u0126': 'H', 139 | '\u2C67': 'H', 140 | '\u2C75': 'H', 141 | '\uA78D': 'H', 142 | '\u24BE': 'I', 143 | '\uFF29': 'I', 144 | '\u00CC': 'I', 145 | '\u00CD': 'I', 146 | '\u00CE': 'I', 147 | '\u0128': 'I', 148 | '\u012A': 'I', 149 | '\u012C': 'I', 150 | '\u0130': 'I', 151 | '\u00CF': 'I', 152 | '\u1E2E': 'I', 153 | '\u1EC8': 'I', 154 | '\u01CF': 'I', 155 | '\u0208': 'I', 156 | '\u020A': 'I', 157 | '\u1ECA': 'I', 158 | '\u012E': 'I', 159 | '\u1E2C': 'I', 160 | '\u0197': 'I', 161 | '\u24BF': 'J', 162 | '\uFF2A': 'J', 163 | '\u0134': 'J', 164 | '\u0248': 'J', 165 | '\u24C0': 'K', 166 | '\uFF2B': 'K', 167 | '\u1E30': 'K', 168 | '\u01E8': 'K', 169 | '\u1E32': 'K', 170 | '\u0136': 'K', 171 | '\u1E34': 'K', 172 | '\u0198': 'K', 173 | '\u2C69': 'K', 174 | '\uA740': 'K', 175 | '\uA742': 'K', 176 | '\uA744': 'K', 177 | '\uA7A2': 'K', 178 | '\u24C1': 'L', 179 | '\uFF2C': 'L', 180 | '\u013F': 'L', 181 | '\u0139': 'L', 182 | '\u013D': 'L', 183 | '\u1E36': 'L', 184 | '\u1E38': 'L', 185 | '\u013B': 'L', 186 | '\u1E3C': 'L', 187 | '\u1E3A': 'L', 188 | '\u0141': 'L', 189 | '\u023D': 'L', 190 | '\u2C62': 'L', 191 | '\u2C60': 'L', 192 | '\uA748': 'L', 193 | '\uA746': 'L', 194 | '\uA780': 'L', 195 | '\u01C7': 'LJ', 196 | '\u01C8': 'Lj', 197 | '\u24C2': 'M', 198 | '\uFF2D': 'M', 199 | '\u1E3E': 'M', 200 | '\u1E40': 'M', 201 | '\u1E42': 'M', 202 | '\u2C6E': 'M', 203 | '\u019C': 'M', 204 | '\u24C3': 'N', 205 | '\uFF2E': 'N', 206 | '\u01F8': 'N', 207 | '\u0143': 'N', 208 | '\u00D1': 'N', 209 | '\u1E44': 'N', 210 | '\u0147': 'N', 211 | '\u1E46': 'N', 212 | '\u0145': 'N', 213 | '\u1E4A': 'N', 214 | '\u1E48': 'N', 215 | '\u0220': 'N', 216 | '\u019D': 'N', 217 | '\uA790': 'N', 218 | '\uA7A4': 'N', 219 | '\u01CA': 'NJ', 220 | '\u01CB': 'Nj', 221 | '\u24C4': 'O', 222 | '\uFF2F': 'O', 223 | '\u00D2': 'O', 224 | '\u00D3': 'O', 225 | '\u00D4': 'O', 226 | '\u1ED2': 'O', 227 | '\u1ED0': 'O', 228 | '\u1ED6': 'O', 229 | '\u1ED4': 'O', 230 | '\u00D5': 'O', 231 | '\u1E4C': 'O', 232 | '\u022C': 'O', 233 | '\u1E4E': 'O', 234 | '\u014C': 'O', 235 | '\u1E50': 'O', 236 | '\u1E52': 'O', 237 | '\u014E': 'O', 238 | '\u022E': 'O', 239 | '\u0230': 'O', 240 | '\u00D6': 'O', 241 | '\u022A': 'O', 242 | '\u1ECE': 'O', 243 | '\u0150': 'O', 244 | '\u01D1': 'O', 245 | '\u020C': 'O', 246 | '\u020E': 'O', 247 | '\u01A0': 'O', 248 | '\u1EDC': 'O', 249 | '\u1EDA': 'O', 250 | '\u1EE0': 'O', 251 | '\u1EDE': 'O', 252 | '\u1EE2': 'O', 253 | '\u1ECC': 'O', 254 | '\u1ED8': 'O', 255 | '\u01EA': 'O', 256 | '\u01EC': 'O', 257 | '\u00D8': 'O', 258 | '\u01FE': 'O', 259 | '\u0186': 'O', 260 | '\u019F': 'O', 261 | '\uA74A': 'O', 262 | '\uA74C': 'O', 263 | '\u01A2': 'OI', 264 | '\uA74E': 'OO', 265 | '\u0222': 'OU', 266 | '\u24C5': 'P', 267 | '\uFF30': 'P', 268 | '\u1E54': 'P', 269 | '\u1E56': 'P', 270 | '\u01A4': 'P', 271 | '\u2C63': 'P', 272 | '\uA750': 'P', 273 | '\uA752': 'P', 274 | '\uA754': 'P', 275 | '\u24C6': 'Q', 276 | '\uFF31': 'Q', 277 | '\uA756': 'Q', 278 | '\uA758': 'Q', 279 | '\u024A': 'Q', 280 | '\u24C7': 'R', 281 | '\uFF32': 'R', 282 | '\u0154': 'R', 283 | '\u1E58': 'R', 284 | '\u0158': 'R', 285 | '\u0210': 'R', 286 | '\u0212': 'R', 287 | '\u1E5A': 'R', 288 | '\u1E5C': 'R', 289 | '\u0156': 'R', 290 | '\u1E5E': 'R', 291 | '\u024C': 'R', 292 | '\u2C64': 'R', 293 | '\uA75A': 'R', 294 | '\uA7A6': 'R', 295 | '\uA782': 'R', 296 | '\u24C8': 'S', 297 | '\uFF33': 'S', 298 | '\u1E9E': 'S', 299 | '\u015A': 'S', 300 | '\u1E64': 'S', 301 | '\u015C': 'S', 302 | '\u1E60': 'S', 303 | '\u0160': 'S', 304 | '\u1E66': 'S', 305 | '\u1E62': 'S', 306 | '\u1E68': 'S', 307 | '\u0218': 'S', 308 | '\u015E': 'S', 309 | '\u2C7E': 'S', 310 | '\uA7A8': 'S', 311 | '\uA784': 'S', 312 | '\u24C9': 'T', 313 | '\uFF34': 'T', 314 | '\u1E6A': 'T', 315 | '\u0164': 'T', 316 | '\u1E6C': 'T', 317 | '\u021A': 'T', 318 | '\u0162': 'T', 319 | '\u1E70': 'T', 320 | '\u1E6E': 'T', 321 | '\u0166': 'T', 322 | '\u01AC': 'T', 323 | '\u01AE': 'T', 324 | '\u023E': 'T', 325 | '\uA786': 'T', 326 | '\uA728': 'TZ', 327 | '\u24CA': 'U', 328 | '\uFF35': 'U', 329 | '\u00D9': 'U', 330 | '\u00DA': 'U', 331 | '\u00DB': 'U', 332 | '\u0168': 'U', 333 | '\u1E78': 'U', 334 | '\u016A': 'U', 335 | '\u1E7A': 'U', 336 | '\u016C': 'U', 337 | '\u00DC': 'U', 338 | '\u01DB': 'U', 339 | '\u01D7': 'U', 340 | '\u01D5': 'U', 341 | '\u01D9': 'U', 342 | '\u1EE6': 'U', 343 | '\u016E': 'U', 344 | '\u0170': 'U', 345 | '\u01D3': 'U', 346 | '\u0214': 'U', 347 | '\u0216': 'U', 348 | '\u01AF': 'U', 349 | '\u1EEA': 'U', 350 | '\u1EE8': 'U', 351 | '\u1EEE': 'U', 352 | '\u1EEC': 'U', 353 | '\u1EF0': 'U', 354 | '\u1EE4': 'U', 355 | '\u1E72': 'U', 356 | '\u0172': 'U', 357 | '\u1E76': 'U', 358 | '\u1E74': 'U', 359 | '\u0244': 'U', 360 | '\u24CB': 'V', 361 | '\uFF36': 'V', 362 | '\u1E7C': 'V', 363 | '\u1E7E': 'V', 364 | '\u01B2': 'V', 365 | '\uA75E': 'V', 366 | '\u0245': 'V', 367 | '\uA760': 'VY', 368 | '\u24CC': 'W', 369 | '\uFF37': 'W', 370 | '\u1E80': 'W', 371 | '\u1E82': 'W', 372 | '\u0174': 'W', 373 | '\u1E86': 'W', 374 | '\u1E84': 'W', 375 | '\u1E88': 'W', 376 | '\u2C72': 'W', 377 | '\u24CD': 'X', 378 | '\uFF38': 'X', 379 | '\u1E8A': 'X', 380 | '\u1E8C': 'X', 381 | '\u24CE': 'Y', 382 | '\uFF39': 'Y', 383 | '\u1EF2': 'Y', 384 | '\u00DD': 'Y', 385 | '\u0176': 'Y', 386 | '\u1EF8': 'Y', 387 | '\u0232': 'Y', 388 | '\u1E8E': 'Y', 389 | '\u0178': 'Y', 390 | '\u1EF6': 'Y', 391 | '\u1EF4': 'Y', 392 | '\u01B3': 'Y', 393 | '\u024E': 'Y', 394 | '\u1EFE': 'Y', 395 | '\u24CF': 'Z', 396 | '\uFF3A': 'Z', 397 | '\u0179': 'Z', 398 | '\u1E90': 'Z', 399 | '\u017B': 'Z', 400 | '\u017D': 'Z', 401 | '\u1E92': 'Z', 402 | '\u1E94': 'Z', 403 | '\u01B5': 'Z', 404 | '\u0224': 'Z', 405 | '\u2C7F': 'Z', 406 | '\u2C6B': 'Z', 407 | '\uA762': 'Z', 408 | '\u24D0': 'a', 409 | '\uFF41': 'a', 410 | '\u1E9A': 'a', 411 | '\u00E0': 'a', 412 | '\u00E1': 'a', 413 | '\u00E2': 'a', 414 | '\u1EA7': 'a', 415 | '\u1EA5': 'a', 416 | '\u1EAB': 'a', 417 | '\u1EA9': 'a', 418 | '\u00E3': 'a', 419 | '\u0101': 'a', 420 | '\u0103': 'a', 421 | '\u1EB1': 'a', 422 | '\u1EAF': 'a', 423 | '\u1EB5': 'a', 424 | '\u1EB3': 'a', 425 | '\u0227': 'a', 426 | '\u01E1': 'a', 427 | '\u00E4': 'a', 428 | '\u01DF': 'a', 429 | '\u1EA3': 'a', 430 | '\u00E5': 'a', 431 | '\u01FB': 'a', 432 | '\u01CE': 'a', 433 | '\u0201': 'a', 434 | '\u0203': 'a', 435 | '\u1EA1': 'a', 436 | '\u1EAD': 'a', 437 | '\u1EB7': 'a', 438 | '\u1E01': 'a', 439 | '\u0105': 'a', 440 | '\u2C65': 'a', 441 | '\u0250': 'a', 442 | '\uA733': 'aa', 443 | '\u00E6': 'ae', 444 | '\u01FD': 'ae', 445 | '\u01E3': 'ae', 446 | '\uA735': 'ao', 447 | '\uA737': 'au', 448 | '\uA739': 'av', 449 | '\uA73B': 'av', 450 | '\uA73D': 'ay', 451 | '\u24D1': 'b', 452 | '\uFF42': 'b', 453 | '\u1E03': 'b', 454 | '\u1E05': 'b', 455 | '\u1E07': 'b', 456 | '\u0180': 'b', 457 | '\u0183': 'b', 458 | '\u0253': 'b', 459 | '\u24D2': 'c', 460 | '\uFF43': 'c', 461 | '\u0107': 'c', 462 | '\u0109': 'c', 463 | '\u010B': 'c', 464 | '\u010D': 'c', 465 | '\u00E7': 'c', 466 | '\u1E09': 'c', 467 | '\u0188': 'c', 468 | '\u023C': 'c', 469 | '\uA73F': 'c', 470 | '\u2184': 'c', 471 | '\u24D3': 'd', 472 | '\uFF44': 'd', 473 | '\u1E0B': 'd', 474 | '\u010F': 'd', 475 | '\u1E0D': 'd', 476 | '\u1E11': 'd', 477 | '\u1E13': 'd', 478 | '\u1E0F': 'd', 479 | '\u0111': 'd', 480 | '\u018C': 'd', 481 | '\u0256': 'd', 482 | '\u0257': 'd', 483 | '\uA77A': 'd', 484 | '\u01F3': 'dz', 485 | '\u01C6': 'dz', 486 | '\u24D4': 'e', 487 | '\uFF45': 'e', 488 | '\u00E8': 'e', 489 | '\u00E9': 'e', 490 | '\u00EA': 'e', 491 | '\u1EC1': 'e', 492 | '\u1EBF': 'e', 493 | '\u1EC5': 'e', 494 | '\u1EC3': 'e', 495 | '\u1EBD': 'e', 496 | '\u0113': 'e', 497 | '\u1E15': 'e', 498 | '\u1E17': 'e', 499 | '\u0115': 'e', 500 | '\u0117': 'e', 501 | '\u00EB': 'e', 502 | '\u1EBB': 'e', 503 | '\u011B': 'e', 504 | '\u0205': 'e', 505 | '\u0207': 'e', 506 | '\u1EB9': 'e', 507 | '\u1EC7': 'e', 508 | '\u0229': 'e', 509 | '\u1E1D': 'e', 510 | '\u0119': 'e', 511 | '\u1E19': 'e', 512 | '\u1E1B': 'e', 513 | '\u0247': 'e', 514 | '\u025B': 'e', 515 | '\u01DD': 'e', 516 | '\u24D5': 'f', 517 | '\uFF46': 'f', 518 | '\u1E1F': 'f', 519 | '\u0192': 'f', 520 | '\uA77C': 'f', 521 | '\u24D6': 'g', 522 | '\uFF47': 'g', 523 | '\u01F5': 'g', 524 | '\u011D': 'g', 525 | '\u1E21': 'g', 526 | '\u011F': 'g', 527 | '\u0121': 'g', 528 | '\u01E7': 'g', 529 | '\u0123': 'g', 530 | '\u01E5': 'g', 531 | '\u0260': 'g', 532 | '\uA7A1': 'g', 533 | '\u1D79': 'g', 534 | '\uA77F': 'g', 535 | '\u24D7': 'h', 536 | '\uFF48': 'h', 537 | '\u0125': 'h', 538 | '\u1E23': 'h', 539 | '\u1E27': 'h', 540 | '\u021F': 'h', 541 | '\u1E25': 'h', 542 | '\u1E29': 'h', 543 | '\u1E2B': 'h', 544 | '\u1E96': 'h', 545 | '\u0127': 'h', 546 | '\u2C68': 'h', 547 | '\u2C76': 'h', 548 | '\u0265': 'h', 549 | '\u0195': 'hv', 550 | '\u24D8': 'i', 551 | '\uFF49': 'i', 552 | '\u00EC': 'i', 553 | '\u00ED': 'i', 554 | '\u00EE': 'i', 555 | '\u0129': 'i', 556 | '\u012B': 'i', 557 | '\u012D': 'i', 558 | '\u00EF': 'i', 559 | '\u1E2F': 'i', 560 | '\u1EC9': 'i', 561 | '\u01D0': 'i', 562 | '\u0209': 'i', 563 | '\u020B': 'i', 564 | '\u1ECB': 'i', 565 | '\u012F': 'i', 566 | '\u1E2D': 'i', 567 | '\u0268': 'i', 568 | '\u0131': 'i', 569 | '\u24D9': 'j', 570 | '\uFF4A': 'j', 571 | '\u0135': 'j', 572 | '\u01F0': 'j', 573 | '\u0249': 'j', 574 | '\u24DA': 'k', 575 | '\uFF4B': 'k', 576 | '\u1E31': 'k', 577 | '\u01E9': 'k', 578 | '\u1E33': 'k', 579 | '\u0137': 'k', 580 | '\u1E35': 'k', 581 | '\u0199': 'k', 582 | '\u2C6A': 'k', 583 | '\uA741': 'k', 584 | '\uA743': 'k', 585 | '\uA745': 'k', 586 | '\uA7A3': 'k', 587 | '\u24DB': 'l', 588 | '\uFF4C': 'l', 589 | '\u0140': 'l', 590 | '\u013A': 'l', 591 | '\u013E': 'l', 592 | '\u1E37': 'l', 593 | '\u1E39': 'l', 594 | '\u013C': 'l', 595 | '\u1E3D': 'l', 596 | '\u1E3B': 'l', 597 | '\u017F': 'l', 598 | '\u0142': 'l', 599 | '\u019A': 'l', 600 | '\u026B': 'l', 601 | '\u2C61': 'l', 602 | '\uA749': 'l', 603 | '\uA781': 'l', 604 | '\uA747': 'l', 605 | '\u01C9': 'lj', 606 | '\u24DC': 'm', 607 | '\uFF4D': 'm', 608 | '\u1E3F': 'm', 609 | '\u1E41': 'm', 610 | '\u1E43': 'm', 611 | '\u0271': 'm', 612 | '\u026F': 'm', 613 | '\u24DD': 'n', 614 | '\uFF4E': 'n', 615 | '\u01F9': 'n', 616 | '\u0144': 'n', 617 | '\u00F1': 'n', 618 | '\u1E45': 'n', 619 | '\u0148': 'n', 620 | '\u1E47': 'n', 621 | '\u0146': 'n', 622 | '\u1E4B': 'n', 623 | '\u1E49': 'n', 624 | '\u019E': 'n', 625 | '\u0272': 'n', 626 | '\u0149': 'n', 627 | '\uA791': 'n', 628 | '\uA7A5': 'n', 629 | '\u01CC': 'nj', 630 | '\u24DE': 'o', 631 | '\uFF4F': 'o', 632 | '\u00F2': 'o', 633 | '\u00F3': 'o', 634 | '\u00F4': 'o', 635 | '\u1ED3': 'o', 636 | '\u1ED1': 'o', 637 | '\u1ED7': 'o', 638 | '\u1ED5': 'o', 639 | '\u00F5': 'o', 640 | '\u1E4D': 'o', 641 | '\u022D': 'o', 642 | '\u1E4F': 'o', 643 | '\u014D': 'o', 644 | '\u1E51': 'o', 645 | '\u1E53': 'o', 646 | '\u014F': 'o', 647 | '\u022F': 'o', 648 | '\u0231': 'o', 649 | '\u00F6': 'o', 650 | '\u022B': 'o', 651 | '\u1ECF': 'o', 652 | '\u0151': 'o', 653 | '\u01D2': 'o', 654 | '\u020D': 'o', 655 | '\u020F': 'o', 656 | '\u01A1': 'o', 657 | '\u1EDD': 'o', 658 | '\u1EDB': 'o', 659 | '\u1EE1': 'o', 660 | '\u1EDF': 'o', 661 | '\u1EE3': 'o', 662 | '\u1ECD': 'o', 663 | '\u1ED9': 'o', 664 | '\u01EB': 'o', 665 | '\u01ED': 'o', 666 | '\u00F8': 'o', 667 | '\u01FF': 'o', 668 | '\u0254': 'o', 669 | '\uA74B': 'o', 670 | '\uA74D': 'o', 671 | '\u0275': 'o', 672 | '\u01A3': 'oi', 673 | '\u0223': 'ou', 674 | '\uA74F': 'oo', 675 | '\u24DF': 'p', 676 | '\uFF50': 'p', 677 | '\u1E55': 'p', 678 | '\u1E57': 'p', 679 | '\u01A5': 'p', 680 | '\u1D7D': 'p', 681 | '\uA751': 'p', 682 | '\uA753': 'p', 683 | '\uA755': 'p', 684 | '\u24E0': 'q', 685 | '\uFF51': 'q', 686 | '\u024B': 'q', 687 | '\uA757': 'q', 688 | '\uA759': 'q', 689 | '\u24E1': 'r', 690 | '\uFF52': 'r', 691 | '\u0155': 'r', 692 | '\u1E59': 'r', 693 | '\u0159': 'r', 694 | '\u0211': 'r', 695 | '\u0213': 'r', 696 | '\u1E5B': 'r', 697 | '\u1E5D': 'r', 698 | '\u0157': 'r', 699 | '\u1E5F': 'r', 700 | '\u024D': 'r', 701 | '\u027D': 'r', 702 | '\uA75B': 'r', 703 | '\uA7A7': 'r', 704 | '\uA783': 'r', 705 | '\u24E2': 's', 706 | '\uFF53': 's', 707 | '\u00DF': 's', 708 | '\u015B': 's', 709 | '\u1E65': 's', 710 | '\u015D': 's', 711 | '\u1E61': 's', 712 | '\u0161': 's', 713 | '\u1E67': 's', 714 | '\u1E63': 's', 715 | '\u1E69': 's', 716 | '\u0219': 's', 717 | '\u015F': 's', 718 | '\u023F': 's', 719 | '\uA7A9': 's', 720 | '\uA785': 's', 721 | '\u1E9B': 's', 722 | '\u24E3': 't', 723 | '\uFF54': 't', 724 | '\u1E6B': 't', 725 | '\u1E97': 't', 726 | '\u0165': 't', 727 | '\u1E6D': 't', 728 | '\u021B': 't', 729 | '\u0163': 't', 730 | '\u1E71': 't', 731 | '\u1E6F': 't', 732 | '\u0167': 't', 733 | '\u01AD': 't', 734 | '\u0288': 't', 735 | '\u2C66': 't', 736 | '\uA787': 't', 737 | '\uA729': 'tz', 738 | '\u24E4': 'u', 739 | '\uFF55': 'u', 740 | '\u00F9': 'u', 741 | '\u00FA': 'u', 742 | '\u00FB': 'u', 743 | '\u0169': 'u', 744 | '\u1E79': 'u', 745 | '\u016B': 'u', 746 | '\u1E7B': 'u', 747 | '\u016D': 'u', 748 | '\u00FC': 'u', 749 | '\u01DC': 'u', 750 | '\u01D8': 'u', 751 | '\u01D6': 'u', 752 | '\u01DA': 'u', 753 | '\u1EE7': 'u', 754 | '\u016F': 'u', 755 | '\u0171': 'u', 756 | '\u01D4': 'u', 757 | '\u0215': 'u', 758 | '\u0217': 'u', 759 | '\u01B0': 'u', 760 | '\u1EEB': 'u', 761 | '\u1EE9': 'u', 762 | '\u1EEF': 'u', 763 | '\u1EED': 'u', 764 | '\u1EF1': 'u', 765 | '\u1EE5': 'u', 766 | '\u1E73': 'u', 767 | '\u0173': 'u', 768 | '\u1E77': 'u', 769 | '\u1E75': 'u', 770 | '\u0289': 'u', 771 | '\u24E5': 'v', 772 | '\uFF56': 'v', 773 | '\u1E7D': 'v', 774 | '\u1E7F': 'v', 775 | '\u028B': 'v', 776 | '\uA75F': 'v', 777 | '\u028C': 'v', 778 | '\uA761': 'vy', 779 | '\u24E6': 'w', 780 | '\uFF57': 'w', 781 | '\u1E81': 'w', 782 | '\u1E83': 'w', 783 | '\u0175': 'w', 784 | '\u1E87': 'w', 785 | '\u1E85': 'w', 786 | '\u1E98': 'w', 787 | '\u1E89': 'w', 788 | '\u2C73': 'w', 789 | '\u24E7': 'x', 790 | '\uFF58': 'x', 791 | '\u1E8B': 'x', 792 | '\u1E8D': 'x', 793 | '\u24E8': 'y', 794 | '\uFF59': 'y', 795 | '\u1EF3': 'y', 796 | '\u00FD': 'y', 797 | '\u0177': 'y', 798 | '\u1EF9': 'y', 799 | '\u0233': 'y', 800 | '\u1E8F': 'y', 801 | '\u00FF': 'y', 802 | '\u1EF7': 'y', 803 | '\u1E99': 'y', 804 | '\u1EF5': 'y', 805 | '\u01B4': 'y', 806 | '\u024F': 'y', 807 | '\u1EFF': 'y', 808 | '\u24E9': 'z', 809 | '\uFF5A': 'z', 810 | '\u017A': 'z', 811 | '\u1E91': 'z', 812 | '\u017C': 'z', 813 | '\u017E': 'z', 814 | '\u1E93': 'z', 815 | '\u1E95': 'z', 816 | '\u01B6': 'z', 817 | '\u0225': 'z', 818 | '\u0240': 'z', 819 | '\u2C6C': 'z', 820 | '\uA763': 'z', 821 | '\u0386': '\u0391', 822 | '\u0388': '\u0395', 823 | '\u0389': '\u0397', 824 | '\u038A': '\u0399', 825 | '\u03AA': '\u0399', 826 | '\u038C': '\u039F', 827 | '\u038E': '\u03A5', 828 | '\u03AB': '\u03A5', 829 | '\u038F': '\u03A9', 830 | '\u03AC': '\u03B1', 831 | '\u03AD': '\u03B5', 832 | '\u03AE': '\u03B7', 833 | '\u03AF': '\u03B9', 834 | '\u03CA': '\u03B9', 835 | '\u0390': '\u03B9', 836 | '\u03CC': '\u03BF', 837 | '\u03CD': '\u03C5', 838 | '\u03CB': '\u03C5', 839 | '\u03B0': '\u03C5', 840 | '\u03C9': '\u03C9', 841 | '\u03C2': '\u03C3' 842 | }; 843 | 844 | 845 | function stripDiacritics (text) { 846 | // Used 'uni range + named function' from http://jsperf.com/diacritics/18 847 | function match(a) { 848 | return DIACRITICS[a] || a; 849 | } 850 | return text.replace(/[^\u0000-\u007E]/g, match); 851 | } 852 | 853 | // The following matcher is a modification version of the default matcher 854 | // of select2 855 | function matcher(params, data) { 856 | // Always return the object if there is nothing to compare 857 | if ($.trim(params.term) === '') { 858 | return data; 859 | } 860 | 861 | // Do a recursive check for options with children 862 | if (data.children && data.children.length > 0) { 863 | // Clone the data object if there are children 864 | // This is required as we modify the object to remove any non-matches 865 | var match = $.extend(true, {}, data); 866 | 867 | // Check each child of the option 868 | for (var c = data.children.length - 1; c >= 0; c--) { 869 | var child = data.children[c]; 870 | 871 | var matches = matcher(params, child); 872 | 873 | // If there wasn't a match, remove the object in the array 874 | if (matches == null) { 875 | match.children.splice(c, 1); 876 | } 877 | } 878 | 879 | // If any children matched, return the new object 880 | if (match.children.length > 0) { 881 | return match; 882 | } 883 | 884 | // If there were no matching children, check just the plain object 885 | return matcher(params, match); 886 | } 887 | 888 | var original = stripDiacritics(data.text).toUpperCase(); 889 | var term = stripDiacritics(params.term).toUpperCase(); 890 | 891 | // Check if the text contains the term 892 | if (original.indexOf(term) > -1) { 893 | return data; 894 | } 895 | 896 | // add by Haixing Hu: also match the value of an option 897 | if (data.id) { 898 | var originalValue = stripDiacritics(data.id).toUpperCase(); 899 | if (originalValue.indexOf(term) > -1) { 900 | return data; 901 | } 902 | } 903 | 904 | // If it doesn't contain the term, don't return anything 905 | return null; 906 | } 907 | 908 | module.exports = matcher; -------------------------------------------------------------------------------- /src/vue-select.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The default language used by this component. 3 | */ 4 | var DEFAULT_LANGUAGE = "en-US"; 5 | 6 | /** 7 | * A bootstrap style selection (combobox) control using the select2 plugin. 8 | * 9 | * @param options 10 | * the array of options of the selection control. It could be an array of 11 | * strings, e.g., "['opt1', 'opt2']"; or an array of objects specifying 12 | * the text and value of each option, e.g., 13 | * "[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]"; 14 | * or it could be an array of objects specifying the option group, e.g. 15 | * "[{label: 'group1', options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]}, 16 | * {label: 'group2', options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}]}]". 17 | * @param model 18 | * the model bind to the control, which must be a two way binding variable. 19 | * @param searchable 20 | * the optional flag indicates whether to show the search box. Default value 21 | * is false. 22 | * @param matchValue 23 | * the optional flag indicates whether the searching should match both the 24 | * texts and values of options. Default value is true. 25 | * @param multiple 26 | * indicates whether the selection control support multiple values. Default 27 | * value is false. 28 | * @param language 29 | * the optional code of language used by the select2 plugin. If it is not set, 30 | * and the [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin is used, 31 | * the component will use the language code `$language` provided by the 32 | * [vue-i18n](https://github.com/Haixing-Hu/vue-i18n) plugin; otherwise, the 33 | * component will use the default value "en-US". 34 | * @param theme 35 | * the optional name of the theme of the select2. Default value is "bootstrap". 36 | * @param name 37 | * the optional name of the selection control. 38 | * @author Haixing Hu 39 | */ 40 | module.exports = { 41 | replace: true, 42 | inherit: false, 43 | template: "", 50 | props: { 51 | options: { 52 | type: Array, 53 | required: true 54 | }, 55 | model: { 56 | required: true, 57 | twoWay: true 58 | }, 59 | searchable: { 60 | type: Boolean, 61 | required: false, 62 | default: false 63 | }, 64 | matchValue: { 65 | type: Boolean, 66 | required: false, 67 | default: true 68 | }, 69 | name: { 70 | type: String, 71 | required: false, 72 | default: "" 73 | }, 74 | language: { 75 | type: String, 76 | required: false, 77 | default: "" 78 | }, 79 | multiple: { 80 | type: Boolean, 81 | required: false, 82 | default: false 83 | }, 84 | theme: { 85 | type: String, 86 | required: false, 87 | default: "bootstrap" 88 | } 89 | }, 90 | data: function() { 91 | return { 92 | optionsType: "unknown" 93 | } 94 | }, 95 | beforeCompile: function() { 96 | this.isChanging = false; 97 | this.control = null; 98 | this.optionsType = this.getOptionsType(); 99 | }, 100 | watch: { 101 | "options": function(val, oldVal) { 102 | //console.debug("options.change"); 103 | this.optionsType = this.getOptionsType(); 104 | var found = this.inOptions(this.model); 105 | var newValue = (found ? this.model : null); 106 | this.control.removeData("data"); // remove the cached options data 107 | // note that setting the model will automatically changed in the "change" 108 | // event of the select2 control 109 | this.isChanging = true; 110 | this.model = newValue; 111 | this.control.val(newValue).trigger("change"); 112 | this.isChanging = false; 113 | }, 114 | "model": function(val, oldVal) { 115 | //console.debug("model.change"); 116 | if (! this.isChanging) { 117 | this.isChanging = true; 118 | this.control.val(val).trigger("change"); 119 | this.isChanging = false; 120 | } 121 | } 122 | }, 123 | ready: function() { 124 | var language = this.language; 125 | if (language === null || language === "") { 126 | if (this.$language) { 127 | language = this.$language; 128 | } else { 129 | language = DEFAULT_LANGUAGE; 130 | } 131 | } 132 | var args = { 133 | theme: this.theme, 134 | language: this.getLanguageCode(language) 135 | }; 136 | if (! this.searchable) { 137 | args.minimumResultsForSearch = Infinity; // hide the search box 138 | } else { 139 | if (this.matchValue) { 140 | args.matcher = require("./value-text-matcher.js"); 141 | } 142 | } 143 | this.control = $(this.$el); 144 | this.control.select2(args); 145 | var me = this; 146 | this.control.on("change", function(e) { 147 | //console.debug("control.change"); 148 | if (! me.isChanging) { 149 | me.isChanging = true; 150 | me.model = me.control.val(); 151 | me.$nextTick(function () { 152 | me.isChanging = false; 153 | }); 154 | } 155 | }); 156 | }, 157 | methods: { 158 | 159 | /** 160 | * Gets the type of the `options` property of this component. 161 | * 162 | * The `options` property of this component may have the following types: 163 | * - "values": the `options` is an array of strings, e.g., `[value1, value2, value3]`; 164 | * - "options": the `options` is an array of options, e.g., `[{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]`; 165 | * - "groups": the `options` is an array of option groups, e.g., 166 | * `[{label: 'group1', options: [{text: 'name1', value: 'val1'}, {text: 'name2', value: 'val2'}]}, 167 | * {label: 'group2', options: [{text: 'name3', value: 'val3'}, {text: 'name4', value: 'val4'}]}]`; 168 | * 169 | * @param options 170 | * the new options. 171 | * @return 172 | * the string representing the type of the `options` property of this 173 | * component. 174 | */ 175 | getOptionsType: function() { 176 | if (this.options.length === 0) { 177 | return "values"; 178 | } 179 | var el = this.options[0]; 180 | if (typeof el == "string" || el instanceof String) { 181 | return "values"; 182 | } else if (typeof el.text !== "undefined") { 183 | return "options"; 184 | } else if (typeof el.label !== "undefined") { 185 | return "groups"; 186 | } else { 187 | return "unknown"; 188 | } 189 | }, 190 | 191 | /** 192 | * Tests whether a specified value exists in the options. 193 | * 194 | * @param value 195 | * the value to test. 196 | * @return 197 | * true if the specified value exists in the options; false otherwise. 198 | */ 199 | inOptions: function(value) { 200 | var type = this.getOptionsType(); 201 | var list = this.options; 202 | var i, j; 203 | switch (type) { 204 | case "values": 205 | for (i = 0; i < list.length; ++i) { 206 | if (value === list[i]) { 207 | return true; 208 | } 209 | } 210 | break; 211 | case "options": 212 | for (i = 0; i < list.length; ++i) { 213 | if (value === list[i].value) { 214 | return true; 215 | } 216 | } 217 | break; 218 | case "groups": 219 | for (i = 0; i < list.length; ++i) { 220 | var options = list[i].options; 221 | for (j = 0; j < options.length; ++j) { 222 | if (value === options[j].value) { 223 | return true; 224 | } 225 | } 226 | } 227 | break; 228 | default: 229 | break; 230 | } 231 | return false; 232 | }, 233 | 234 | /** 235 | * Gets the language code from the "language-country" locale code. 236 | * 237 | * The function will strip the language code before the first "-" of a 238 | * locale code. For example, pass "en-US" will returns "en". But for some 239 | * special locales, the function reserves the locale code. For example, 240 | * the "zh-CN" for the simplified Chinese and the "zh-TW" for the 241 | * traditional Chinese. 242 | * 243 | * @param locale 244 | * A locale code. 245 | * @return 246 | * the language code of the locale. 247 | */ 248 | getLanguageCode: function(locale) { 249 | if (locale === null || locale.length === 0) { 250 | return "en"; 251 | } 252 | if (locale.length <= 2) { 253 | return locale; 254 | } else { 255 | switch (locale) { 256 | case "pt-BR": 257 | case "zh-CN": 258 | case "zh-TW": 259 | return locale; 260 | default: 261 | // reserve only the first two letters language code 262 | return locale.substr(0, 2); 263 | } 264 | } 265 | } 266 | } 267 | }; 268 | -------------------------------------------------------------------------------- /test/specs/i18n/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "hello": "您好" 3 | } -------------------------------------------------------------------------------- /test/specs/vue-select.js: -------------------------------------------------------------------------------- 1 | var assert = require("assert"); 2 | var Vue = require("vue"); 3 | var Demo = require("../../demo/demo.vue"); 4 | var VueI18n = require("../../lib/vue-i18n-plugin/src/vue-i18n.js"); 5 | var VueSelect = require("../../src/vue-select.js"); 6 | 7 | var getVM = function(rootId, initResult1, initResult2, initResult3, initResult4) { 8 | return Vue.extend({ 9 | template: "
", 15 | el: function() { 16 | var el = document.createElement("div"); 17 | el.id = rootId; 18 | document.body.appendChild(el); 19 | return el; 20 | }, 21 | components: { 22 | "demo": Demo 23 | }, 24 | data: function() { 25 | return { 26 | result1: initResult1, 27 | result2: initResult2, 28 | result3: initResult3, 29 | result4: initResult4 30 | }; 31 | } 32 | }); 33 | }; 34 | 35 | describe("vue-select", function() { 36 | 37 | describe("static render", function() { 38 | var VM = getVM("static-render", null, "value2", "value6", ["value2", "value5"]); 39 | var vm = new VM(); 40 | 41 | it("select1", function(done) { 42 | vm.$nextTick(function() { 43 | var root = $("#static-render"); 44 | var select1 = root.find(".vue-select1"); 45 | assert.equal(select1.prop("tagName"), "SELECT"); 46 | assert.equal(select1.prop("name"), "select1"); 47 | var options1 = select1.find("option"); 48 | assert.equal(options1.length, 3); 49 | assert.equal(options1[0].text, "value1"); 50 | assert.equal(options1[0].value, "value1"); 51 | assert.equal(options1[1].text, "value2"); 52 | assert.equal(options1[1].value, "value2"); 53 | assert.equal(options1[2].text, "value3"); 54 | assert.equal(options1[2].value, "value3"); 55 | 56 | // check the value of the select1 57 | assert.equal(select1.val(), null); 58 | 59 | // check the text content of select1 60 | var select1Text = select1.next(".select2").find(".select2-selection__rendered"); 61 | assert.equal(select1Text.text(), ""); 62 | 63 | // check results 64 | var result1 = root.find(".vue-result1"); 65 | assert.equal(result1.text(), ""); 66 | 67 | // check vm data 68 | assert.equal(vm.result1, null); 69 | 70 | done(); 71 | }); 72 | }); 73 | 74 | it("select2", function(done) { 75 | vm.$nextTick(function() { 76 | var root = $("#static-render"); 77 | // check select2 78 | var select2 = root.find(".vue-select2"); 79 | assert.equal(select2.prop("tagName"), "SELECT"); 80 | assert.equal(select2.prop("name"), "select2"); 81 | var options2 = select2.find("option"); 82 | assert.equal(options2.length, 3); 83 | assert.equal(options2[0].text, "name1"); 84 | assert.equal(options2[0].value, "value1"); 85 | assert.equal(options2[1].text, "name2"); 86 | assert.equal(options2[1].value, "value2"); 87 | assert.equal(options2[2].text, "name3"); 88 | assert.equal(options2[2].value, "value3"); 89 | 90 | // check the value of the select2 91 | assert.equal(select2.val(), "value2"); 92 | 93 | // check the text content of select2 94 | var select2Text = select2.next(".select2").find(".select2-selection__rendered"); 95 | assert.equal(select2Text.text(), "name2"); 96 | 97 | // check results 98 | var result2 = root.find(".vue-result2"); 99 | assert.equal(result2.text(), "value2"); 100 | 101 | // check vm data 102 | assert.equal(vm.result2, "value2"); 103 | 104 | done(); 105 | }); 106 | }); 107 | 108 | it("select3", function(done) { 109 | vm.$nextTick(function() { 110 | var root = $("#static-render"); 111 | // check select3 112 | var select3 = root.find(".vue-select3"); 113 | assert.equal(select3.prop("tagName"), "SELECT"); 114 | assert.equal(select3.prop("name"), "select3"); 115 | var optgroups3 = select3.find("optgroup"); 116 | assert.equal(optgroups3.length, 2); 117 | var options3_1 = $(optgroups3[0]).find("option"); 118 | assert.equal(options3_1.length, 3); 119 | assert.equal(options3_1[0].text, "name1"); 120 | assert.equal(options3_1[0].value, "value1"); 121 | assert.equal(options3_1[1].text, "name2"); 122 | assert.equal(options3_1[1].value, "value2"); 123 | assert.equal(options3_1[2].text, "name3"); 124 | assert.equal(options3_1[2].value, "value3"); 125 | 126 | var options3_2 = $(optgroups3[1]).find("option"); 127 | assert.equal(options3_2.length, 3); 128 | assert.equal(options3_2[0].text, "name4"); 129 | assert.equal(options3_2[0].value, "value4"); 130 | assert.equal(options3_2[1].text, "name5"); 131 | assert.equal(options3_2[1].value, "value5"); 132 | assert.equal(options3_2[2].text, "name6"); 133 | assert.equal(options3_2[2].value, "value6"); 134 | 135 | // check the value of the select3 136 | assert.equal(select3.val(), "value6"); 137 | 138 | // check the text content of select1 139 | var select3Text = select3.next(".select2").find(".select2-selection__rendered"); 140 | assert.equal(select3Text.text(), "name6"); 141 | 142 | // check results 143 | var result3 = root.find(".vue-result3"); 144 | assert.equal(result3.text(), "value6"); 145 | 146 | // check vm data 147 | assert.equal(vm.result3, "value6"); 148 | 149 | done(); 150 | }); 151 | }); 152 | 153 | 154 | it("select4", function(done) { 155 | vm.$nextTick(function() { 156 | var root = $("#static-render"); 157 | var select4 = root.find(".vue-select4"); 158 | assert.equal(select4.prop("tagName"), "SELECT"); 159 | assert.equal(select4.prop("name"), "select4"); 160 | var options4 = select4.find("option"); 161 | assert.equal(options4.length, 9); 162 | assert.equal(options4[0].text, "value1"); 163 | assert.equal(options4[0].value, "value1"); 164 | assert.equal(options4[1].text, "value2"); 165 | assert.equal(options4[1].value, "value2"); 166 | assert.equal(options4[2].text, "value3"); 167 | assert.equal(options4[2].value, "value3"); 168 | assert.equal(options4[3].text, "value4"); 169 | assert.equal(options4[3].value, "value4"); 170 | assert.equal(options4[4].text, "value5"); 171 | assert.equal(options4[4].value, "value5"); 172 | assert.equal(options4[5].text, "value6"); 173 | assert.equal(options4[5].value, "value6"); 174 | assert.equal(options4[6].text, "value7"); 175 | assert.equal(options4[6].value, "value7"); 176 | assert.equal(options4[7].text, "value8"); 177 | assert.equal(options4[7].value, "value8"); 178 | assert.equal(options4[8].text, "value9"); 179 | assert.equal(options4[8].value, "value9"); 180 | 181 | // check the value of the select4 182 | assert.deepEqual(select4.val(), ["value2", "value5"]); 183 | 184 | // check the text content of select4 185 | var select4Text = select4.next(".select2").find(".select2-selection__rendered"); 186 | assert.equal(select4Text.text(), "×value2×value5"); 187 | 188 | // check results 189 | var result4 = root.find(".vue-result4"); 190 | assert.equal(result4.text(), "value2,value5"); 191 | 192 | // check vm data 193 | assert.deepEqual(vm.result4, ["value2", "value5"]); 194 | 195 | done(); 196 | }); 197 | }); 198 | }); 199 | 200 | describe("change the model", function() { 201 | var VM = getVM("change-model", "", "value2", "value6", ["value8", "value1"]); 202 | var vm = new VM(); 203 | it("select1", function(done) { 204 | vm.$nextTick(function() { 205 | var root = $("#change-model"); 206 | var select1 = root.find(".vue-select1"); 207 | var select1Text = select1.next(".select2").find(".select2-selection__rendered"); 208 | assert.equal(select1.val(), null); 209 | assert.equal(select1Text.text(), ""); 210 | // change the vm 211 | vm.result1 = "value2"; 212 | vm.$nextTick(function() { 213 | assert.equal(select1.val(), "value2"); 214 | assert.equal(select1Text.text(), "value2"); 215 | done(); 216 | }); 217 | }); 218 | }); 219 | 220 | it("select2", function(done) { 221 | vm.$nextTick(function() { 222 | var root = $("#change-model"); 223 | var select2 = root.find(".vue-select2"); 224 | var select2Text = select2.next(".select2").find(".select2-selection__rendered"); 225 | assert.equal(select2.val(), "value2"); 226 | assert.equal(select2Text.text(), "name2"); 227 | // change the vm 228 | vm.result2 = "value1"; 229 | vm.$nextTick(function() { 230 | assert.equal(select2.val(), "value1"); 231 | assert.equal(select2Text.text(), "name1"); 232 | // change the vm 233 | vm.result2 = null; 234 | vm.$nextTick(function() { 235 | assert.equal(select2.val(), null); 236 | assert.equal(select2Text.text(), ""); 237 | done(); 238 | }); 239 | }); 240 | }); 241 | }); 242 | 243 | it("select3", function(done) { 244 | vm.$nextTick(function() { 245 | var root = $("#change-model"); 246 | var select3 = root.find(".vue-select3"); 247 | var select3Text = select3.next(".select2").find(".select2-selection__rendered"); 248 | assert.equal(select3.val(), "value6"); 249 | assert.equal(select3Text.text(), "name6"); 250 | // change the vm 251 | vm.result3 = "value3"; 252 | vm.$nextTick(function() { 253 | assert.equal(select3.val(), "value3"); 254 | assert.equal(select3Text.text(), "name3"); 255 | done(); 256 | }); 257 | }); 258 | }); 259 | 260 | 261 | it("select4", function(done) { 262 | vm.$nextTick(function() { 263 | var root = $("#change-model"); 264 | var select4 = root.find(".vue-select4"); 265 | var select4Text = select4.next(".select2").find(".select2-selection__rendered"); 266 | assert.deepEqual(select4.val(), ["value1", "value8"]); 267 | assert.equal(select4Text.text(), "×value1×value8"); 268 | // change the vm 269 | vm.result4 = ["value3"]; 270 | vm.$nextTick(function() { 271 | assert.equal(select4.val(), "value3"); 272 | assert.equal(select4Text.text(), "×value3"); 273 | done(); 274 | }); 275 | }); 276 | }); 277 | 278 | }); 279 | 280 | describe("change the selection", function() { 281 | var VM = getVM("change-selection", "", "value2", "value6", []); 282 | var vm = new VM(); 283 | 284 | it("select1", function(done) { 285 | vm.$nextTick(function() { 286 | var root = $("#change-selection"); 287 | var select1 = root.find(".vue-select1"); 288 | var select1Text = select1.next(".select2").find(".select2-selection__rendered"); 289 | assert.equal(select1.val(), null); 290 | assert.equal(select1Text.text(), ""); 291 | // change the selection 292 | select1.val("value2").trigger("change"); 293 | vm.$nextTick(function() { 294 | assert.equal(select1.val(), "value2"); 295 | assert.equal(select1Text.text(), "value2"); 296 | assert.equal(vm.result1, "value2"); 297 | done(); 298 | }); 299 | }); 300 | }); 301 | 302 | 303 | it("select2", function(done) { 304 | vm.$nextTick(function() { 305 | var root = $("#change-selection"); 306 | var select2 = root.find(".vue-select2"); 307 | var select2Text = select2.next(".select2").find(".select2-selection__rendered"); 308 | assert.equal(select2.val(), "value2"); 309 | assert.equal(select2Text.text(), "name2"); 310 | // change the selection 311 | select2.val("value3").trigger("change"); 312 | vm.$nextTick(function() { 313 | assert.equal(select2.val(), "value3"); 314 | assert.equal(select2Text.text(), "name3"); 315 | assert.equal(vm.result2, "value3"); 316 | done(); 317 | }); 318 | }); 319 | }); 320 | 321 | 322 | it("select3", function(done) { 323 | vm.$nextTick(function() { 324 | var root = $("#change-selection"); 325 | var select3 = root.find(".vue-select3"); 326 | var select3Text = select3.next(".select2").find(".select2-selection__rendered"); 327 | assert.equal(select3.val(), "value6"); 328 | assert.equal(select3Text.text(), "name6"); 329 | // change the selection 330 | select3.val("value4").trigger("change"); 331 | vm.$nextTick(function() { 332 | assert.equal(select3.val(), "value4"); 333 | assert.equal(select3Text.text(), "name4"); 334 | assert.equal(vm.result3, "value4"); 335 | done(); 336 | }); 337 | }); 338 | }); 339 | 340 | 341 | it("select4", function(done) { 342 | vm.$nextTick(function() { 343 | var root = $("#change-selection"); 344 | var select4 = root.find(".vue-select4"); 345 | var select4Text = select4.next(".select2").find(".select2-selection__rendered"); 346 | assert.equal(select4.val(), null); 347 | assert.equal(select4Text.text(), ""); 348 | // change the selection 349 | select4.val("value4").trigger("change"); 350 | vm.$nextTick(function() { 351 | assert.equal(select4.val(), "value4"); 352 | assert.equal(select4Text.text(), "×value4"); 353 | assert.deepEqual(vm.result4, ["value4"]); 354 | done(); 355 | }); 356 | }); 357 | }); 358 | 359 | 360 | }); 361 | 362 | describe("change the options", function() { 363 | var VM = getVM("change-options", "value1", "value2", "value6", []); 364 | var vm = new VM(); 365 | 366 | it("select1", function(done) { 367 | vm.$nextTick(function() { 368 | var root = $("#change-options"); 369 | var select1 = root.find(".vue-select1"); 370 | var select1Text = select1.next(".select2").find(".select2-selection__rendered"); 371 | assert.equal(select1Text.text(), "value1"); 372 | assert.equal(vm.result1, "value1"); 373 | var demo = vm.$refs.demo; 374 | demo.options1 = ["val1", "val2", "val3", "val4"]; 375 | vm.$nextTick(function() { 376 | var options1 = select1.find("option"); 377 | assert.equal(options1.length, 4); 378 | assert.equal(options1[0].text, "val1"); 379 | assert.equal(options1[0].value, "val1"); 380 | assert.equal(options1[1].text, "val2"); 381 | assert.equal(options1[1].value, "val2"); 382 | assert.equal(options1[2].text, "val3"); 383 | assert.equal(options1[2].value, "val3"); 384 | assert.equal(options1[3].text, "val4"); 385 | assert.equal(options1[3].value, "val4"); 386 | assert.equal(select1Text.text(), ""); 387 | assert.equal(vm.result1, null); 388 | done(); 389 | }); 390 | }); 391 | }); 392 | 393 | it("select2", function(done) { 394 | vm.$nextTick(function() { 395 | var root = $("#change-options"); 396 | var select2 = root.find(".vue-select2"); 397 | var select2Text = select2.next(".select2").find(".select2-selection__rendered"); 398 | assert.equal(select2Text.text(), "name2"); 399 | assert.equal(vm.result2, "value2"); 400 | var demo = vm.$refs.demo; 401 | demo.options2 = [{ 402 | text: "item1", 403 | value: "value1" 404 | }, { 405 | text: "item2", 406 | value: "value2" 407 | }]; 408 | vm.$nextTick(function() { 409 | var options2 = select2.find("option"); 410 | assert.equal(options2.length, 2); 411 | assert.equal(options2[0].text, "item1"); 412 | assert.equal(options2[0].value, "value1"); 413 | assert.equal(options2[1].text, "item2"); 414 | assert.equal(options2[1].value, "value2"); 415 | assert.equal(select2Text.text(), "item2"); 416 | assert.equal(vm.result2, "value2"); 417 | done(); 418 | }); 419 | }); 420 | }); 421 | 422 | it("select3", function(done) { 423 | vm.$nextTick(function() { 424 | var root = $("#change-options"); 425 | var select3 = root.find(".vue-select3"); 426 | var select3Text = select3.next(".select2").find(".select2-selection__rendered"); 427 | assert.equal(select3Text.text(), "name6"); 428 | assert.equal(vm.result3, "value6"); 429 | var demo = vm.$refs.demo; 430 | demo.options3.push({ 431 | label: "group3", 432 | options: [{ 433 | text: "name7", 434 | value: "value7" 435 | }, { 436 | text: "name8", 437 | value: "value8" 438 | }] 439 | }); 440 | vm.$nextTick(function() { 441 | var optgroups3 = select3.find("optgroup"); 442 | assert.equal(optgroups3.length, 3); 443 | var options3_1 = $(optgroups3[0]).find("option"); 444 | assert.equal(options3_1.length, 3); 445 | assert.equal(options3_1[0].text, "name1"); 446 | assert.equal(options3_1[0].value, "value1"); 447 | assert.equal(options3_1[1].text, "name2"); 448 | assert.equal(options3_1[1].value, "value2"); 449 | assert.equal(options3_1[2].text, "name3"); 450 | assert.equal(options3_1[2].value, "value3"); 451 | var options3_2 = $(optgroups3[1]).find("option"); 452 | assert.equal(options3_2.length, 3); 453 | assert.equal(options3_2[0].text, "name4"); 454 | assert.equal(options3_2[0].value, "value4"); 455 | assert.equal(options3_2[1].text, "name5"); 456 | assert.equal(options3_2[1].value, "value5"); 457 | assert.equal(options3_2[2].text, "name6"); 458 | assert.equal(options3_2[2].value, "value6"); 459 | var options3_3 = $(optgroups3[2]).find("option"); 460 | assert.equal(options3_3.length, 2); 461 | assert.equal(options3_3[0].text, "name7"); 462 | assert.equal(options3_3[0].value, "value7"); 463 | assert.equal(options3_3[1].text, "name8"); 464 | assert.equal(options3_3[1].value, "value8"); 465 | assert.equal(select3Text.text(), "name6"); 466 | assert.equal(vm.result3, "value6"); 467 | done(); 468 | }); 469 | }); 470 | }); 471 | }); 472 | 473 | // FIXME: I don't know how to get the options of a select2 control, 474 | // so the following test cannot be performed. 475 | 476 | // describe("test the i18n plugin", function() { 477 | // before(function() { 478 | // Vue.use(VueI18n, { 479 | // baseUrl: "/base/test/specs/i18n" 480 | // }); 481 | // }); 482 | // var VM = Vue.extend({ 483 | // template: "
", 484 | // el: function() { 485 | // var el = document.createElement("div"); 486 | // el.id = "test-i18n"; 487 | // document.body.appendChild(el); 488 | // return el; 489 | // }, 490 | // components: { 491 | // "vue-select": VueSelect 492 | // }, 493 | // data: function() { 494 | // return { 495 | // options: ["value1", "value2", "value3"], 496 | // result: null 497 | // }; 498 | // }, 499 | // beforeCompile: function() { 500 | // this.$setLanguage("zh-CN"); 501 | // } 502 | // }); 503 | // it.only("test language", function(done) { 504 | // var vm = new VM(); 505 | // vm.$nextTick(function() { 506 | // var select = vm.$refs.select.control; 507 | // assert.equal(select.options.get("language"), "zh-CN"); 508 | // done(); 509 | // }); 510 | // }); 511 | // }); 512 | }); -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | // Configuration file of webpack 2 | var path = require("path"); 3 | var webpack = require("webpack"); 4 | var BowerWebpackPlugin = require("bower-webpack-plugin"); 5 | var pkg = require(path.join(__dirname, "package.json")); 6 | var dirs = pkg.configs.directories; 7 | var version = process.env.VERSION || pkg.version; 8 | var banner = pkg.name + " v" + version + "\n" + 9 | "(c) " + new Date().getFullYear() + 10 | " " + pkg.author.name + "\n" + 11 | "Released under the " + pkg.license + " License."; 12 | 13 | module.exports = { 14 | entry: { 15 | "vue-select": path.join(__dirname, dirs.src, "vue-select.js") 16 | }, 17 | resolve: { 18 | root: [__dirname], 19 | modulesDirectories: [ "lib" ] 20 | }, 21 | plugins: [ 22 | new webpack.optimize.DedupePlugin(), 23 | new BowerWebpackPlugin({ 24 | modulesDirectories: [ "lib" ], 25 | manifestFiles: "bower.json", 26 | includes: /.*/, 27 | excludes: [], 28 | searchResolveModulesDirectories: true 29 | }), 30 | new webpack.BannerPlugin(banner) 31 | ], 32 | output: { 33 | path: path.join(__dirname, dirs.dist), 34 | filename: "[name].js", 35 | sourceMapFilename: "[file].map" 36 | } 37 | }; 38 | --------------------------------------------------------------------------------