Make up and down scrolling better in suggest.js, a=chris

Chris Pollett [2012-06-20 07:Jun:th]
Make up and down scrolling better in suggest.js, a=chris
Filename
scripts/suggest.js
views/search_view.php
diff --git a/scripts/suggest.js b/scripts/suggest.js
index 0337e29c1..5033b5370 100644
--- a/scripts/suggest.js
+++ b/scripts/suggest.js
@@ -123,6 +123,7 @@ function onTypeTerm(event, text_field)
                 }
                 setSelectedTerm(cursor_pos, "selected");
             }
+            scroll_count = 1;
             scroll_pos = (cursor_pos - MAX_DISPLAY > 0) ?
                 (cursor_pos - MAX_DISPLAY + 1) : 1;
             suggest_dropdown.scrollTop = scroll_pos * FONT_HEIGHT;
@@ -137,8 +138,10 @@ function onTypeTerm(event, text_field)
                 }
                 setSelectedTerm(cursor_pos, "selected");
             }
-            scroll_pos = (cursor_pos - MAX_DISPLAY > 0) ?
-                (cursor_pos - MAX_DISPLAY + 1) : 1;
+            scroll_pos = (cursor_pos - MAX_DISPLAY + scroll_count > 0) ?
+                (cursor_pos - MAX_DISPLAY + scroll_count) : 1;
+            scroll_count = (MAX_DISPLAY > scroll_count) ? scroll_count + 1 :
+                MAX_DISPLAY;
             suggest_dropdown.scrollTop = scroll_pos * FONT_HEIGHT;
         }
     }
diff --git a/views/search_view.php b/views/search_view.php
index 1d3af0bd8..ce4886c63 100755
--- a/views/search_view.php
+++ b/views/search_view.php
@@ -118,7 +118,8 @@ class SearchView extends View implements CrawlConstants
                 e($data['YIOOP_TOKEN']); ?>" />
             <input type="hidden" name="its" value="<?php e($data['its']); ?>" />
             <input type="text" <?php if(WORD_SUGGEST) { ?>
-                autocomplete="off"  onkeyup="onTypeTerm(event, this)"
+                autocomplete="off"  onkeyup="onTypeTerm(event, this)"
+                onpaste="onTypeTerm(event, this)"
                 <?php } ?>
                 title="<?php e(tl('search_view_input_label')); ?>"
                 id="query-field" name="q" value="<?php
@@ -273,7 +274,7 @@ class SearchView extends View implements CrawlConstants
             <?php
             } //end foreach
             $this->paginationHelper->render(
-                $data['PAGING_QUERY']."&amp;YIOOP_TOKEN=".$data['YIOOP_TOKEN'],
+                $data['PAGING_QUERY']."&amp;YIOOP_TOKEN=".$data['YIOOP_TOKEN'],
                 $data['LIMIT'], $data['RESULTS_PER_PAGE'], $data['TOTAL_ROWS']);
             ?>
ViewGit