Improve event triggering from notes inline-edit dialog

This commit is contained in:
Thomas Bruederli 2014-04-16 10:15:18 +02:00
parent 046382eb84
commit 0e88a3fb98
2 changed files with 16 additions and 8 deletions

View file

@ -815,6 +815,8 @@ function rcube_kolab_notes_ui(settings)
// notify subscribers // notify subscribers
rcmail.triggerEvent('kolab_notes_render', { data:data, readonly:readonly, html:is_html }); rcmail.triggerEvent('kolab_notes_render', { data:data, readonly:readonly, html:is_html });
if (rcmail.is_framed())
parent.rcmail.triggerEvent('kolab_notes_render', { data:data, readonly:readonly, html:is_html });
// Trigger resize (needed for proper editor resizing) // Trigger resize (needed for proper editor resizing)
$(window).resize(); $(window).resize();

View file

@ -26,9 +26,16 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
*/ */
function kolab_note_dialog(url) function kolab_note_dialog(url)
{ {
var frame, name, mywin = window, edit = url && url._id; var frame, name, mywin = window, edit = url && url._id,
$dialog = $('#kolabnotesinlinegui');
function dialog_render(p)
{
$dialog.parent().find('.ui-dialog-buttonset .ui-button')
.prop('disabled', p.readonly)
.last().prop('disabled', false);
}
var $dialog = $('#kolabnotesinlinegui');
// create dialog if not exists // create dialog if not exists
if (!$dialog.length) { if (!$dialog.length) {
$dialog = $('<iframe>') $dialog = $('<iframe>')
@ -40,14 +47,12 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
.bind('load', function(e){ .bind('load', function(e){
frame = rcmail.get_frame_window('kolabnotesinlinegui'); frame = rcmail.get_frame_window('kolabnotesinlinegui');
name = $('.notetitle', frame.rcmail.gui_objects.noteviewtitle); name = $('.notetitle', frame.rcmail.gui_objects.noteviewtitle);
frame.rcmail.addEventListener('responseafteraction', refresh_mailview); frame.rcmail.addEventListener('responseafteraction', refresh_mailview);
frame.rcmail.addEventListener('kolab_notes_render', function(p){
$dialog.parent().find('.ui-dialog-buttonset .ui-button')
.prop('disabled', p.readonly)
.last().prop('disabled', false);
})
}); });
// subscribe event in parent window which is also triggered from iframe
// (probably before the 'load' event from above)
rcmail.addEventListener('kolab_notes_render', dialog_render);
} }
// close show dialog first // close show dialog first
else if ($dialog.is(':ui-dialog')) { else if ($dialog.is(':ui-dialog')) {
@ -101,6 +106,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
}, },
close: function() { close: function() {
$dialog.dialog('destroy').remove(); $dialog.dialog('destroy').remove();
rcmail.removeEventListener('kolab_notes_render', dialog_render);
}, },
buttons: buttons, buttons: buttons,
minWidth: 480, minWidth: 480,