bootstrap_builders 0.0.28 → 0.0.29

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: d6ee6c39d0d6737f378b4d59df2cdadffc6b0056
4
- data.tar.gz: 7b5f59a19ab1a6c2c6147c04740903760055ac29
3
+ metadata.gz: 928d598c2a05f26dd498653023cff0c55bea8522
4
+ data.tar.gz: 31330263588604f16128308f247fd97b9c0090e8
5
5
  SHA512:
6
- metadata.gz: 908e60ca9d74183126c319daee2b8f14557222b47b0f82edd18ec3ee59aca8d44ef2d6f833c97ad5a1a1bc814683a3214409aff81744658db1924149b41a3138
7
- data.tar.gz: 3dbbe3e24c96d1ee7bdad39ffa30297ba039bd2afa971f96f9371dd0a261781e3e6f72e56146f35cccf394eea0c1ada72e6cbb0f037609b4083f0830bdc05240
6
+ metadata.gz: cbcff0e97d5d14df0a141adf5024c5d7f57e0a0818914868db682c4c4c3e4752b77bac536858b13b5307b83212df34d2b0e0dec9686136707b1f7986692c6319
7
+ data.tar.gz: a58490472ff40e00ffadb47080d4e043b0bbe093844b6a5fd2ca2416e45d255815d8c3a4cccc2a13324074a35a313da25a1833ddf933067d824e6d5ddd4b7afc
@@ -1,4 +1,5 @@
1
1
  $ ->
2
+ # Used to load dynamic content of a tab
2
3
  loadAjaxTab = (li) ->
3
4
  link = $("a", li)
4
5
  content_id = link.attr("href").substring(1, 999)
@@ -10,17 +11,38 @@ $ ->
10
11
  content.html(data)
11
12
  content.fadeIn "fast"
12
13
 
14
+ # Loads the dynamic content of a tab when activated and sets the URL to the tab ID
13
15
  $("body").on "click", ".bb-tabs-container .nav li", ->
14
16
  li = $(this)
15
17
 
16
- if li.data("specific-id-given")
18
+ if li.data("ignore-next-history-push")
19
+ li.data("ignore-next-history-push", null)
20
+ else if li.data("specific-id-given")
17
21
  urlb = new UrlBuilder(window.location.href)
18
22
  urlb.queryParameters["bb_selected_tab"] = $(this).data("tab-container-id")
19
23
 
20
- window.history.pushState("bb-tab-change", "", urlb.pathWithQueryParameters())
24
+ window.history.pushState({active_tab: li.data("tab-container-id"), event: "bb-tab-change"}, null, urlb.pathWithQueryParameters())
21
25
 
22
26
  if li.data("ajax-url") && !li.data("ajax-loaded")
23
27
  loadAjaxTab(li)
24
28
 
29
+ # Changes the tab on 'back' and 'forward' events
30
+ $(window).bind "popstate", (e) ->
31
+ if e.originalEvent.state && e.originalEvent.state.event == "bb-tab-change"
32
+ selected_tab = e.originalEvent.state.active_tab
33
+ else
34
+ urlb = new UrlBuilder(window.location.href)
35
+ selected_tab = urlb.queryParameters["bb_selected_tab"]
36
+
37
+ selected_tab = $($(".bb-tabs-container .nav li").first()).data("tab-container-id") unless selected_tab
38
+
39
+ li = $("li[data-tab-container-id='" + selected_tab + "']") if selected_tab
40
+
41
+ if li && !li.hasClass("active")
42
+ console.log("Click on LI")
43
+ li.data("ignore-next-history-push", true)
44
+ $("a", li).click()
45
+
46
+ # Makes sure the correct tab is loaded on page load
25
47
  active_tab = $(".bb-tabs-container .nav li.active[data-ajax-url]")
26
48
  loadAjaxTab(active_tab) if active_tab.length > 0
@@ -1,3 +1,3 @@
1
1
  module BootstrapBuilders
2
- VERSION = "0.0.28".freeze
2
+ VERSION = "0.0.29".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_builders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-15 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.5.2
105
+ rubygems_version: 2.6.8
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: A library to generate Bootstrap HTML for Rails.