hooch 0.13.2 → 0.14.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 +56 -5
- data/lib/hooch/hooch_helper.rb +6 -6
- data/lib/hooch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb20ac68cd5d280812465183224f608f8f09ba43
|
4
|
+
data.tar.gz: 463a25fee2d56b8432ef99a42aa78e4357c2749c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e865332a62301a80b2ea2adcdc58e08e7201b39535e298569e5f41a223b5940ca9809bf795220b8ba39a6ea65ffc2c9d4fdbc8e215dc02c7744b8b069aa1211
|
7
|
+
data.tar.gz: 1abebd42f529a8b413df43b3b1f13aee584dc02b5b1cc367dbed4c86fd595ab36b3e38661e0aeeb4ccc34514f5550815738cdeb7b4ed758c4e8f99fc2a8603bd
|
@@ -586,6 +586,9 @@ var initHooch = function(){
|
|
586
586
|
},
|
587
587
|
addKeyValue: function(key,value){
|
588
588
|
this.addState(key,value)
|
589
|
+
this.setNewParams()
|
590
|
+
},
|
591
|
+
setNewParams: function(){
|
589
592
|
history['replaceState'](this.state, null, this.toUrl());
|
590
593
|
},
|
591
594
|
replacePath: function(new_path){
|
@@ -595,16 +598,64 @@ var initHooch = function(){
|
|
595
598
|
}),
|
596
599
|
HistoryPusher: Class.extend({
|
597
600
|
init: function($history_pusher){
|
598
|
-
this
|
599
|
-
this.
|
601
|
+
this.$history_pusher = $history_pusher
|
602
|
+
this.getPusherType()
|
603
|
+
var history_pusher = this
|
604
|
+
this.bindPusher()
|
605
|
+
},
|
606
|
+
bindPusher: function(){
|
607
|
+
var bind_method = 'bind' + this.pusher_type
|
608
|
+
this[bind_method]()
|
609
|
+
},
|
610
|
+
bindLink: function(){
|
600
611
|
var history_pusher = this
|
601
|
-
|
612
|
+
this.$history_pusher.on('click apiclick', function(){
|
602
613
|
history_pusher.pushIt()
|
603
614
|
})
|
604
615
|
},
|
616
|
+
bindForm: function(){
|
617
|
+
var history_pusher = this
|
618
|
+
this.$history_pusher.on('submit apisubmit', function(){
|
619
|
+
history_pusher.pushIt()
|
620
|
+
})
|
621
|
+
},
|
622
|
+
getPusherType: function(){
|
623
|
+
switch(this.$history_pusher.get(0).nodeName.toLowerCase()){
|
624
|
+
case 'form':
|
625
|
+
this.pusher_type = 'Form'
|
626
|
+
break;
|
627
|
+
case 'a':
|
628
|
+
default:
|
629
|
+
this.pusher_type = 'Link'
|
630
|
+
break;
|
631
|
+
}
|
632
|
+
},
|
633
|
+
getNewParams: function(){
|
634
|
+
var get_params_method = 'get' + this.pusher_type + 'Params'
|
635
|
+
this[get_params_method]()
|
636
|
+
},
|
637
|
+
getFormParams: function(){
|
638
|
+
this.new_params = this.$history_pusher.serializeArray().
|
639
|
+
reduce(
|
640
|
+
function(obj, item) {
|
641
|
+
obj[item.name] = item.value;
|
642
|
+
return obj;
|
643
|
+
},
|
644
|
+
{}
|
645
|
+
);
|
646
|
+
},
|
647
|
+
getLinkParams: function(){
|
648
|
+
this.new_params = {}
|
649
|
+
this.new_params[this.$history_pusher.data('key')] = this.$history_pusher.data('value')
|
650
|
+
},
|
605
651
|
pushIt: function(){
|
606
|
-
this.
|
607
|
-
this
|
652
|
+
this.getNewParams()
|
653
|
+
var history_pusher = this
|
654
|
+
history_pusher.current_state = new hooch.IhHistoryState(history.state)
|
655
|
+
$.each(this.new_params,function(new_key,new_value){
|
656
|
+
history_pusher.current_state.addState(new_key,new_value)
|
657
|
+
})
|
658
|
+
history_pusher.current_state.setNewParams()
|
608
659
|
}
|
609
660
|
}),
|
610
661
|
HistoryReplacer: Class.extend({
|
data/lib/hooch/hooch_helper.rb
CHANGED
@@ -170,19 +170,19 @@ module Hooch
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
def history_pusher_attrs(key,value)
|
173
|
+
def history_pusher_attrs(key = nil,value = nil)
|
174
174
|
''.tap do |attrs|
|
175
175
|
attrs.concat 'data-history-pusher=true'
|
176
|
-
attrs.concat " data-key=#{key}"
|
177
|
-
attrs.concat " data-value=\"#{value}\""
|
176
|
+
attrs.concat " data-key=#{key}" if key
|
177
|
+
attrs.concat " data-value=\"#{value}\"" if value
|
178
178
|
end.html_safe
|
179
179
|
end
|
180
180
|
|
181
|
-
def history_pusher(key,value)
|
181
|
+
def history_pusher(key = nil,value = nil)
|
182
182
|
{}.tap do |params|
|
183
183
|
params['data-history-pusher'] = true
|
184
|
-
params['data-key'] = key
|
185
|
-
params['data-value'] = value
|
184
|
+
params['data-key'] = key if key
|
185
|
+
params['data-value'] = value if value
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
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.14.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: 2016-10-
|
11
|
+
date: 2016-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|