From 06c990ead24edee69f07912f8169a0422c411422 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 13 Feb 2012 03:39:39 -0500
Subject: [PATCH] - Added mailto: protocol handler registration link in User Preferences (#1486580)

---
 skins/default/common.css              |    3 +
 CHANGELOG                             |    1 
 skins/default/settings.css            |    5 --
 program/steps/settings/edit_prefs.inc |    9 +++-
 program/steps/settings/func.inc       |   13 ++++++
 program/localization/en_US/labels.inc |   20 +++++----
 program/js/app.js                     |   28 +++++++++++++
 7 files changed, 60 insertions(+), 19 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 328d8da..9ab55fe 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Added mailto: protocol handler registration link in User Preferences (#1486580)
 - Handle identity details box with an iframe (#1487020)
 - Fix issue where some text from original message was missing on reply (#1488340)
 - Fix parse errors in DDL files for MS SQL Server
diff --git a/program/js/app.js b/program/js/app.js
index 53a7462..208e9b4 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -4849,7 +4849,7 @@
 
     return true;
   };
-  
+
   this.update_identity_row = function(id, name, add)
   {
     var row, col, list = this.identity_list,
@@ -6316,6 +6316,32 @@
     }
   };
 
+  this.mailto_handler_uri = function()
+  {
+    return location.href.split('?')[0] + '?_task=mail&_action=compose&_to=%s';
+  };
+
+  this.register_protocol_handler = function(name)
+  {
+    try {
+      window.navigator.registerProtocolHandler('mailto', this.mailto_handler_uri(), name);
+    }
+    catch(e) {};
+  };
+
+  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; });
+  };
+
 }  // end object rcube_webmail
 
 
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index f42c1af..0622746 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -354,18 +354,18 @@
 $labels['done'] = 'Done';
 
 // settings
-$labels['settingsfor']  = 'Settings for';
+$labels['settingsfor'] = 'Settings for';
 $labels['about'] = 'About';
-$labels['preferences']  = 'Preferences';
-$labels['userpreferences']  = 'User preferences';
-$labels['editpreferences']  = 'Edit user preferences';
+$labels['preferences'] = 'Preferences';
+$labels['userpreferences'] = 'User preferences';
+$labels['editpreferences'] = 'Edit user preferences';
 
-$labels['identities']  = 'Identities';
-$labels['manageidentities']  = 'Manage identities for this account';
-$labels['newidentity']  = 'New identity';
+$labels['identities'] = 'Identities';
+$labels['manageidentities'] = 'Manage identities for this account';
+$labels['newidentity'] = 'New identity';
 
-$labels['newitem']  = 'New item';
-$labels['edititem']  = 'Edit item';
+$labels['newitem'] = 'New item';
+$labels['edititem'] = 'Edit item';
 
 $labels['preferhtml'] = 'Display HTML';
 $labels['defaultcharset'] = 'Default Character Set';
@@ -422,6 +422,7 @@
 $labels['displaynext'] = 'After message delete/move display the next message';
 $labels['defaultfont'] = 'Default font of HTML message';
 $labels['mainoptions'] = 'Main Options';
+$labels['browseroptions'] = 'Browser Options';
 $labels['section'] = 'Section';
 $labels['maintenance'] = 'Maintenance';
 $labels['newmessage'] = 'New Message';
@@ -451,6 +452,7 @@
 $labels['spellcheckignorenums'] = 'Ignore words with numbers';
 $labels['spellcheckignorecaps'] = 'Ignore words with all letters capitalized';
 $labels['addtodict'] = 'Add to dictionary';
+$labels['mailtoprotohandler'] = 'Register protocol handler for mailto: links';
 
 $labels['folder']  = 'Folder';
 $labels['folders']  = 'Folders';
diff --git a/program/steps/settings/edit_prefs.inc b/program/steps/settings/edit_prefs.inc
index 6e03b08..d0abb28 100644
--- a/program/steps/settings/edit_prefs.inc
+++ b/program/steps/settings/edit_prefs.inc
@@ -51,8 +51,13 @@
         if ($option['advanced'])
 	      $table->set_row_attribs('advanced');
 
-        $table->add('title', $option['title']);
-	    $table->add(null, $option['content']);
+        if (isset($option['title'])) {
+          $table->add('title', $option['title']);
+  	      $table->add(null, $option['content']);
+        }
+        else {
+          $table->add(array('colspan' => 2), $option['content']);
+        }
       }
 
       $out .= html::tag('fieldset', null, html::tag('legend', null, $block['name']) . $table->show($attrib));
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 35e015d..fc836ed 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -159,7 +159,8 @@
     case 'general':
 
     $blocks = array(
-      'main' => array('name' => Q(rcube_label('mainoptions'))),
+      'main'    => array('name' => Q(rcube_label('mainoptions'))),
+      'browser' => array('name' => Q(rcube_label('browseroptions'))),
     );
 
     // language selection
@@ -263,6 +264,16 @@
       }
     }
 
+    $product_name = $RCMAIL->config->get('product_name', 'Roundcube Webmail');
+    $RCMAIL->output->add_script(sprintf("%s.check_protocol_handler('%s', '#mailtoprotohandler');",
+      JS_OBJECT_NAME, JQ($product_name)), 'foot');
+
+    $blocks['browser']['options']['mailtoprotohandler'] = array(
+      'content' => html::a(array(
+        'href' => '#',
+        'id' => 'mailtoprotohandler'), Q(rcube_label('mailtoprotohandler'))),
+    );
+
     break;
 
     // Mailbox view (mail screen)
diff --git a/skins/default/common.css b/skins/default/common.css
index c509564..f1c66b9 100644
--- a/skins/default/common.css
+++ b/skins/default/common.css
@@ -759,7 +759,8 @@
   opacity: 0.8;
 }
 
-.disabled
+.disabled,
+a.disabled
 {
   color: #999;
 }
diff --git a/skins/default/settings.css b/skins/default/settings.css
index 963600a..7515866 100644
--- a/skins/default/settings.css
+++ b/skins/default/settings.css
@@ -87,11 +87,6 @@
   text-align: right;
 }
 
-input.disabled
-{
-  color: #999999;
-}
-
 #bottomboxes
 {
   position: absolute;

--
Gitblit v1.9.1