From 4d80104403169a583ee80582e06241cebbde3337 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 2 Dec 2014 17:19:13 +0000 Subject: [PATCH] allow to disable date widget with set_readonly on run-time --- etemplate/js/et2_widget_date.js | 14 ++++++++++++++ phpgwapi/js/jsapi/egw_calendar.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index 3861016cb4..07541750c8 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -106,6 +106,20 @@ var et2_date = et2_inputWidget.extend( } }, + /** + * Dynamic disable or enable datepicker + * + * @param {boolean} _ro + */ + set_readonly: function(_ro) + { + if (this.input_date && !this.input_date.attr('disabled') != !_ro) + { + this.input_date.attr('disabled', !!_ro) + .datepicker('option', 'disabled', !!_ro); + } + }, + /** * Set (full) year of current date * diff --git a/phpgwapi/js/jsapi/egw_calendar.js b/phpgwapi/js/jsapi/egw_calendar.js index 6244c9f3d2..abb1bf6280 100644 --- a/phpgwapi/js/jsapi/egw_calendar.js +++ b/phpgwapi/js/jsapi/egw_calendar.js @@ -83,7 +83,7 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) if (!calendar_translated) { // Set template's icon for date popup - could probably use jquery-ui icons - _egw.css(".et2_date input.hasDatepicker:hover", "background-image: url(" + egw().image('datepopup') + ")"); + _egw.css(".et2_date input.hasDatepicker:enabled:hover", "background-image: url(" + egw().image('datepopup') + ")"); translateCalendar(); calendar_translated = true;