summaryrefslogtreecommitdiff
path: root/program/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'program/js/app.js')
-rw-r--r--program/js/app.js122
1 files changed, 87 insertions, 35 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 1ef341415..7fb644145 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -564,7 +564,7 @@ function rcube_webmail()
// execute a specific command on the web client
this.command = function(command, props, obj, event)
{
- var ret, uid, cid, url, flag;
+ var ret, uid, cid, url, flag, aborted = false;
if (obj && obj.blur)
obj.blur();
@@ -650,11 +650,16 @@ function rcube_webmail()
var form = this.gui_objects.messageform,
win = this.open_window('');
- this.save_compose_form_local();
- $("input[name='_action']", form).val('compose');
- form.action = this.url('mail/compose', { _id: this.env.compose_id, _extwin: 1 });
- form.target = win.name;
- form.submit();
+ if (win) {
+ this.save_compose_form_local();
+ $("input[name='_action']", form).val('compose');
+ form.action = this.url('mail/compose', { _id: this.env.compose_id, _extwin: 1 });
+ form.target = win.name;
+ form.submit();
+ }
+ else {
+ // this.display_message(this.get_label('windowopenerror'), 'error');
+ }
}
else {
this.open_window(this.env.permaurl, true);
@@ -1049,7 +1054,10 @@ function rcube_webmail()
// Reset the auto-save timer
clearTimeout(this.save_timer);
- this.upload_file(props || this.gui_objects.uploadform, 'upload');
+ if (!this.upload_file(props || this.gui_objects.uploadform, 'upload')) {
+ alert(this.get_label('selectimportfile'));
+ aborted = true;
+ }
break;
case 'insert-sig':
@@ -1172,8 +1180,13 @@ function rcube_webmail()
case 'import-messages':
var form = props || this.gui_objects.importform;
- $('input[name="_unlock"]', form).val(this.set_busy(true, 'importwait'));
- this.upload_file(form, 'import');
+ var importlock = this.set_busy(true, 'importwait');
+ $('input[name="_unlock"]', form).val(importlock);
+ if (!this.upload_file(form, 'import')) {
+ this.set_busy(false, null, importlock);
+ alert(this.get_label('selectimportfile'));
+ aborted = true;
+ }
break;
case 'import':
@@ -1181,6 +1194,7 @@ function rcube_webmail()
var file = document.getElementById('rcmimportfile');
if (file && !file.value) {
alert(this.get_label('selectimportfile'));
+ aborted = true;
break;
}
this.gui_objects.importform.submit();
@@ -1232,9 +1246,9 @@ function rcube_webmail()
break;
}
- if (this.triggerEvent('after'+command, props) === false)
+ if (!aborted && this.triggerEvent('after'+command, props) === false)
ret = false;
- this.triggerEvent('actionafter', {props:props, action:command});
+ this.triggerEvent('actionafter', { props:props, action:command, aborted:aborted });
return ret === false ? false : obj ? false : true;
};
@@ -1888,11 +1902,11 @@ function rcube_webmail()
row.className = row_class;
// build subject link
- if (!bw.ie && cols.subject) {
+ if (cols.subject) {
var action = flags.mbox == this.env.drafts_mailbox ? 'compose' : 'show';
var uid_param = flags.mbox == this.env.drafts_mailbox ? '_draft_uid' : '_uid';
cols.subject = '<a href="./?_task=mail&_action='+action+'&_mbox='+urlencode(flags.mbox)+'&'+uid_param+'='+uid+'"'+
- ' onclick="return rcube_event.cancel(event)" onmouseover="rcube_webmail.long_subject_title(this,'+(message.depth+1)+')">'+cols.subject+'</a>';
+ ' onclick="return rcube_event.cancel(event)" onmouseover="rcube_webmail.long_subject_title(this,'+(message.depth+1)+')"><span>'+cols.subject+'</span></a>';
}
// add each submitted col
@@ -3094,7 +3108,12 @@ function rcube_webmail()
// close compose step in opener
if (opener_rc && opener_rc.env.action == 'compose') {
- setTimeout(function(){ opener.history.back(); }, 100);
+ setTimeout(function(){
+ if (opener.history.length > 1)
+ opener.history.back();
+ else
+ opener_rc.redirect(opener_rc.get_task_url('mail'));
+ }, 100);
this.env.opened_extwin = true;
}
@@ -3618,6 +3637,10 @@ function rcube_webmail()
this.env.draft_id = id;
$("input[name='_draft_saveid']").val(id);
+ // reset history of hidden iframe used for saving draft (#1489643)
+ if (window.frames['savetarget'] && window.frames['savetarget'].history) {
+ window.frames['savetarget'].history.back();
+ }
}
// always remove local copy upon saving as draft
@@ -3967,7 +3990,7 @@ function rcube_webmail()
if (numfiles) {
if (this.env.max_filesize && this.env.filesizeerror && size > this.env.max_filesize) {
this.display_message(this.env.filesizeerror, 'error');
- return;
+ return false;
}
var frame_name = this.async_upload_form(form, action || 'upload', function(e) {
@@ -4001,11 +4024,13 @@ function rcube_webmail()
if (this.env.upload_progress_time) {
this.upload_progress_start('upload', ts);
}
+
+ // set reference to the form object
+ this.gui_objects.attachmentform = form;
+ return true;
}
- // set reference to the form object
- this.gui_objects.attachmentform = form;
- return true;
+ return false;
};
// add file name to attachment list
@@ -4047,8 +4072,10 @@ function rcube_webmail()
this.remove_from_attachment_list = function(name)
{
- delete this.env.attachments[name];
- $('#'+name).remove();
+ if (this.env.attachments) {
+ delete this.env.attachments[name];
+ $('#'+name).remove();
+ }
};
this.remove_attachment = function(name)
@@ -4296,11 +4323,15 @@ function rcube_webmail()
this.ksearch_destroy();
// insert all members of a group
- if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].id) {
+ if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].type == 'group') {
insert += this.env.contacts[id].name + this.env.recipients_delimiter;
this.group2expand[this.env.contacts[id].id] = $.extend({ input: this.ksearch_input }, this.env.contacts[id]);
this.http_request('mail/group-expand', {_source: this.env.contacts[id].source, _gid: this.env.contacts[id].id}, false);
}
+ else if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].name) {
+ insert = this.env.contacts[id].name + this.env.recipients_delimiter;
+ trigger = true;
+ }
else if (typeof this.env.contacts[id] === 'string') {
insert = this.env.contacts[id] + this.env.recipients_delimiter;
trigger = true;
@@ -4314,7 +4345,7 @@ function rcube_webmail()
this.ksearch_input.setSelectionRange(cpos, cpos);
if (trigger) {
- this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert });
+ this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert, data:this.env.contacts[id] });
this.compose_type_activity++;
}
};
@@ -4409,7 +4440,7 @@ function rcube_webmail()
return;
// display search results
- var i, len, ul, li, text, init,
+ var i, len, ul, li, text, type, init,
value = this.ksearch_value,
data = this.ksearch_data,
maxlen = this.env.autocomplete_max ? this.env.autocomplete_max : 15;
@@ -4443,11 +4474,13 @@ function rcube_webmail()
if (results && (len = results.length)) {
for (i=0; i < len && maxlen > 0; i++) {
text = typeof results[i] === 'object' ? results[i].name : results[i];
+ type = typeof results[i] === 'object' ? results[i].type : '';
li = document.createElement('LI');
li.innerHTML = text.replace(new RegExp('('+RegExp.escape(value)+')', 'ig'), '##$1%%').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/##([^%]+)%%/g, '<b>$1</b>');
li.onmouseover = function(){ ref.ksearch_select(this); };
li.onmouseup = function(){ ref.ksearch_click(this) };
li._rcm_id = this.env.contacts.length + i;
+ if (type) li.className = type;
ul.appendChild(li);
maxlen -= 1;
}
@@ -6099,7 +6132,10 @@ function rcube_webmail()
// disable/enable input buttons
if (button.type == 'input') {
button.status = state;
- obj.disabled = !state;
+ obj.disabled = state == 'pas';
+ }
+ else if (button.type == 'uibutton') {
+ $(obj).button('option', 'disabled', state == 'pas');
}
}
};
@@ -6670,8 +6706,9 @@ function rcube_webmail()
this.element_position = function(element, obj)
{
var obj = $(obj), win = $(window),
- width = obj.width(),
- height = obj.height(),
+ width = obj.outerWidth(),
+ height = obj.outerHeight(),
+ menu_pos = obj.data('menu-pos'),
win_height = win.height(),
elem_height = $(element).height(),
elem_width = $(element).width(),
@@ -6679,6 +6716,13 @@ function rcube_webmail()
top = pos.top,
left = pos.left + width;
+ if (menu_pos == 'bottom') {
+ top += height;
+ left -= width;
+ }
+ else
+ left -= 5;
+
if (top + elem_height > win_height) {
top -= elem_height - height;
if (top < 0)
@@ -7472,20 +7516,28 @@ function rcube_webmail()
try {
window.navigator.registerProtocolHandler('mailto', this.mailto_handler_uri(), name);
}
- catch(e) {};
+ catch(e) {
+ this.display_message(String(e), 'error');
+ };
};
this.check_protocol_handler = function(name, elem)
{
var nav = window.navigator;
- if (!nav
- || (typeof nav.registerProtocolHandler != 'function')
- || ((typeof nav.isProtocolHandlerRegistered == 'function')
- && nav.isProtocolHandlerRegistered('mailto', this.mailto_handler_uri()) == 'registered')
- )
- $(elem).addClass('disabled');
- else
- $(elem).click(function() { rcmail.register_protocol_handler(name); return false; });
+ if (!nav || (typeof nav.registerProtocolHandler != 'function')) {
+ $(elem).addClass('disabled').click(function(){ return false; });
+ }
+ else {
+ var status = null;
+ if (typeof nav.isProtocolHandlerRegistered == 'function') {
+ status = nav.isProtocolHandlerRegistered('mailto', this.mailto_handler_uri());
+ if (status)
+ $(elem).parent().find('.mailtoprotohandler-status').html(status);
+ }
+ else {
+ $(elem).click(function() { rcmail.register_protocol_handler(name); return false; });
+ }
+ }
};
// Checks browser capabilities eg. PDF support, TIF support