├── .bowerrc
├── .gitignore
├── .jshintrc
├── .travis.yml
├── CONTRIBUTING.md
├── Gruntfile.js
├── LICENSE
├── README.md
├── bower.json
├── demo
├── app.js
├── bower.json
└── index.html
├── docs
├── index.html
└── styles.css
├── package.json
├── src
└── select2.js
└── test
├── karma.conf.js
└── select2Spec.js
/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "bower_components"
3 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | bower_components
3 | demo/bower_components
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "curly": true,
3 | "eqeqeq": true,
4 | "immed": true,
5 | "latedef": true,
6 | "newcap": true,
7 | "noarg": true,
8 | "sub": true,
9 | "boss": true,
10 | "eqnull": true
11 | }
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "0.8"
4 | - "0.10"
5 |
6 | before_install:
7 | - export DISPLAY=:99.0
8 | - sh -e /etc/init.d/xvfb start
9 | - npm install -g karma bower grunt-cli
10 | - bower install
11 | - npm install
12 |
13 | script: "grunt"
14 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | CONTRIBUTING
2 | ============
3 |
4 | * Open a [Pull Request (PR)](https://github.com/angular-ui/ui-select2/pull/new/master)
5 | * Make sure your PR is on a **new branch** you created off of the latest version of master
6 | * Do **not** open a PR from your master branch
7 | * Open a PR to start a discussion even if the code isn't finished (easier to collect feedback this way)
8 | * Make sure all previous tests pass and add new tests for added behaviors
9 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | 'use strict';
3 |
4 | var initConfig;
5 |
6 | // Loading external tasks
7 | require('load-grunt-tasks')(grunt);
8 |
9 | // Project configuration.
10 | initConfig = {
11 | bower: 'bower_components',
12 | pkg: grunt.file.readJSON('package.json'),
13 | watch: {
14 | test: {
15 | // Lint & run unit tests in Karma
16 | // Just running `$ grunt watch` will only lint your code; to run tests
17 | // on watch, use `$ grunt watch:karma` to start a Karma server first
18 | files: ['src/select2.js', 'test/select2Spec.js'],
19 | tasks: ['jshint', 'karma:unit:run']
20 | }
21 | },
22 | karma: {
23 | options: {
24 | configFile: 'test/karma.conf.js',
25 | browsers: ['Firefox', 'PhantomJS']
26 | },
27 | unit: {
28 | singleRun: true
29 | },
30 | watch: {
31 | autoWatch: true
32 | },
33 | server: {
34 | background: true
35 | }
36 | },
37 | jshint: {
38 | all:[
39 | 'gruntFile.js',
40 | 'src/**/*.js',
41 | 'test/**/*Spec.js'
42 | ],
43 | options: {
44 | jshintrc: '.jshintrc'
45 | }
46 | },
47 | changelog: {
48 | options: {
49 | dest: 'CHANGELOG.md'
50 | }
51 | }
52 | };
53 |
54 | // Register tasks
55 | grunt.registerTask('default', ['jshint', 'karma:unit']);
56 | grunt.registerTask('watch', ['jshint', 'karma:watch']);
57 |
58 | grunt.initConfig(initConfig);
59 | };
60 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2012 the AngularUI Team, http://angular-ui.github.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ui-select2 (deprecated) [](https://travis-ci.org/angular-ui/ui-select2)
2 | ========================
3 |
4 | # Annoucement
5 |
6 |
7 | This **directive is now obsolete**. A new initiative, more active, and 100% angular is available at https://github.com/angular-ui/ui-select.
8 |
9 | As development slowed down on ui-select2, it is getting unlikely that bugs will be fixed. So the new alternative should be used as soon as possible.
10 |
11 | # Description
12 |
13 | This directive allows you to enhance your select elements with behaviour from the [select2](http://ivaynberg.github.io/select2/) library.
14 |
15 | # Requirements
16 |
17 | - [AngularJS](http://angularjs.org/)
18 | - [JQuery](http://jquery.com/)
19 | - [Select2](http://ivaynberg.github.io/select2/)
20 |
21 | ## Setup
22 |
23 | 1. Install **Karma**, **Grunt** and **Bower**
24 | `$ npm install -g karma grunt-cli bower`
25 | 2. Install development dependencies
26 | `$ npm install`
27 | 3. Install components
28 | `$ bower install`
29 | 4. ???
30 | 5. Profit!
31 |
32 | ## Testing
33 |
34 | We use [Grunt](http://gruntjs.com/) to check for JavaScript syntax errors and execute all unit tests. To run Grunt, simply execute:
35 |
36 | `$ grunt`
37 |
38 | This will lint and test the code, then exit. To have Grunt stay open and automatically lint and test your files whenever you make a code change, use:
39 |
40 | `$ grunt karma:server watch`
41 |
42 | This will start a Karma server in the background and run unit tests in Firefox and PhantomJS whenever the source code or spec file is saved.
43 |
44 | # Usage
45 |
46 | We use [bower](https://github.com/bower/bower) for dependency management. Install AngularUI Select2 into your project by running the command
47 |
48 | `$ bower install angular-ui-select2`
49 |
50 | If you use a `bower.json` file in your project, you can have Bower save ui-select2 as a dependency by passing the `--save` or `--save-dev` flag with the above command.
51 |
52 | This will copy the ui-select2 files into your `bower_components` folder, along with its dependencies. Load the script files in your application:
53 | ```html
54 |
55 |
56 |
57 |
58 |
59 | ```
60 |
61 | (Note that `jquery` must be loaded before `angular` so that it doesn't use `jqLite` internally)
62 |
63 |
64 | Add the select2 module as a dependency to your application module:
65 |
66 | ```javascript
67 | var myAppModule = angular.module('MyApp', ['ui.select2']);
68 | ```
69 |
70 | Apply the directive to your form elements:
71 |
72 | ```html
73 |
79 | ```
80 |
81 | ## Options
82 |
83 | All the select2 options can be passed through the directive. You can read more about the supported list of options and what they do on the [Select2 Documentation Page](http://ivaynberg.github.com/select2/)
84 |
85 | ```javascript
86 | myAppModule.controller('MyController', function($scope) {
87 | $scope.select2Options = {
88 | allowClear:true
89 | };
90 | });
91 | ```
92 |
93 | ```html
94 |
99 | ```
100 |
101 | Some times it may make sense to specify the options in the template file.
102 |
103 | ```html
104 |
109 | ```
110 |
111 | To define global defaults, you can configure the `uiSelect2Config` injectable:
112 |
113 | ```javascript
114 | myAppModule.run(['uiSelect2Config', function(uiSelect2Config) {
115 | uiSelect2Config.placeholder = "Placeholder text";
116 | }]);
117 | ```
118 |
119 | ## Working with ng-model
120 |
121 | The ui-select2 directive plays nicely with ng-model and validation directives such as ng-required.
122 |
123 | If you add the ng-model directive to same the element as ui-select2 then the picked option is automatically synchronized with the model value.
124 |
125 | ## Working with dynamic options
126 | `ui-select2` is incompatible with `