0013122: navigate anchors in mails via javascript
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 17 May 2017 13:07:09 +0000 (15:07 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 23 May 2017 13:18:46 +0000 (15:18 +0200)
TODO
* improve scrolling accuracy

https://forge.tine20.org/view.php?id=13122

Change-Id: Iaf87c316be868a34c5a4e52757a3624124800ad3
Reviewed-on: http://gerrit.tine20.com/customers/4688
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Felamimail/Controller/MessageTest.php
tine20/Felamimail/Controller/Message.php
tine20/Felamimail/HTMLPurifier/AttrTransform/AValidator.php
tine20/Felamimail/js/GridDetailsPanel.js

index fbefaf5..c1ebe83 100644 (file)
@@ -1669,22 +1669,8 @@ class Felamimail_Controller_MessageTest extends TestCase
         $cachedMessage = $this->messageTestHelper('invalid_html.eml');
         $message = $this->_controller->getCompleteMessage($cachedMessage);
         
-        $this->assertContains('hier seine Daten :)<br /><br /><span id="felamimail_inline_felamimail-body-signature">
+        $this->assertContains('hier seine Daten :)<br /><br /><span id="felamimail-body-signature">
         </span><pre><span style="font-family:tahoma;">John Smith
 Photographer', $message->body);
     }
-    
-    /**
-     * @see: 0010150: Jump Labels get converted
-     * 
-     * https://forge.tine20.org/mantisbt/view.php?id=10150
-     */
-    public function testHtmlJumpLabels()
-    {
-        $cachedMessage = $this->messageTestHelper('html_jump_labels.eml');
-        $message = $this->_controller->getCompleteMessage($cachedMessage);
-        $this->assertContains('<a href="#felamimail_inline_test" target="_blank">test</a>
-<p>Hello,</p>
-<p id="felamimail_inline_test">Text Content</p>', $message->body);
-    }
 }
index d908a64..3716e51 100644 (file)
@@ -721,8 +721,7 @@ class Felamimail_Controller_Message extends Tinebase_Controller_Record_Abstract
         
         // @see: http://htmlpurifier.org/live/configdoc/plain.html#Attr.EnableID
         $config->set('Attr.EnableID', TRUE);
-        $config->set('Attr.IDPrefix', 'felamimail_inline_');
-        
+
         // @see: http://htmlpurifier.org/live/configdoc/plain.html#HTML.TidyLevel
         $config->set('HTML.TidyLevel', 'heavy');
         
index e620071..07ef91b 100644 (file)
@@ -26,17 +26,7 @@ class Felamimail_HTMLPurifier_AttrTransform_AValidator extends HTMLPurifier_Attr
     public function transform($attr, $config, $context)
     {
         $attr['target'] = '_blank';
-        
-        if (isset($attr['href'])) {
-            $href = preg_replace('/^#([^\/.]+)$/', '#felamimail_inline_$1', $attr['href']);
-            
-            if ($attr['href'] != $href) {
-                $attr['target'] = '_self';
-            }
-            
-            $attr['href'] = $href;
-        }
-        
+
         return $attr;
     }
 }
index 4d54fc7..f5675ae 100644 (file)
@@ -374,7 +374,8 @@ Ext.ns('Tine.Felamimail');
             'span[class=tinebase-download-link]',
             'a[class=tinebase-email-link]',
             'span[class=tinebase-addtocontacts-link]',
-            'span[class=tinebase-showheaders-link]'
+            'span[class=tinebase-showheaders-link]',
+            'a[href^=#]'
         ];
         
         // find the correct target
@@ -491,6 +492,18 @@ Ext.ns('Tine.Felamimail');
                 target.innerHTML = html;
                 
                 break;
+            case 'a[href^=#]':
+                e.stopEvent();
+                var anchor = this.getEl().query('#' + target.href.replace(/.*#/, ''));
+                if (anchor.length) {
+                    var scrollEl = Ext.fly(anchor[0]).findParent('.x-panel-body');
+                    if (scrollEl) {
+                        var box = Ext.fly(anchor[0]).getBox();
+                        // TODO improve accuracy of scrolling
+                        scrollEl.scrollTop = box.y - 180;
+                    }
+                }
+                break;
         }
     }
 });