bootstrap_builders 0.0.12 → 0.0.13
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 871085f57ae41b057c60bae61417ded98714eca8
|
4
|
+
data.tar.gz: e2faf748dd49c93a425aec8e107e3592f7c976cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bd67268a0c668e10f288b6df3b650c9c19ca1030dc010e982f22e196872680745ae003d1e35e2650f4a8abfcc0afaddebae4ca0a680f41eaf38c2549f792f0f
|
7
|
+
data.tar.gz: aa374e5c6162e0391cb6789fcf9cbad156372755f07c253abf4b73cf1bbc4bccfa31d5a38110586df11973e78649616b7d3033f95c1b2b200847f5d6ea0cad18
|
@@ -1,14 +1,26 @@
|
|
1
1
|
$ ->
|
2
|
-
|
3
|
-
li = $(this)
|
2
|
+
loadAjaxTab = (li) ->
|
4
3
|
link = $("a", li)
|
5
4
|
content_id = link.attr("href").substring(1, 999)
|
6
5
|
content = $(".bb-tabs-container #" + content_id + " .bb-tab-container")
|
7
6
|
|
8
|
-
return if li.data("ajax-loaded")
|
9
7
|
li.data("ajax-loaded", true)
|
10
|
-
|
11
8
|
content.fadeOut 0, ->
|
12
9
|
$.get li.data("ajax-url"), (data) ->
|
13
10
|
content.html(data)
|
14
11
|
content.fadeIn "fast"
|
12
|
+
|
13
|
+
$("body").on "click", ".bb-tabs-container .nav li", ->
|
14
|
+
li = $(this)
|
15
|
+
|
16
|
+
if li.data("specific-id-given")
|
17
|
+
urlb = new UrlBuilder(window.location.href)
|
18
|
+
urlb.queryParameters["bb_selected_tab"] = $(this).data("tab-container-id")
|
19
|
+
|
20
|
+
window.history.pushState("bb-tab-change", "", urlb.pathWithQueryParameters())
|
21
|
+
|
22
|
+
if li.data("ajax-url") && !li.data("ajax-loaded")
|
23
|
+
loadAjaxTab(li)
|
24
|
+
|
25
|
+
active_tab = $(".bb-tabs-container .nav li.active[data-ajax-url]")
|
26
|
+
loadAjaxTab(active_tab) if active_tab.length > 0
|
@@ -7,6 +7,12 @@ class BootstrapBuilders::Tab
|
|
7
7
|
@label = args.fetch(:label)
|
8
8
|
@ajax_url = args[:ajax_url]
|
9
9
|
|
10
|
+
if args[:container_id]
|
11
|
+
@specific_id_given = true
|
12
|
+
else
|
13
|
+
@specific_id_given = false
|
14
|
+
end
|
15
|
+
|
10
16
|
@container_id = args[:container_id].presence
|
11
17
|
@container_id ||= SecureRandom.hex
|
12
18
|
end
|
@@ -14,4 +20,8 @@ class BootstrapBuilders::Tab
|
|
14
20
|
def active?
|
15
21
|
@active
|
16
22
|
end
|
23
|
+
|
24
|
+
def specific_id_given?
|
25
|
+
@specific_id_given
|
26
|
+
end
|
17
27
|
end
|
@@ -26,7 +26,7 @@ class BootstrapBuilders::Tabs
|
|
26
26
|
container.add_ele(:div, classes: ["clearfix"])
|
27
27
|
|
28
28
|
@tabs.each do |tab|
|
29
|
-
li = ul.add_ele(:li)
|
29
|
+
li = ul.add_ele(:li, data: {specific_id_given: tab.specific_id_given?, tab_container_id: tab.container_id})
|
30
30
|
li.add_ele(:a, str: tab.label, attr: {href: "##{tab.container_id}"}, data: {toggle: "tab"})
|
31
31
|
li.classes << "active" if tab.active?
|
32
32
|
li.data[:ajax_url] = tab.ajax_url if tab.ajax_url.present?
|
@@ -62,6 +62,18 @@ private
|
|
62
62
|
|
63
63
|
def set_default_first_active
|
64
64
|
return if @tabs.any?(&:active?)
|
65
|
-
|
65
|
+
|
66
|
+
active_found = false
|
67
|
+
|
68
|
+
if @context.params["bb_selected_tab"].present?
|
69
|
+
tab = @tabs.find { |tab_i| tab_i.container_id == @context.params["bb_selected_tab"] }
|
70
|
+
|
71
|
+
if tab
|
72
|
+
tab.active = true
|
73
|
+
active_found = true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
@tabs.first.active = true if @tabs.any? && !active_found
|
66
78
|
end
|
67
79
|
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.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
276
|
version: '0'
|
277
277
|
requirements: []
|
278
278
|
rubyforge_project:
|
279
|
-
rubygems_version: 2.
|
279
|
+
rubygems_version: 2.2.2
|
280
280
|
signing_key:
|
281
281
|
specification_version: 4
|
282
282
|
summary: A library to generate Bootstrap HTML for Rails.
|