diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/include/rcube_json_output.php | 24 | ||||
-rwxr-xr-x | program/include/rcube_template.php | 66 | ||||
-rw-r--r-- | program/js/app.js | 268 | ||||
-rw-r--r-- | program/js/googiespell.js | 4 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 2 |
6 files changed, 208 insertions, 157 deletions
@@ -27,6 +27,7 @@ CHANGELOG Roundcube Webmail - Prevent from inserting empty link when composing HTML message (#1486944) - Add caching support in id2uid and uid2id functions (#1487019) - Add SASL proxy authentication for SMTP (#1486693) +- Improve displaying of UI messages (#1486977) RELEASE 0.4.2 ------------- diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php index 3b95a4928..337a82b6e 100644 --- a/program/include/rcube_json_output.php +++ b/program/include/rcube_json_output.php @@ -134,14 +134,14 @@ class rcube_json_output public function command() { $cmd = func_get_args(); - + if (strpos($cmd[0], 'plugin.') === 0) $this->callbacks[] = $cmd; else $this->commands[] = $cmd; } - - + + /** * Add a localized label to the client environment */ @@ -150,7 +150,7 @@ class rcube_json_output $args = func_get_args(); if (count($args) == 1 && is_array($args[0])) $args = $args[0]; - + foreach ($args as $name) { $this->texts[$name] = rcube_label($name); } @@ -203,8 +203,8 @@ class rcube_json_output $this->remote_response("window.setTimeout(\"location.href='{$location}'\", $delay);"); exit; } - - + + /** * Send an AJAX response to the client. */ @@ -213,8 +213,8 @@ class rcube_json_output $this->remote_response(); exit; } - - + + /** * Send an AJAX response with executable JS code * @@ -237,17 +237,17 @@ class rcube_json_output unset($this->env['task'], $this->env['action'], $this->env['comm_path']); $rcmail = rcmail::get_instance(); - $response = array('action' => $rcmail->action, 'unlock' => (bool)$_REQUEST['_unlock']); - + $response = array('action' => $rcmail->action, 'unlock' => get_input_value('_unlock', RCUBE_INPUT_GPC)); + if (!empty($this->env)) $response['env'] = $this->env; - + if (!empty($this->texts)) $response['texts'] = $this->texts; // send function calls $response['exec'] = $this->get_js_commands() . $add; - + if (!empty($this->callbacks)) $response['callbacks'] = $this->callbacks; diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index d923c6478..e9b2b2118 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -57,7 +57,7 @@ class rcube_template extends rcube_html_page $this->app = rcmail::get_instance(); $this->config = $this->app->config->all(); $this->browser = new rcube_browser(); - + //$this->framed = $framed; $this->set_env('task', $task); $this->set_env('request_token', $this->app->get_request_token()); @@ -129,7 +129,7 @@ class rcube_template extends rcube_html_page else { $title = ucfirst($this->env['task']); } - + return $title; } @@ -140,7 +140,7 @@ class rcube_template extends rcube_html_page public function set_skin($skin) { $valid = false; - + if (!empty($skin) && is_dir('skins/'.$skin) && is_readable('skins/'.$skin)) { $skin_path = 'skins/'.$skin; $valid = true; @@ -152,7 +152,7 @@ class rcube_template extends rcube_html_page $this->app->config->set('skin_path', $skin_path); $this->config['skin_path'] = $skin_path; - + return $valid; } @@ -226,7 +226,7 @@ class rcube_template extends rcube_html_page $args = func_get_args(); if (count($args) == 1 && is_array($args[0])) $args = $args[0]; - + foreach ($args as $name) { $this->command('add_label', $name, rcube_label($name)); } @@ -315,7 +315,7 @@ class rcube_template extends rcube_html_page // set output asap ob_flush(); flush(); - + if ($exit) { exit; } @@ -331,14 +331,18 @@ class rcube_template extends rcube_html_page public function write($template = '') { // unlock interface after iframe load + $unlock = preg_replace('/[^a-z0-9]/i', '', $_GET['_unlock']); if ($this->framed) { - array_unshift($this->js_commands, array('set_busy', false)); + array_unshift($this->js_commands, array('set_busy', false, null, $unlock)); + } + else if ($unlock) { + array_unshift($this->js_commands, array('hide_message', $unlock)); } // write all env variables to client $js = $this->framed ? "if(window.parent) {\n" : ''; $js .= $this->get_js_commands() . ($this->framed ? ' }' : ''); $this->add_script($js, 'head_top'); - + // make sure all <form> tags have a valid request token $template = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $template); $this->footer = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $this->footer); @@ -361,7 +365,7 @@ class rcube_template extends rcube_html_page { $skin_path = $this->config['skin_path']; $plugin = false; - + $temp = explode(".", $name, 2); if (count($temp) > 1) { $plugin = $temp[0]; @@ -373,7 +377,7 @@ class rcube_template extends rcube_html_page $skin_path = $this->app->plugins->dir . $skin_dir; } } - + $path = "$skin_path/templates/$name.html"; // read template file @@ -387,7 +391,7 @@ class rcube_template extends rcube_html_page ), true, true); return false; } - + // replace all path references to plugins/... with the configured plugins dir // and /this/ to the current plugin skin directory if ($plugin) { @@ -397,7 +401,7 @@ class rcube_template extends rcube_html_page // parse for specialtags $output = $this->parse_conditions($templ); $output = $this->parse_xml($output); - + // trigger generic hook where plugins can put additional content to the page $hook = $this->app->plugins->exec_hook("render_page", array('template' => $name, 'content' => $output)); @@ -408,7 +412,7 @@ class rcube_template extends rcube_html_page <textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:10px" spellcheck="false"></textarea></div>' ); } - + $output = $this->parse_with_globals($hook['content']); $this->write(trim($output)); if ($exit) { @@ -441,7 +445,7 @@ class rcube_template extends rcube_html_page implode(',', $args) ); } - + return $out; } @@ -545,8 +549,8 @@ class rcube_template extends rcube_html_page { return eval("return (".$this->parse_expression($condition).");"); } - - + + /** * Inserts hidden field with CSRF-prevention-token into POST forms */ @@ -554,12 +558,12 @@ class rcube_template extends rcube_html_page { $out = $matches[0]; $attrib = parse_attrib_string($matches[1]); - + if (strtolower($attrib['method']) == 'post') { $hidden = new html_hiddenfield(array('name' => '_token', 'value' => $this->app->get_request_token())); $out .= "\n" . $hidden->show(); } - + return $out; } @@ -660,7 +664,7 @@ class rcube_template extends rcube_html_page $hook = $this->app->plugins->exec_hook("template_plugin_include", $attrib); return $hook['content']; break; - + // define a container block case 'container': if ($attrib['name'] && $attrib['id']) { @@ -706,7 +710,7 @@ class rcube_template extends rcube_html_page $title .= $this->get_pagetitle(); $content = Q($title); } - + // exec plugin hooks for this template object $hook = $this->app->plugins->exec_hook("template_object_$object", $attrib + array('content' => $content)); return $hook['content']; @@ -715,7 +719,7 @@ class rcube_template extends rcube_html_page case 'exp': $value = $this->parse_expression($attrib['expression']); return eval("return Q($value);"); - + // return variable case 'var': $var = explode(':', $attrib['name']); @@ -803,7 +807,7 @@ class rcube_template extends rcube_html_page if ($attrib['task']) $command = $attrib['task'] . '.' . $command; - + if (!$attrib['image']) { $attrib['image'] = $attrib['imagepas'] ? $attrib['imagepas'] : $attrib['imageact']; } @@ -939,17 +943,17 @@ class rcube_template extends rcube_html_page $hiddenfield = new html_hiddenfield(array('name' => '_framed', 'value' => '1')); $hidden = $hiddenfield->show(); } - + if (!$content) $attrib['noclose'] = true; - + return html::tag('form', $attrib + array('action' => "./", 'method' => "get"), $hidden . $content, array('id','class','style','name','method','action','enctype','onsubmit')); } - - + + /** * Build a form tag with a unique request token * @@ -966,10 +970,10 @@ class rcube_template extends rcube_html_page if ($attrib['action']) { $hidden->add(array('name' => '_action', 'value' => $attrib['action'])); } - + unset($attrib['task'], $attrib['request']); $attrib['action'] = './'; - + // we already have a <form> tag if ($attrib['form']) return $hidden->show() . $content; @@ -1022,7 +1026,7 @@ class rcube_template extends rcube_html_page $default_host = $this->config['default_host']; $_SESSION['temp'] = true; - + // save original url $url = get_input_value('_url', RCUBE_INPUT_POST); if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) @@ -1079,7 +1083,7 @@ class rcube_template extends rcube_html_page $out .= $input_tzone->show(); $out .= $input_url->show(); $out .= $table->show(); - + if ($hide_host) { $out .= $input_host->show(); } @@ -1137,7 +1141,7 @@ class rcube_template extends rcube_html_page if ($attrib['type'] == 'search' && !$this->browser->khtml) { unset($attrib['type'], $attrib['results']); } - + $input_q = new html_inputfield($attrib); $out = $input_q->show(); diff --git a/program/js/app.js b/program/js/app.js index 12792a537..cb94d9597 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -29,6 +29,7 @@ function rcube_webmail() this.commands = {}; this.command_handlers = {}; this.onloads = []; + this.messages = {}; // create protected reference to myself this.ref = 'rcmail'; @@ -147,8 +148,10 @@ function rcube_webmail() this.init_buttons(); // tell parent window that this frame is loaded - if (this.env.framed && parent.rcmail && parent.rcmail.set_busy) - parent.rcmail.set_busy(false); + if (this.env.framed && parent.rcmail && parent.rcmail.set_busy) { + parent.rcmail.set_busy(false, null, parent.rcmail.env.frame_lock); + parent.rcmail.env.frame_lock = null; + } // enable general commands this.enable_command('logout', 'mail', 'addressbook', 'settings', true); @@ -369,7 +372,7 @@ function rcube_webmail() // display 'loading' message on form submit $('form').submit(function () { - rcmail.display_message(rcmail.get_label('loading'), 'loading', true); + rcmail.display_message(rcmail.get_label('loading'), 'loading'); }); this.enable_command('login', true); @@ -844,10 +847,12 @@ function rcube_webmail() if (!this.env.drafts_mailbox || this.cmp_hash == this.compose_field_hash()) break; - this.set_busy(true, 'savingmessage'); - var form = this.gui_objects.messageform; + var form = this.gui_objects.messageform, + msgid = this.set_busy(true, 'savingmessage'); + form.target = "savetarget"; form._draft.value = '1'; + form.action = this.add_url(form.action, '_unlock', msgid); form.submit(); break; @@ -862,10 +867,12 @@ function rcube_webmail() self.clearTimeout(this.save_timer); // all checks passed, send message - this.set_busy(true, 'sendingmessage'); - var form = this.gui_objects.messageform; + var form = this.gui_objects.messageform, + msgid = this.set_busy(true, 'sendingmessage'); + form.target = 'savetarget'; form._draft.value = ''; + form.action = this.add_url(form.action, '_unlock', msgid); form.submit(); // clear timeout (sending could take longer) @@ -1030,19 +1037,17 @@ function rcube_webmail() }; // lock/unlock interface - this.set_busy = function(a, message) + this.set_busy = function(a, message, id) { if (a && message) { var msg = this.get_label(message); if (msg == message) msg = 'Loading...'; - // @TODO: show many messages at a time (one below the other ?) - if (this.message_type() != 'error') - this.display_message(msg, 'loading', true); + id = this.display_message(msg, 'loading'); } - else if (!a && this.message_type() != 'error') { - this.hide_message(); + else if (!a && id) { + this.hide_message(id); } this.busy = a; @@ -1058,6 +1063,8 @@ function rcube_webmail() // set timer for requests if (a && this.env.request_timeout) this.request_timer = window.setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000); + + return id; }; // return a localized string @@ -1112,6 +1119,26 @@ function rcube_webmail() location.href = this.env.comm_path; }; + // Add variable to GET string, replace old value if exists + this.add_url = function(url, name, value) + { + value = urlencode(value); + + if (/(\?.*)$/.test(url)) { + var urldata = RegExp.$1, + datax = RegExp('((\\?|&)'+RegExp.escape(name)+'=[^&]*)'); + + if (datax.test(urldata)) { + urldata = urldata.replace(datax, RegExp.$2 + name + '=' + value); + } + else + urldata += '&' + name + '=' + value + + return url.replace(/(\?.*)$/, urldata); + } + else + return url + '?' + name + '=' + value; + }; /*********************************************************/ /********* event handling methods *********/ @@ -1769,7 +1796,8 @@ function rcube_webmail() if (action == 'preview' && String(target.location.href).indexOf(url) >= 0) this.show_contentframe(true); else { - this.set_busy(true, 'loading'); + if (!this.env.frame_lock) + this.env.frame_lock = this.set_busy(true, 'loading'); target.location.href = this.env.comm_path+url; // mark as read and change mbox unread counter @@ -1829,7 +1857,8 @@ function rcube_webmail() // list messages of a specific mailbox using filter this.filter_mailbox = function(filter) { - var search; + var search, lock = this.set_busy(true, 'searching'); + if (this.gui_objects.qsearchbox) search = this.gui_objects.qsearchbox.value; @@ -1837,10 +1866,9 @@ function rcube_webmail() // reset vars this.env.current_page = 1; - this.set_busy(true, 'searching'); this.http_request('search', '_filter='+filter + (search ? '&_q='+urlencode(search) : '') - + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : ''), true); + + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : ''), lock); }; // list messages of a specific mailbox @@ -1913,9 +1941,9 @@ function rcube_webmail() this.message_list.clear(); // send request to server - var url = '_mbox='+urlencode(mbox)+(page ? '&_page='+page : ''); - this.set_busy(true, 'loading'); - this.http_request('list', url+add_url, true); + var url = '_mbox='+urlencode(mbox)+(page ? '&_page='+page : ''), + lock = this.set_busy(true, 'loading'); + this.http_request('list', url+add_url, lock); }; // removes messages that doesn't exists from list selection array @@ -2320,9 +2348,8 @@ function rcube_webmail() var add_url = '&_target_mbox='+urlencode(mbox)+'&_from='+(this.env.action ? this.env.action : ''); // show wait message - if (this.env.action=='show') { - lock = true; - this.set_busy(true, 'movingmessage'); + if (this.env.action == 'show') { + lock = this.set_busy(true, 'movingmessage'); } else this.show_contentframe(false); @@ -2655,8 +2682,7 @@ function rcube_webmail() // lock interface if it's the active mailbox if (mbox == this.env.mailbox) { - lock = true; - this.set_busy(true, 'loading'); + lock = this.set_busy(true, 'loading'); add_url = '&_reload=1'; } @@ -2675,8 +2701,7 @@ function rcube_webmail() // lock interface if it's the active mailbox if (mbox == this.env.mailbox) { - lock = true; - this.set_busy(true, 'loading'); + lock = this.set_busy(true, 'loading'); add_url = '&_reload=1'; } @@ -3240,12 +3265,12 @@ function rcube_webmail() // reset vars this.env.current_page = 1; - this.set_busy(true, 'searching'); + var lock = this.set_busy(true, 'searching'); this.http_request('search', '_q='+urlencode(value) + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '') + (this.env.source ? '&_source='+urlencode(this.env.source) : '') + (this.env.group ? '&_gid='+urlencode(this.env.group) : '') - + (addurl ? addurl : ''), true); + + (addurl ? addurl : ''), lock); } return true; }; @@ -3262,7 +3287,7 @@ function rcube_webmail() this.sent_successfully = function(type, msg) { - this.display_message(msg, type, true); + this.display_message(msg, type); // before redirect we need to wait some time for Chrome (#1486177) window.setTimeout(function(){ ref.list_mailbox(); }, 500); }; @@ -3417,8 +3442,8 @@ function rcube_webmail() if (old_value && old_value.length && this.env.contacts && !this.env.contacts.length && q.indexOf(old_value) == 0) return; - this.display_message(this.get_label('searching'), 'loading', false); - this.http_post('autocomplete', '_search='+urlencode(q)); + var lock = this.display_message(this.get_label('searching'), 'loading'); + this.http_post('autocomplete', '_search='+urlencode(q), lock); }; this.ksearch_query_results = function(results, search) @@ -3427,7 +3452,6 @@ function rcube_webmail() if (this.ksearch_value && search != this.ksearch_value) return; - this.hide_message(); this.env.contacts = results ? results : []; this.ksearch_display_results(this.env.contacts); }; @@ -3586,7 +3610,9 @@ function rcube_webmail() this.enable_command('delete', 'compose', false); // send request to server - var url = (src ? '_source='+urlencode(src) : '') + (page ? (src?'&':'') + '_page='+page : ''); + var url = (src ? '_source='+urlencode(src) : '') + (page ? (src?'&':'') + '_page='+page : ''), + lock = this.set_busy(true, 'loading'); + this.env.source = src; this.env.group = group; @@ -3597,8 +3623,7 @@ function rcube_webmail() if (this.env.search_request) url += '&_search='+this.env.search_request; - this.set_busy(true, 'loading'); - this.http_request('list', url, true); + this.http_request('list', url, lock); }; // load contact record @@ -3808,11 +3833,11 @@ function rcube_webmail() var newname = this.name_input.val(); if (newname) { - this.set_busy(true, 'loading'); + var lock = this.set_busy(true, 'loading'); if (this.env.group_renaming) - this.http_post('group-rename', '_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+'&_name='+urlencode(newname), true); + this.http_post('group-rename', '_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+'&_name='+urlencode(newname), lock); else - this.http_post('group-create', '_source='+urlencode(this.env.source)+'&_name='+urlencode(newname), true); + this.http_post('group-create', '_source='+urlencode(this.env.source)+'&_name='+urlencode(newname), lock); } return false; } @@ -4021,8 +4046,8 @@ function rcube_webmail() var basename = this.env.folder.replace(reg, ''); var newname = this.env.dstfolder==this.env.delimiter ? basename : this.env.dstfolder+this.env.delimiter+basename; - this.set_busy(true, 'foldermoving'); - this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.folder)+'&_folder_newname='+urlencode(newname), true); + var lock = this.set_busy(true, 'foldermoving'); + this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.folder)+'&_folder_newname='+urlencode(newname), lock); } this.drag_active = false; this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder)); @@ -4046,8 +4071,8 @@ function rcube_webmail() if (this.env.folder && name != '') name = this.env.folder+this.env.delimiter+name; - this.set_busy(true, 'foldercreating'); - this.http_post('create-folder', '_name='+urlencode(name), true); + var lock = this.set_busy(true, 'foldercreating'); + this.http_post('create-folder', '_name='+urlencode(name), lock); } else if (form.elements['_folder_name']) form.elements['_folder_name'].focus(); @@ -4113,8 +4138,8 @@ function rcube_webmail() if (this.name_input.__parent) newname = this.name_input.__parent + this.env.delimiter + newname; - this.set_busy(true, 'folderrenaming'); - this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.subscriptionrows[this.edit_folder][0])+'&_folder_newname='+urlencode(newname), true); + var lock = this.set_busy(true, 'folderrenaming'); + this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.subscriptionrows[this.edit_folder][0])+'&_folder_newname='+urlencode(newname), lock); } } // escape @@ -4131,8 +4156,8 @@ function rcube_webmail() this.reset_folder_rename(); if (folder && confirm(this.get_label('deletefolderconfirm'))) { - this.set_busy(true, 'folderdeleting'); - this.http_post('delete-folder', '_mboxes='+urlencode(folder), true); + var lock = this.set_busy(true, 'folderdeleting'); + this.http_post('delete-folder', '_mboxes='+urlencode(folder), lock); this.set_env('folder', null); $(this.gui_objects.createfolderhint).html(''); @@ -4501,61 +4526,74 @@ function rcube_webmail() document.title = title; }; - // display a system message - this.display_message = function(msg, type, hold) + // display a system message, list of types in common.css (below #message definition) + this.display_message = function(msg, type) { - if (!this.loaded) { - // save message in order to display after page loaded - this.pending_message = new Array(msg, type); - return true; - } - // pass command to parent window if (this.env.framed && parent.rcmail) - return parent.rcmail.display_message(msg, type, hold); + return parent.rcmail.display_message(msg, type); - if (!this.gui_objects.message) + if (!this.gui_objects.message) { + // save message in order to display after page loaded + if (type != 'loading') + this.pending_message = new Array(msg, type); return false; + } - if (this.message_timer) - clearTimeout(this.message_timer); + type = type ? type : 'notice'; - var cont = msg; - if (type) - cont = '<div class="'+type+'">'+cont+'</div>'; + var date = new Date(), + id = type + date.getTime(); - var obj = $(this.gui_objects.message).html(cont).show(); - this.gui_objects.message.__type = type; + // The same message of type 'loading' is already displayed + if (type == 'loading' && this.messages[msg]) { + this.messages[msg].elements.push(id); + return id; + } - if (type!='loading') - obj.bind('mousedown', function(){ ref.hide_message(); return true; }); + var ref = this, + obj = $('<div>').addClass(type).html(msg), + cont = $(this.gui_objects.message).show(); - if (!hold) - this.message_timer = window.setTimeout(function(){ ref.hide_message(true); }, this.message_time); + if (type == 'loading') { + obj.appendTo(cont); + this.messages[msg] = {'obj': obj, 'elements': [id]}; + window.setTimeout(function() { rcmail.hide_message(id); }, this.env.request_timeout * 1000); + return id; + } + else { + obj.appendTo(cont).bind('mousedown', function(){ return ref.hide_message(obj); }); + window.setTimeout(function(){ ref.hide_message(obj, true); }, this.message_time); + return obj; + } }; - // make a message row disapear - this.hide_message = function(fade) + // make a message to disapear + this.hide_message = function(obj, fade) { - var msg; - if (this.gui_objects.message) - msg = this.gui_objects.message; - else if (this.env.framed && parent.rcmail) - msg = parent.rcmail.gui_objects.message; + // pass command to parent window + if (this.env.framed && parent.rcmail) + return parent.rcmail.hide_message(obj, fade); - if (msg) { - $(msg).unbind()[(fade?'fadeOut':'hide')](); - msg.__type = null; + if (typeof(obj) == 'object') { + // custom message + $(obj)[fade?'fadeOut':'hide'](); + } + else { + // 'loading' message + var k, n; + for (k in this.messages) { + for (n in this.messages[k].elements) { + if (this.messages[k].elements[n] == obj) { + this.messages[k].elements.splice(n, 1); + if (!this.messages[k].elements.length) { + this.messages[k].obj[fade?'fadeOut':'hide'](); + delete this.messages[k]; + } + } + } + } } - }; - - // get type of currently displayed message - this.message_type = function() - { - if (this.gui_objects.message) - return this.gui_objects.message.__type; - else if (this.env.framed && parent.rcmail && parent.rcmail.gui_objects.message) - return parent.rcmail.gui_objects.message.__type; }; // mark a mailbox as selected and set environment variable @@ -4764,14 +4802,8 @@ function rcube_webmail() // display fetched raw headers this.set_headers = function(content) { - if (this.gui_objects.all_headers_row && this.gui_objects.all_headers_box && content) { + if (this.gui_objects.all_headers_row && this.gui_objects.all_headers_box && content) $(this.gui_objects.all_headers_box).html(content).show(); - - if (this.env.framed && parent.rcmail) - parent.rcmail.set_busy(false); - else - this.set_busy(false); - } }; // display all-headers row and fetch raw message headers @@ -4786,8 +4818,8 @@ function rcube_webmail() // fetch headers only once if (!this.gui_objects.all_headers_box.innerHTML) { - this.display_message(this.get_label('loading'), 'loading', true); - this.http_post('headers', '_uid='+this.env.uid); + var lock = this.display_message(this.get_label('loading'), 'loading'); + this.http_post('headers', '_uid='+this.env.uid, lock); } }; @@ -4872,22 +4904,22 @@ function rcube_webmail() this.html2plain = function(htmlText, id) { var rcmail = this, - url = '?_task=utils&_action=html2text'; + url = '?_task=utils&_action=html2text', + lock = this.set_busy(true, 'converting'); - this.set_busy(true, 'converting'); console.log('HTTP POST: ' + url); $.ajax({ type: 'POST', url: url, data: htmlText, contentType: 'application/octet-stream', - error: function(o) { rcmail.http_error(o); }, - success: function(data) { rcmail.set_busy(false); $(document.getElementById(id)).val(data); console.log(data); } + error: function(o, status, err) { rcmail.http_error(o, status, err, lock); }, + success: function(data) { rcmail.set_busy(false, null, lock); $(document.getElementById(id)).val(data); console.log(data); } }); }; this.plain2html = function(plainText, id) { - this.set_busy(true, 'converting'); + var lock = this.set_busy(true, 'converting'); $(document.getElementById(id)).val('<pre>'+plainText+'</pre>'); - this.set_busy(false); + this.set_busy(false, null, lock); }; @@ -4946,7 +4978,11 @@ function rcube_webmail() // send request console.log('HTTP GET: ' + url); - $.get(url, { _unlock:(lock?1:0) }, function(data){ ref.http_response(data); }, 'json'); + $.ajax({ + type: 'GET', url: url, data: { _unlock:(lock?lock:0) }, dataType: 'json', + success: function(data){ ref.http_response(data); }, + error: function(o, status, err) { rcmail.http_error(o, status, err, lock); } + }); }; // send a http POST request to the server @@ -4964,10 +5000,10 @@ function rcube_webmail() if (postdata && typeof(postdata) == 'object') { postdata._remote = 1; - postdata._unlock = (lock ? 1 : 0); + postdata._unlock = (lock ? lock : 0); } else - postdata += (postdata ? '&' : '') + '_remote=1' + (lock ? '&_unlock=1' : ''); + postdata += (postdata ? '&' : '') + '_remote=1' + (lock ? '&_unlock='+lock : ''); // trigger plugin hook var result = this.triggerEvent('request'+action, postdata); @@ -4981,12 +5017,19 @@ function rcube_webmail() // send request console.log('HTTP POST: ' + url); - $.post(url, postdata, function(data){ ref.http_response(data); }, 'json'); + $.ajax({ + type: 'POST', url: url, data: postdata, dataType: 'json', + success: function(data){ ref.http_response(data); }, + error: function(o, status, err) { rcmail.http_error(o, status, err, lock); } + }); }; // handle HTTP response this.http_response = function(response) { + if (!response) + return; + if (response.unlock) this.set_busy(false); @@ -5081,16 +5124,19 @@ function rcube_webmail() break; } + if (response.unlock) + this.hide_message(response.unlock); + this.triggerEvent('responseafter', {response: response}); this.triggerEvent('responseafter'+response.action, {response: response}); }; // handle HTTP request errors - this.http_error = function(request, status, err) + this.http_error = function(request, status, err, lock) { var errmsg = request.statusText; - this.set_busy(false); + this.set_busy(false, null, lock); request.abort(); if (errmsg) @@ -5122,10 +5168,10 @@ function rcube_webmail() if (this.busy) return; - var addurl = '_t=' + (new Date().getTime()) + '&_mbox=' + urlencode(this.env.mailbox); + var lock, addurl = '_t=' + (new Date().getTime()) + '&_mbox=' + urlencode(this.env.mailbox); if (refresh) { - this.set_busy(true, 'checkingmail'); + lock = this.set_busy(true, 'checkingmail'); addurl += '&_refresh=1'; // reset check-recent interval this.start_keepalive(); @@ -5138,7 +5184,7 @@ function rcube_webmail() if (this.env.search_request) addurl += '&_search=' + this.env.search_request; - this.http_request('check-recent', addurl, true); + this.http_request('check-recent', addurl, lock); }; diff --git a/program/js/googiespell.js b/program/js/googiespell.js index aaea16c47..8892c63ea 100644 --- a/program/js/googiespell.js +++ b/program/js/googiespell.js @@ -977,13 +977,13 @@ this.removeIndicator = function(elm) { //$(this.indicator).remove(); // roundcube mod. if (window.rcmail) - rcmail.set_busy(false); + rcmail.set_busy(false, null, this.rc_msg_id); }; this.appendIndicator = function(elm) { // modified by roundcube if (window.rcmail) - rcmail.set_busy(true, 'checking'); + this.rc_msg_id = rcmail.set_busy(true, 'checking'); /* this.indicator = document.createElement('img'); $(this.indicator).attr('src', this.img_dir + 'indicator.gif') diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index da79c2f83..c8ceb8f80 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -24,7 +24,7 @@ $OUTPUT->reset(); $OUTPUT->framed = TRUE; -$savedraft = !empty($_POST['_draft']) ? TRUE : FALSE; +$savedraft = !empty($_POST['_draft']) ? true : false; /****** checks ********/ |