scrivito_tabs_in_details 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae70051dd90570231796e64e79b0fd4ea7adac4f
4
+ data.tar.gz: cc3886392b9f272b4fcca486e7c966fbcfb5c974
5
+ SHA512:
6
+ metadata.gz: 55b56cb2fb0f49aa9abe028e336a9b5dbed84d324dfadc033485b1ba7554a92f977aec4d5edc474a846b41ccf0b7ef93babfeae344274940174348e37f259347
7
+ data.tar.gz: 72f3be88192772019e6c0a30bdbe3f3afa3767810a0d46367c15437371d473ebc59d598ec32d3787400a1a2d3db2aeb553b45af3d46e63770513dfda45fc2698
data/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ Copyright (c) 2009 - 2016 Infopark AG (http://www.infopark.com)
2
+
3
+ This software can be used and modified under the LGPL-3.0. Please refer to
4
+ http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'bundler'
2
+
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,28 @@
1
+ ;(function() {
2
+ scrivito.on('content', function(content) {
3
+ $content = $(content);
4
+
5
+ $content.find('.scrivito_tabs_block').hide();
6
+ $content.find('.scrivito_tabs_block:first').show();
7
+
8
+ $content.find('.scrivito_tabs').each(function() {
9
+ var $tabs = $(this);
10
+ var $titles = $tabs.find('.scrivito_tabs_title');
11
+ var $blocks = $tabs.find('.scrivito_tabs_block');
12
+
13
+ $titles.each(function() {
14
+ var $title = $(this);
15
+
16
+ $title.on('click', function() {
17
+ $titles.removeClass('scrivito_tabs_active');
18
+ $title.addClass('scrivito_tabs_active');
19
+
20
+ $blocks.hide();
21
+ $($title.find('a').attr('href')).show();
22
+
23
+ return false;
24
+ });
25
+ });
26
+ });
27
+ });
28
+ }());
@@ -0,0 +1,30 @@
1
+ .scrivito_tabs .scrivito_tabs_title {
2
+ border-top-left-radius: 4px;
3
+ border-top-right-radius: 4px;
4
+ float: left;
5
+ margin: 0 .25em 0 0;
6
+ padding: 10px;
7
+ }
8
+
9
+ .scrivito_tabs .scrivito_tabs_title a {
10
+ color: #666;
11
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
12
+ font-size: 1.3em;
13
+ font-weight: normal;
14
+ text-decoration: none;
15
+ }
16
+
17
+ .scrivito_tabs .scrivito_tabs_title.scrivito_tabs_active {
18
+ background: #ddd;
19
+ box-shadow: 0 -10px 20px -15px black;
20
+ }
21
+
22
+ .scrivito_tabs .scrivito_tabs_clear {
23
+ clear: both;
24
+ }
25
+
26
+ .scrivito_tabs .scrivito_tabs_block {
27
+ background: #ddd;
28
+ margin-bottom: 10px;
29
+ padding: 10px;
30
+ }
@@ -0,0 +1,74 @@
1
+ module ScrivitoTabsHelper
2
+ def scrivito_tabs
3
+ builder = ScrivitoTabsBuilder.new(self)
4
+ yield builder
5
+ builder.render
6
+ end
7
+
8
+ class ScrivitoTabsBuilder < Struct.new(:view_context)
9
+ delegate :content_tag, :capture, :concat, :link_to, to: :view_context
10
+
11
+ def initialize(*args)
12
+ super
13
+
14
+ @titles, @blocks = [], []
15
+ @random_id = SecureRandom.hex(3)
16
+ end
17
+
18
+ def tab(title, &block)
19
+ @titles << title
20
+ @blocks << block
21
+
22
+ nil
23
+ end
24
+
25
+ def render
26
+ content_tag(:div, class: 'scrivito_tabs') do
27
+ capture do
28
+ concat(render_titles)
29
+ concat(content_tag(:div, '', class: 'scrivito_tabs_clear'))
30
+ concat(render_blocks)
31
+ end
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def render_titles
38
+ content_tag(:div) do
39
+ capture do
40
+ @titles.each_with_index do |title, index|
41
+ concat(render_title(title, index))
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ def render_title(title, index)
48
+ css_class = 'scrivito_tabs_title'
49
+ css_class << ' scrivito_tabs_active' if index == 0
50
+
51
+ content_tag(:div, class: css_class) do
52
+ link_to(title, "##{tab_id(index)}")
53
+ end
54
+ end
55
+
56
+ def render_blocks
57
+ content_tag(:div) do
58
+ capture do
59
+ @blocks.each_with_index do |block, index|
60
+ concat(render_block(block, index))
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ def render_block(block, index)
67
+ content_tag(:div, id: tab_id(index), class: 'scrivito_tabs_block', &block)
68
+ end
69
+
70
+ def tab_id(index)
71
+ "scrivito_tabs_#{@random_id}_block_#{index}"
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,4 @@
1
+ module ScrivitoTabsInDetails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ScrivitoTabsInDetails
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'scrivito_tabs_in_details/engine'
2
+
3
+ module ScrivitoTabsInDetails
4
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrivito_tabs_in_details
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scrivito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: scrivito
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem provides a template helper for creating simple tabs in details
56
+ dialogs in Scrivito CMS.
57
+ email:
58
+ - support@scrivito.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - LICENSE
64
+ - Rakefile
65
+ - app/assets/javascripts/scrivito_tabs_in_details.js
66
+ - app/assets/stylesheets/scrivito_tabs_in_details.css
67
+ - app/helpers/scrivito_tabs_helper.rb
68
+ - lib/scrivito_tabs_in_details.rb
69
+ - lib/scrivito_tabs_in_details/engine.rb
70
+ - lib/scrivito_tabs_in_details/version.rb
71
+ homepage: https://scrivito.com
72
+ licenses:
73
+ - LGPL-3.0
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Simple tabs template helper for details dialogs in Scrivito CMS
95
+ test_files: []