| | |
| | | this.env[p] = value; |
| | | }; |
| | | |
| | | |
| | | // add a localized label to the client environment |
| | | this.add_label = function(key, value) |
| | | { |
| | | this.labels[key] = value; |
| | | }; |
| | | |
| | | |
| | | // add a button to the button list |
| | | this.register_button = function(command, id, type, act, sel, over) |
| | |
| | | break; |
| | | } |
| | | |
| | | |
| | | // enable basic commands |
| | | this.enable_command('logout', true); |
| | | |
| | |
| | | // start keep-alive interval |
| | | this.start_keepalive(); |
| | | |
| | | |
| | | // execute all foreign onload scripts |
| | | for (var i=0; i<this.onloads.length; i++) |
| | | { |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | // start interval for keep-alive/recent_check signal |
| | | this.start_keepalive = function() |
| | | { |
| | |
| | | else if (this.env.keep_alive && !this.env.framed && this.task!='login') |
| | | this._int = setInterval(function(){ ref.send_keep_alive(); }, this.env.keep_alive * 1000); |
| | | } |
| | | |
| | | |
| | | this.init_message_row = function(row) |
| | | { |
| | |
| | | row.flagged_icon.onmousedown = function(e) { p.command('toggle_flag', this); }; |
| | | } |
| | | }; |
| | | |
| | | |
| | | // init message compose form: set focus and eventhandlers |
| | | this.init_messageform = function() |
| | |
| | | }; |
| | | |
| | | |
| | | |
| | | /*********************************************************/ |
| | | /********* client command interface *********/ |
| | | /*********************************************************/ |
| | | |
| | | |
| | | // execute a specific command on the web client |
| | | this.command = function(command, props, obj) |
| | |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // check input before leaving compose step |
| | | if (this.task=='mail' && this.env.action=='compose' && (command=='list' || command=='mail' || command=='addressbook' || command=='settings')) |
| | |
| | | return obj ? false : true; |
| | | }; |
| | | |
| | | |
| | | // set command enabled or disabled |
| | | this.enable_command = function() |
| | | { |
| | |
| | | } |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | // lock/unlock interface |
| | | this.set_busy = function(a, message) |
| | |
| | | this.request_timer = window.setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000); |
| | | }; |
| | | |
| | | |
| | | // return a localized string |
| | | this.get_label = function(name) |
| | | { |
| | |
| | | else |
| | | return name; |
| | | }; |
| | | |
| | | |
| | | // switch to another application task |
| | | this.switch_task = function(task) |
| | |
| | | this.redirect(url); |
| | | }; |
| | | |
| | | |
| | | this.get_task_url = function(task, url) |
| | | { |
| | | if (!url) |
| | |
| | | |
| | | return url.replace(/_task=[a-z]+/, '_task='+task); |
| | | }; |
| | | |
| | | |
| | | // called when a request timed out |
| | | this.request_timed_out = function() |
| | |
| | | /*********************************************************/ |
| | | /********* event handling methods *********/ |
| | | /*********************************************************/ |
| | | |
| | | |
| | | this.doc_mouse_up = function(e) |
| | | { |
| | |
| | | return rcube_event.get_button(e) == 2 ? true : rcube_event.cancel(e); |
| | | }; |
| | | |
| | | |
| | | this.msglist_select = function(list) |
| | | { |
| | | if (this.preview_timer) |
| | |
| | | this.show_contentframe(false); |
| | | }; |
| | | |
| | | |
| | | this.msglist_dbl_click = function(list) |
| | | { |
| | | if (this.preview_timer) |
| | |
| | | else if (uid) |
| | | this.show_message(uid, false, false); |
| | | }; |
| | | |
| | | |
| | | this.msglist_keypress = function(list) |
| | | { |
| | |
| | | list.shiftkey = false; |
| | | }; |
| | | |
| | | |
| | | this.msglist_get_preview = function() |
| | | { |
| | | var uid = this.get_single_uid(); |
| | |
| | | else if (this.env.contentframe) |
| | | this.show_contentframe(false); |
| | | }; |
| | | |
| | | |
| | | this.check_droptarget = function(id) |
| | | { |
| | |
| | | // when user doble-clicks on a row |
| | | this.show_message = function(id, safe, preview) |
| | | { |
| | | if (!id) return; |
| | | |
| | | var add_url = ''; |
| | | var action = preview ? 'preview': 'show'; |
| | | var target = window; |
| | | |
| | | if (preview && this.env.contentframe && window.frames && window.frames[this.env.contentframe]) |
| | | { |
| | | target = window.frames[this.env.contentframe]; |
| | |
| | | // also send search request to get the right messages |
| | | if (this.env.search_request) |
| | | add_url += '&_search='+this.env.search_request; |
| | | |
| | | if (id) |
| | | { |
| | | var url = '&_action='+action+'&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url; |
| | | if (action == 'preview' && String(target.location.href).indexOf(url) >= 0) |
| | | this.show_contentframe(true); |
| | |
| | | { |
| | | this.set_busy(true, 'loading'); |
| | | target.location.href = this.env.comm_path+url; |
| | | // mark as read and change mbox unread counter |
| | | if (action == 'preview' && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread) |
| | | { |
| | | this.set_message(id, 'unread', false); |
| | | if (this.env.unread_counts[this.env.mailbox]) |
| | | { |
| | | this.env.unread_counts[this.env.mailbox] -= 1; |
| | | this.set_unread_count(this.env.mailbox, this.env.unread_counts[this.env.mailbox], this.env.mailbox == 'INBOX'); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | this.show_contentframe = function(show) |
| | | { |
| | |
| | | if (!show && this.busy) |
| | | this.set_busy(false); |
| | | }; |
| | | |
| | | |
| | | // list a specific page |
| | | this.list_page = function(page) |
| | |
| | | this.list_contacts(this.env.source, page); |
| | | } |
| | | }; |
| | | |
| | | |
| | | // list messages of a specific mailbox |
| | | this.list_mailbox = function(mbox, page, sort) |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | // send remote request to load message list |
| | | this.list_mailbox_remote = function(mbox, page, add_url) |
| | | { |
| | |
| | | this.set_busy(true, 'loading'); |
| | | this.http_request('list', url+add_url, true); |
| | | }; |
| | | |
| | | |
| | | this.expunge_mailbox = function(mbox) |
| | | { |
| | |
| | | var url = '_mbox='+urlencode(mbox); |
| | | this.http_post('expunge', url+add_url, lock); |
| | | }; |
| | | |
| | | |
| | | this.purge_mailbox = function(mbox) |
| | | { |
| | |
| | | this.permanently_remove_messages(); |
| | | }; |
| | | |
| | | |
| | | // delete the selected messages permanently |
| | | this.permanently_remove_messages = function() |
| | | { |
| | |
| | | // send request to server |
| | | this.http_post(action, '_uid='+a_uids.join(',')+'&_mbox='+urlencode(this.env.mailbox)+add_url, lock); |
| | | }; |
| | | |
| | | |
| | | // set a specific flag to one or more messages |
| | | this.mark_message = function(flag, uid) |
| | |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.flag_as_undeleted = function(a_uids) |
| | | { |
| | | for (var i=0; i<a_uids.length; i++) |
| | |
| | | this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=undelete'); |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.flag_as_deleted = function(a_uids) |
| | | { |
| | |
| | | this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url); |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | // flag as read without mark request (called from backend) |
| | | // argument should be a coma-separated list of uids |
| | |
| | | /*********************************************************/ |
| | | /********* message compose methods *********/ |
| | | /*********************************************************/ |
| | | |
| | | |
| | | // checks the input fields before sending a message |
| | | this.check_compose_input = function() |
| | |
| | | this.enable_command('spellcheck', this.spellcheck_ready); |
| | | }; |
| | | |
| | | |
| | | this.set_draft_id = function(id) |
| | | { |
| | | var f; |
| | |
| | | // Unlock interface now that saving is complete |
| | | this.busy = false; |
| | | }; |
| | | |
| | | |
| | | this.compose_field_hash = function(save) |
| | | { |
| | |
| | | |
| | | return str; |
| | | }; |
| | | |
| | | |
| | | this.change_identity = function(obj) |
| | | { |
| | |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.show_attachment_form = function(a) |
| | | { |
| | | if (!this.gui_objects.uploadbox) |
| | |
| | | |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | // upload attachment file |
| | | this.upload_file = function(form) |
| | |
| | | this.gui_objects.attachmentform = form; |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | // add file name to attachment list |
| | | // called from upload page |
| | |
| | | this.env.search_request = null; |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.sent_successfully = function(type, msg) |
| | | { |
| | |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.insert_recipient = function(id) |
| | | { |
| | | if (!this.env.contacts[id] || !this.ksearch_input) |
| | |
| | | if (this.ksearch_input.setSelectionRange) |
| | | this.ksearch_input.setSelectionRange(cpos, cpos); |
| | | }; |
| | | |
| | | |
| | | // address search processor |
| | | this.ksearch_get_results = function() |
| | |
| | | this.ksearch_hide(); |
| | | }; |
| | | |
| | | |
| | | this.ksearch_blur = function(e, obj) |
| | | { |
| | | if (this.ksearch_timer) |
| | |
| | | }; |
| | | |
| | | |
| | | |
| | | /*********************************************************/ |
| | | /********* address book methods *********/ |
| | | /*********************************************************/ |
| | |
| | | if (list.key_pressed == list.DELETE_KEY) |
| | | this.command('delete'); |
| | | }; |
| | | |
| | | |
| | | this.contactlist_select = function(list) |
| | | { |
| | |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | |
| | | this.list_contacts = function(src, page) |
| | | { |
| | |
| | | target.location.href = this.env.comm_path+(src ? '&_source='+urlencode(src) : '')+(page ? '&_page='+page : '')+add_url; |
| | | }; |
| | | |
| | | |
| | | // send remote request to load contacts list |
| | | this.list_contacts_remote = function(src, page) |
| | | { |
| | |
| | | this.set_busy(true, 'loading'); |
| | | this.http_request('list', url, true); |
| | | }; |
| | | |
| | | |
| | | // load contact record |
| | | this.load_contact = function(cid, action, framed) |
| | |
| | | this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs); |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | // update a contact record in the list |
| | | this.update_contact_row = function(cid, cols_arr) |
| | |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.delete_identity = function(id) |
| | | { |
| | | // exit if no mailbox specified or if selection is empty |
| | |
| | | this.goto_url('delete-identity', '_iid='+id, true); |
| | | return true; |
| | | }; |
| | | |
| | | |
| | | this.focus_subscription = function(id) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | this.unfocus_subscription = function(id) |
| | | { |
| | | var row; |
| | |
| | | else |
| | | this.set_classname(this.subscription_list.frame, 'droptarget', false); |
| | | } |
| | | |
| | | |
| | | this.subscription_select = function(list) |
| | | { |
| | |
| | | this.gui_objects.createfolderhint.innerHTML = this.env.folder ? this.get_label('addsubfolderhint') : ''; |
| | | }; |
| | | |
| | | |
| | | this.subscription_move_folder = function(list) |
| | | { |
| | | var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$'); |
| | |
| | | this.drag_active = false; |
| | | this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder)); |
| | | }; |
| | | |
| | | |
| | | // tell server to create and subscribe a new mailbox |
| | | this.create_folder = function(name) |
| | |
| | | else if (form.elements['_folder_name']) |
| | | form.elements['_folder_name'].focus(); |
| | | }; |
| | | |
| | | |
| | | // start renaming the mailbox name. |
| | | // this will replace the name string with an input field |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | // remove the input field and write the current mailbox name to the table cell |
| | | this.reset_folder_rename = function() |
| | | { |
| | |
| | | |
| | | this.edit_folder = null; |
| | | }; |
| | | |
| | | |
| | | // handler for keyboard events on the input field |
| | | this.name_input_keypress = function(e) |
| | |
| | | this.reset_folder_rename(); |
| | | }; |
| | | |
| | | |
| | | // delete a specific mailbox with all its messages |
| | | this.delete_folder = function(id) |
| | | { |
| | |
| | | this.gui_objects.createfolderhint.innerHTML = ''; |
| | | } |
| | | }; |
| | | |
| | | |
| | | // add a new folder to the subscription list by cloning a folder row |
| | | this.add_folder_row = function(name, display_name, replace, before) |
| | |
| | | document.getElementById(id).scrollIntoView(); |
| | | }; |
| | | |
| | | |
| | | // replace an existing table row with a new folder line |
| | | this.replace_folder_row = function(oldfolder, newfolder, display_name, before) |
| | | { |
| | |
| | | form.elements['_folder_newname'].value = ''; |
| | | } |
| | | }; |
| | | |
| | | |
| | | // remove the table row of a specific mailbox from the table |
| | | // (the row will not be removed, just hidden) |
| | |
| | | form.elements['_folder_newname'].value = ''; |
| | | }; |
| | | |
| | | |
| | | this.subscribe_folder = function(folder) |
| | | { |
| | | if (folder) |
| | | this.http_post('subscribe', '_mbox='+urlencode(folder)); |
| | | }; |
| | | |
| | | |
| | | this.unsubscribe_folder = function(folder) |
| | | { |
| | | if (folder) |
| | | this.http_post('unsubscribe', '_mbox='+urlencode(folder)); |
| | | }; |
| | | |
| | | |
| | | // helper method to find a specific mailbox row ID |
| | | this.get_folder_row_id = function(folder) |
| | |
| | | /********* GUI functionality *********/ |
| | | /*********************************************************/ |
| | | |
| | | |
| | | // eable/disable buttons for page shifting |
| | | this.set_page_buttons = function() |
| | | { |
| | |
| | | this.enable_command('previouspage', (this.env.current_page > 1)); |
| | | this.enable_command('firstpage', (this.env.current_page > 1)); |
| | | } |
| | | |
| | | |
| | | // set button to a specific state |
| | | this.set_button = function(command, state) |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | // set/unset a specific class name |
| | | this.set_classname = function(obj, classname, set) |
| | | { |
| | |
| | | obj.className += ' '+classname; |
| | | }; |
| | | |
| | | |
| | | // write to the document/window title |
| | | this.set_pagetitle = function(title) |
| | | { |
| | | if (title && document.title) |
| | | document.title = title; |
| | | } |
| | | |
| | | |
| | | // display a system message |
| | | this.display_message = function(msg, type, hold) |
| | |
| | | this.message_timer = window.setTimeout(function(){ ref.hide_message(); }, this.message_time); |
| | | }; |
| | | |
| | | |
| | | // make a message row disapear |
| | | this.hide_message = function() |
| | | { |
| | |
| | | this.gui_objects.message.onmousedown = null; |
| | | } |
| | | }; |
| | | |
| | | |
| | | // mark a mailbox as selected and set environment variable |
| | | this.select_folder = function(name, old) |
| | |
| | | |
| | | return null; |
| | | }; |
| | | |
| | | |
| | | // for reordering column array, Konqueror workaround |
| | | this.set_message_coltypes = function(coltypes) |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | // replace content of row count display |
| | | this.set_rowcount = function(text) |
| | | { |
| | |
| | | // update page navigation buttons |
| | | this.set_page_buttons(); |
| | | }; |
| | | |
| | | |
| | | // replace content of mailboxname display |
| | | this.set_mailboxname = function(content) |
| | |
| | | this.gui_objects.quotadisplay.innerHTML = content; |
| | | }; |
| | | |
| | | |
| | | // update the mailboxlist |
| | | this.set_unread_count = function(mbox, count, set_title) |
| | | { |
| | |
| | | this.env.unread_counts[mbox] = count; |
| | | this.set_unread_count_display(mbox, set_title); |
| | | } |
| | | |
| | | |
| | | // update the mailbox count display |
| | | this.set_unread_count_display = function(mbox, set_title) |
| | |
| | | this.enable_command('export', (this.contact_list.rowcount > 0)); |
| | | }; |
| | | |
| | | |
| | | this.toggle_editor = function(checkbox, textAreaId) |
| | | { |
| | | var ischecked = checkbox.checked; |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | this.toggle_prefer_html = function(checkbox) |
| | | { |
| | | var addrbook_show_images; |
| | | if (addrbook_show_images = document.getElementById('rcmfd_addrbook_show_images')) |
| | | addrbook_show_images.disabled = !checkbox.checked; |
| | | } |
| | | |
| | | |
| | | // display fetched raw headers |
| | | this.set_headers = function(content) |
| | |
| | | this.set_busy(false); |
| | | } |
| | | }; |
| | | |
| | | |
| | | // display all-headers row and fetch raw message headers |
| | | this.load_headers = function(elem) |
| | |
| | | this.http_post('headers', '_uid='+this.env.uid); |
| | | } |
| | | } |
| | | |
| | | |
| | | // hide all-headers row |
| | | this.hide_headers = function(elem) |
| | |
| | | this.redirect(this.env.comm_path+'&_action='+action+querystring, lock); |
| | | }; |
| | | |
| | | |
| | | this.http_sockets = new Array(); |
| | | |
| | | // find a non-busy socket or create a new one |
| | |
| | | |
| | | return this.http_sockets[i]; |
| | | }; |
| | | |
| | | |
| | | // send a http request to the server |
| | | this.http_request = function(action, querystring, lock) |
| | |
| | | this.http_response = function(request_obj) |
| | | { |
| | | var ctype = request_obj.get_header('Content-Type'); |
| | | if (ctype){ |
| | | if (ctype) |
| | | { |
| | | ctype = String(ctype).toLowerCase(); |
| | | var ctype_array=ctype.split(";"); |
| | | ctype = ctype_array[0]; |
| | |
| | | request_obj.reset(); |
| | | }; |
| | | |
| | | |
| | | // handle HTTP request errors |
| | | this.http_error = function(request_obj) |
| | | { |
| | | //alert('Error sending request: '+request_obj.url+' => HTTP '+request_obj.xmlhttp.status); |
| | | |
| | | if (request_obj.__lock) |
| | | this.set_busy(false); |
| | | |
| | |
| | | this.display_message('Unknown Server Error!', 'error'); |
| | | }; |
| | | |
| | | |
| | | // use an image to send a keep-alive siganl to the server |
| | | this.send_keep_alive = function() |
| | | { |
| | | var d = new Date(); |
| | | this.http_request('keep-alive', '_t='+d.getTime()); |
| | | }; |
| | | |
| | | |
| | | // send periodic request to check for recent messages |
| | | this.check_for_recent = function() |
| | |
| | | return obj.value.length; |
| | | }; |
| | | |
| | | |
| | | this.set_caret2start = function(obj) |
| | | { |
| | | if (obj.createTextRange) |
| | |
| | | |
| | | obj.focus(); |
| | | }; |
| | | |
| | | |
| | | // set all fields of a form disabled |
| | | this.lock_form = function(form, lock) |
| | |
| | | } // end object rcube_webmail |
| | | |
| | | |
| | | |
| | | /** |
| | | * Class for sending HTTP requests |
| | | * @constructor |
| | |
| | | this.url = ''; |
| | | this.busy = false; |
| | | this.xmlhttp = null; |
| | | |
| | | |
| | | // reset object properties |
| | | this.reset = function() |
| | |
| | | this.busy = false; |
| | | this.xmlhttp = null; |
| | | } |
| | | |
| | | |
| | | // create HTMLHTTP object |
| | | this.build = function() |
| | |
| | | this.xmlhttp.send(null); |
| | | }; |
| | | |
| | | |
| | | this.POST = function(url, body, contentType) |
| | | { |
| | | // default value for contentType if not provided |
| | |
| | | this.xmlhttp.setRequestHeader('X-RoundCube-Referer', bw.get_cookie('roundcube_sessid')); |
| | | this.xmlhttp.send(req_body); |
| | | }; |
| | | |
| | | |
| | | // handle onreadystatechange event |
| | | this.xmlhttp_onreadystatechange = function() |