summaryrefslogtreecommitdiff
path: root/addons/website_form/static/src/js/website_form.js
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2016-11-23 16:03:35 +0100
committerfwi-odoo <fwi@odoo.com>2017-01-30 10:29:37 +0100
commitbe697f74253050e5fcf3b4192f4500b31bbd9c1b (patch)
tree0b75d5e48965d596d35adc778c921e27420330d8 /addons/website_form/static/src/js/website_form.js
parent89093a1695f859b4576146420a6448943f77358e (diff)
[FIX] website_form: lazy load datetimepicker + update
Replace deprecated options for the updated version of the bootstrap-datetimepicker lib. Lazy load the library in the front-end as well in order to avoid loading it in all the front-end views.
Diffstat (limited to 'addons/website_form/static/src/js/website_form.js')
-rw-r--r--addons/website_form/static/src/js/website_form.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/addons/website_form/static/src/js/website_form.js b/addons/website_form/static/src/js/website_form.js
index 001bc5e44c0..f94371261d9 100644
--- a/addons/website_form/static/src/js/website_form.js
+++ b/addons/website_form/static/src/js/website_form.js
@@ -13,6 +13,14 @@ odoo.define('website_form.animation', function (require) {
snippet_animation.registry.form_builder_send = snippet_animation.Class.extend({
selector: '.s_website_form',
+ willStart: function(){
+ var def;
+ if(!$.fn.datetimepicker){
+ def = ajax.loadJS("/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js");
+ }
+ return $.when(this._super.apply(this, arguments), def);
+ },
+
start: function() {
var self = this;
qweb.add_template('/website_form/static/src/xml/website_form.xml');
@@ -21,22 +29,23 @@ odoo.define('website_form.animation', function (require) {
// Initialize datetimepickers
var l10n = _t.database.parameters;
var datepickers_options = {
- startDate: moment({ y: 1900 }),
- endDate: moment().add(200, "y"),
+ minDate: moment({ y: 1900 }),
+ maxDate: moment().add(200, "y"),
calendarWeeks: true,
icons : {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
+ next: 'fa fa-chevron-right',
+ previous: 'fa fa-chevron-left',
up: 'fa fa-chevron-up',
- down: 'fa fa-chevron-down'
+ down: 'fa fa-chevron-down',
},
- language : moment.locale(),
+ locale : moment.locale(),
format : time.strftime_to_moment_format(l10n.date_format +' '+ l10n.time_format),
- }
+ };
this.$target.find('.o_website_form_datetime').datetimepicker(datepickers_options);
// Adapt options to date-only pickers
- datepickers_options.pickTime = false;
datepickers_options.format = time.strftime_to_moment_format(l10n.date_format);
this.$target.find('.o_website_form_date').datetimepicker(datepickers_options);
},