浏览代码

[search] Scroll to field

Enrico Berti 11 年之前
父节点
当前提交
84df243
共有 2 个文件被更改,包括 26 次插入4 次删除
  1. 18 4
      apps/search/src/search/templates/search.mako
  2. 8 0
      apps/search/static/css/search.css

+ 18 - 4
apps/search/src/search/templates/search.mako

@@ -436,10 +436,10 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
           <strong>${_('Field Name')}</strong>
         </div>
         <div class="fields-list" data-bind="foreach: $root.collection.template.filteredAttributeFields" style="max-height: 230px; overflow-y: auto; padding-left: 4px">
-          <label class="checkbox">
-            <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" />
-            <span data-bind="text: name"></span>
-          </label>
+          <div style="margin-bottom: 3px">
+            <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" style="margin: 0" />
+            <div class="field-selector" data-bind="text: name" style="display: inline-block; margin-left: 3px; min-height: 20px; line-height: 20px"></div>
+          </div>
         </div>
         <div data-bind="visible: $root.collection.template.filteredAttributeFields().length == 0" style="padding-left: 4px; padding-top: 5px; font-size: 40px; color: #CCC">
           <i class="fa fa-frown-o"></i>
@@ -1688,6 +1688,20 @@ $(document).ready(function () {
     $("#result-main").height($("#result-container").outerHeight() + 100);
   });
 
+$(document).on("click", ".field-selector", function () {
+    var _t = $("#result-container");
+    var _text = $.trim($(this).text());
+    var _col = _t.find("th").filter(function() {
+      return $.trim($(this).text()) == _text;
+    });
+    _t.find(".columnSelected").removeClass("columnSelected");
+    _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").addClass("columnSelected");
+    _t.parent().animate({
+      scrollLeft: _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").position().left + _t.parent().scrollLeft() - _t.parent().offset().left - 30
+    }, 300);
+  });
+
+
 </script>
 
 

+ 8 - 0
apps/search/static/css/search.css

@@ -548,3 +548,11 @@ body.modal-open {
 .clearable.onX {
   cursor: pointer !important;
 }
+
+.field-selector {
+  cursor: pointer;
+}
+
+.field-selector:hover {
+  background-color: #DDD;
+}