Skip to content

Commit 6cf5fd8

Browse files
committed
Initial commit
0 parents  commit 6cf5fd8

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/**/*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Mark Chapman
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.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# fng-bootstrap-date
2+
3+
Plugin for forms-angular that adds date picker from [Angular UI Bootstrap](https://github.com/angular-ui/bootstrap) support.
4+
5+
## Usage
6+
7+
bower install fng-bootstrap-date
8+
9+
Add the following line to your index.html (or equivalent) file.
10+
11+
<script src="bower_components/fng-bootstrap-date/fng-bootstrap-date.js"></script>
12+
13+
Add `fng.uiBootstrapDate` to the list of servies your Angular module depends on.
14+
15+
In your Mongoose schemas you can set up fields like this:
16+
17+
applicationReceived: {type: Date, form: {
18+
directive:"fng-ui-bootstrap-date-picker",
19+
fngUiBootstrapDatePicker: {
20+
format: 'dd MMM yyyy',
21+
"ng-model-options":"{timezone:\'UTC\'}"
22+
}
23+
}},
24+
25+
Options can be added to a fngUiBootstrapDatePicker object within the form object as illustrated by the examples above. For (my) convenience, the default format has been changed to dd/MM/yyyy
26+
27+
###Known Limitations:
28+
29+
Styling in (unsupported) Bootstrap 2 applications (such as the forms-angular.org website at the time of writing) has a few issues,
30+
including inline help placing and the width of the first columnof the dropdown when weeks are not shown.

bower.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "fng-bootstrap-date",
3+
"description": "Date input plugin for forms-angular, using the Bootstrap datepicker from Angular-ui-bootstrap",
4+
"main": "fng-bootstrap-date.js",
5+
"authors": [
6+
"Mark Chapman"
7+
],
8+
"license": "MIT",
9+
"keywords": [
10+
"forms-angular",
11+
"datepicker"
12+
],
13+
"dependencies": {
14+
"angular-ui-bootstrap-bower": "2.5.0"
15+
},
16+
"homepage": "https://github.com/forms-angular/fng-bootstrap-date",
17+
"ignore": [
18+
"**/.*",
19+
"node_modules",
20+
"bower_components",
21+
"test",
22+
"tests"
23+
]
24+
}

fng-bootstrap-date.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(function () {
2+
'use strict';
3+
4+
var uiBootstrapDateModule = angular.module('fng.uiBootstrapDate', ['ui.bootstrap']);
5+
6+
uiBootstrapDateModule.controller('FngUIBootstrapDateCtrl', ['$scope', function ($scope) {
7+
$scope.popup = {
8+
opened: false
9+
};
10+
11+
$scope.open = function() {
12+
$scope.popup.opened = true;
13+
}
14+
}])
15+
.directive('fngUiBootstrapDatePicker', ['$compile', '$filter', 'pluginHelper', 'formMarkupHelper', 'cssFrameworkService',
16+
function ($compile, $filter, pluginHelper, formMarkupHelper, cssFrameworkService) {
17+
return {
18+
restrict: 'E',
19+
replace: true,
20+
priority: 1,
21+
controller: 'FngUIBootstrapDateCtrl',
22+
link: function (scope, element, attrs) {
23+
var template;
24+
var processedAttr = pluginHelper.extractFromAttr(attrs, 'fngUiBootstrapDatePicker');
25+
template = pluginHelper.buildInputMarkup(scope, attrs.model, processedAttr.info, processedAttr.options, false, false, function (buildingBlocks) {
26+
return formMarkupHelper.generateSimpleInput(
27+
buildingBlocks.common + ' uib-datepicker-popup="' + (processedAttr.directiveOptions.format || 'dd/MM/yy') + '" is-open="popup.opened" ng-click="open()" ' + formMarkupHelper.addTextInputMarkup(buildingBlocks, processedAttr.info, ''),
28+
processedAttr.info,
29+
processedAttr.options
30+
);
31+
});
32+
element.replaceWith($compile(template)(scope));
33+
}
34+
};
35+
}]
36+
)
37+
})();

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "fng-bootstrap-date",
3+
"version": "0.1.0",
4+
"description": "Date input plugin for forms-angular, using the Bootstrap datepicker from Angular-ui-bootstrap",
5+
"main": "fng-bootstrap-date.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [
10+
"forms-angular",
11+
"datepicker"
12+
],
13+
"author": "Mark Chapman",
14+
"license": "MIT"
15+
}

0 commit comments

Comments
 (0)