Thomas Bruederli
2014-03-21 5934e238242cb0d96e128bfad3905809b5aeb093
Disable link registering mailto: protocol handler if not supported by the browser (#1489569)
5 files modified
53 ■■■■ changed files
program/js/app.js 26 ●●●●● patch | view | raw | blame | history
program/steps/settings/func.inc 9 ●●●●● patch | view | raw | blame | history
skins/classic/common.css 7 ●●●●● patch | view | raw | blame | history
skins/larry/settings.css 5 ●●●●● patch | view | raw | blame | history
skins/larry/styles.css 6 ●●●●● patch | view | raw | blame | history
program/js/app.js
@@ -7510,20 +7510,28 @@
    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
program/steps/settings/func.inc
@@ -376,13 +376,16 @@
            if ($current) {
                $product_name = $RCMAIL->config->get('product_name', 'Roundcube Webmail');
                $RCMAIL->output->add_script(sprintf("%s.check_protocol_handler('%s', '#mailtoprotohandler');",
                    rcmail_output::JS_OBJECT_NAME, rcube::JQ($product_name)), 'foot');
                    rcmail_output::JS_OBJECT_NAME, rcube::JQ($product_name)), 'docready');
            }
            $blocks['browser']['options']['mailtoprotohandler'] = array(
                'content' => html::a(array(
                'href'    => '#',
                'id'      => 'mailtoprotohandler'), rcube::Q($RCMAIL->gettext('mailtoprotohandler'))),
                    'href'    => '#',
                    'id'      => 'mailtoprotohandler'
                ),
                rcube::Q($RCMAIL->gettext('mailtoprotohandler'))) .
                html::span('mailtoprotohandler-status', ''),
            );
        break;
skins/classic/common.css
@@ -55,6 +55,13 @@
  text-align: center;
}
a.disabled
{
  color: #999;
  text-decoration: none;
  cursor: default;
}
hr
{
  height: 1px;
skins/larry/settings.css
@@ -319,3 +319,8 @@
#rcmfd_signature_toolbar2 td {
    width: auto;
}
.mailtoprotohandler-status {
    padding-left: 1em;
    font-style: italic;
}
skins/larry/styles.css
@@ -1564,6 +1564,12 @@
    width: 95%;
}
.propform a.disabled {
    color: #999;
    text-decoration: none;
    cursor: default;
}
fieldset.floating {
    float: left;
    margin-right: 10px;