plugins/kolab_notes
Thomas Brüderli
bruederli at kolabsys.com
Tue Apr 15 16:02:01 CEST 2014
plugins/kolab_notes/notes_mail.js | 149 ++++++++++++++
plugins/kolab_notes/skins/larry/templates/dialogview.html | 61 +++++
2 files changed, 210 insertions(+)
New commits:
commit 9b38634115ae6e685e3eabe6878db1b54d944075
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Tue Apr 15 16:01:52 2014 +0200
Add missing file for notes in mail integration
diff --git a/plugins/kolab_notes/notes_mail.js b/plugins/kolab_notes/notes_mail.js
new file mode 100644
index 0000000..1b6b827
--- /dev/null
+++ b/plugins/kolab_notes/notes_mail.js
@@ -0,0 +1,149 @@
+/**
+ * Mail integration script for the Kolab Notes plugin
+ *
+ * @author Thomas Bruederli <bruederli at kolabsys.com>
+ *
+ * Copyright (C) 2014, Kolab Systems AG <contact at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+window.rcmail && rcmail.addEventListener('init', function(evt) {
+ /**
+ * Open the notes edit GUI in a jquery UI dialog
+ */
+ function kolab_note_dialog(url)
+ {
+ var frame, name, mywin = window, edit = url && url._id;
+
+ var $dialog = $('#kolabnotesinlinegui');
+ // create dialog if not exists
+ if (!$dialog.length) {
+ $dialog = $('<iframe>')
+ .attr('id', 'kolabnotesinlinegui')
+ .attr('name', 'kolabnotesdialog')
+ .attr('src', 'about:blank')
+ .css('min-width', '100%')
+ .appendTo(document.body)
+ .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);
+ })
+ });
+ }
+ // close show dialog first
+ else if ($dialog.is(':ui-dialog')) {
+ $dialog.dialog('close');
+ }
+
+ if (!url) url = {};
+ url._framed = 1;
+ $dialog.attr('src', rcmail.url('notes/dialog-ui', url));
+
+ // dialog buttons
+ var buttons = {};
+ buttons[rcmail.gettext('save')] = function() {
+ // frame is not loaded
+ if (!frame)
+ return;
+
+ // do some input validation
+ if (!name.val() || name.val().length < 2) {
+ alert(rcmail.gettext('entertitle', 'kolab_notes'));
+ name.select();
+ return;
+ }
+
+ frame.rcmail.command('save');
+ };
+
+ if (edit) {
+ buttons[rcmail.gettext('delete')] = function() {
+ if (confirm(rcmail.gettext('deletenotesconfirm','kolab_notes'))) {
+ rcmail.addEventListener('responseafteraction', refresh_mailview);
+ rcmail.http_post('notes/action', { _data: { uid: url._id, list: url._list }, _do: 'delete' }, true);
+ $dialog.dialog('close');
+ }
+ };
+ }
+
+ buttons[rcmail.gettext(edit ? 'close' : 'cancel')] = function() {
+ $dialog.dialog('close');
+ };
+
+ // open jquery UI dialog
+ var win = $(window);
+ $dialog.dialog({
+ modal: true,
+ resizable: true,
+ closeOnEscape: true,
+ title: edit ? rcmail.gettext('editnote','kolab_notes') : rcmail.gettext('appendnote','kolab_notes'),
+ open: function() {
+ $dialog.parent().find('.ui-dialog-buttonset .ui-button').prop('disabled', true).first().addClass('mainaction');
+ },
+ close: function() {
+ $dialog.dialog('destroy').remove();
+ },
+ buttons: buttons,
+ minWidth: 480,
+ width: 680,
+ height: Math.min(640, win.height() - 100)
+ }).show();
+ }
+
+ /**
+ * Reload the mail view/preview to update the notes listing
+ */
+ function refresh_mailview(e)
+ {
+ var win = rcmail.env.contentframe ? rcmail.get_frame_window(rcmail.env.contentframe) : mywin;
+ if (win && e.response) {
+ win.location.reload();
+ // $dialog.dialog('close');
+ }
+ }
+
+ // register commands
+ rcmail.register_command('edit-kolab-note', kolab_note_dialog, true);
+ rcmail.register_command('append-kolab-note', function() {
+ var uid;
+ if ((uid = rcmail.get_single_uid())) {
+ kolab_note_dialog({ _msg: uid + '-' + rcmail.env.mailbox });
+ }
+ });
+
+ if (rcmail.env.action == 'show') {
+ rcmail.enable_command('append-kolab-note', true);
+ }
+ else {
+ rcmail.env.message_commands.push('append-kolab-note');
+ }
+
+ // register handlers for inline note editing
+ if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') {
+ $('.kolabmessagenotes a.kolabnotesref').click(function(e){
+ var ref = String($(this).attr('rel')).split('@'),
+ win = rcmail.is_framed() ? parent.window : window;
+ win.rcmail.command('edit-kolab-note', { _list:ref[1], _id:ref[0] });
+ return false;
+ });
+ }
+});
diff --git a/plugins/kolab_notes/skins/larry/templates/dialogview.html b/plugins/kolab_notes/skins/larry/templates/dialogview.html
new file mode 100644
index 0000000..1acab5b
--- /dev/null
+++ b/plugins/kolab_notes/skins/larry/templates/dialogview.html
@@ -0,0 +1,61 @@
+<roundcube:object name="doctype" value="html5" />
+<html>
+<head>
+<title><roundcube:object name="pagetitle" /></title>
+<roundcube:include file="/includes/links.html" />
+</head>
+<body class="iframe notesview notesdialog noscroll">
+
+<div id="notedetailsbox">
+ <div id="notesdialogheader" class="boxtitle">
+ <roundcube:object name="plugin.notetitle" id="notedetailstitle" />
+ <div class="notebookselect" style="display:none">
+ <label for="notebook"><roundcube:label name="kolab_notes.savein" /></label>
+ <roundcube:object name="plugin.notebooks" id="kolab-notebook" type="select" />
+ </div>
+ </div>
+ <roundcube:object name="plugin.editform" id="noteform" />
+ <roundcube:object name="plugin.detailview" id="notedetails" class="scroller" />
+ <div id="notereferences">
+ <roundcube:object name="plugin.attachments_list" id="attachment-list" class="attachmentslist" />
+ </div>
+</div>
+
+<script type="text/javascript">
+
+// UI startup
+var UI = new rcube_mail_ui();
+
+$(document).ready(function(e){
+ UI.init();
+
+ function layout_view()
+ {
+ var form = $('#noteform, #notedetails'),
+ content = $('#notecontent'),
+ header = $('#notesdialogheader'),
+ w, h;
+
+ form.css('top', header.outerHeight()+'px');
+
+ w = form.outerWidth();
+ h = form.outerHeight();
+ content.width(w).height(h);
+
+ $('#notecontent_tbl').width(w+'px').height('').css('margin-top', '-1px');
+ $('#notecontent_ifr').width(w+'px').height((h-54)+'px');
+ }
+
+ $(window).resize(function(e){
+ layout_view();
+ });
+
+ rcmail.addEventListener('kolab_notes_render', function(p){
+ $('#notesdialogheader .notebookselect')[p.readonly ? 'hide' : 'show']();
+ });
+});
+
+</script>
+
+</body>
+</html>
More information about the commits
mailing list