Aleksander Machniak
2015-01-22 5d42a9353b3df5e08b7dfc2ac6a92978a89cceca
program/js/app.js
@@ -1055,12 +1055,9 @@
        url = {};
        if (this.task == 'mail') {
          url._mbox = this.env.mailbox;
          url = {_mbox: this.env.mailbox, _search: this.env.search_request};
          if (props)
            url._to = props;
          // also send search request so we can go back to search result after message is sent
          if (this.env.search_request)
            url._search = this.env.search_request;
        }
        // modify url if we're in addressbook
        else if (this.task == 'addressbook') {
@@ -1155,7 +1152,7 @@
      case 'reply-list':
      case 'reply':
        if (uid = this.get_single_uid()) {
          url = {_reply_uid: uid, _mbox: this.get_message_mailbox(uid)};
          url = {_reply_uid: uid, _mbox: this.get_message_mailbox(uid), _search: this.env.search_request};
          if (command == 'reply-all')
            // do reply-list, when list is detected and popup menu wasn't used
            url._all = (!props && this.env.reply_all_mode == 1 && this.commands['reply-list'] ? 'list' : 'all');
@@ -1957,7 +1954,7 @@
    // attach events
    $.each(fn, function(i, f) {
      row[i].onclick = function(e) { f(e); return rcube_event.cancel(e); };
      if (bw.touch) {
      if (bw.touch && row[i].addEventListener) {
        row[i].addEventListener('touchend', function(e) {
          if (e.changedTouches.length == 1) {
            f(e);
@@ -2487,6 +2484,16 @@
        selection.push(selected[i]);
    this.message_list.selection = selection;
    // reset preview frame, if currently previewed message is not selected (has been removed)
    try {
      var win = this.get_frame_window(this.env.contentframe),
        id = win.rcmail.env.uid;
      if (id && $.inArray(id, selection) < 0)
        this.show_contentframe(false);
    }
    catch (e) {};
  };
  // expand all threads with unread children
@@ -3781,14 +3788,13 @@
  this.set_draft_id = function(id)
  {
    var rc;
    if (id && id != this.env.draft_id) {
      if (rc = this.opener()) {
        // refresh the drafts folder in opener window
        if (rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == this.env.drafts_mailbox)
          rc.command('checkmail');
      }
      var filter = {task: 'mail', action: ''},
        rc = this.opener(false, filter) || this.opener(true, filter);
      // refresh the drafts folder in the opener window
      if (rc && rc.env.mailbox == this.env.drafts_mailbox)
        rc.command('checkmail');
      this.env.draft_id = id;
      $("input[name='_draft_saveid']").val(id);
@@ -3974,7 +3980,6 @@
    this.local_storage_remove_item('compose.index');
  };
  this.change_identity = function(obj, show_sig)
  {
@@ -4344,6 +4349,7 @@
      (this.env.search_request && (this.env.search_scope || 'base') != 'base');
  };
  // action executed after mail is sent
  this.sent_successfully = function(type, msg, folders)
  {
    this.display_message(msg, type);
@@ -4352,11 +4358,13 @@
    if (this.env.extwin) {
      this.lock_form(this.gui_objects.messageform);
      var rc = this.opener();
      var filter = {task: 'mail', action: ''},
        rc = this.opener(false, filter) || this.opener(true, filter);
      if (rc) {
        rc.display_message(msg, type);
        // refresh the folder where sent message was saved or replied message comes from
        if (folders && rc.env.task == 'mail' && rc.env.action == '' && $.inArray(rc.env.mailbox, folders) >= 0) {
        if (folders && $.inArray(rc.env.mailbox, folders) >= 0) {
          rc.command('checkmail');
        }
      }
@@ -5799,6 +5807,9 @@
        // on the list when dragging starts (and stops), this is slow, but
        // I didn't find a method to check droptarget on over event
        accept: function(node) {
          if (!$(node).is('.mailbox'))
            return false;
          var source_folder = ref.folder_id2name($(node).attr('id')),
            dest_folder = ref.folder_id2name(this.id),
            source = ref.env.subscriptionrows[source_folder],
@@ -5819,7 +5830,7 @@
  this.folder_id2name = function(id)
  {
    return ref.html_identifier_decode(id.replace(/^rcmli/, ''));
    return id ? ref.html_identifier_decode(id.replace(/^rcmli/, '')) : null;
  };
  this.subscription_select = function(id)
@@ -7894,12 +7905,24 @@
  };
  // get window.opener.rcmail if available
  this.opener = function()
  this.opener = function(deep, filter)
  {
    var i, win = window.opener;
    // catch Error: Permission denied to access property rcmail
    try {
      if (window.opener && !opener.closed && opener.rcmail)
        return opener.rcmail;
      if (win && !win.closed) {
        // try parent of the opener window, e.g. preview frame
        if (deep && (!win.rcmail || win.rcmail.env.framed) && win.parent && win.parent.rcmail)
          win = win.parent;
        if (win.rcmail && filter)
          for (i in filter)
            if (win.rcmail.env[i] != filter[i])
              return;
        return win.rcmail;
      }
    }
    catch (e) {}
  };