selectivity-rails 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58e09b754ba44eb93296962ee65fbe033c0bff39
4
- data.tar.gz: 376445a768766dab8cd7114df1c4835f60e7f18a
3
+ metadata.gz: 7cd41b43f08c37783717975b788ce16e47394e1f
4
+ data.tar.gz: 882fd6a6887214fff3d6890286d06dd4fc7e74b9
5
5
  SHA512:
6
- metadata.gz: 2456e51fa9d51d274baf7d0c27fd5edcf0039372a8c84c7ec79361f52345a5f318d50e4c0e25b1ec0444e27fcdfb7cb816ff046b23d0445902d3aab8e7dbef64
7
- data.tar.gz: ca842a32f3e8cf0f77be4e2ad5c41564aa346e4db102a80a6aba660feef0d2c31e835e45154d78b1d6f85a07644cf574d0bb65fff68201a991e35e809c58ba5d
6
+ metadata.gz: f04f3950356f55d3ef7fc2bf678fb137240c45d8bd29480ed716fe8da8f3f85e215f73f77cf0c2c51ec37d5425c105b37fd2a625b7434a9417d7debe8103cbeb
7
+ data.tar.gz: e88316785228fac112e55256cbe16a291fea233d293a727f9d544840c9942aaf9a812ce8cc3698c288f33476b9b5e4a7e73fe47a3956163a07183c8d276d1012
@@ -31,5 +31,14 @@ $input-border: #ccc !default
31
31
  top: 0.5em
32
32
 
33
33
 
34
+ .form-horizontal
35
+ .form-control.selectivity-input
36
+ padding-left: 0
37
+ padding-right: 0
38
+
39
+ .selectivity-single-result-container
40
+ padding-left: 6px
41
+
42
+
34
43
  .selectivity-dropdown
35
44
  margin-top: 2px
@@ -1,5 +1,5 @@
1
1
  module Selectivity
2
2
  module Rails
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -52,7 +52,8 @@ module Selectivity
52
52
  input.click
53
53
 
54
54
  within 'div.selectivity-dropdown' do
55
- if find('div.selectivity-result-item', text: item).visible?
55
+ # if find('div.selectivity-result-item', text: item).visible?
56
+ if find(:xpath, "//div[@class='selectivity-result-item'][contains(text(), '#{item}')]").visible?
56
57
  page.evaluate_script("$('div.selectivity-result-item:contains(#{item})').trigger('click')")
57
58
  end
58
59
  end
@@ -2353,8 +2353,6 @@ function SelectivityDropdown(options) {
2353
2353
  this.position();
2354
2354
  this.setupCloseHandler();
2355
2355
 
2356
- this._scrolledProxy = debounce(this._scrolled.bind(this), 50);
2357
-
2358
2356
  this._suppressMouseWheel();
2359
2357
 
2360
2358
  if (options.showSearchInput) {
@@ -2364,6 +2362,8 @@ function SelectivityDropdown(options) {
2364
2362
 
2365
2363
  EventDelegator.call(this);
2366
2364
 
2365
+ this.$results.on('scroll touchmove touchend', debounce(this._scrolled.bind(this), 50));
2366
+
2367
2367
  this.showLoading();
2368
2368
 
2369
2369
  setTimeout(this.triggerOpen.bind(this), 1);
@@ -2744,29 +2744,6 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
2744
2744
  }
2745
2745
  },
2746
2746
 
2747
- /**
2748
- * @private
2749
- */
2750
- _scrollToHighlight: function(options) {
2751
-
2752
- var el;
2753
- if (this.highlightedResult) {
2754
- var quotedId = Selectivity.quoteCssAttr(this.highlightedResult.id);
2755
- el = this.$('.selectivity-result-item[data-item-id=' + quotedId + ']')[0];
2756
- } else if (this.loadMoreHighlighted) {
2757
- el = this.$('.selectivity-load-more')[0];
2758
- } else {
2759
- return; // no highlight to scroll to
2760
- }
2761
-
2762
- var rect = el.getBoundingClientRect(),
2763
- containerRect = this.$results[0].getBoundingClientRect();
2764
-
2765
- if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
2766
- el.scrollIntoView(options.alignToTop);
2767
- }
2768
- },
2769
-
2770
2747
  /**
2771
2748
  * @private
2772
2749
  */
@@ -3019,21 +2996,27 @@ function listener(selectivity, $input) {
3019
2996
  }
3020
2997
 
3021
2998
  function scrollToHighlight() {
3022
- var el;
2999
+ var $el;
3023
3000
  if (dropdown.highlightedResult) {
3024
3001
  var quotedId = Selectivity.quoteCssAttr(dropdown.highlightedResult.id);
3025
- el = dropdown.$('.selectivity-result-item[data-item-id=' + quotedId + ']')[0];
3002
+ $el = dropdown.$('.selectivity-result-item[data-item-id=' + quotedId + ']');
3026
3003
  } else if (dropdown.loadMoreHighlighted) {
3027
- el = dropdown.$('.selectivity-load-more')[0];
3004
+ $el = dropdown.$('.selectivity-load-more');
3028
3005
  } else {
3029
3006
  return; // no highlight to scroll to
3030
3007
  }
3031
3008
 
3032
- var rect = el.getBoundingClientRect(),
3033
- containerRect = dropdown.$results[0].getBoundingClientRect();
3009
+ var position = $el.position();
3010
+ if (!position) {
3011
+ return;
3012
+ }
3034
3013
 
3035
- if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
3036
- el.scrollIntoView(delta < 0);
3014
+ var top = position.top;
3015
+ var elHeight = $el.height();
3016
+ var resultsHeight = dropdown.$results.height();
3017
+ if (top < 0 || top > resultsHeight - elHeight) {
3018
+ top += dropdown.$results.scrollTop();
3019
+ dropdown.$results.scrollTop(delta < 0 ? top : top - resultsHeight + elHeight);
3037
3020
  }
3038
3021
  }
3039
3022
 
@@ -21,6 +21,7 @@
21
21
  .selectivity-results-container
22
22
  max-height: 28em
23
23
  overflow: auto
24
+ position: relative
24
25
 
25
26
  .selectivity-load-more,
26
27
  .selectivity-result-item
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selectivity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konrad Jurkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler