hooch 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9e66bf94543b7f6e7e5e759eff4e5e2796894a4
4
- data.tar.gz: 1be8f61352c852e60eca3f02a73871e6a9edcd73
3
+ metadata.gz: c983987b651132cb265c5856ff3ed79cef4351f5
4
+ data.tar.gz: 0ff1c5e46583ba88c61675033aa444ff4e815933
5
5
  SHA512:
6
- metadata.gz: 275448fc8402520410d89412902126152d4fd3f40772c5f7e8e6b4fc8a9fb056b76675ea3f774e41a0935096f131a1b9d49c46c93922a2cb89c7efca35e3488f
7
- data.tar.gz: 57a6d9f6ea03864adfa87e5b754ecea5707bab0bd4833105b41467f36f63fd909706fd1ec5df40074cfd8751beea87785505f8d125f6f25f9f5b1306f54211c7
6
+ metadata.gz: d9d97d3f6c920289ce956a45a9158a39e43ee5a5c42533d40abda87d5f0881b99349a27838797eb4f5d90ee2cbcb4a3511a2f0d2623f9a224c4a03abbc62124f
7
+ data.tar.gz: 242c54f8d9e76a2d2c32b14a6884bd4e8c5b9d5c54ec2986a999067474c33daf51841ccd89f588479daeccf6f38c69dc5f503f33427438f6271e4643943e792a
@@ -177,6 +177,7 @@ var initHooch = function(){
177
177
  this.$expander = $expander;
178
178
  this.target = target;
179
179
  this.expand_class = $expander.data('expand-class')
180
+ this.collapse_class = $expander.data('collapse-class')
180
181
  if($expander.data('fake-dropdown')){
181
182
  target.$expandable.on('click',function(){
182
183
  target.toggle();
@@ -190,15 +191,25 @@ var initHooch = function(){
190
191
  })
191
192
  },
192
193
  hide: function(){
193
- if(this.expand_class){
194
- this.$expander.addClass(this.expand_class)
194
+ if(this.expand_class || this.collapse_class){
195
+ if(this.expand_class){
196
+ this.$expander.addClass(this.expand_class)
197
+ }
198
+ if(this.collapse_class){
199
+ this.$expander.removeClass(this.collapse_class)
200
+ }
195
201
  } else if(this.target.collapsers.length > 0) {
196
202
  this.$expander.hide();
197
203
  }
198
204
  },
199
205
  show: function(){
200
- if(this.expand_class){
201
- this.$expander.removeClass(this.expand_class)
206
+ if(this.expand_class || this.collapse_class){
207
+ if(this.expand_class){
208
+ this.$expander.removeClass(this.expand_class)
209
+ }
210
+ if(this.collapse_class){
211
+ this.$expander.addClass(this.collapse_class)
212
+ }
202
213
  } else if(this.target.collapsers.length > 0) {
203
214
  this.$expander.show();
204
215
  }
@@ -34,7 +34,7 @@ describe("hooch", function() {
34
34
  expect($('[data-expand-state]').css('display')).toEqual('none');
35
35
  })
36
36
 
37
- it('expands an element with a class and modifies trigger with a class', function(){
37
+ it('expands an element with a class and modifies trigger with an expand class', function(){
38
38
  var expander = affix('[data-expander="true"][data-expand-id="my_expander"][data-expand-class="test-class-trigger"]')
39
39
  var expandable = affix('[data-expand-state="collapsed"][data-expand-id="my_expander"][data-expand-class="test-class-content"]')
40
40
  $('[data-expand-state]').each(function(){new hooch.Expandable($(this))});
@@ -48,6 +48,20 @@ describe("hooch", function() {
48
48
  expect($('[data-expander]').hasClass("test-class-trigger")).toBe(false);
49
49
  })
50
50
 
51
+ it('expands an element with a class and modifies trigger with a collapse class', function(){
52
+ var expander = affix('[data-expander="true"][data-expand-id="my_expander"][data-collapse-class="test-class-trigger"]')
53
+ var expandable = affix('[data-expand-state="collapsed"][data-expand-id="my_expander"][data-expand-class="test-class-content"]')
54
+ $('[data-expand-state]').each(function(){new hooch.Expandable($(this))});
55
+ expect($('[data-expand-state]').hasClass("test-class-content")).toBe(false);
56
+ expect($('[data-expander]').hasClass("test-class-trigger")).toBe(true);
57
+ $('[data-expander]').click()
58
+ expect($('[data-expand-state]').hasClass("test-class-content")).toBe(true);
59
+ expect($('[data-expander]').hasClass("test-class-trigger")).toBe(false);
60
+ $('[data-expander]').click()
61
+ expect($('[data-expand-state]').hasClass("test-class-content")).toBe(false);
62
+ expect($('[data-expander]').hasClass("test-class-trigger")).toBe(true);
63
+ })
64
+
51
65
  it('expands and collapses an element with separate triggers', function(){
52
66
  var expander = affix('[data-expander="true"][data-expand-id="my_expander"]')
53
67
  var collapser = affix('[data-collapser="true"][data-expand-id="my_expander"]')
data/lib/hooch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hooch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hooch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails