plugins/kolab_notes

Thomas Brüderli bruederli at kolabsys.com
Wed Apr 16 10:15:26 CEST 2014


 plugins/kolab_notes/notes.js      |    2 ++
 plugins/kolab_notes/notes_mail.js |   22 ++++++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit 0e88a3fb981d371894590fe799f9ce93761e8858
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Apr 16 10:15:18 2014 +0200

    Improve event triggering from notes inline-edit dialog

diff --git a/plugins/kolab_notes/notes.js b/plugins/kolab_notes/notes.js
index 0eb02fc..4818dfd 100644
--- a/plugins/kolab_notes/notes.js
+++ b/plugins/kolab_notes/notes.js
@@ -815,6 +815,8 @@ function rcube_kolab_notes_ui(settings)
 
         // notify subscribers
         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)
         $(window).resize();
diff --git a/plugins/kolab_notes/notes_mail.js b/plugins/kolab_notes/notes_mail.js
index 1b6b827..6d575f7 100644
--- a/plugins/kolab_notes/notes_mail.js
+++ b/plugins/kolab_notes/notes_mail.js
@@ -26,9 +26,16 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
      */
     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
         if (!$dialog.length) {
             $dialog = $('<iframe>')
@@ -40,14 +47,12 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
                 .bind('load', function(e){
                     frame = rcmail.get_frame_window('kolabnotesinlinegui');
                     name = $('.notetitle', frame.rcmail.gui_objects.noteviewtitle);
-
                     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
         else if ($dialog.is(':ui-dialog')) {
@@ -101,6 +106,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
             },
             close: function() {
                 $dialog.dialog('destroy').remove();
+                rcmail.removeEventListener('kolab_notes_render', dialog_render);
             },
             buttons: buttons,
             minWidth: 480,




More information about the commits mailing list