├── .bowerrc ├── .esformatter ├── .eslintignore ├── .eslintrc ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bower.json ├── demo └── index.html ├── dist ├── date.js └── date.js.map ├── karma.conf.js ├── package.json ├── src ├── date.js └── date.spec.js └── webpack.config.js /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "demo/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /.esformatter: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "esformatter-semicolons", 4 | "esformatter-add-trailing-commas", 5 | "esformatter-quotes", 6 | "esformatter-braces", 7 | "esformatter-spaced-lined-comment" 8 | ], 9 | "quotes": { 10 | "type": "single" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | ./dist/*.js 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "ecmaFeatures": { 4 | "arrowFunctions": true, 5 | "blockBindings": true, 6 | "classes": true, 7 | "defaultParams": true, 8 | "destructuring": true, 9 | "forOf": true, 10 | "generators": false, 11 | "modules": true, 12 | "objectLiteralComputedProperties": true, 13 | "objectLiteralDuplicateProperties": false, 14 | "objectLiteralShorthandMethods": true, 15 | "objectLiteralShorthandProperties": true, 16 | "restParams": true, 17 | "spread": true, 18 | "superInFunctions": true, 19 | "templateStrings": true, 20 | "jsx": true 21 | }, 22 | 23 | "env": { 24 | "jasmine": true, 25 | "node": true, 26 | "mocha": true, 27 | "browser": true, 28 | "builtin": true 29 | }, 30 | "globals": { 31 | "angular": true, 32 | "$": true, 33 | "inject": true, 34 | }, 35 | "rules": { 36 | "block-scoped-var": 2, 37 | "camelcase": 2, 38 | "comma-style": [ 39 | 2, 40 | "last" 41 | ], 42 | "curly": [ 43 | 2, 44 | "all" 45 | ], 46 | "dot-notation": [ 47 | 2, 48 | { 49 | "allowKeywords": true 50 | } 51 | ], 52 | "eqeqeq": [ 53 | 2, 54 | "allow-null" 55 | ], 56 | "guard-for-in": 2, 57 | "new-cap": 2, 58 | "no-bitwise": 2, 59 | "no-caller": 2, 60 | "no-cond-assign": [ 61 | 2, 62 | "except-parens" 63 | ], 64 | "no-debugger": 2, 65 | "no-empty": 2, 66 | "no-eval": 2, 67 | "no-extend-native": 2, 68 | "no-extra-parens": 2, 69 | "no-irregular-whitespace": 2, 70 | "no-iterator": 2, 71 | "no-loop-func": 2, 72 | "no-multi-str": 2, 73 | "no-new": 2, 74 | "no-plusplus": 2, 75 | "no-proto": 2, 76 | "no-script-url": 2, 77 | "no-sequences": 2, 78 | "no-shadow": 2, 79 | "no-undef": 2, 80 | "no-unused-vars": [2, 81 | {"vars": "all", "varsIgnorePattern": "^_"} 82 | ], 83 | "no-with": 2, 84 | "quotes": [ 85 | 2, 86 | "single" 87 | ], 88 | "semi": [ 89 | 0, 90 | "never" 91 | ], 92 | "strict": 2, 93 | "valid-typeof": 2, 94 | "wrap-iife": [ 95 | 2, 96 | "inside" 97 | ] 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1. Describe the problem and the steps to reproduce 4 | 2. Describe the expected result 5 | 3. Please create a jsbin/plunkr/etc and preferably non-anonymous so that it does not expire 6 | 4. Which version of ui-date/angular are you using? 7 | 5. Describe the debugging that has been performed and where in the code you suspect the issue may be 8 | 6. Any other useful information? 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | components/ 2 | node_modules/ 3 | *bower_components/ 4 | demo/assets/date.js 5 | npm-debug.log 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | 5 | before_install: 6 | - export DISPLAY=:99.0 7 | - sh -e /etc/init.d/xvfb start 8 | #- npm install -g bower grunt-cli 9 | #- npm install 10 | #- bower install 11 | 12 | #script: "grunt" 13 | sudo: false 14 | 15 | cache: 16 | directories: 17 | - node_modules 18 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## [1.1.1](https://github.com/angular-ui/ui-date/compare/1.0.1...v1.1.1) (2016-03-31) 3 | 4 | ### Bug Fixes 5 | 6 | * **ui-date:** Fix for ie10/11 focus issues 7 | 8 | 9 | 10 | ## [1.0.1](https://github.com/angular-ui/ui-date/compare/1.0.0...v1.0.1) (2016-03-31) 11 | 12 | 13 | 14 | # [1.0.0](https://github.com/angular-ui/ui-date/compare/1.0.0-beta.3...v1.0.0) (2016-02-18) 15 | 16 | 17 | ### Bug Fixes 18 | 19 | * **ui-date:** Validator is ok for blank or null dates ([93e6141](https://github.com/angular-ui/ui-date/commit/93e6141)) 20 | 21 | 22 | 23 | 24 | # [1.0.0-beta.0](https://github.com/angular-ui/ui-date/compare/0.0.11...v1.0.0-beta.0) (2015-12-09) 25 | 26 | Update build to support umd and webpack. 27 | 28 | 29 | 30 | ## [0.0.11](https://github.com/angular-ui/ui-date/compare/0.0.10...v0.0.11) (2015-12-03) 31 | 32 | 33 | ### Bug Fixes 34 | 35 | * **date:** Prevent jquery datepicker formatDate exception ([10c0e54](https://github.com/angular-ui/ui-date/commit/10c0e54)), closes [#48](https://github.com/angular-ui/ui-date/issues/48) 36 | 37 | 38 | 39 | 40 | ## [0.0.10](https://github.com/angular-ui/ui-date/compare/0.0.8...v0.0.10) (2015-11-26) 41 | 42 | 43 | ### Features 44 | 45 | * **date:** common js support ([7e94737](https://github.com/angular-ui/ui-date/commit/7e94737)) 46 | 47 | 48 | 49 | 50 | ## [0.0.8](https://github.com/angular-ui/ui-date/compare/0.0.7...0.0.8) (2015-06-11) 51 | 52 | 53 | ### Bug Fixes 54 | 55 | * **setViewValue:** Don't lose time info on update ([af19760](https://github.com/angular-ui/ui-date/commit/af19760)) 56 | 57 | 58 | 59 | 60 | ## [0.0.7](https://github.com/angular-ui/ui-date/compare/0.0.6...0.0.7) (2015-01-08) 61 | 62 | 63 | ### Bug Fixes 64 | 65 | * **date:** destroy datepicker when element is removed ([26f36d2](https://github.com/angular-ui/ui-date/commit/26f36d2)), closes [#23](https://github.com/angular-ui/ui-date/issues/23) [#61](https://github.com/angular-ui/ui-date/issues/61) [#79](https://github.com/angular-ui/ui-date/issues/79) 66 | 67 | 68 | 69 | 70 | ## [0.0.6](https://github.com/angular-ui/ui-date/compare/0.0.5...0.0.6) (2014-11-12) 71 | 72 | 73 | 74 | 75 | 76 | ## [0.0.5](https://github.com/angular-ui/ui-date/compare/0.0.4...0.0.5) (2014-11-10) 77 | 78 | 79 | 80 | 81 | 82 | ## [0.0.4](https://github.com/angular-ui/ui-date/compare/0.0.3...0.0.4) (2014-08-06) 83 | 84 | 85 | ### Bug Fixes 86 | 87 | * **setViewValue:** only update the model with the real date on blur ([5f24c7c](https://github.com/angular-ui/ui-date/commit/5f24c7c)), closes [#18](https://github.com/angular-ui/ui-date/issues/18) 88 | 89 | 90 | 91 | 92 | ## [0.0.3](https://github.com/angular-ui/ui-date/compare/0.0.2...0.0.3) (2013-06-19) 93 | 94 | 95 | 96 | 97 | 98 | ## [0.0.2](https://github.com/angular-ui/ui-date/compare/0.0.1...0.0.2) (2013-03-25) 99 | 100 | 101 | ### Bug Fixes 102 | 103 | * **date-format:** should return null not undefined if viewValue is empty string ([3768719](https://github.com/angular-ui/ui-date/commit/3768719)) 104 | 105 | 106 | 107 | 108 | ## [0.0.1](https://github.com/angular-ui/ui-date/compare/bcb1fd9...0.0.1) (2013-03-16) 109 | 110 | 111 | ### Bug Fixes 112 | 113 | * **component:** Corrected path to main js file ([8947cfd](https://github.com/angular-ui/ui-date/commit/8947cfd)) 114 | * **date:** ensure date picker doesn't pop up again on IE ([2c62c92](https://github.com/angular-ui/ui-date/commit/2c62c92)) 115 | * **test:** remove unwanted dump() statement ([e8586e4](https://github.com/angular-ui/ui-date/commit/e8586e4)) 116 | * **tests:** Attempted to fix most tests and added new angular-module component ([b4d243d](https://github.com/angular-ui/ui-date/commit/b4d243d)) 117 | * **tests:** Forgot .travis.yml ([0bb9ed7](https://github.com/angular-ui/ui-date/commit/0bb9ed7)) 118 | * **tests:** Made build status clickable ([e77ca50](https://github.com/angular-ui/ui-date/commit/e77ca50)) 119 | * **ui.date module:** add [] to create module ([8581ede](https://github.com/angular-ui/ui-date/commit/8581ede)) 120 | * **uiDateConfig:** add directive specific config ([bcb1fd9](https://github.com/angular-ui/ui-date/commit/bcb1fd9)) 121 | 122 | ### Features 123 | 124 | * **tests:** Added image for build status ([aad7b9f](https://github.com/angular-ui/ui-date/commit/aad7b9f)) 125 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Got a question or problem? 2 | 3 | Please, do not open issues for the general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [StackOverflow](http://stackoverflow.com/). 4 | 5 | StackOverflow is a much better place to ask questions since: 6 | * there are hundreds of people willing to help on StackOverflow 7 | * questions and answers stay available for public viewing so your question / answer might help someone else 8 | * the StackOverflow voting system assures that the best answers are prominently visible. 9 | 10 | To save your and our time we will be systematically closing all the issues that are requests for general support and redirecting people to StackOverflow. 11 | 12 | ## You think you've found a bug? 13 | 14 | Oh, we are ashamed and want to fix it asap! But before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs we will systematically ask you to provide a _minimal_ reproduce scenario using http://plnkr.co/ or [jsbin](http://jsbin.com). Having a live reproduce scenario gives us wealth of important information without going back & forth to you with additional questions like: 15 | * version of AngularJS used 16 | * version of this library that you are using 17 | * 3rd-party libraries used, if any 18 | * and most importantly - a use-case that fails 19 | 20 | A minimal reproduce scenario using http://plnkr.co/ allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. 21 | 22 | We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal plunk. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it. 23 | 24 | Unfortunately we are not able to investigate / fix bugs without a minimal reproduce scenario using http://plnkr.co/, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced. 25 | 26 | ## You want to contribute some code? 27 | 28 | Fantastic, we are always looking for the quality contributions and will be happy to accept your Pull Requests as long as those adhere to some basic rules: 29 | 30 | * Please assure that you are submitting quality code, specifically make sure that: 31 | * your contribution has accompanying tests and all the tests are passing 32 | * your PR doesn't break the build; check the Travis-CI build status after opening a PR and push corrective commits if anything goes wrong 33 | * your commit messages conform to the conventions established [here](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit) 34 | 35 | [](http://commitizen.github.io/cz-cli/) 36 | 37 | # Testing 38 | 39 | We use [karma](http://karma-runner.github.io/) and jshint to ensure the quality of the code. The easiest way to run these checks is the following 40 | 41 | npm install 42 | npm test 43 | -------------------------------------------------------------------------------- /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-date directive [](https://travis-ci.org/angular-ui/ui-date) 2 | 3 | This directive allows you to add a date-picker to your form elements. 4 | 5 | # Alternatives 6 | 7 | We recommend using the excellent [ui-bootstrap](https://angular-ui.github.io/bootstrap/) date-picker which is maintained by a larger team. 8 | 9 | WARNING: Support for this module may eventually be phased out as angular 2.0 arrives as there are no plans to move this to angular 2 at this time. 10 | 11 | # Requirements 12 | 13 | - JQuery 14 | - JQueryUI 15 | - AngularJS 16 | 17 | # Bower Usage 18 | 19 | You may use [bower](http://bower.io/) for dependency management but would recommend using webpack or browserify for modules. 20 | 21 | Install and save to bower.json by running: 22 | 23 | bower install angular-ui-date --save 24 | 25 | This will copy the ui-date files into your `bower_components` folder, along with its dependencies. 26 | 27 | Add the css: 28 | 29 | ```html 30 | 31 | ``` 32 | 33 | Load the script files in your application: 34 | 35 | ```html 36 | 37 | 38 | 39 | 40 | ``` 41 | 42 | Add the date module as a dependency to your application module: 43 | 44 | ```js 45 | angular.module('MyApp', ['ui.date']) 46 | ``` 47 | 48 | Apply the directive to your form elements: 49 | 50 | ```html 51 | 52 | ``` 53 | 54 | ## Options 55 | 56 | All the [jQueryUI DatePicker options](http://api.jqueryui.com/datepicker/) can be passed through the directive including minDate, maxDate, yearRange etc. 57 | 58 | ```js 59 | myAppModule.controller('MyController', function($scope) { 60 | $scope.dateOptions = { 61 | changeYear: true, 62 | changeMonth: true, 63 | yearRange: '1900:-0', 64 | }; 65 | }); 66 | ``` 67 | 68 | then pass through your options: 69 | 70 | ```html 71 | 72 | ``` 73 | 74 | ## Static Inline Picker 75 | 76 | If you want a static picker then simply apply the directive to a div rather than an input element. 77 | 78 | ```html 79 |
80 | ``` 81 | 82 | ## Working with ng-model 83 | 84 | The ui-date directive plays nicely with ng-model and validation directives such as ng-required. 85 | 86 | If you add the ng-model directive to same the element as ui-date then the picked date is automatically synchronized with the model value. 87 | 88 | _The ui-date directive stores and expects the model value to be a standard javascript Date object._ 89 | 90 | ## ui-date-format directive 91 | 92 | The ui-date directive only works with Date objects. 93 | If you want to pass date strings to and from the date directive via ng-model then you must use the ui-date-format directive. 94 | This directive specifies the format of the date string that will be expected in the ng-model. 95 | The format string syntax is that defined by the JQueryUI Date picker. For example 96 | 97 | ```html 98 | 99 | ``` 100 | 101 | Now you can set myDate in the controller. 102 | 103 | ```js 104 | $scope.myDate = "Thursday, 11 October, 2012"; 105 | ``` 106 | 107 | ## ng-required directive 108 | 109 | If you apply the required directive to element then the form element is invalid until a date is picked. 110 | 111 | Note: Remember that the ng-required directive must be explictly set, i.e. to "true". This is especially true on divs: 112 | 113 | ```html 114 | 115 | ``` 116 | 117 | ## focusing the next element for tabbing 118 | 119 | There is a problem with IE that re-opens the datepicker on focus(). However, this breaks tabbing. If tabbing is more 120 | important than IE for your use cases, pass in the onClose option. 121 | 122 | ```javascript 123 | myAppModule.controller('MyController', function($scope) { 124 | $scope.dateOptions = { 125 | onClose: (value, picker, $element) => { 126 | $element.focus() 127 | } 128 | }; 129 | }); 130 | ``` 131 | 132 | ## Usage with webpack 133 | 134 | Install with npm: 135 | 136 | npm install --save-dev jquery jquery-ui angular angular-ui-date 137 | 138 | Use in your app: 139 | 140 | ```javascript 141 | import angular from 'angular'; 142 | import uiDate from 'angular-ui-date'; 143 | 144 | require('jquery-ui/themes/base/minified/jquery-ui.min.css'); 145 | 146 | angular.module('MyTest', [uiDate.name]) 147 | .controller('MyCtrl', ['$scope', function($scope) { 148 | $scope.myDate = new Date('2015-11-17'); 149 | }]); 150 | ``` 151 | 152 | It is also good to ensure that jQuery is available so that angular and jquery ui can attach to it. 153 | 154 | ```javascript 155 | webpack: { 156 | plugins: [ 157 | new webpack.ProvidePlugin({ 158 | 'window.jQuery': 'jquery', 159 | }), 160 | ] 161 | } 162 | ``` 163 | 164 | another method of making jQuery recognized is to use the webpack expose-loader to expose it both as $ and jQuery 165 | 166 | ```javascript 167 | webpack: { 168 | module: { 169 | loaders: [ 170 | // it helps angular to have jQuery exposed so that it uses $ instead of jqLite 171 | { 172 | test: require.resolve('jquery'), 173 | loader: 'expose?$!expose?jQuery', 174 | }, 175 | ] 176 | } 177 | } 178 | ``` 179 | ## Need help? 180 | Need help using UI date? 181 | 182 | * Ask a question in [StackOverflow](http://stackoverflow.com/) under the [angular-ui-date](http://stackoverflow.com/questions/tagged/angular-ui-date) tag. 183 | 184 | **Please do not create new issues in this repository to ask questions about using UI date** 185 | 186 | ## Found a bug? 187 | Please take a look at [CONTRIBUTING.md](CONTRIBUTING.md#you-think-youve-found-a-bug). 188 | 189 | # Contributing to the project 190 | 191 | We are always looking for the quality contributions! Please check the [CONTRIBUTING.md](CONTRIBUTING.md) for the contribution guidelines. 192 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-ui-date", 3 | "version": "1.1.1", 4 | "description": "This directive allows you to add a date-picker to your form elements.", 5 | "author": "https://github.com/angular-ui/ui-date/graphs/contributors", 6 | "license": "MIT", 7 | "homepage": "http://angular-ui.github.com/ui-date", 8 | "main": "./dist/date.js", 9 | "ignore": [ 10 | "**/.*", 11 | "node_modules", 12 | "bower_components", 13 | "test*", 14 | "demo*", 15 | "gruntFile.js", 16 | "package.json" 17 | ], 18 | "dependencies": { 19 | "angular": "^1.3.x", 20 | "jquery-ui": "^1.9" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |