diff options
| author | fwi-odoo <fwi@odoo.com> | 2016-11-23 16:03:35 +0100 |
|---|---|---|
| committer | fwi-odoo <fwi@odoo.com> | 2017-01-30 10:29:37 +0100 |
| commit | be697f74253050e5fcf3b4192f4500b31bbd9c1b (patch) | |
| tree | 0b75d5e48965d596d35adc778c921e27420330d8 /addons | |
| parent | 89093a1695f859b4576146420a6448943f77358e (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')
| -rw-r--r-- | addons/website_form/static/src/js/website_form.js | 21 | ||||
| -rw-r--r-- | addons/website_form/views/assets.xml | 4 |
2 files changed, 15 insertions, 10 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); }, diff --git a/addons/website_form/views/assets.xml b/addons/website_form/views/assets.xml index 73dbd97e071..c74c2f109e9 100644 --- a/addons/website_form/views/assets.xml +++ b/addons/website_form/views/assets.xml @@ -6,10 +6,6 @@ <xpath expr="." position="inside"> <link rel='stylesheet' href='/website_form/static/src/less/website_form.less'/> <script type="text/javascript" src="/website_form/static/src/js/website_form.js"/> - - <!-- Bootstrap datetimepicker is currently only included in the backend --> - <link rel="stylesheet" href="/web/static/lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css"/> - <script type="text/javascript" src="/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"/> </xpath> </template> |
