[Bps-public-commit] RT-Extension-PreviewInSearch branch, master, updated. 8214b5ffa7684323276277de19bb8dad0c3e9c19

Wallace Reis wreis at bestpractical.com
Thu Dec 4 13:10:38 EST 2014


The branch, master has been updated
       via  8214b5ffa7684323276277de19bb8dad0c3e9c19 (commit)
      from  c6f425cad64c62c9a5f5ff23233b049fb91646de (commit)

Summary of changes:
 .../Search/Results.html/AfterResults               | 63 ++++++++++++----------
 1 file changed, 36 insertions(+), 27 deletions(-)

- Log -----------------------------------------------------------------
commit 8214b5ffa7684323276277de19bb8dad0c3e9c19
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Thu Dec 4 16:09:23 2014 -0200

    SideBySidePreview - improve UX
    
    * reduce animate() transition to reduce the effect of scrolling;
    * load the first ticket in preview on page-load;

diff --git a/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults b/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults
index d2e558d..e19c266 100644
--- a/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults
+++ b/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults
@@ -33,39 +33,48 @@ tr.in-preview td { background: #ffb }
 </style>
 <div id="ticket-preview-container" ></div>
 <script type="text/javascript">
+var get_ticket_row = function (from) {
+    var row = jQuery(from).closest('tr');
+    var even_or_odd = row.hasClass('oddline')? 'evenline': 'oddline';
+    row = row.add(row.prevUntil('.'+even_or_odd, '[class*="line"]'))
+        .add(row.nextUntil('.'+even_or_odd, '[class*="line"]'));
+    return row;
+};
+var do_preview = function(row) {
+    var tid = row.find('> td a[href*="Display.html?id="]')
+        .first().attr('href').match(/Display\.html\?id=(\d+)/)[1];
+    var url = <% RT->Config->Get('WebPath') |n,j %> +'/Helpers/TicketPreview?id='+tid;
+    row.siblings('tr').removeClass('in-preview');
+    row.addClass('in-preview');
+    jQuery('#ticket-preview-container').text(<% loc('Loading...') |n,j %>).load( url );
+% if ( RT->Config->Get('SideBySidePreview') ) {
+    jQuery('table.collection-as-table').wrap( "<div class='collection-as-table-with-previewinsearch'></div>" );
+    jQuery('#ticket-preview-container').show();
+    jQuery('div.refresh').addClass('refresh-with-previewinsearch');
+    jQuery('div.collection-as-table-with-previewinsearch').animate({
+        scrollTop: '+='+(jQuery("tr.in-preview").offset().top-jQuery('div.collection-as-table-with-previewinsearch').offset().top)
+    }, 1);
+    jQuery('div.paging').addClass('paging-with-previewinsearch');
+% } else {
+    jQuery('html, body').animate({
+        scrollTop: '+='+(jQuery("#ticket-preview-container").offset().top-jQuery(window).scrollTop())
+    }, 1000);
+% }
+};
+
+% if ( RT->Config->Get('SideBySidePreview') ) {
+jQuery(document).ready(function() {
+    do_preview( get_ticket_row( jQuery('table.ticket-list tbody tr td').first() ) );
+});
+% }
+
 jQuery(function(){
-    var get_ticket_row = function (from) {
-        var row = jQuery(from).closest('tr');
-        var even_or_odd = row.hasClass('oddline')? 'evenline': 'oddline';
-        row = row.add(row.prevUntil('.'+even_or_odd, '[class*="line"]'))
-            .add(row.nextUntil('.'+even_or_odd, '[class*="line"]'));
-        return row;
-    };
     jQuery('table.ticket-list > tbody > tr > td').on('click', function (e) {
         if (e.target.tagName != 'TD')
             return;
 
         var row = get_ticket_row(e.target);
-        var tid = row.find('> td a[href*="Display.html?id="]')
-            .first().attr('href').match(/Display\.html\?id=(\d+)/)[1];
-        var url = <% RT->Config->Get('WebPath') |n,j %> +'/Helpers/TicketPreview?id='+tid;
-        row.siblings('tr').removeClass('in-preview');
-        row.addClass('in-preview');
-        jQuery('#ticket-preview-container').text(<% loc('Loading...') |n,j %>)
-            .load( url );
-% if ( RT->Config->Get('SideBySidePreview') ) {
-        jQuery('table.collection-as-table').wrap( "<div class='collection-as-table-with-previewinsearch'></div>" );
-        jQuery('#ticket-preview-container').show();
-        jQuery('div.refresh').addClass('refresh-with-previewinsearch');
-        jQuery('div.collection-as-table-with-previewinsearch').animate({
-            scrollTop: '+='+(jQuery("tr.in-preview").offset().top-jQuery('div.collection-as-table-with-previewinsearch').offset().top)
-        }, 1000);
-        jQuery('div.paging').addClass('paging-with-previewinsearch');
-% } else {
-        jQuery('html, body').animate({
-            scrollTop: '+='+(jQuery("#ticket-preview-container").offset().top-jQuery(window).scrollTop())
-        }, 1000);
-% }
+        do_preview(row);
     });
 });
 </script>

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list