hooch 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/hooch.js +40 -7
- data/jasmine/karma.conf.js +1 -1
- data/jasmine/spec/hoochSpec.js +83 -56
- data/lib/hooch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 075938e121455aeb850d8794770df4c194edb6fe
|
4
|
+
data.tar.gz: 690ab05a9d8a2ba37d3fbf3425790b3e36750f3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cce71ebf2f5b2b04213c0ed762360fde8e1f759d1375aaf5c4ad6a0bda28cd931c6b8f2e87d76acf5e45a9bf82f6bb7e34dee14c3dad65cc5f8de139fef33b1e
|
7
|
+
data.tar.gz: 800b30b97ee0b5173243c0034ccaa0fc312ffd26009982a34c91cbe73ebdddbd09bbd70fc97641d17ac0a4c205d51fc906cb33229207993542ffe26bb5639662
|
@@ -563,16 +563,49 @@ var initHooch = function(){
|
|
563
563
|
init: function(reload_page){
|
564
564
|
window.location.href = reload_page;
|
565
565
|
}
|
566
|
+
}),
|
567
|
+
FakeSelect: Class.extend({
|
568
|
+
init: function($fake_select){
|
569
|
+
this.select_display = $fake_select.find('[data-select-display]')
|
570
|
+
this.real_select = $fake_select.find('input')
|
571
|
+
var fake_select = this
|
572
|
+
$fake_select.find('[data-select-value][data-select-name]').each(function(){
|
573
|
+
new hooch.FakeOption($(this),fake_select)
|
574
|
+
})
|
575
|
+
},
|
576
|
+
select: function(fake_option){
|
577
|
+
this.select_display.html(fake_option.select_name);
|
578
|
+
this.real_select.val(fake_option.select_value);
|
579
|
+
this.select_display.trigger('click');
|
580
|
+
}
|
581
|
+
}),
|
582
|
+
FakeOption: Class.extend({
|
583
|
+
init: function($fake_option,$fake_select){
|
584
|
+
this.select_value = $fake_option.data('select-value')
|
585
|
+
this.select_name = $fake_option.data('select-name')
|
586
|
+
var fake_option = this
|
587
|
+
$fake_option.on('click',function(){
|
588
|
+
$fake_select.select(fake_option)
|
589
|
+
})
|
590
|
+
}
|
566
591
|
})
|
567
592
|
};
|
568
593
|
hooch.AjaxExpandable = hooch.Expandable.extend({
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
}
|
574
|
-
this._super();
|
594
|
+
expand: function(){
|
595
|
+
if(!this.ajax_loaded){
|
596
|
+
this.ajax_loaded = true;
|
597
|
+
new thin_man.AjaxLinkSubmission(this.$expander);
|
575
598
|
}
|
599
|
+
this._super();
|
600
|
+
}
|
601
|
+
});
|
602
|
+
hooch.SelectActionChanger = hooch.FakeSelect.extend({
|
603
|
+
select: function(fake_option){
|
604
|
+
var form = this.select_display.parents('form:first');
|
605
|
+
form.attr('action', fake_option.select_value);
|
606
|
+
this.select_display.html(fake_option.select_name);
|
607
|
+
this.select_display.trigger('click');
|
608
|
+
}
|
576
609
|
});
|
577
610
|
hooch.FormFieldRevealer = hooch.Revealer.extend({
|
578
611
|
init: function($revealer){
|
@@ -670,7 +703,7 @@ var initHooch = function(){
|
|
670
703
|
window.any_time_manager.registerList(
|
671
704
|
['hover_overflow','hidey_button','submit-proxy','click-proxy','field-filler','revealer',
|
672
705
|
'checkbox-hidden-proxy','prevent-double-submit','prevent-double-link-click', 'tab-group',
|
673
|
-
'hover-reveal', 'emptier', 'remover', 'checkbox-proxy'],'hooch');
|
706
|
+
'hover-reveal', 'emptier', 'remover', 'checkbox-proxy', 'fake-select', 'select-action-changer'],'hooch');
|
674
707
|
window.any_time_manager.load();
|
675
708
|
};
|
676
709
|
$(document).ready(function(){
|
data/jasmine/karma.conf.js
CHANGED
@@ -18,7 +18,7 @@ module.exports = function(config) {
|
|
18
18
|
'test-main.js',
|
19
19
|
{pattern: 'jquery.js'},
|
20
20
|
{pattern: 'inheritance.js'},
|
21
|
-
{pattern: 'jasmine-fixture
|
21
|
+
{pattern: 'jasmine-fixture.js'},
|
22
22
|
{pattern: '../app/assets/javascripts/hooch.js'},
|
23
23
|
{pattern: 'spec/**/*Spec.js', included: false}
|
24
24
|
],
|
data/jasmine/spec/hoochSpec.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
describe("hooch", function() {
|
2
2
|
|
3
|
-
|
4
|
-
});
|
5
|
-
|
6
|
-
it("empties an element", function() {
|
3
|
+
it("Emptier", function() {
|
7
4
|
var emptier_div = affix('[data-emptier="true"][data-target="#my_div"]')
|
8
5
|
var emptier_target = affix('#my_div')
|
9
6
|
emptier_target.html('stuff')
|
@@ -13,7 +10,7 @@ describe("hooch", function() {
|
|
13
10
|
expect(emptier_target.html()).not.toMatch('stuff');
|
14
11
|
});
|
15
12
|
|
16
|
-
it("
|
13
|
+
it("Remover", function(){
|
17
14
|
var remover_div = affix('[data-remover="true"][data-target="#my_div"]')
|
18
15
|
var remover_target = affix('#my_div')
|
19
16
|
$('[data-remover]').each(function(){new hooch.Remover($(this))})
|
@@ -22,60 +19,90 @@ describe("hooch", function() {
|
|
22
19
|
expect($('#my_div').length).toEqual(0);
|
23
20
|
});
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
describe("Expander",function(){
|
23
|
+
it('expands and collapses an element', function(){
|
24
|
+
var expander = affix('[data-expander="true"][data-expand-id="my_expander"]')
|
25
|
+
var expandable = affix('[data-expand-state="collapsed"][data-expand-id="my_expander"]')
|
26
|
+
$('[data-expand-state]').each(function(){new hooch.Expandable($(this))});
|
27
|
+
expect($('[data-expand-state]').css('display')).toEqual('none');
|
28
|
+
$('[data-expander]').click()
|
29
|
+
expect($('[data-expand-state]').css('display')).not.toEqual('none');
|
30
|
+
expect($('[data-expander]').css('display')).not.toEqual('none');
|
31
|
+
$('[data-expander]').click()
|
32
|
+
expect($('[data-expand-state]').css('display')).toEqual('none');
|
33
|
+
})
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
35
|
+
it('expands an element with a class and modifies trigger with an expand class', function(){
|
36
|
+
var expander = affix('[data-expander="true"][data-expand-id="my_expander"][data-expand-class="test-class-trigger"]')
|
37
|
+
var expandable = affix('[data-expand-state="collapsed"][data-expand-id="my_expander"][data-expand-class="test-class-content"]')
|
38
|
+
$('[data-expand-state]').each(function(){new hooch.Expandable($(this))});
|
39
|
+
expect($('[data-expand-state]').hasClass("test-class-content")).toBe(false);
|
40
|
+
expect($('[data-expander]').hasClass("test-class-trigger")).toBe(false);
|
41
|
+
$('[data-expander]').click()
|
42
|
+
expect($('[data-expand-state]').hasClass("test-class-content")).toBe(true);
|
43
|
+
expect($('[data-expander]').hasClass("test-class-trigger")).toBe(true);
|
44
|
+
$('[data-expander]').click()
|
45
|
+
expect($('[data-expand-state]').hasClass("test-class-content")).toBe(false);
|
46
|
+
expect($('[data-expander]').hasClass("test-class-trigger")).toBe(false);
|
47
|
+
})
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
49
|
+
it('expands an element with a class and modifies trigger with a collapse class', function(){
|
50
|
+
var expander = affix('[data-expander="true"][data-expand-id="my_expander"][data-collapse-class="test-class-trigger"]')
|
51
|
+
var expandable = affix('[data-expand-state="collapsed"][data-expand-id="my_expander"][data-expand-class="test-class-content"]')
|
52
|
+
$('[data-expand-state]').each(function(){new hooch.Expandable($(this))});
|
53
|
+
expect($('[data-expand-state]').hasClass("test-class-content")).toBe(false);
|
54
|
+
expect($('[data-expander]').hasClass("test-class-trigger")).toBe(true);
|
55
|
+
$('[data-expander]').click()
|
56
|
+
expect($('[data-expand-state]').hasClass("test-class-content")).toBe(true);
|
57
|
+
expect($('[data-expander]').hasClass("test-class-trigger")).toBe(false);
|
58
|
+
$('[data-expander]').click()
|
59
|
+
expect($('[data-expand-state]').hasClass("test-class-content")).toBe(false);
|
60
|
+
expect($('[data-expander]').hasClass("test-class-trigger")).toBe(true);
|
61
|
+
})
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
63
|
+
it('expands and collapses an element with separate triggers', function(){
|
64
|
+
var expander = affix('[data-expander="true"][data-expand-id="my_expander"]')
|
65
|
+
var collapser = affix('[data-collapser="true"][data-expand-id="my_expander"]')
|
66
|
+
var expandable = affix('[data-expand-state="collapsed"][data-expand-id="my_expander"]')
|
67
|
+
$('[data-expand-state]').each(function(){new hooch.Expandable($(this))});
|
68
|
+
expect($('[data-expand-state]').css('display')).toEqual('none');
|
69
|
+
$('[data-expander]').click()
|
70
|
+
expect($('[data-expand-state]').css('display')).not.toEqual('none');
|
71
|
+
expect($('[data-collapser]').css('display')).not.toEqual('none');
|
72
|
+
expect($('[data-expander]').css('display')).toEqual('none');
|
73
|
+
$('[data-collapser]').click()
|
74
|
+
expect($('[data-expand-state]').css('display')).toEqual('none');
|
75
|
+
expect($('[data-collapser]').css('display')).toEqual('none');
|
76
|
+
expect($('[data-expander]').css('display')).not.toEqual('none');
|
77
|
+
})
|
78
|
+
});
|
79
|
+
it('FakeSelect', function(){
|
80
|
+
var fake_select = affix('[data-fake-select="color"]')
|
81
|
+
var fake_display = fake_select.affix('[data-select-display]')
|
82
|
+
var fake_option1 = fake_select.affix('[data-select-value="blue"][data-select-name="Blue"]')
|
83
|
+
var fake_option2 = fake_select.affix('[data-select-value="green"][data-select-name="Green"]')
|
84
|
+
var real_input = fake_select.affix('input[type="hidden"][data-real-select="true"]')
|
85
|
+
$('[data-fake-select]').each(function(){new hooch.FakeSelect($(this))})
|
86
|
+
$('[data-select-value="blue"]').click();
|
87
|
+
expect($('[data-select-display]').html()).toEqual('Blue');
|
88
|
+
expect($('input').val()).toEqual('blue');
|
89
|
+
$('[data-select-value="green"]').click();
|
90
|
+
expect($('[data-select-display]').html()).toEqual('Green');
|
91
|
+
expect($('input').val()).toEqual('green');
|
79
92
|
})
|
80
93
|
|
94
|
+
it('SelectActionChanger', function(){
|
95
|
+
var form = affix('form')
|
96
|
+
var fake_select = form.affix('[data-select-action-changer="search"]')
|
97
|
+
var fake_display = fake_select.affix('[data-select-display]')
|
98
|
+
var fake_option1 = fake_select.affix('[data-select-value="pretty/url"][data-select-name="Pretty Stuff"]')
|
99
|
+
var fake_option2 = fake_select.affix('[data-select-value="strong/url"][data-select-name="Strong Stuff"]')
|
100
|
+
$('[data-select-action-changer]').each(function(){new hooch.SelectActionChanger($(this))})
|
101
|
+
$('[data-select-value="pretty/url"]').click();
|
102
|
+
expect($('[data-select-display]').html()).toEqual('Pretty Stuff');
|
103
|
+
expect($('form').prop('action')).toMatch('pretty/url');
|
104
|
+
$('[data-select-value="strong/url"]').click();
|
105
|
+
expect($('[data-select-display]').html()).toEqual('Strong Stuff');
|
106
|
+
expect($('form').prop('action')).toMatch('strong/url');
|
107
|
+
})
|
81
108
|
});
|
data/lib/hooch/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -3310,7 +3310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
3310
3310
|
version: '0'
|
3311
3311
|
requirements: []
|
3312
3312
|
rubyforge_project:
|
3313
|
-
rubygems_version: 2.4.
|
3313
|
+
rubygems_version: 2.4.6
|
3314
3314
|
signing_key:
|
3315
3315
|
specification_version: 4
|
3316
3316
|
summary: Tools for building a browser UI. Get the good stuff.
|