Highlight referencing fields on hovering FK values when browsing table data
authorLeonardo Sápiras <l.sapiras@gmail.com>
Fri, 7 Jan 2011 14:37:39 +0000 (15:37 +0100)
committerGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Fri, 7 Jan 2011 14:37:39 +0000 (15:37 +0100)
js/display.js
themes/global.css

index f9180c67a6333b939760d4b8ba5cf40c1eae52e5..bac28ecb8be2c1f640cab3e4bc86f3f00c6c21eb 100644 (file)
@@ -6,7 +6,7 @@ $(document).ready(function() {
        $('#fkcontainer').append('<div id="root" />');
        
        jQuery.ppa = { 
-               root: $('#root'),
+               root: $('#root')
        };
        
        $("a.fk").live('click', function (event) {
@@ -55,6 +55,15 @@ $(document).ready(function() {
                                /* creating the data div */
                                newdiv = $('<div class="fk '+divclass+'">').html(answer);
                                
+                               /* highlight referencing fields */
+                               newdiv.data('ref', this).data('refclass', $(this).attr('class').split(' ')[1])
+                                       .mouseenter(function (event) {
+                                               $(this).data('ref').closest('tr').find('a.'+$(this).data('refclass')).closest('div').addClass('highlight');
+                                       })
+                                       .mouseleave(function (event) {
+                                               $(this).data('ref').closest('tr').find('a.'+$(this).data('refclass')).closest('div').removeClass('highlight');
+                                       });
+
                                /* appending it to the level-1 div */
                                pdiv.append(newdiv);
                        },
@@ -72,7 +81,10 @@ $(document).ready(function() {
        });
 
        $(".fk_delete").live('click', function (event) {
-               $(this).closest('div').remove();
+               with($(this).closest('div')) {
+                       data('ref').closest('tr').find('a.'+data('refclass')).closest('div').removeClass('highlight');
+                       remove();
+               }
                return false; // do not refresh the page
        });
 });
index 106e208b2462c4d28a90973b521aa88c2ee411ee..6e62f0f5fda34221217f961026c4324e055ceacf 100644 (file)
@@ -102,6 +102,9 @@ div#fkcontainer {
 div.fk_value {
        display:inline-block;
 }
+.highlight {
+       background-color: #FFFF00;
+}
 /** Syntax highlighting **/
 .comment {color: #008080}
 .keyword {color: #FF8000}