
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
aurelia-bootstrap-datetimepicker
Advanced tools
An Aurelia Custom Element for the 3rd party addon [Eonasdan Bootstrap Datepicker]
An Aurelia Custom Element for the 3rd party addon Eonasdan Bootstrap Datepicker
Screenshots from the demo app
A quick example of the code in action. Note that the value is available under the value.bind
.
<abp-datetime-picker value.bind="post.dateEntered" options.bind="{ format: 'YYYY-MM-DD' }"></abp-datetime-picker>
For conveniencies, we provide 2 bindable attributes (both are also two-way
binding as well). The first is for the formatted date which is available through value.bind
, while the second binding is called via model.bind
to deal with a standard Date Object.
Note: since both attributes (value.bind
,model.bind
) are two-way binding, it also means that both can affect the picker.
Example:
<abp-datetime-picker value.bind="dateEntered" model.bind="dateObject" options.bind="{ format:'YYYY-MM-DD hh:mm' }"></abp-datetime-picker>
if we use the date string '2005-05-05 10:00', the output will be (also note that I'm on the Eastern Timezone):
value.bind="dateEntered" // output --> 2005-05-05 10:00
model.bind="dateObject" // output --> Thu May 05 2005 10:00:00 GMT-0400 (Eastern Daylight Time)
Every options of Bootstrap Datepicker
can be call through options.bind=""
. For the complete list, please visit the official site Bootstrap Datepicker - Options.
NOTE:
The picker options can also be defined globally through main.js
via a config.options
configuration, see Global Options
Examples
from the View
<abp-datetime-picker options.bind="{ format: 'YYYY-MM-DD' }"></abp-datetime-picker>
from the ViewModel
<abp-datetime-picker options.bind="pickerOptions"></abp-datetime-picker>
export class Example {
pickerOptions = {
format: 'YYYY-MM-DD'
};
}
Some extra bindable attributes were added to the Custom Element to add extra flexibility. The way to call them is through an attribute call in the View. The list of these extras is the following
font-awesome
or glyphicon
), (default: 'glyphicon'
)input group
with a Calendar icon on the right of the input (default: true
)Example
from the View
<abp-datetime-picker icon-base="font-awesome" with-date-icon="false"></abp-datetime-picker>
NOTE:
The extra attributes can also be defined globally through main.js
via a config.extra
configuration, see Global Options
Again every single methods which comes with Bootstrap Datepicker
are available. For the complete list, please visit the official site Bootstrap Datepicker - Functions.
To have access to the methods/functions, you will need to expose the element itself through element.bind
to expose the methods (also note that doing so will also give you access to events
, options
and methods
).
Example
View (exposing the element)
<abp-datetime-picker element.bind="picker" value.bind="user.birthdate"></abp-datetime-picker>
ViewModel (calling the method)
export class Example {
@bindable picker;
pickerChanged() {
// disable Sunday & Saturday
this.picker.methods.daysOfWeekDisabled([0,6]);
}
}
Every events of Bootstrap Datepicker
are, as no surprises, available as well. For the complete list, please visit the official site Bootstrap Datepicker - Events.
To have access to the events
, you will need to expose the element itself through element.bind
to expose the methods (also note that doing so will also give you access to events
, options
and methods
).
Note
The events are called with the syntax of onEvent
which differs from the original syntax. Example, for the dp.change
, we would use the onChange
event.
Example
View (exposing the element)
<abp-datetime-picker element.bind="picker" value.bind="user.birthdate"></abp-datetime-picker>
ViewModel (calling the onEvent trigger)
export class Example {
pickerChanged() {
this.picker.events.onHide = (e) => console.log('onHide');
this.picker.events.onShow = (e) => console.log('onShow');
this.picker.events.onChange = (e) => console.log('onChange');
this.picker.events.onError = (e) => console.log('onError');
this.picker.events.onUpdate = (e) => console.log('onUpdate');
}
}
You can run the examples or build your own by doing the following.
npm install --save aurelia-bootstrap-datetimepicker
For CLI
you will need to add (eonasdan-bootstrap-datetimepicker
and aurelia-bootstrap-datetimepicker
) to your aurelia.json
file. The exported class is abp-datetime-picker
.
{
"name": "eonasdan-bootstrap-datetimepicker",
"path": "../node_modules/eonasdan-bootstrap-datetimepicker/build",
"main": "js/bootstrap-datetimepicker.min",
"resources": [
"css/bootstrap-datetimepicker.min.css"
]
},
{
"name": "aurelia-bootstrap-datetimepicker",
"path": "../node_modules/aurelia-bootstrap-datetimepicker/dist/amd",
"main": "index",
"resources": [
"**/*.{css,html}"
]
},
index.html
<link rel="stylesheet" type="text/css"
href="../node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css">
Bootstrap-Datetimepicker
and possibly others require to have the same jQuery
accross the bundle. You will need to modify your webpack.config.babel.js
for this to work correctly.
const ENV...
+ const ProvidePlugin = require('webpack/lib/ProvidePlugin')
+ const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
let config = generateConfig(
{
entry: {
'app': ['./src/main' /* this is filled by the aurelia-webpack-plugin */],
'aurelia-bootstrap': coreBundles.bootstrap,
'aurelia': coreBundles.aurelia.filter(pkg => coreBundles.bootstrap.indexOf(pkg) === -1)
},
output: {
path: outDir
},
+ plugins: [
+ new ContextReplacementPlugin(/moment[\/\\]locale$/, /en|fr/),
+ new ProvidePlugin({
+ $: "jquery",
+ jQuery: "jquery",
+ 'window.jQuery': 'jquery',
+ 'window.Tether': 'tether',
+ Tether: 'tether'
+ })
+ ],
+ resolve: {
+ alias: {
+ // Force all modules to use the same jquery version.
+ 'jquery': path.join(__dirname, 'node_modules/jquery/src/jquery')
+ }
+ }
},
Make the plugin available globally in your main.js
file. Please note the exported class is abp-datetime-picker
import 'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-bootstrap-datetimepicker');
aurelia.start().then(() => aurelia.setRoot());
}
You can change any of the global options directly in the main.js
through a config
as shown below:
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-bootstrap-datetimepicker', config => {
// extra attributes, with config.extra
config.extra.iconBase = 'glyphicon';
config.extra.withDateIcon = true;
// or any picker options, with config.options
config.options.allowInputToggle = true;
});
aurelia.start().then(() => aurelia.setRoot());
}
Contributions are welcome. This plugin was created to help the community (and myself), if you wish to suggest something and/or want to make a PR (Pull Request), please feel free to do so.
You like and use an Aurelia-Bootstrap-Plugin, please click on the :star: and spead the word.
FAQs
An Aurelia Custom Element for the 3rd party addon [Eonasdan Bootstrap Datepicker]
The npm package aurelia-bootstrap-datetimepicker receives a total of 93 weekly downloads. As such, aurelia-bootstrap-datetimepicker popularity was classified as not popular.
We found that aurelia-bootstrap-datetimepicker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.