X-Git-Url: https://git.donarmstrong.com/?p=roundcube.git;a=blobdiff_plain;f=program%2Fjs%2Fapp.js.src;h=a127b29331cc56a5f55817b54c3f91588492d940;hp=411aa2ba4e31ca563063254d1634dc915474c076;hb=a2dd2e41259a5e90016efcd7d083020b95e25527;hpb=fe4a852cd4335d3d2089b13e10d409fa2fa816d8 diff --git a/program/js/app.js.src b/program/js/app.js.src index 411aa2b..a127b29 100644 --- a/program/js/app.js.src +++ b/program/js/app.js.src @@ -3,7 +3,7 @@ | Roundcube Webmail Client Script | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2010, Roundcube Dev, - Switzerland | + | Copyright (C) 2005-2010, The Roundcube Dev Team | | Licensed under the GNU GPL | | | +-----------------------------------------------------------------------+ @@ -14,10 +14,9 @@ | Requires: jquery.js, common.js, list.js | +-----------------------------------------------------------------------+ - $Id: app.js 4763 2011-05-13 17:31:09Z alec $ + $Id: app.js 5281 2011-09-27 07:29:49Z alec $ */ - function rcube_webmail() { this.env = {}; @@ -41,11 +40,6 @@ function rcube_webmail() this.identifier_expr = new RegExp('[^0-9a-z\-_]', 'gi'); - // mimetypes supported by the browser (default settings) - this.mimetypes = new Array('text/plain', 'text/html', 'text/xml', - 'image/jpeg', 'image/gif', 'image/png', - 'application/x-javascript', 'application/pdf', 'application/x-shockwave-flash'); - // default environment vars this.env.keep_alive = 60; // seconds this.env.request_timeout = 180; // seconds @@ -63,7 +57,7 @@ function rcube_webmail() // set environment variable(s) this.set_env = function(p, value) { - if (p != null && typeof(p) == 'object' && !value) + if (p != null && typeof p === 'object' && !value) for (var n in p) this.env[n] = p[n]; else @@ -71,9 +65,12 @@ function rcube_webmail() }; // add a localized label to the client environment - this.add_label = function(key, value) + this.add_label = function(p, value) { - this.labels[key] = value; + if (typeof p == 'string') + this.labels[p] = value; + else if (typeof p == 'object') + $.extend(this.labels, p); }; // add a button to the button list @@ -88,12 +85,15 @@ function rcube_webmail() if (over) button_prop.over = over; this.buttons[command].push(button_prop); + + if (this.loaded) + init_button(command, button_prop); }; // register a specific gui object this.gui_object = function(name, id) { - this.gui_objects[name] = id; + this.gui_objects[name] = this.loaded ? rcube_find_object(id) : id; }; // register a container object @@ -154,7 +154,7 @@ function rcube_webmail() } // enable general commands - this.enable_command('logout', 'mail', 'addressbook', 'settings', true); + this.enable_command('logout', 'mail', 'addressbook', 'settings', 'save-pref', 'undo', true); if (this.env.permaurl) this.enable_command('permaurl', true); @@ -199,12 +199,12 @@ function rcube_webmail() $(this.gui_objects.qsearchbox).focusin(function() { rcmail.message_list.blur(); }); } - if (this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox) + if (!this.env.flag_for_deletion && this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox) this.set_alttext('delete', 'movemessagetotrash'); this.env.message_commands = ['show', 'reply', 'reply-all', 'reply-list', 'forward', 'moveto', 'copy', 'delete', 'open', 'mark', 'edit', 'viewsource', 'download', - 'print', 'load-attachment', 'load-headers']; + 'print', 'load-attachment', 'load-headers', 'forward-attachment']; if (this.env.action=='show' || this.env.action=='preview') { this.enable_command(this.env.message_commands, this.env.uid); @@ -228,7 +228,7 @@ function rcube_webmail() } } else if (this.env.action == 'compose') { - this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'toggle-editor']; + this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel', 'toggle-editor']; if (this.env.drafts_mailbox) this.env.compose_commands.push('savedraft') @@ -250,7 +250,10 @@ function rcube_webmail() } // show printing dialog else if (this.env.action == 'print' && this.env.uid) - window.print(); + if (bw.safari) + window.setTimeout('window.print()', 10); + else + window.print(); // get unread count for each mailbox if (this.gui_objects.mailboxlist) { @@ -270,7 +273,6 @@ function rcube_webmail() break; - case 'addressbook': if (this.gui_objects.folderlist) this.env.contactfolders = $.extend($.extend({}, this.env.address_sources), this.env.contactgroups); @@ -295,55 +297,54 @@ function rcube_webmail() if (this.gui_objects.qsearchbox) { $(this.gui_objects.qsearchbox).focusin(function() { rcmail.contact_list.blur(); }); } + + this.update_group_commands(); } this.set_page_buttons(); - if (this.env.address_sources && this.env.address_sources[this.env.source] && !this.env.address_sources[this.env.source].readonly) { - this.enable_command('add', 'import', true); - this.enable_command('group-create', this.env.address_sources[this.env.source].groups); - } - if (this.env.cid) { this.enable_command('show', 'edit', true); // register handlers for group assignment via checkboxes if (this.gui_objects.editform) { - $('input.groupmember').change(function(){ - var cmd = this.checked ? 'group-addmembers' : 'group-delmembers'; - ref.http_post(cmd, '_cid='+urlencode(ref.env.cid) - + '&_source='+urlencode(ref.env.source) - + '&_gid='+urlencode(this.value)); + $('input.groupmember').change(function() { + ref.group_member_change(this.checked ? 'add' : 'del', ref.env.cid, ref.env.source, this.value); }); } } - if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform) { + if (this.gui_objects.editform) { this.enable_command('save', true); - $("input[type='text']").first().select(); + if (this.env.action == 'add' || this.env.action == 'edit') + this.init_contact_form(); } - else if (this.gui_objects.qsearchbox) { + if (this.gui_objects.qsearchbox) { this.enable_command('search', 'reset-search', 'moveto', true); - $(this.gui_objects.qsearchbox).select(); } if (this.contact_list && this.contact_list.rowcount > 0) this.enable_command('export', true); - this.enable_command('list', 'listgroup', true); + this.enable_command('add', 'import', this.env.writable_source); + this.enable_command('list', 'listgroup', 'advanced-search', true); + + // load contacts of selected source + if (!this.env.action) + this.command('list', this.env.source); break; case 'settings': this.enable_command('preferences', 'identities', 'save', 'folders', true); - if (this.env.action=='identities') { + if (this.env.action == 'identities') { this.enable_command('add', this.env.identities_level < 2); } - else if (this.env.action=='edit-identity' || this.env.action=='add-identity') { + else if (this.env.action == 'edit-identity' || this.env.action == 'add-identity') { this.enable_command('add', this.env.identities_level < 2); this.enable_command('save', 'delete', 'edit', 'toggle-editor', true); } - else if (this.env.action=='folders') { + else if (this.env.action == 'folders') { this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', true); } else if (this.env.action == 'edit-folder' && this.gui_objects.editform) { @@ -387,7 +388,7 @@ function rcube_webmail() // display 'loading' message on form submit, lock submit button $('form').submit(function () { - $('input[type=submit]', this).attr('disabled', true); + $('input[type=submit]', this).prop('disabled', true); rcmail.display_message('', 'loading'); }); @@ -398,12 +399,16 @@ function rcube_webmail() break; } + // prevent from form submit with Enter key in file input fields + if (bw.ie) + $('input[type=file]').keydown(function(e) { if (e.keyCode == '13') e.preventDefault(); }); + // flag object as complete this.loaded = true; // show message if (this.pending_message) - this.display_message(this.pending_message[0], this.pending_message[1]); + this.display_message(this.pending_message[0], this.pending_message[1], this.pending_message[2]); // map implicit containers if (this.gui_objects.folderlist) @@ -415,9 +420,9 @@ function rcube_webmail() // execute all foreign onload scripts // @deprecated for (var i in this.onloads) { - if (typeof(this.onloads[i]) == 'string') + if (typeof this.onloads[i] === 'string') eval(this.onloads[i]); - else if (typeof(this.onloads[i]) == 'function') + else if (typeof this.onloads[i] === 'function') this.onloads[i](); } @@ -425,6 +430,11 @@ function rcube_webmail() this.start_keepalive(); }; + this.log = function(msg) + { + if (window.console && console.log) + console.log(msg); + }; /*********************************************************/ /********* client command interface *********/ @@ -455,24 +465,24 @@ function rcube_webmail() } // process external commands - if (typeof this.command_handlers[command] == 'function') { + if (typeof this.command_handlers[command] === 'function') { var ret = this.command_handlers[command](props, obj); - return ret !== null ? ret : (obj ? false : true); + return ret !== undefined ? ret : (obj ? false : true); } - else if (typeof this.command_handlers[command] == 'string') { + else if (typeof this.command_handlers[command] === 'string') { var ret = window[this.command_handlers[command]](props, obj); - return ret !== null ? ret : (obj ? false : true); + return ret !== undefined ? ret : (obj ? false : true); } // trigger plugin hooks this.triggerEvent('actionbefore', {props:props, action:command}); - var event_ret = this.triggerEvent('before'+command, props); - if (typeof event_ret != 'undefined') { + var ret = this.triggerEvent('before'+command, props); + if (ret !== undefined) { // abort if one the handlers returned false - if (event_ret === false) + if (ret === false) return false; else - props = event_ret; + props = ret; } // process internal command @@ -518,15 +528,15 @@ function rcube_webmail() this.list_mailbox(props); - if (this.env.trash_mailbox) + if (this.env.trash_mailbox && !this.env.flag_for_deletion) this.set_alttext('delete', this.env.mailbox != this.env.trash_mailbox ? 'movemessagetotrash' : 'deletemessage'); } - else if (this.task=='addressbook') { + else if (this.task == 'addressbook') { if (!this.env.search_request || (props != this.env.source)) this.reset_qsearch(); this.list_contacts(props); - this.enable_command('add', 'import', (this.env.address_sources && !this.env.address_sources[this.env.source].readonly)); + this.enable_command('add', 'import', this.env.writable_source); } break; @@ -578,7 +588,7 @@ function rcube_webmail() // common commands used in multiple tasks case 'show': - if (this.task=='mail') { + if (this.task == 'mail') { var uid = this.get_single_uid(); if (uid && (!this.env.uid || uid != this.env.uid)) { if (this.env.mailbox == this.env.drafts_mailbox) @@ -587,17 +597,17 @@ function rcube_webmail() this.show_message(uid); } } - else if (this.task=='addressbook') { + else if (this.task == 'addressbook') { var cid = props ? props : this.get_single_cid(); - if (cid && !(this.env.action=='show' && cid==this.env.cid)) + if (cid && !(this.env.action == 'show' && cid == this.env.cid)) this.load_contact(cid, 'show'); } break; case 'add': - if (this.task=='addressbook') + if (this.task == 'addressbook') this.load_contact(0, 'add'); - else if (this.task=='settings') { + else if (this.task == 'settings') { this.identity_list.clear_selection(); this.load_identity(0, 'add-identity'); } @@ -616,32 +626,40 @@ function rcube_webmail() break; case 'save': - if (this.gui_objects.editform) { - var input_pagesize = $("input[name='_pagesize']"); - var input_name = $("input[name='_name']"); - var input_email = $("input[name='_email']"); - + var input, form = this.gui_objects.editform; + if (form) { + // adv. search + if (this.env.action == 'search') { + } // user prefs - if (input_pagesize.length && isNaN(parseInt(input_pagesize.val()))) { + else if ((input = $("input[name='_pagesize']", form)) && input.length && isNaN(parseInt(input.val()))) { alert(this.get_label('nopagesizewarning')); - input_pagesize.focus(); + input.focus(); break; } // contacts/identities else { - if (input_name.length && input_name.val() == '') { - alert(this.get_label('nonamewarning')); - input_name.focus(); - break; + // reload form + if (props == 'reload') { + form.action += '?_reload=1'; } - else if (input_email.length && !rcube_check_email(input_email.val())) { + else if (this.task == 'settings' && (this.env.identities_level % 2) == 0 && + (input = $("input[name='_email']", form)) && input.length && !rcube_check_email(input.val()) + ) { alert(this.get_label('noemailwarning')); - input_email.focus(); + input.focus(); break; } + + // clear empty input fields + $('input.placeholder').each(function(){ if (this.value == this._placeholder) this.value = ''; }); } - this.gui_objects.editform.submit(); + // add selected source (on the list) + if (parent.rcmail && parent.rcmail.env.source) + form.action = this.add_url(form.action, '_orig_source', parent.rcmail.env.source); + + form.submit(); } break; @@ -727,7 +745,7 @@ function rcube_webmail() var qstring = '_mbox='+urlencode(this.env.mailbox)+'&_uid='+this.env.uid+'&_part='+props.part; // open attachment in frame if it's of a supported mimetype - if (this.env.uid && props.mimetype && $.inArray(props.mimetype, this.mimetypes)>=0) { + if (this.env.uid && props.mimetype && this.env.mimetypes && $.inArray(props.mimetype, this.env.mimetypes)>=0) { if (props.mimetype == 'text/html') qstring += '&_safe=1'; this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment'); @@ -798,10 +816,10 @@ function rcube_webmail() case 'compose': var url = this.env.comm_path+'&_action=compose'; - if (this.task=='mail') { + if (this.task == 'mail') { url += '&_mbox='+urlencode(this.env.mailbox); - if (this.env.mailbox==this.env.drafts_mailbox) { + if (this.env.mailbox == this.env.drafts_mailbox) { var uid; if (uid = this.get_single_uid()) url += '&_draft_uid='+uid; @@ -810,7 +828,7 @@ function rcube_webmail() url += '&_to='+urlencode(props); } // modify url if we're in addressbook - else if (this.task=='addressbook') { + else if (this.task == 'addressbook') { // switch to mail compose step directly if (props && props.indexOf('@') > 0) { url = this.get_task_url('mail', url); @@ -819,25 +837,22 @@ function rcube_webmail() } // use contact_id passed as command parameter - var a_cids = []; + var n, len, a_cids = []; if (props) a_cids.push(props); // get selected contacts else if (this.contact_list) { var selection = this.contact_list.get_selection(); - for (var n=0; n 0) { - var add_url = (this.env.source ? '_source='+urlencode(this.env.source)+'&' : ''); - if (this.env.search_request) - add_url += '_search='+this.env.search_request; - - this.goto_url('export', add_url); + this.goto_url('export', { _source:this.env.source, _gid:this.env.group, _search:this.env.search_request }); } break; + case 'upload-photo': + this.upload_contact_photo(props); + break; + + case 'delete-photo': + this.replace_contact_photo('-del-'); + break; + // user settings commands case 'preferences': case 'identities': @@ -1011,10 +1045,14 @@ function rcube_webmail() this.goto_url('settings/' + command); break; + case 'undo': + this.http_request('undo', '', this.display_message('', 'loading')); + break; + // unified command call (command name == function name) default: var func = command.replace(/-/g, '_'); - if (this[func] && typeof this[func] == 'function') + if (this[func] && typeof this[func] === 'function') this[func](props); break; } @@ -1152,7 +1190,19 @@ function rcube_webmail() this.is_framed = function() { - return (this.env.framed && parent.rcmail); + return (this.env.framed && parent.rcmail && parent.rcmail != this && parent.rcmail.command); + }; + + this.save_pref = function(prop) + { + var request = {'_name': prop.name, '_value': prop.value}; + + if (prop.session) + request['_session'] = prop.session; + if (prop.env) + this.env[prop.env] = prop.value; + + this.http_post('save-pref', request); }; @@ -1163,12 +1213,12 @@ function rcube_webmail() this.drag_menu = function(e, target) { var modkey = rcube_event.get_modifier(e), - menu = $('#'+this.gui_objects.message_dragmenu); + menu = this.gui_objects.message_dragmenu; if (menu && modkey == SHIFT_KEY && this.commands['copy']) { var pos = rcube_event.get_mouse_pos(e); this.env.drag_target = target; - menu.css({top: (pos.y-10)+'px', left: (pos.x-10)+'px'}).show(); + $(menu).css({top: (pos.y-10)+'px', left: (pos.x-10)+'px'}).show(); return true; } @@ -1177,9 +1227,9 @@ function rcube_webmail() this.drag_menu_action = function(action) { - var menu = $('#'+this.gui_objects.message_dragmenu); + var menu = this.gui_objects.message_dragmenu; if (menu) { - menu.hide(); + $(menu).hide(); } this.command(action, this.env.drag_target); this.env.drag_target = null; @@ -1249,7 +1299,7 @@ function rcube_webmail() var toffset = -moffset-boffset; var li, div, pos, mouse, check, oldclass, layerclass = 'draglayernormal'; - + if (this.contact_list && this.contact_list.draglayer) oldclass = this.contact_list.draglayer.attr('class'); @@ -1326,12 +1376,12 @@ function rcube_webmail() ul.show(); div.removeClass('collapsed').addClass('expanded'); var reg = new RegExp('&'+urlencode(id)+'&'); - this.set_env('collapsed_folders', this.env.collapsed_folders.replace(reg, '')); + this.env.collapsed_folders = this.env.collapsed_folders.replace(reg, ''); } else { ul.hide(); div.removeClass('expanded').addClass('collapsed'); - this.set_env('collapsed_folders', this.env.collapsed_folders+'&'+urlencode(id)+'&'); + this.env.collapsed_folders = this.env.collapsed_folders+'&'+urlencode(id)+'&'; // select parent folder if one of its childs is currently selected if (this.env.mailbox.indexOf(id + this.env.delimiter) == 0) @@ -1347,7 +1397,7 @@ function rcube_webmail() } } - this.http_post('save-pref', '_name=collapsed_folders&_value='+urlencode(this.env.collapsed_folders)); + this.command('save-pref', { name: 'collapsed_folders', value: this.env.collapsed_folders }); this.set_unread_count_display(id, false); }; @@ -1388,7 +1438,7 @@ function rcube_webmail() // reset 'pressed' buttons if (this.buttons_sel) { for (id in this.buttons_sel) - if (typeof id != 'function') + if (typeof id !== 'function') this.button_out(this.buttons_sel[id], id); this.buttons_sel = {}; } @@ -1420,7 +1470,7 @@ function rcube_webmail() if (selected) { // Hide certain command buttons when Drafts folder is selected if (this.env.mailbox == this.env.drafts_mailbox) - this.enable_command('reply', 'reply-all', 'reply-list', 'forward', false); + this.enable_command('reply', 'reply-all', 'reply-list', 'forward', 'forward-attachment', false); // Disable reply-list when List-Post header is not set else { var msg = this.env.messages[list.get_single_selection()]; @@ -1516,12 +1566,12 @@ function rcube_webmail() } if ((found = $.inArray('flag', this.env.coltypes)) >= 0) - this.set_env('flagged_col', found); + this.env.flagged_col = found; if ((found = $.inArray('subject', this.env.coltypes)) >= 0) - this.set_env('subject_col', found); + this.env.subject_col = found; - this.http_post('save-pref', { '_name':'list_cols', '_value':this.env.coltypes, '_session':'list_attrib/columns' }); + this.command('save-pref', { name: 'list_cols', value: this.env.coltypes, session: 'list_attrib/columns' }); }; this.check_droptarget = function(id) @@ -1672,7 +1722,7 @@ function rcube_webmail() message.expanded = true; } else if (message.has_children) { - if (typeof(message.expanded) == 'undefined' && (this.env.autoexpand_threads == 1 || (this.env.autoexpand_threads == 2 && message.unread_children))) { + if (message.expanded === undefined && (this.env.autoexpand_threads == 1 || (this.env.autoexpand_threads == 2 && message.unread_children))) { message.expanded = true; } } @@ -1760,7 +1810,7 @@ function rcube_webmail() { var update, add_url = ''; - if (typeof sort_col == 'undefined') + if (sort_col === undefined) sort_col = this.env.sort_col; if (!sort_order) sort_order = this.env.sort_order; @@ -1825,10 +1875,7 @@ function rcube_webmail() if (action == 'preview' && String(target.location.href).indexOf(url) >= 0) this.show_contentframe(true); else { - if (!this.env.frame_lock) { - (this.is_framed() ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading'); - } - target.location.href = this.env.comm_path+url; + this.location_href(this.env.comm_path+url, target, true); // 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.env.preview_pane_mark_read >= 0) { @@ -1862,6 +1909,12 @@ function rcube_webmail() this.set_busy(false, null, this.env.frame_lock); }; + this.lock_frame = function() + { + if (!this.env.frame_lock) + (this.is_framed() ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading'); + }; + // list a specific page this.list_page = function(page) { @@ -1950,7 +2003,7 @@ function rcube_webmail() // load message list to target frame/window if (mbox) { this.set_busy(true, 'loading'); - target.location.href = this.env.comm_path+'&_mbox='+urlencode(mbox)+(page ? '&_page='+page : '')+url; + this.location_href(this.env.comm_path+'&_mbox='+urlencode(mbox)+(page ? '&_page='+page : '')+url, target); } }; @@ -2356,7 +2409,7 @@ function rcube_webmail() // copy selected messages to the specified mailbox this.copy_messages = function(mbox) { - if (mbox && typeof mbox == 'object') + if (mbox && typeof mbox === 'object') mbox = mbox.id; // exit if current or no mailbox specified or if selection is empty @@ -2385,7 +2438,7 @@ function rcube_webmail() // move selected messages to the specified mailbox this.move_messages = function(mbox) { - if (mbox && typeof mbox == 'object') + if (mbox && typeof mbox === 'object') mbox = mbox.id; // exit if current or no mailbox specified or if selection is empty @@ -2573,33 +2626,35 @@ function rcube_webmail() // set class to read/unread this.toggle_read_status = function(flag, a_uids) { + var i, len = a_uids.length, + url = '_uid='+this.uids_to_list(a_uids)+'&_flag='+flag, + lock = this.display_message(this.get_label('markingmessage'), 'loading'); + // mark all message rows as read/unread - for (var i=0; i 0) { + ac_props = { + threads: this.env.autocomplete_threads, + sources: this.env.autocomplete_sources + }; + } // init live search events - this.init_address_input_events(input_to); + this.init_address_input_events(input_to, ac_props); for (var i in ac_fields) { - this.init_address_input_events($("[name='_"+ac_fields[i]+"']")); + this.init_address_input_events($("[name='_"+ac_fields[i]+"']"), ac_props); } if (!html_mode) { this.set_caret_pos(input_message, this.env.top_posting ? 0 : $(input_message).val().length); // add signature according to selected identity // if we have HTML editor, signature is added in callback - if (input_from.attr('type') == 'select-one' && $("input[name='_draft_saveid']").val() == '') { + if (input_from.prop('type') == 'select-one' && $("input[name='_draft_saveid']").val() == '') { this.change_identity(input_from[0]); } } @@ -2845,9 +2912,9 @@ function rcube_webmail() this.auto_save_start(); }; - this.init_address_input_events = function(obj) + this.init_address_input_events = function(obj, props) { - obj[bw.ie || bw.safari || bw.chrome ? 'keydown' : 'keypress'](function(e){ return ref.ksearch_keydown(e, this); }) + obj[bw.ie || bw.safari || bw.chrome ? 'keydown' : 'keypress'](function(e) { return ref.ksearch_keydown(e, this, props); }) .attr('autocomplete', 'off'); }; @@ -2863,7 +2930,7 @@ function rcube_webmail() input_message = $("[name='_message']"); // check sender (if have no identities) - if (input_from.attr('type') == 'text' && !rcube_check_email(input_from.val(), true)) { + if (input_from.prop('type') == 'text' && !rcube_check_email(input_from.val(), true)) { alert(this.get_label('nosenderwarning')); input_from.focus(); return false; @@ -2879,7 +2946,7 @@ function rcube_webmail() // check if all files has been uploaded for (var key in this.env.attachments) { - if (typeof this.env.attachments[key] == 'object' && !this.env.attachments[key].complete) { + if (typeof this.env.attachments[key] === 'object' && !this.env.attachments[key].complete) { alert(this.get_label('notuploadedwarning')); return false; } @@ -2976,6 +3043,36 @@ function rcube_webmail() this.enable_command('spellcheck', this.spellcheck_ready); }; + // get selected language + this.spellcheck_lang = function() + { + var ed; + if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody)) && ed.plugins.spellchecker) { + return ed.plugins.spellchecker.selectedLang; + } + else if (this.env.spellcheck) { + return GOOGIE_CUR_LANG; + } + }; + + // resume spellchecking, highlight provided mispellings without new ajax request + this.spellcheck_resume = function(ishtml, data) + { + if (ishtml) { + var ed = tinyMCE.get(this.env.composebody); + sp = ed.plugins.spellchecker; + + sp.active = 1; + sp._markWords(data); + ed.nodeChanged(); + } + else { + var sp = this.env.spellcheck; + sp.prepare(false, true); + sp.processData(data); + } + } + this.set_draft_id = function(id) { $("input[name='_draft_saveid']").val(id); @@ -3159,37 +3256,23 @@ function rcube_webmail() if (!form) return false; - // get file input fields - var send = false; - for (var n=0; n