Fixed default calendar edit form handling
This commit is contained in:
parent
479819d4bb
commit
a13fec7a21
4 changed files with 27 additions and 13 deletions
|
@ -1310,8 +1310,8 @@ function rcube_calendar_ui(settings)
|
|||
success: function(data) {
|
||||
$dialog.html(data);
|
||||
// resize and reposition dialog window
|
||||
me.dialog_resize('#calendarform', $('#calendar-details').height(), $('#calendar-details').width());
|
||||
form = $('form', $('#calendarform')); // '#calendarform > form' doesn't work here
|
||||
me.dialog_resize('#calendarform', form.height(), form.width());
|
||||
name = $('#calendar-name').prop('disabled', !calendar.editable).val(calendar.editname || calendar.name);
|
||||
color = $('#calendar-color').val(calendar.color).miniColors({ value: calendar.color });
|
||||
name.select();
|
||||
|
@ -1362,7 +1362,7 @@ function rcube_calendar_ui(settings)
|
|||
}).show();
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.calendar_remove = function(calendar)
|
||||
{
|
||||
if (confirm(rcmail.gettext('deletecalendarconfirm', 'calendar'))) {
|
||||
|
@ -1371,7 +1371,7 @@ function rcube_calendar_ui(settings)
|
|||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
this.calendar_destroy_source = function(id)
|
||||
{
|
||||
if (this.calendars[id]) {
|
||||
|
@ -1429,7 +1429,7 @@ function rcube_calendar_ui(settings)
|
|||
this.reset_quicksearch();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// reset search and get back to normal event listing
|
||||
this.reset_quicksearch = function()
|
||||
{
|
||||
|
@ -1454,7 +1454,7 @@ function rcube_calendar_ui(settings)
|
|||
this.search_request = this.search_query = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// callback if all sources have been fetched from server
|
||||
this.events_loaded = function(count)
|
||||
{
|
||||
|
@ -1465,17 +1465,18 @@ function rcube_calendar_ui(settings)
|
|||
// resize and reposition (center) the dialog window
|
||||
this.dialog_resize = function(id, height, width)
|
||||
{
|
||||
height = Math.min(400, height+90);
|
||||
width = Math.min(500, width+50);
|
||||
|
||||
var win = $(window), w = win.width(), h = win.height();
|
||||
|
||||
height = Math.min(h-20, height+125);
|
||||
width = Math.min(w-20, width+50);
|
||||
|
||||
w = w - width < 0 ? 0 : (w - width) / 2;
|
||||
h = h - height < 0 ? 0 : (h - height) / 2;
|
||||
|
||||
$(id).dialog('option', { height: height, width: width, position: [w, h] });
|
||||
};
|
||||
|
||||
|
||||
/*** startup code ***/
|
||||
|
||||
// create list of event sources AKA calendars
|
||||
|
|
|
@ -305,10 +305,11 @@ abstract class calendar_driver
|
|||
*
|
||||
* @param string Request action 'form-edit|form-new'
|
||||
* @param array Calendar properties (e.g. id, color)
|
||||
* @param string HTML code of default edit form
|
||||
*
|
||||
* @return string HTML content of the form
|
||||
*/
|
||||
public function calendar_form($action, $calendar)
|
||||
public function calendar_form($action, $calendar, $html)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -827,10 +827,11 @@ class kolab_driver extends calendar_driver
|
|||
*
|
||||
* @param string Request action 'form-edit|form-new'
|
||||
* @param array Calendar properties (e.g. id, color)
|
||||
* @param string HTML code of default edit form
|
||||
*
|
||||
* @return string HTML content of the form
|
||||
*/
|
||||
public function calendar_form($action, $calendar)
|
||||
public function calendar_form($action, $calendar, $html)
|
||||
{
|
||||
// Remove any scripts/css/js
|
||||
$this->rc->output->reset();
|
||||
|
|
|
@ -537,10 +537,21 @@ class calendar_ui
|
|||
*/
|
||||
function calendar_editform($action, $calendar = array())
|
||||
{
|
||||
$html = $this->calendar->driver->calendar_form($action, $calendar);
|
||||
// compose default calendar form
|
||||
$input_name = new html_inputfield(array('name' => 'name', 'id' => 'calendar-name', 'size' => 20));
|
||||
$html = html::div('form-section',
|
||||
html::label('calendar-name', $this->calendar->gettext('name')) .
|
||||
$input_name->show($calendar['name']));
|
||||
|
||||
if (!$html)
|
||||
$html = $this->rc->output->parse('calendar.calendarform', false, false);
|
||||
$input_color = new html_inputfield(array('name' => 'color', 'id' => 'calendar-color', 'size' => 6));
|
||||
$html .= html::div('form-section',
|
||||
html::label('calendar-color', $this->calendar->gettext('color')) .
|
||||
$input_color->show($calendar['color']));
|
||||
|
||||
$html = html::tag('form', array('action' => "#", 'method' => "get", 'id' => 'calendarpropform'), $html);
|
||||
|
||||
// allow driver to extend or replace the form content
|
||||
$html = $this->calendar->driver->calendar_form($action, $calendar, $html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue