hooch 0.15.2 → 0.15.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: 452e37dc668ff73f2176e935edc337fb1d39fc40
4
- data.tar.gz: fd342beba6379e2e8011434084e836931dba0047
3
+ metadata.gz: 52c149faace46de6b5c09101da5c55b29a6dfe9e
4
+ data.tar.gz: 0fdc3af73d3dc87c8627e219b9ab43bfb6d02442
5
5
  SHA512:
6
- metadata.gz: e249d34c18a953a8332f86b7474119e6c2b40a1988f964d9f51c1d4d0e573526e3118dd8a31238d04c6cbbb7bfd10f95e7c00d28fdf8e56d8fcf00a2b9c5910f
7
- data.tar.gz: 9f650265a8f72416b1ec86151d9069cd2aded9ef451d7268b4ba6bb508ae361714b0ea1b9e37885fe3aebdea2759353182fd440b3087508cdb45fa2b2fc13e7c
6
+ metadata.gz: 01b12c2623fb4f008c561dbfe14d2af46b3b16467e1a87b9ac3a84911450e053b5cc90709ba560b796c158be943e8ea12e683679f51f293ad4835c3192c3bd06
7
+ data.tar.gz: 27662733491a9211d5e6093fd0363db0c9cc08e200ab706187d5ad68aea5b72cf9657f4a2d83bf64d54c49155eb0bbff9e03a475c9d9ad4bcf73b52bcb98c904
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Hooch
1
+ [![Build Status](https://semaphoreci.com/api/v1/invitedhome/hooch/branches/master/badge.svg)](https://semaphoreci.com/invitedhome/hooch)
2
2
 
3
- TODO: Write a gem description
3
+ # Hooch
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ See the [Wiki](https://github.com/edraut/hooch/wiki)
24
24
 
25
25
  ## Contributing
26
26
 
@@ -443,6 +443,7 @@ var initHooch = function(){
443
443
  TabGroup: Class.extend({
444
444
  init: function($tab_group){
445
445
  this.$tab_group = $tab_group;
446
+ this.getStateBehavior();
446
447
  this.getName();
447
448
  this.tab_triggers = [];
448
449
  this.tab_triggers_by_id = {};
@@ -477,9 +478,10 @@ var initHooch = function(){
477
478
  this.$content_parent = this.tab_triggers[0].getParent();
478
479
  },
479
480
  handleDefault: function(){
481
+
480
482
  if(this.$tab_group.data('default-tab')){
481
483
  this.default_tab = this.tab_triggers_by_id[this.$tab_group.data('default-tab')];
482
- this.default_tab.toggleTarget('replace');
484
+ this.default_tab.toggleTarget(this.state_behavior);
483
485
  }
484
486
  },
485
487
  hideAll: function(trigger){
@@ -510,12 +512,20 @@ var initHooch = function(){
510
512
  },
511
513
  getActiveTab: function(){
512
514
  return this.active_tab;
515
+ },
516
+ getStateBehavior: function(){
517
+ if(this.$tab_group.data('no-history')){
518
+ this.state_behavior = 'no history'
519
+ } else {
520
+ this.state_behavior = 'replace'
521
+ }
513
522
  }
514
523
  }),
515
524
  TabTrigger: Class.extend({
516
525
  init: function($tab_trigger,tab_group){
517
526
  this.$tab_trigger = $tab_trigger;
518
527
  this.tab_group = tab_group;
528
+ this.state_behavior = this.tab_group.state_behavior
519
529
  this.tab_group_name = tab_group.name;
520
530
  this.tab_id = $tab_trigger.data('tab-target-id');
521
531
  this.getPushState();
@@ -536,20 +546,22 @@ var initHooch = function(){
536
546
  this.push_state = this.$tab_trigger.data('push-state')
537
547
  }
538
548
  },
539
- toggleTarget: function(state_behavior){
549
+ toggleTarget: function(requested_state_behavior){
540
550
  var was_visible = this.$target.is(':visible');
541
551
  if(!was_visible){
542
552
  this.tab_group.setActiveTab(this);
543
553
  this.resize();
544
554
  var change_history = true;
545
555
  var history_method = 'pushState'
546
- if('no history' == state_behavior){
556
+ if('no history' == requested_state_behavior || 'no history' == this.state_behavior){
547
557
  change_history = false
548
- } else if('replace' == state_behavior){
558
+ } else if('replace' == requested_state_behavior){
549
559
  history_method = 'replaceState'
550
560
  }
551
561
  if (this.push_state && change_history) {
552
- var current_state = new hooch.IhHistoryState(history.state)
562
+ var current_query = jQuery.extend(true, {}, hooch.beginning_params);
563
+ current_query = jQuery.extend(true, current_query, history.state);
564
+ var current_state = new hooch.IhHistoryState(current_query)
553
565
  current_state.addState(this.tab_group_name, this.push_state);
554
566
  history[history_method](current_state.state, null, current_state.toUrl());
555
567
  }
@@ -1787,6 +1799,21 @@ var initHooch = function(){
1787
1799
  e.cancelBubble=true;
1788
1800
  e.returnValue=false;
1789
1801
  }
1802
+
1803
+ //https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
1804
+ hooch.beginning_params = (function(a) {
1805
+ if (a == "") return {};
1806
+ var b = {};
1807
+ for (var i = 0; i < a.length; ++i)
1808
+ {
1809
+ var p=a[i].split('=', 2);
1810
+ if (p.length == 1)
1811
+ b[p[0]] = "";
1812
+ else
1813
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
1814
+ }
1815
+ return b;
1816
+ })(window.location.search.substr(1).split('&'));
1790
1817
  $.fn.findExclude = function( selector, mask, result )
1791
1818
  {
1792
1819
  result = typeof result !== 'undefined' ? result : new jQuery();
@@ -1,12 +1,13 @@
1
1
  module Hooch
2
2
  module HoochHelper
3
- def tab_set(name, type: nil, default_tab: nil)
3
+ def tab_set(name, type: nil, default_tab: nil, no_history: nil)
4
4
  if :ajax == type
5
5
  type = 'AjaxTabGroup'
6
6
  end
7
7
  attrs = 'data-tab-group=' + name
8
8
  attrs += ' data-sub-type=' + type if type.present?
9
9
  attrs += ' data-default-tab=' + default_tab if default_tab.present?
10
+ attrs += ' data-no-history=true' if no_history.present?
10
11
  attrs
11
12
  end
12
13
 
@@ -1,3 +1,3 @@
1
1
  module Hooch
2
- VERSION = "0.15.2"
2
+ VERSION = "0.15.3"
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.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails