Aleksander Machniak
2016-05-09 5b3a86da57a47a723f89d8dd64ce484002b8e4bb
skins/larry/ui.js
@@ -1,5 +1,3 @@
// @license http://creativecommons.org/publicdomain/zero/1.0/legalcode CC0
/**
 * Roundcube functions for default skin interface
 *
@@ -9,6 +7,8 @@
 * License. It is allowed to copy, distribute, transmit and to adapt the work
 * by keeping credits to the original autors in the README file.
 * See http://creativecommons.org/licenses/by-sa/3.0/ for details.
 *
 * @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
 */
function rcube_mail_ui()
@@ -136,6 +136,7 @@
      rcmail.addEventListener('menu-open', menu_toggle)
        .addEventListener('menu-close', menu_toggle)
        .addEventListener('menu-save', save_listoptions)
        .addEventListener('enable-command', enable_command)
        .addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list', true) })
        .addEventListener('responseaftersearch', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list', true) });
@@ -146,15 +147,20 @@
      }
      if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') {
        rcmail.addEventListener('enable-command', enable_command)
          .addEventListener('aftershow-headers', function() { layout_messageview(); })
        rcmail.addEventListener('aftershow-headers', function() { layout_messageview(); })
          .addEventListener('afterhide-headers', function() { layout_messageview(); });
        $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(); return false });
        $('#previewheaderstoggle').click(function(e) {
            toggle_preview_headers();
            if (this.blur && !rcube_event.is_keyboard(e))
                this.blur();
            return false;
        });
        // add menu link for each attachment
        $('#attachment-list > li').each(function() {
          $(this).append($('<a class="drop" tabindex="0" aria-haspopup="true">Show options</a>')
              .bind('click keypress', function(e) {
              .on('click keypress', function(e) {
                  if (e.type != 'keypress' || rcube_event.get_keycode(e) == 13) {
                      attachmentmenu(this, e);
                      return false;
@@ -166,14 +172,22 @@
        if (get_pref('previewheaders') == '1') {
          toggle_preview_headers();
        }
        if (rcmail.env.action == 'show') {
            $('#messagecontent').focus()
        }
      }
      else if (rcmail.env.action == 'compose') {
        rcmail.addEventListener('aftersend-attachment', show_uploadform)
          .addEventListener('add-recipient', function(p){ show_header_row(p.field, true); })
          .addEventListener('aftertoggle-editor', function(e){
          .addEventListener('aftertoggle-editor', function(e) {
            window.setTimeout(function(){ layout_composeview() }, 200);
            if (e && e.mode)
              $("select[name='editorSelector']").val(e.mode);
          })
          .addEventListener('compose-encrypted', function(e) {
            $("select[name='editorSelector']").prop('disabled', e.active);
            $('a.button.attach, a.button.responses')[(e.active?'addClass':'removeClass')]('disabled');
            $('#responseslist a.insertresponse')[(e.active?'removeClass':'addClass')]('active');
          });
        // Show input elements with non-empty value
@@ -222,12 +236,13 @@
        $('#mailthreadmode').addClass(rcmail.env.threading ? 'selected' : '').click(function(e) { switch_view_mode('thread'); return false; });
        mailviewsplit = new rcube_splitter({ id:'mailviewsplitter', p1:'#mailview-top', p2:'#mailview-bottom',
          orientation:'h', relative:true, start:310, min:150, size:12, offset:4 });
          orientation:'h', relative:true, start:276, min:150, size:12, offset:4 });
        if (previewframe)
          mailviewsplit.init();
        rcmail.init_pagejumper('#pagejumper');
        rcmail.addEventListener('setquota', update_quota)
          .addEventListener('enable-command', enable_command)
          .addEventListener('afterimport-messages', show_uploadform);
      }
      else if (rcmail.env.action == 'get') {
@@ -272,26 +287,31 @@
          orientation:'v', relative:true, start:266, min:180, size:12 }).init();
      }
      else if (rcmail.env.action == 'edit-prefs') {
        $('<a href="#toggle"></a>')
        var legend = $('#preferences-details fieldset.advanced legend'),
          toggle = $('<a href="#toggle"></a>')
            .text(env.toggleoptions)
            .attr('title', env.toggleoptions)
            .addClass('advanced-toggle')
            .appendTo('#preferences-details fieldset.advanced legend');
            .addClass('advanced-toggle');
          $('#preferences-details fieldset.advanced legend').click(function(e){
            var collapsed = $(this).hasClass('collapsed'),
              toggle = $('.advanced-toggle', this).html(collapsed ? '&#9650;' : '&#9660;');
            $(this)
              .toggleClass('collapsed')
              .closest('fieldset').children('.propform').toggle()
          }).addClass('collapsed')
        legend.click(function(e) {
          toggle.html($(this).hasClass('collapsed') ? '&#9650;' : '&#9660;');
          $(this).toggleClass('collapsed')
            .closest('fieldset').children('.propform').toggle()
        }).append(toggle).addClass('collapsed')
        // this magically fixes incorrect position of toggle link created above in Firefox 3.6
        if (bw.mz)
          legend.parents('form').css('display', 'inline');
      }
    }
    /***  addressbook task  ***/
    else if (rcmail.env.task == 'addressbook') {
      rcmail.addEventListener('afterupload-photo', show_uploadform)
        .addEventListener('beforepushgroup', push_contactgroup)
        .addEventListener('beforepopgroup', pop_contactgroup);
        .addEventListener('beforepopgroup', pop_contactgroup)
        .addEventListener('menu-open', menu_toggle)
        .addEventListener('menu-close', menu_toggle);
      if (rcmail.env.action == '') {
        new rcube_splitter({ id:'addressviewsplitterd', p1:'#addressview-left', p2:'#addressview-right',
@@ -411,6 +431,7 @@
      if (me.message_timer) {
        window.clearTimeout(me.message_timer);
      }
      if (!me.messagedialog) {
        me.messagedialog = $('<div>').addClass('popupdialog').hide();
      }
@@ -421,7 +442,7 @@
          me.messagedialog.is(':visible') && me.messagedialog.dialog('destroy').hide();
        };
      if (me.messagedialog.is(':visible'))
      if (me.messagedialog.is(':visible') && me.messagedialog.text() != msg)
        msg = me.messagedialog.html() + '<p>' + p.message + '</p>';
      me.messagedialog.html(msg)
@@ -456,6 +477,14 @@
    if (!$('#attachment-list li').length) {
      $('div.rightcol').hide().attr('aria-hidden', 'true');
      $('div.leftcol').css('margin-right', '0');
    }
    var mvlpe = $('#messagebody.mailvelope, #messagebody > .mailvelope');
    if (mvlpe.length) {
      var h = $('#messagecontent').length ?
        $('#messagecontent').height() - 16 :
        $(window).height() - mvlpe.offset().top - 10;
      mvlpe.height(h);
    }
  }
@@ -523,6 +552,7 @@
      y -= step;
    element.css('background-position', '0 -' + y + 'px');
    element.attr('class', 'countdisplay p' + (Math.round(p.percent / 10) * 10));
    if (p.table) {
      if (!menu.length)
@@ -576,6 +606,10 @@
        $('a.button.replyall').attr('title', label);
      else
        $('a.button.reply-all').text(label).attr('title', label);
    }
    else if (p.command == 'compose-encrypted') {
      // show the toolbar button for Mailvelope
      $('a.button.encrypt').show();
    }
  }
@@ -794,11 +828,11 @@
  {
    var id = elem.parentNode.id.replace(/^attach/, '');
    $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) {
    $('#attachmenuopen').off('click').attr('onclick', '').click(function(e) {
      return rcmail.command('open-attachment', id, this);
    });
    $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() {
    $('#attachmenudownload').off('click').attr('onclick', '').click(function() {
      rcmail.command('download-attachment', id, this);
    });
@@ -819,7 +853,7 @@
        li = $('<li role="menuitem">');
        link = $('<a href="#'+k+'" tabindex="0"></a>').text(rcmail.env.spell_langs[k])
          .addClass('active').data('lang', k)
          .bind('click keypress', function(e) {
          .on('click keypress', function(e) {
              if (e.type != 'keypress' || rcube_event.get_keycode(e) == 13) {
                  rcmail.spellcheck_lang_set($(this).data('lang'));
                  rcmail.hide_menu('spellmenu', e);
@@ -1004,6 +1038,10 @@
      return;
    }
    // do nothing if mailvelope editor is active
    if (rcmail.mailvelope_editor)
      return;
    // add icons to clone file input field
    if (rcmail.env.action == 'compose' && !$dialog.data('extended')) {
      $('<a>')
@@ -1138,14 +1176,11 @@
   */
  function show_about(elem)
  {
    var frame = $('<iframe>').attr('id', 'aboutframe')
      .attr('src', rcmail.url('settings/about'))
      .attr('frameborder', '0')
      .appendTo(document.body);
    var frame = $('<iframe>').attr({id: 'aboutframe', src: rcmail.url('settings/about'), frameborder: '0'});
      h = Math.floor($(window).height() * 0.75),
      buttons = {},
      supportln = $('#supportlink');
    var h = Math.floor($(window).height() * 0.75);
    var buttons = {};
    var supportln = $('#supportlink');
    if (supportln.length && (env.supporturl = supportln.attr('href')))
      buttons[supportln.html()] = function(e){ env.supporturl.indexOf('mailto:') < 0 ? window.open(env.supporturl) : location.href = env.supporturl };
@@ -1246,7 +1281,7 @@
      .attr('role', 'presentation')
      .addClass('splitter ' + (this.horizontal ? 'splitter-h' : 'splitter-v'))
      .appendTo(this.parent)
      .bind('mousedown', onDragStart);
      .mousedown(onDragStart);
    if (this.horizontal) {
      var top = this.p1pos.top + this.p1.outerHeight();
@@ -1327,7 +1362,7 @@
    me.drag_active = true;
    // start listening to mousemove events
    $(document).bind('mousemove.'+this.id, onDrag).bind('mouseup.'+this.id, onDragStop);
    $(document).on('mousemove.' + this.id, onDrag).on('mouseup.' + this.id, onDragStop);
    // enable dragging above iframes
    $('iframe').each(function(i, elem) {
@@ -1404,7 +1439,7 @@
      document.body.style.webkitUserSelect = 'auto';
    // cancel the listening for drag events
    $(document).unbind('.'+me.id);
    $(document).off('.' + me.id);
    me.drag_active = false;
    // remove temp divs